]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/ground_2/relocation/rtmap_coafter.ma
xoa notation refactoring and minor additions
[helm.git] / matita / matita / contribs / lambdadelta / ground_2 / relocation / rtmap_coafter.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 include "ground_2/notation/relations/rcoafter_3.ma".
16 include "ground_2/relocation/rtmap_sor.ma".
17 include "ground_2/relocation/rtmap_after.ma".
18
19 (* RELOCATION MAP ***********************************************************)
20
21 coinductive coafter: relation3 rtmap rtmap rtmap ≝
22 | coafter_refl: ∀f1,f2,f,g1,g2,g. coafter f1 f2 f →
23                 ↑f1 = g1 → ↑f2 = g2 → ↑f = g → coafter g1 g2 g
24 | coafter_push: ∀f1,f2,f,g1,g2,g. coafter f1 f2 f →
25                 ↑f1 = g1 → ⫯f2 = g2 → ⫯f = g → coafter g1 g2 g
26 | coafter_next: ∀f1,f2,f,g1,g. coafter f1 f2 f →
27                 ⫯f1 = g1 → ↑f = g → coafter g1 f2 g
28 .
29
30 interpretation "relational co-composition (rtmap)"
31    'RCoAfter f1 f2 f = (coafter f1 f2 f).
32
33 definition H_coafter_inj: predicate rtmap ≝
34                           λf1. 𝐓⦃f1⦄ →
35                           ∀f,f21,f22. f1 ~⊚ f21 ≡ f → f1 ~⊚ f22 ≡ f → f21 ≗ f22.
36
37 definition H_coafter_fwd_isid2: predicate rtmap ≝
38                                 λf1. ∀f2,f. f1 ~⊚ f2 ≡ f → 𝐓⦃f1⦄ → 𝐈⦃f⦄ → 𝐈⦃f2⦄.
39
40 definition H_coafter_isfin2_fwd: predicate rtmap ≝
41                                  λf1. ∀f2. 𝐅⦃f2⦄ → 𝐓⦃f1⦄ → ∀f. f1 ~⊚ f2 ≡ f →  𝐅⦃f⦄.
42
43 (* Basic inversion lemmas ***************************************************)
44
45 lemma coafter_inv_ppx: ∀g1,g2,g. g1 ~⊚ g2 ≡ g → ∀f1,f2. ↑f1 = g1 → ↑f2 = g2 →
46                        ∃∃f. f1 ~⊚ f2 ≡ f & ↑f = g.
47 #g1 #g2 #g * -g1 -g2 -g #f1 #f2 #f #g1
48 [ #g2 #g #Hf #H1 #H2 #H #x1 #x2 #Hx1 #Hx2 destruct
49   >(injective_push … Hx1) >(injective_push … Hx2) -x2 -x1
50   /2 width=3 by ex2_intro/
51 | #g2 #g #_ #_ #H2 #_ #x1 #x2 #_ #Hx2 destruct
52   elim (discr_push_next … Hx2)
53 | #g #_ #H1 #_ #x1 #x2 #Hx1 #_ destruct
54   elim (discr_push_next … Hx1)
55 ]
56 qed-.
57
58 lemma coafter_inv_pnx: ∀g1,g2,g. g1 ~⊚ g2 ≡ g → ∀f1,f2. ↑f1 = g1 → ⫯f2 = g2 →
59                        ∃∃f. f1 ~⊚ f2 ≡ f & ⫯f = g.
60 #g1 #g2 #g * -g1 -g2 -g #f1 #f2 #f #g1
61 [ #g2 #g #_ #_ #H2 #_ #x1 #x2 #_ #Hx2 destruct
62   elim (discr_next_push … Hx2)
63 | #g2 #g #Hf #H1 #H2 #H3 #x1 #x2 #Hx1 #Hx2 destruct
64   >(injective_push … Hx1) >(injective_next … Hx2) -x2 -x1
65   /2 width=3 by ex2_intro/
66 | #g #_ #H1 #_ #x1 #x2 #Hx1 #_ destruct
67   elim (discr_push_next … Hx1)
68 ]
69 qed-.
70
71 lemma coafter_inv_nxx: ∀g1,f2,g. g1 ~⊚ f2 ≡ g → ∀f1. ⫯f1 = g1 →
72                        ∃∃f. f1 ~⊚ f2 ≡ f & ↑f = g.
73 #g1 #f2 #g * -g1 -f2 -g #f1 #f2 #f #g1
74 [ #g2 #g #_ #H1 #_ #_ #x1 #Hx1 destruct
75   elim (discr_next_push … Hx1)
76 | #g2 #g #_ #H1 #_ #_ #x1 #Hx1 destruct
77   elim (discr_next_push … Hx1)
78 | #g #Hf #H1 #H #x1 #Hx1 destruct
79   >(injective_next … Hx1) -x1
80   /2 width=3 by ex2_intro/
81 ]
82 qed-.
83
84 (* Advanced inversion lemmas ************************************************)
85
86 lemma coafter_inv_ppp: ∀g1,g2,g. g1 ~⊚ g2 ≡ g →
87                        ∀f1,f2,f. ↑f1 = g1 → ↑f2 = g2 → ↑f = g → f1 ~⊚ f2 ≡ f.
88 #g1 #g2 #g #Hg #f1 #f2 #f #H1 #H2 #H
89 elim (coafter_inv_ppx … Hg … H1 H2) -g1 -g2 #x #Hf #Hx destruct
90 <(injective_push … Hx) -f //
91 qed-.
92
93 lemma coafter_inv_ppn: ∀g1,g2,g. g1 ~⊚ g2 ≡ g →
94                        ∀f1,f2,f. ↑f1 = g1 → ↑f2 = g2 → ⫯f = g → ⊥.
95 #g1 #g2 #g #Hg #f1 #f2 #f #H1 #H2 #H
96 elim (coafter_inv_ppx … Hg … H1 H2) -g1 -g2 #x #Hf #Hx destruct
97 elim (discr_push_next … Hx)
98 qed-.
99
100 lemma coafter_inv_pnn: ∀g1,g2,g. g1 ~⊚ g2 ≡ g →
101                        ∀f1,f2,f. ↑f1 = g1 → ⫯f2 = g2 → ⫯f = g → f1 ~⊚ f2 ≡ f.
102 #g1 #g2 #g #Hg #f1 #f2 #f #H1 #H2 #H
103 elim (coafter_inv_pnx … Hg … H1 H2) -g1 -g2 #x #Hf #Hx destruct
104 <(injective_next … Hx) -f //
105 qed-.
106
107 lemma coafter_inv_pnp: ∀g1,g2,g. g1 ~⊚ g2 ≡ g →
108                        ∀f1,f2,f. ↑f1 = g1 → ⫯f2 = g2 → ↑f = g → ⊥.
109 #g1 #g2 #g #Hg #f1 #f2 #f #H1 #H2 #H
110 elim (coafter_inv_pnx … Hg … H1 H2) -g1 -g2 #x #Hf #Hx destruct
111 elim (discr_next_push … Hx)
112 qed-.
113
114 lemma coafter_inv_nxp: ∀g1,f2,g. g1 ~⊚ f2 ≡ g →
115                        ∀f1,f. ⫯f1 = g1 → ↑f = g → f1 ~⊚ f2 ≡ f.
116 #g1 #f2 #g #Hg #f1 #f #H1 #H
117 elim (coafter_inv_nxx … Hg … H1) -g1 #x #Hf #Hx destruct
118 <(injective_push … Hx) -f //
119 qed-.
120
121 lemma coafter_inv_nxn: ∀g1,f2,g. g1 ~⊚ f2 ≡ g →
122                        ∀f1,f. ⫯f1 = g1 → ⫯f = g → ⊥.
123 #g1 #f2 #g #Hg #f1 #f #H1 #H
124 elim (coafter_inv_nxx … Hg … H1) -g1 #x #Hf #Hx destruct
125 elim (discr_push_next … Hx)
126 qed-.
127
128 lemma coafter_inv_pxp: ∀g1,g2,g. g1 ~⊚ g2 ≡ g →
129                        ∀f1,f. ↑f1 = g1 → ↑f = g →
130                        ∃∃f2. f1 ~⊚ f2 ≡ f & ↑f2 = g2.
131 #g1 #g2 #g #Hg #f1 #f #H1 #H elim (pn_split g2) * #f2 #H2
132 [ lapply (coafter_inv_ppp … Hg … H1 H2 H) -g1 -g /2 width=3 by ex2_intro/
133 | elim (coafter_inv_pnp … Hg … H1 H2 H)
134 ]
135 qed-.
136
137 lemma coafter_inv_pxn: ∀g1,g2,g. g1 ~⊚ g2 ≡ g →
138                        ∀f1,f. ↑f1 = g1 → ⫯f = g →
139                        ∃∃f2. f1 ~⊚ f2 ≡ f & ⫯f2 = g2.
140 #g1 #g2 #g #Hg #f1 #f #H1 #H elim (pn_split g2) * #f2 #H2
141 [ elim (coafter_inv_ppn … Hg … H1 H2 H)
142 | lapply (coafter_inv_pnn … Hg … H1 … H) -g1 -g /2 width=3 by ex2_intro/
143 ]
144 qed-.
145
146 lemma coafter_inv_xxn: ∀g1,g2,g. g1 ~⊚ g2 ≡ g → ∀f. ⫯f = g →
147                        ∃∃f1,f2. f1 ~⊚ f2 ≡ f & ↑f1 = g1 & ⫯f2 = g2.
148 #g1 #g2 #g #Hg #f #H elim (pn_split g1) * #f1 #H1
149 [ elim (coafter_inv_pxn … Hg … H1 H) -g /2 width=5 by ex3_2_intro/
150 | elim (coafter_inv_nxn … Hg … H1 H)
151 ]
152 qed-.
153
154 lemma coafter_inv_xnn: ∀g1,g2,g. g1 ~⊚ g2 ≡ g →
155                        ∀f2,f. ⫯f2 = g2 → ⫯f = g →
156                        ∃∃f1. f1 ~⊚ f2 ≡ f & ↑f1 = g1.
157 #g1 #g2 #g #Hg #f2 #f #H2 destruct #H
158 elim (coafter_inv_xxn … Hg … H) -g
159 #z1 #z2 #Hf #H1 #H2 destruct /2 width=3 by ex2_intro/
160 qed-.
161
162 lemma coafter_inv_xxp: ∀g1,g2,g. g1 ~⊚ g2 ≡ g → ∀f. ↑f = g →
163                        (∃∃f1,f2. f1 ~⊚ f2 ≡ f & ↑f1 = g1 & ↑f2 = g2) ∨
164                        ∃∃f1. f1 ~⊚ g2 ≡ f & ⫯f1 = g1.
165 #g1 #g2 #g #Hg #f #H elim (pn_split g1) * #f1 #H1
166 [ elim (coafter_inv_pxp … Hg … H1 H) -g
167   /3 width=5 by or_introl, ex3_2_intro/
168 | /4 width=5 by coafter_inv_nxp, or_intror, ex2_intro/
169 ]
170 qed-.
171
172 lemma coafter_inv_pxx: ∀g1,g2,g. g1 ~⊚ g2 ≡ g → ∀f1. ↑f1 = g1 →
173                        (∃∃f2,f. f1 ~⊚ f2 ≡ f & ↑f2 = g2 & ↑f = g) ∨
174                        (∃∃f2,f. f1 ~⊚ f2 ≡ f & ⫯f2 = g2 & ⫯f = g).
175 #g1 #g2 #g #Hg #f1 #H1 elim (pn_split g2) * #f2 #H2
176 [ elim (coafter_inv_ppx … Hg … H1 H2) -g1
177   /3 width=5 by or_introl, ex3_2_intro/
178 | elim (coafter_inv_pnx … Hg … H1 H2) -g1
179   /3 width=5 by or_intror, ex3_2_intro/
180 ]
181 qed-.
182
183 (* Basic properties *********************************************************)
184
185 corec lemma coafter_eq_repl_back2: ∀f1,f. eq_repl_back (λf2. f2 ~⊚ f1 ≡ f).
186 #f1 #f #f2 * -f2 -f1 -f
187 #f21 #f1 #f #g21 [1,2: #g1 ] #g #Hf #H21 [1,2: #H1 ] #H #g22 #H0
188 [ cases (eq_inv_px …  H0 …  H21) -g21 /3 width=7 by coafter_refl/
189 | cases (eq_inv_px …  H0 …  H21) -g21 /3 width=7 by coafter_push/
190 | cases (eq_inv_nx …  H0 …  H21) -g21 /3 width=5 by coafter_next/
191 ]
192 qed-.
193
194 lemma coafter_eq_repl_fwd2: ∀f1,f. eq_repl_fwd (λf2. f2 ~⊚ f1 ≡ f).
195 #f1 #f @eq_repl_sym /2 width=3 by coafter_eq_repl_back2/
196 qed-.
197
198 corec lemma coafter_eq_repl_back1: ∀f2,f. eq_repl_back (λf1. f2 ~⊚ f1 ≡ f).
199 #f2 #f #f1 * -f2 -f1 -f
200 #f2 #f11 #f #g2 [1,2: #g11 ] #g #Hf #H2 [1,2: #H11 ] #H #g2 #H0
201 [ cases (eq_inv_px …  H0 …  H11) -g11 /3 width=7 by coafter_refl/
202 | cases (eq_inv_nx …  H0 …  H11) -g11 /3 width=7 by coafter_push/
203 | @(coafter_next … H2 H) /2 width=5 by/
204 ]
205 qed-.
206
207 lemma coafter_eq_repl_fwd1: ∀f2,f. eq_repl_fwd (λf1. f2 ~⊚ f1 ≡ f).
208 #f2 #f @eq_repl_sym /2 width=3 by coafter_eq_repl_back1/
209 qed-.
210
211 corec lemma coafter_eq_repl_back0: ∀f1,f2. eq_repl_back (λf. f2 ~⊚ f1 ≡ f).
212 #f2 #f1 #f * -f2 -f1 -f
213 #f2 #f1 #f01 #g2 [1,2: #g1 ] #g01 #Hf01 #H2 [1,2: #H1 ] #H01 #g02 #H0
214 [ cases (eq_inv_px …  H0 …  H01) -g01 /3 width=7 by coafter_refl/
215 | cases (eq_inv_nx …  H0 …  H01) -g01 /3 width=7 by coafter_push/
216 | cases (eq_inv_px …  H0 …  H01) -g01 /3 width=5 by coafter_next/
217 ]
218 qed-.
219
220 lemma coafter_eq_repl_fwd0: ∀f2,f1. eq_repl_fwd (λf. f2 ~⊚ f1 ≡ f).
221 #f2 #f1 @eq_repl_sym /2 width=3 by coafter_eq_repl_back0/
222 qed-.
223
224 (* Main inversion lemmas ****************************************************)
225
226 corec theorem coafter_mono: ∀f1,f2,x,y. f1 ~⊚ f2 ≡ x → f1 ~⊚ f2 ≡ y → x ≗ y.
227 #f1 #f2 #x #y * -f1 -f2 -x
228 #f1 #f2 #x #g1 [1,2: #g2 ] #g #Hx #H1 [1,2: #H2 ] #H0x #Hy
229 [ cases (coafter_inv_ppx … Hy … H1 H2) -g1 -g2 /3 width=8 by eq_push/
230 | cases (coafter_inv_pnx … Hy … H1 H2) -g1 -g2 /3 width=8 by eq_next/
231 | cases (coafter_inv_nxx … Hy … H1) -g1 /3 width=8 by eq_push/
232 ]
233 qed-.
234
235 lemma coafter_mono_eq: ∀f1,f2,f. f1 ~⊚ f2 ≡ f → ∀g1,g2,g. g1 ~⊚ g2 ≡ g →
236                        f1 ≗ g1 → f2 ≗ g2 → f ≗ g.
237 /4 width=4 by coafter_mono, coafter_eq_repl_back1, coafter_eq_repl_back2/ qed-.
238
239 (* Inversion lemmas with pushs **********************************************)
240
241 lemma coafter_fwd_pushs: ∀n,g2,g1,g. g2 ~⊚ g1 ≡ g → @⦃0, g2⦄ ≡ n →
242                          ∃f. ↑*[n]f = g.
243 #n elim n -n /2 width=2 by ex_intro/
244 #n #IH #g2 #g1 #g #Hg #Hg2
245 cases (at_inv_pxn … Hg2) -Hg2 [ |*: // ] #f2 #Hf2 #H2
246 cases (coafter_inv_nxx … Hg … H2) -Hg -H2 #f #Hf #H0 destruct
247 elim (IH … Hf Hf2) -g1 -g2 -f2 /2 width=2 by ex_intro/
248 qed-.
249
250 (* Inversion lemmas with tail ***********************************************)
251
252 lemma coafter_inv_tl1: ∀g2,g1,g. g2 ~⊚ ⫱g1 ≡ g →
253                        ∃∃f. ↑g2 ~⊚ g1 ≡ f & ⫱f = g.
254 #g2 #g1 #g elim (pn_split g1) * #f1 #H1 #H destruct
255 [ /3 width=7 by coafter_refl, ex2_intro/
256 | @(ex2_intro … (⫯g)) /2 width=7 by coafter_push/ (**) (* full auto fails *)
257 ]
258 qed-.
259
260 lemma coafter_inv_tl0: ∀g2,g1,g. g2 ~⊚ g1 ≡ ⫱g →
261                        ∃∃f1. ↑g2 ~⊚ f1 ≡ g & ⫱f1 = g1.
262 #g2 #g1 #g elim (pn_split g) * #f #H0 #H destruct
263 [ /3 width=7 by coafter_refl, ex2_intro/
264 | @(ex2_intro … (⫯g1)) /2 width=7 by coafter_push/ (**) (* full auto fails *)
265 ]
266 qed-.
267
268 (* Properties with iterated tail ********************************************)
269
270 lemma coafter_tls: ∀n,f1,f2,f. @⦃0, f1⦄ ≡ n →
271                    f1 ~⊚ f2 ≡ f → ⫱*[n]f1 ~⊚ f2 ≡ ⫱*[n]f.
272 #n elim n -n //
273 #n #IH #f1 #f2 #f #Hf1 #Hf
274 cases (at_inv_pxn … Hf1) -Hf1 [ |*: // ] #g1 #Hg1 #H1
275 cases (coafter_inv_nxx … Hf … H1) -Hf #g #Hg #H0 destruct
276 <tls_xn <tls_xn /2 width=1 by/
277 qed.
278
279 lemma coafter_tls_succ: ∀g2,g1,g. g2 ~⊚ g1 ≡ g →
280                         ∀n. @⦃0, g2⦄ ≡ n → ⫱*[⫯n]g2 ~⊚ ⫱g1 ≡ ⫱*[⫯n]g.
281 #g2 #g1 #g #Hg #n #Hg2
282 lapply (coafter_tls … Hg2 … Hg) -Hg #Hg
283 lapply (at_pxx_tls … Hg2) -Hg2 #H
284 elim (at_inv_pxp … H) -H [ |*: // ] #f2 #H2
285 elim (coafter_inv_pxx … Hg … H2) -Hg * #f1 #f #Hf #H1 #H0 destruct
286 <tls_S <tls_S <H2 <H0 -g2 -g -n //
287 qed.
288
289 lemma coafter_fwd_xpx_pushs: ∀g2,f1,g,n. g2 ~⊚ ↑f1 ≡ g → @⦃0, g2⦄ ≡ n →
290                              ∃f. ↑*[⫯n]f = g.
291 #g2 #g1 #g #n #Hg #Hg2
292 elim (coafter_fwd_pushs … Hg Hg2) #f #H0 destruct
293 lapply (coafter_tls … Hg2 Hg) -Hg <tls_pushs #Hf
294 lapply (at_pxx_tls … Hg2) -Hg2 #H
295 elim (at_inv_pxp … H) -H [ |*: // ] #f2 #H2
296 elim (coafter_inv_pxx … Hf … H2) -Hf -H2 * #f1 #g #_ #H1 #H0 destruct
297 [ /2 width=2 by ex_intro/
298 | elim (discr_next_push … H1)
299
300 qed-.
301
302 lemma coafter_fwd_xnx_pushs: ∀g2,f1,g,n. g2 ~⊚ ⫯f1 ≡ g → @⦃0, g2⦄ ≡ n →
303                              ∃f. ↑*[n] ⫯f = g.
304 #g2 #g1 #g #n #Hg #Hg2
305 elim (coafter_fwd_pushs … Hg Hg2) #f #H0 destruct
306 lapply (coafter_tls … Hg2 Hg) -Hg <tls_pushs #Hf
307 lapply (at_pxx_tls … Hg2) -Hg2 #H
308 elim (at_inv_pxp … H) -H [ |*: // ] #f2 #H2
309 elim (coafter_inv_pxx … Hf … H2) -Hf -H2 * #f1 #g #_ #H1 #H0 destruct
310 [ elim (discr_push_next … H1)
311 | /2 width=2 by ex_intro/
312
313 qed-.
314
315 (* Properties with test for identity ****************************************)
316
317 corec lemma coafter_isid_sn: ∀f1. 𝐈⦃f1⦄ → ∀f2. f1 ~⊚ f2 ≡ f2.
318 #f1 * -f1 #f1 #g1 #Hf1 #H1 #f2 cases (pn_split f2) * #g2 #H2
319 /3 width=7 by coafter_push, coafter_refl/
320 qed.
321
322 corec lemma coafter_isid_dx: ∀f2,f. 𝐈⦃f2⦄ → 𝐈⦃f⦄ → ∀f1. f1 ~⊚ f2 ≡ f.
323 #f2 #f * -f2 #f2 #g2 #Hf2 #H2 * -f #f #g #Hf #H #f1 cases (pn_split f1) * #g1 #H1
324 [ /3 width=7 by coafter_refl/
325 | @(coafter_next … H1 … H) /3 width=3 by isid_push/
326 ]
327 qed.
328
329 (* Inversion lemmas with test for identity **********************************)
330
331 lemma coafter_isid_inv_sn: ∀f1,f2,f. f1 ~⊚ f2 ≡ f → 𝐈⦃f1⦄ → f2 ≗ f.
332 /3 width=6 by coafter_isid_sn, coafter_mono/ qed-.
333
334 lemma coafter_isid_inv_dx: ∀f1,f2,f. f1 ~⊚ f2 ≡ f → 𝐈⦃f2⦄ → 𝐈⦃f⦄.
335 /4 width=4 by eq_id_isid, coafter_isid_dx, coafter_mono/ qed-.
336
337 (* Properties with test for uniform relocations *****************************)
338
339 lemma coafter_isuni_isid: ∀f2. 𝐈⦃f2⦄ → ∀f1. 𝐔⦃f1⦄ → f1 ~⊚ f2 ≡ f2.
340 #f #Hf #g #H elim H -g
341 /3 width=5 by coafter_isid_sn, coafter_eq_repl_back0, coafter_next, eq_push_inv_isid/
342 qed.
343
344
345 (*
346 lemma coafter_isid_isuni: ∀f1,f2. 𝐈⦃f2⦄ → 𝐔⦃f1⦄ → f1 ~⊚ ⫯f2 ≡ ⫯f1.
347 #f1 #f2 #Hf2 #H elim H -H
348 /5 width=7 by coafter_isid_dx, coafter_eq_repl_back2, coafter_next, coafter_push, eq_push_inv_isid/
349 qed.
350
351 lemma coafter_uni_next2: ∀f2. 𝐔⦃f2⦄ → ∀f1,f. ⫯f2 ~⊚ f1 ≡ f → f2 ~⊚ ⫯f1 ≡ f.
352 #f2 #H elim H -f2
353 [ #f2 #Hf2 #f1 #f #Hf
354   elim (coafter_inv_nxx … Hf) -Hf [2,3: // ] #g #Hg #H0 destruct
355   /4 width=7 by coafter_isid_inv_sn, coafter_isid_sn, coafter_eq_repl_back0, eq_next/
356 | #f2 #_ #g2 #H2 #IH #f1 #f #Hf
357   elim (coafter_inv_nxx … Hf) -Hf [2,3: // ] #g #Hg #H0 destruct
358   /3 width=5 by coafter_next/
359 ]
360 qed.
361 *)
362
363 (* Properties with uniform relocations **************************************)
364
365 lemma coafter_uni_sn: ∀i,f. 𝐔❴i❵ ~⊚ f ≡ ↑*[i] f.
366 #i elim i -i /2 width=5 by coafter_isid_sn, coafter_next/
367 qed.
368
369 (*
370 lemma coafter_uni: ∀n1,n2. 𝐔❴n1❵ ~⊚ 𝐔❴n2❵ ≡ 𝐔❴n1+n2❵.
371 @nat_elim2
372 /4 width=5 by coafter_uni_next2, coafter_isid_sn, coafter_isid_dx, coafter_next/
373 qed.
374
375 (* Forward lemmas on at *****************************************************)
376
377 lemma coafter_at_fwd: ∀i,i1,f. @⦃i1, f⦄ ≡ i → ∀f2,f1. f2 ~⊚ f1 ≡ f →
378                       ∃∃i2. @⦃i1, f1⦄ ≡ i2 & @⦃i2, f2⦄ ≡ i.
379 #i elim i -i [2: #i #IH ] #i1 #f #Hf #f2 #f1 #Hf21
380 [ elim (at_inv_xxn … Hf) -Hf [1,3:* |*: // ]
381   [1: #g #j1 #Hg #H0 #H |2,4: #g #Hg #H ]
382 | elim (at_inv_xxp … Hf) -Hf //
383   #g #H1 #H
384 ]
385 [2: elim (coafter_inv_xxn … Hf21 … H) -f *
386     [ #g2 #g1 #Hg21 #H2 #H1 | #g2 #Hg21 #H2 ]
387 |*: elim (coafter_inv_xxp … Hf21 … H) -f
388     #g2 #g1 #Hg21 #H2 #H1
389 ]
390 [4: -Hg21 |*: elim (IH … Hg … Hg21) -g -IH ]
391 /3 width=9 by at_refl, at_push, at_next, ex2_intro/
392 qed-.
393
394 lemma coafter_fwd_at: ∀i,i2,i1,f1,f2. @⦃i1, f1⦄ ≡ i2 → @⦃i2, f2⦄ ≡ i →
395                       ∀f. f2 ~⊚ f1 ≡ f → @⦃i1, f⦄ ≡ i.
396 #i elim i -i [2: #i #IH ] #i2 #i1 #f1 #f2 #Hf1 #Hf2 #f #Hf
397 [ elim (at_inv_xxn … Hf2) -Hf2 [1,3: * |*: // ]
398   #g2 [ #j2 ] #Hg2 [ #H22 ] #H20
399   [ elim (at_inv_xxn … Hf1 … H22) -i2 *
400     #g1 [ #j1 ] #Hg1 [ #H11 ] #H10
401     [ elim (coafter_inv_ppx … Hf … H20 H10) -f1 -f2 /3 width=7 by at_push/
402     | elim (coafter_inv_pnx … Hf … H20 H10) -f1 -f2 /3 width=6 by at_next/
403     ]
404   | elim (coafter_inv_nxx … Hf … H20) -f2 /3 width=7 by at_next/
405   ]
406 | elim (at_inv_xxp … Hf2) -Hf2 // #g2 #H22 #H20
407   elim (at_inv_xxp … Hf1 … H22) -i2 #g1 #H11 #H10
408   elim (coafter_inv_ppx … Hf … H20 H10) -f1 -f2 /2 width=2 by at_refl/
409 ]
410 qed-.
411
412 lemma coafter_fwd_at2: ∀f,i1,i. @⦃i1, f⦄ ≡ i → ∀f1,i2. @⦃i1, f1⦄ ≡ i2 →
413                        ∀f2. f2 ~⊚ f1 ≡ f → @⦃i2, f2⦄ ≡ i.
414 #f #i1 #i #Hf #f1 #i2 #Hf1 #f2 #H elim (coafter_at_fwd … Hf … H) -f
415 #j1 #H #Hf2 <(at_mono … Hf1 … H) -i1 -i2 //
416 qed-.
417
418 lemma coafter_fwd_at1: ∀i,i2,i1,f,f2. @⦃i1, f⦄ ≡ i → @⦃i2, f2⦄ ≡ i →
419                        ∀f1. f2 ~⊚ f1 ≡ f → @⦃i1, f1⦄ ≡ i2.
420 #i elim i -i [2: #i #IH ] #i2 #i1 #f #f2 #Hf #Hf2 #f1 #Hf1
421 [ elim (at_inv_xxn … Hf) -Hf [1,3: * |*: // ]
422   #g [ #j1 ] #Hg [ #H01 ] #H00
423   elim (at_inv_xxn … Hf2) -Hf2 [1,3,5,7: * |*: // ]
424   #g2 [1,3: #j2 ] #Hg2 [1,2: #H22 ] #H20
425   [ elim (coafter_inv_pxp … Hf1 … H20 H00) -f2 -f /3 width=7 by at_push/
426   | elim (coafter_inv_pxn … Hf1 … H20 H00) -f2 -f /3 width=5 by at_next/
427   | elim (coafter_inv_nxp … Hf1 … H20 H00)
428   | /4 width=9 by coafter_inv_nxn, at_next/
429   ]
430 | elim (at_inv_xxp … Hf) -Hf // #g #H01 #H00
431   elim (at_inv_xxp … Hf2) -Hf2 // #g2 #H21 #H20
432   elim (coafter_inv_pxp … Hf1 … H20 H00) -f2 -f /3 width=2 by at_refl/
433 ]
434 qed-.
435
436 (* Properties with at *******************************************************)
437
438 lemma coafter_uni_dx: ∀i2,i1,f2. @⦃i1, f2⦄ ≡ i2 →
439                       ∀f. f2 ~⊚ 𝐔❴i1❵ ≡ f → 𝐔❴i2❵ ~⊚ ⫱*[i2] f2 ≡ f.
440 #i2 elim i2 -i2
441 [ #i1 #f2 #Hf2 #f #Hf
442   elim (at_inv_xxp … Hf2) -Hf2 // #g2 #H1 #H2 destruct
443   lapply (coafter_isid_inv_dx … Hf ?) -Hf
444   /3 width=3 by coafter_isid_sn, coafter_eq_repl_back0/
445 | #i2 #IH #i1 #f2 #Hf2 #f #Hf
446   elim (at_inv_xxn … Hf2) -Hf2 [1,3: * |*: // ]
447   [ #g2 #j1 #Hg2 #H1 #H2 destruct
448     elim (coafter_inv_pnx … Hf) -Hf [ |*: // ] #g #Hg #H destruct
449     /3 width=5 by coafter_next/
450   | #g2 #Hg2 #H2 destruct
451     elim (coafter_inv_nxx … Hf) -Hf [2,3: // ] #g #Hg #H destruct
452     /3 width=5 by coafter_next/
453   ]
454 ]
455 qed.
456
457 lemma coafter_uni_sn: ∀i2,i1,f2. @⦃i1, f2⦄ ≡ i2 →
458                       ∀f. 𝐔❴i2❵ ~⊚ ⫱*[i2] f2 ≡ f → f2 ~⊚ 𝐔❴i1❵ ≡ f.
459 #i2 elim i2 -i2
460 [ #i1 #f2 #Hf2 #f #Hf
461   elim (at_inv_xxp … Hf2) -Hf2 // #g2 #H1 #H2 destruct
462   lapply (coafter_isid_inv_sn … Hf ?) -Hf
463   /3 width=3 by coafter_isid_dx, coafter_eq_repl_back0/
464 | #i2 #IH #i1 #f2 #Hf2 #f #Hf
465   elim (coafter_inv_nxx … Hf) -Hf [2,3: // ] #g #Hg #H destruct
466   elim (at_inv_xxn … Hf2) -Hf2 [1,3: * |*: // ]
467   [ #g2 #j1 #Hg2 #H1 #H2 destruct /3 width=7 by coafter_push/
468   | #g2 #Hg2 #H2 destruct /3 width=5 by coafter_next/
469   ]
470 ]
471 qed-.
472
473 lemma coafter_uni_succ_dx: ∀i2,i1,f2. @⦃i1, f2⦄ ≡ i2 →
474                            ∀f. f2 ~⊚ 𝐔❴⫯i1❵ ≡ f → 𝐔❴⫯i2❵ ~⊚ ⫱*[⫯i2] f2 ≡ f.
475 #i2 elim i2 -i2
476 [ #i1 #f2 #Hf2 #f #Hf
477   elim (at_inv_xxp … Hf2) -Hf2 // #g2 #H1 #H2 destruct
478   elim (coafter_inv_pnx … Hf) -Hf [ |*: // ] #g #Hg #H
479   lapply (coafter_isid_inv_dx … Hg ?) -Hg
480   /4 width=5 by coafter_isid_sn, coafter_eq_repl_back0, coafter_next/
481 | #i2 #IH #i1 #f2 #Hf2 #f #Hf
482   elim (at_inv_xxn … Hf2) -Hf2 [1,3: * |*: // ]
483   [ #g2 #j1 #Hg2 #H1 #H2 destruct
484     elim (coafter_inv_pnx … Hf) -Hf [ |*: // ] #g #Hg #H destruct
485     /3 width=5 by coafter_next/
486   | #g2 #Hg2 #H2 destruct
487     elim (coafter_inv_nxx … Hf) -Hf [2,3: // ] #g #Hg #H destruct
488     /3 width=5 by coafter_next/
489   ]
490 ]
491 qed.
492
493 lemma coafter_uni_succ_sn: ∀i2,i1,f2. @⦃i1, f2⦄ ≡ i2 →
494                            ∀f. 𝐔❴⫯i2❵ ~⊚ ⫱*[⫯i2] f2 ≡ f → f2 ~⊚ 𝐔❴⫯i1❵ ≡ f.
495 #i2 elim i2 -i2
496 [ #i1 #f2 #Hf2 #f #Hf
497   elim (at_inv_xxp … Hf2) -Hf2 // #g2 #H1 #H2 destruct
498   elim (coafter_inv_nxx … Hf) -Hf [ |*: // ] #g #Hg #H destruct
499   lapply (coafter_isid_inv_sn … Hg ?) -Hg
500   /4 width=7 by coafter_isid_dx, coafter_eq_repl_back0, coafter_push/
501 | #i2 #IH #i1 #f2 #Hf2 #f #Hf
502   elim (coafter_inv_nxx … Hf) -Hf [2,3: // ] #g #Hg #H destruct
503   elim (at_inv_xxn … Hf2) -Hf2 [1,3: * |*: // ]
504   [ #g2 #j1 #Hg2 #H1 #H2 destruct <tls_xn in Hg; /3 width=7 by coafter_push/
505   | #g2 #Hg2 #H2 destruct <tls_xn in Hg; /3 width=5 by coafter_next/
506   ]
507 ]
508 qed-.
509
510 lemma coafter_uni_one_dx: ∀f2,f. ↑f2 ~⊚ 𝐔❴⫯O❵ ≡ f → 𝐔❴⫯O❵ ~⊚ f2 ≡ f.
511 #f2 #f #H @(coafter_uni_succ_dx … (↑f2)) /2 width=3 by at_refl/
512 qed.
513
514 lemma coafter_uni_one_sn: ∀f1,f. 𝐔❴⫯O❵ ~⊚ f1 ≡ f → ↑f1 ~⊚ 𝐔❴⫯O❵ ≡ f.
515 /3 width=3 by coafter_uni_succ_sn, at_refl/ qed-.
516 *)
517 (* Forward lemmas with istot ************************************************)
518 (*
519 lemma coafter_istot_fwd: ∀f2,f1,f. f2 ~⊚ f1 ≡ f → 𝐓⦃f2⦄ → 𝐓⦃f1⦄ → 𝐓⦃f⦄.
520 #f2 #f1 #f #Hf #Hf2 #Hf1 #i1 elim (Hf1 i1) -Hf1
521 #i2 #Hf1 elim (Hf2 i2) -Hf2
522 /3 width=7 by coafter_fwd_at, ex_intro/
523 qed-.
524
525 lemma coafter_fwd_istot_dx: ∀f2,f1,f. f2 ~⊚ f1 ≡ f → 𝐓⦃f⦄ → 𝐓⦃f1⦄.
526 #f2 #f1 #f #H #Hf #i1 elim (Hf i1) -Hf
527 #i2 #Hf elim (coafter_at_fwd … Hf … H) -f /2 width=2 by ex_intro/
528 qed-.
529
530 lemma coafter_fwd_istot_sn: ∀f2,f1,f. f2 ~⊚ f1 ≡ f → 𝐓⦃f⦄ → 𝐓⦃f2⦄.
531 #f2 #f1 #f #H #Hf #i1 elim (Hf i1) -Hf
532 #i #Hf elim (coafter_at_fwd … Hf … H) -f
533 #i2 #Hf1 #Hf2 lapply (at_increasing … Hf1) -f1
534 #Hi12 elim (at_le_ex … Hf2 … Hi12) -i2 /2 width=2 by ex_intro/
535 qed-.
536
537 lemma coafter_inv_istot: ∀f2,f1,f. f2 ~⊚ f1 ≡ f → 𝐓⦃f⦄ → 𝐓⦃f2⦄ ∧ 𝐓⦃f1⦄.
538 /3 width=4 by coafter_fwd_istot_sn, coafter_fwd_istot_dx, conj/ qed-.
539
540 lemma coafter_at1_fwd: ∀f1,i1,i2. @⦃i1, f1⦄ ≡ i2 → ∀f2. 𝐓⦃f2⦄ → ∀f. f2 ~⊚ f1 ≡ f →
541                      ∃∃i. @⦃i2, f2⦄ ≡ i & @⦃i1, f⦄ ≡ i.
542 #f1 #i1 #i2 #Hf1 #f2 #Hf2 #f #Hf elim (Hf2 i2) -Hf2
543 /3 width=8 by coafter_fwd_at, ex2_intro/
544 qed-.
545
546 lemma coafter_fwd_isid_sn: ∀f2,f1,f. 𝐓⦃f⦄ → f2 ~⊚ f1 ≡ f → f1 ≗ f → 𝐈⦃f2⦄.
547 #f2 #f1 #f #H #Hf elim (coafter_inv_istot … Hf H) -H
548 #Hf2 #Hf1 #H @isid_at_total // -Hf2
549 #i2 #i #Hf2 elim (Hf1 i2) -Hf1
550 #i0 #Hf1 lapply (at_increasing … Hf1)
551 #Hi20 lapply (coafter_fwd_at2 … i0 … Hf1 … Hf) -Hf
552 /3 width=7 by at_eq_repl_back, at_mono, at_id_le/
553 qed-.
554
555 lemma coafter_fwd_isid_dx: ∀f2,f1,f.  𝐓⦃f⦄ → f2 ~⊚ f1 ≡ f → f2 ≗ f → 𝐈⦃f1⦄.
556 #f2 #f1 #f #H #Hf elim (coafter_inv_istot … Hf H) -H
557 #Hf2 #Hf1 #H2 @isid_at_total // -Hf1
558 #i1 #i2 #Hi12 elim (coafter_at1_fwd … Hi12 … Hf) -f1
559 /3 width=8 by at_inj, at_eq_repl_back/
560 qed-.
561 *)
562 corec fact coafter_inj_O_aux: ∀f1. @⦃0, f1⦄ ≡ 0 → H_coafter_inj f1.
563 #f1 #H1f1 #H2f1 #f #f21 #f22 #H1f #H2f
564 cases (at_inv_pxp … H1f1) -H1f1 [ |*: // ] #g1 #H1
565 lapply (istot_inv_push … H2f1 … H1) -H2f1 #H2g1
566 cases (H2g1 0) #n #Hn
567 cases (coafter_inv_pxx … H1f … H1) -H1f * #g21 #g #H1g #H21 #H
568 [ cases (coafter_inv_pxp … H2f … H1 H) -f1 -f #g22 #H2g #H22
569   @(eq_push … H21 H22) -f21 -f22
570 | cases (coafter_inv_pxn … H2f … H1 H) -f1 -f #g22 #H2g #H22
571   @(eq_next … H21 H22) -f21 -f22
572 ]
573 @(coafter_inj_O_aux (⫱*[n]g1) … (⫱*[n]g)) -coafter_inj_O_aux
574 /2 width=1 by coafter_tls, istot_tls, at_pxx_tls/
575 qed-.
576
577 fact coafter_inj_aux: (∀f1. @⦃0, f1⦄ ≡ 0 → H_coafter_inj f1) →
578                       ∀i2,f1. @⦃0, f1⦄ ≡ i2 → H_coafter_inj f1.
579 #H0 #i2 elim i2 -i2 /2 width=1 by/ -H0
580 #i2 #IH #f1 #H1f1 #H2f1 #f #f21 #f22 #H1f #H2f
581 elim (at_inv_pxn … H1f1) -H1f1 [ |*: // ] #g1 #H1g1 #H1
582 elim (coafter_inv_nxx … H1f … H1) -H1f #g #H1g #H
583 lapply (coafter_inv_nxp … H2f … H1 H) -f #H2g
584 /3 width=6 by istot_inv_next/
585 qed-.
586
587 theorem coafter_inj: ∀f1. H_coafter_inj f1.
588 #f1 #H cases (H 0) /3 width=7 by coafter_inj_aux, coafter_inj_O_aux/
589 qed-.
590
591 corec fact coafter_fwd_isid2_O_aux: ∀f1. @⦃0, f1⦄ ≡ 0 →
592                                     H_coafter_fwd_isid2 f1.
593 #f1 #H1f1 #f2 #f #H #H2f1 #Hf
594 cases (at_inv_pxp … H1f1) -H1f1 [ |*: // ] #g1 #H1
595 lapply (istot_inv_push … H2f1 … H1) -H2f1 #H2g1
596 cases (H2g1 0) #n #Hn
597 cases (coafter_inv_pxx … H … H1) -H * #g2 #g #H #H2 #H0
598 [ lapply (isid_inv_push … Hf … H0) -Hf #Hg
599   @(isid_push … H2)
600   /3 width=7 by coafter_tls, istot_tls, at_pxx_tls, isid_tls/
601 | cases (isid_inv_next … Hf … H0)
602 ]
603 qed-.
604
605 fact coafter_fwd_isid2_aux: (∀f1. @⦃0, f1⦄ ≡ 0 → H_coafter_fwd_isid2 f1) →
606                             ∀i2,f1. @⦃0, f1⦄ ≡ i2 → H_coafter_fwd_isid2 f1.
607 #H0 #i2 elim i2 -i2 /2 width=1 by/ -H0
608 #i2 #IH #f1 #H1f1 #f2 #f #H #H2f1 #Hf
609 elim (at_inv_pxn … H1f1) -H1f1 [ |*: // ] #g1 #Hg1 #H1
610 elim (coafter_inv_nxx … H … H1) -H #g #Hg #H0
611 @(IH … Hg1 … Hg) /2 width=3 by istot_inv_next, isid_inv_push/ (**) (* full auto fails *)
612 qed-.
613
614 lemma coafter_fwd_isid2: ∀f1. H_coafter_fwd_isid2 f1.
615 #f1 #f2 #f #Hf #H cases (H 0)
616 /3 width=7 by coafter_fwd_isid2_aux, coafter_fwd_isid2_O_aux/
617 qed-.
618
619 fact coafter_isfin2_fwd_O_aux: ∀f1. @⦃0, f1⦄ ≡ 0 →
620                                H_coafter_isfin2_fwd f1.
621 #f1 #Hf1 #f2 #H
622 generalize in match Hf1; generalize in match f1; -f1
623 @(isfin_ind … H) -f2
624 [ /3 width=4 by coafter_isid_inv_dx, isfin_isid/ ]
625 #f2 #_ #IH #f1 #H #Hf1 #f #Hf
626 elim (at_inv_pxp … H) -H [ |*: // ] #g1 #H1
627 lapply (istot_inv_push … Hf1 … H1) -Hf1 #Hg1
628 elim (Hg1 0) #n #Hn
629 [ elim (coafter_inv_ppx … Hf) | elim (coafter_inv_pnx … Hf)
630 ] -Hf [1,6: |*: // ] #g #Hg #H0 destruct
631 /5 width=6 by isfin_next, isfin_push, isfin_inv_tls, istot_tls, at_pxx_tls, coafter_tls/
632 qed-.
633
634 fact coafter_isfin2_fwd_aux: (∀f1. @⦃0, f1⦄ ≡ 0 → H_coafter_isfin2_fwd f1) →
635                              ∀i2,f1. @⦃0, f1⦄ ≡ i2 → H_coafter_isfin2_fwd f1.
636 #H0 #i2 elim i2 -i2 /2 width=1 by/ -H0
637 #i2 #IH #f1 #H1f1 #f2 #Hf2 #H2f1 #f #Hf
638 elim (at_inv_pxn … H1f1) -H1f1 [ |*: // ] #g1 #Hg1 #H1
639 elim (coafter_inv_nxx … Hf … H1) -Hf #g #Hg #H0
640 lapply (IH … Hg1 … Hg) -i2 -Hg
641 /2 width=4 by istot_inv_next, isfin_push/ (**) (* full auto fails *)
642 qed-.
643
644 lemma coafter_isfin2_fwd: ∀f1. H_coafter_isfin2_fwd f1.
645 #f1 #f2 #Hf2 #Hf1 cases (Hf1 0)
646 /3 width=7 by coafter_isfin2_fwd_aux, coafter_isfin2_fwd_O_aux/
647 qed-.
648
649 lemma coafter_inv_sor: ∀f. 𝐅⦃f⦄ → ∀f2. 𝐓⦃f2⦄ → ∀f1. f2 ~⊚ f1 ≡ f → ∀fa,fb. fa ⋓ fb ≡ f →
650                        ∃∃f1a,f1b. f2 ~⊚ f1a ≡ fa & f2 ~⊚ f1b ≡ fb & f1a ⋓ f1b ≡ f1.
651 @isfin_ind
652 [ #f #Hf #f2 #Hf2 #f1 #H1f #fa #fb #H2f
653   elim (sor_inv_isid3 … H2f) -H2f //
654   lapply (coafter_fwd_isid2 … H1f ??) -H1f //
655   /3 width=5 by ex3_2_intro, coafter_isid_dx, sor_isid/
656 | #f #_ #IH #f2 #Hf2 #f1 #H1 #fa #fb #H2
657   elim (sor_inv_xxp … H2) -H2 [ |*: // ] #ga #gb #H2f
658   elim (coafter_inv_xxp … H1) -H1 [1,3: * |*: // ] #g2 [ #g1 ] #H1f #Hgf2
659   [ lapply (istot_inv_push … Hf2 … Hgf2) | lapply (istot_inv_next … Hf2 … Hgf2) ] -Hf2 #Hg2
660   elim (IH … Hg2 … H1f … H2f) -f -Hg2
661   /3 width=11 by sor_pp, ex3_2_intro, coafter_refl, coafter_next/
662 | #f #_ #IH #f2 #Hf2 #f1 #H1 #fa #fb #H2
663   elim (coafter_inv_xxn … H1) -H1 [ |*: // ] #g2 #g1 #H1f #Hgf2
664   lapply (istot_inv_push … Hf2 … Hgf2) -Hf2 #Hg2
665   elim (sor_inv_xxn … H2) -H2 [1,3,4: * |*: // ] #ga #gb #H2f
666   elim (IH … Hg2 … H1f … H2f) -f -Hg2
667   /3 width=11 by sor_np, sor_pn, sor_nn, ex3_2_intro, coafter_refl, coafter_push/
668 ]
669 qed-.
670
671 (* Properties with istot ****************************************************)
672
673 lemma coafter_sor: ∀f. 𝐅⦃f⦄ → ∀f2. 𝐓⦃f2⦄ → ∀f1. f2 ~⊚ f1 ≡ f → ∀f1a,f1b. f1a ⋓ f1b ≡ f1 →
674                    ∃∃fa,fb. f2 ~⊚ f1a ≡ fa & f2 ~⊚ f1b ≡ fb & fa ⋓ fb ≡ f.
675 @isfin_ind
676 [ #f #Hf #f2 #Hf2 #f1 #Hf #f1a #f1b #Hf1
677   lapply (coafter_fwd_isid2 … Hf ??) -Hf // #H2f1
678   elim (sor_inv_isid3 … Hf1) -Hf1 //
679   /3 width=5 by coafter_isid_dx, sor_refl, ex3_2_intro/
680 | #f #_ #IH #f2 #Hf2 #f1 #H1 #f1a #f1b #H2
681   elim (coafter_inv_xxp … H1) -H1 [1,3: * |*: // ]
682   [ #g2 #g1 #Hf #Hgf2 #Hgf1
683     elim (sor_inv_xxp … H2) -H2 [ |*: // ] #ga #gb #Hg1
684     lapply (istot_inv_push … Hf2 … Hgf2) -Hf2 #Hg2
685     elim (IH … Hf … Hg1) // -f1 -g1 -IH -Hg2
686     /3 width=11 by coafter_refl, sor_pp, ex3_2_intro/
687   | #g2 #Hf #Hgf2
688     lapply (istot_inv_next … Hf2 … Hgf2) -Hf2 #Hg2
689     elim (IH … Hf … H2) // -f1 -IH -Hg2
690     /3 width=11 by coafter_next, sor_pp, ex3_2_intro/
691   ]
692 | #f #_ #IH #f2 #Hf2 #f1 #H1 #f1a #f1b #H2
693   elim (coafter_inv_xxn … H1) -H1 [ |*: // ] #g2 #g1 #Hf #Hgf2 #Hgf1
694   lapply (istot_inv_push … Hf2 … Hgf2) -Hf2 #Hg2
695   elim (sor_inv_xxn … H2) -H2 [1,3,4: * |*: // ] #ga #gb #Hg1
696   elim (IH … Hf … Hg1) // -f1 -g1 -IH -Hg2
697   /3 width=11 by coafter_refl, coafter_push, sor_np, sor_pn, sor_nn, ex3_2_intro/
698 ]
699 qed-.
700
701 (* Properties with after ****************************************************)
702 (*
703 corec theorem coafter_trans1: ∀f0,f3,f4. f0 ~⊚ f3 ≡ f4 →
704                             ∀f1,f2. f1 ~⊚ f2 ≡ f0 →
705                             ∀f. f2 ~⊚ f3 ≡ f → f1 ~⊚ f ≡ f4.
706 #f0 #f3 #f4 * -f0 -f3 -f4 #f0 #f3 #f4 #g0 [1,2: #g3 ] #g4
707 [ #Hf4 #H0 #H3 #H4 #g1 #g2 #Hg0 #g #Hg
708   cases (coafter_inv_xxp … Hg0 … H0) -g0
709   #f1 #f2 #Hf0 #H1 #H2
710   cases (coafter_inv_ppx … Hg … H2 H3) -g2 -g3
711   #f #Hf #H /3 width=7 by coafter_refl/
712 | #Hf4 #H0 #H3 #H4 #g1 #g2 #Hg0 #g #Hg
713   cases (coafter_inv_xxp … Hg0 … H0) -g0
714   #f1 #f2 #Hf0 #H1 #H2
715   cases (coafter_inv_pnx … Hg … H2 H3) -g2 -g3
716   #f #Hf #H /3 width=7 by coafter_push/
717 | #Hf4 #H0 #H4 #g1 #g2 #Hg0 #g #Hg
718   cases (coafter_inv_xxn … Hg0 … H0) -g0 *
719   [ #f1 #f2 #Hf0 #H1 #H2
720     cases (coafter_inv_nxx … Hg … H2) -g2
721     #f #Hf #H /3 width=7 by coafter_push/
722   | #f1 #Hf0 #H1 /3 width=6 by coafter_next/
723   ]
724 ]
725 qed-.
726
727 corec theorem coafter_trans2: ∀f1,f0,f4. f1 ~⊚ f0 ≡ f4 →
728                             ∀f2, f3. f2 ~⊚ f3 ≡ f0 →
729                             ∀f. f1 ~⊚ f2 ≡ f → f ~⊚ f3 ≡ f4.
730 #f1 #f0 #f4 * -f1 -f0 -f4 #f1 #f0 #f4 #g1 [1,2: #g0 ] #g4
731 [ #Hf4 #H1 #H0 #H4 #g2 #g3 #Hg0 #g #Hg
732   cases (coafter_inv_xxp … Hg0 … H0) -g0
733   #f2 #f3 #Hf0 #H2 #H3
734   cases (coafter_inv_ppx … Hg … H1 H2) -g1 -g2
735   #f #Hf #H /3 width=7 by coafter_refl/
736 | #Hf4 #H1 #H0 #H4 #g2 #g3 #Hg0 #g #Hg
737   cases (coafter_inv_xxn … Hg0 … H0) -g0 *
738   [ #f2 #f3 #Hf0 #H2 #H3
739     cases (coafter_inv_ppx … Hg … H1 H2) -g1 -g2
740     #f #Hf #H /3 width=7 by coafter_push/
741   | #f2 #Hf0 #H2
742     cases (coafter_inv_pnx … Hg … H1 H2) -g1 -g2
743     #f #Hf #H /3 width=6 by coafter_next/
744   ]
745 | #Hf4 #H1 #H4 #f2 #f3 #Hf0 #g #Hg
746   cases (coafter_inv_nxx … Hg … H1) -g1
747   #f #Hg #H /3 width=6 by coafter_next/
748 ]
749 qed-.
750 *)