]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/reduction/cpx.ma
bc5044b6dfb379e0cc12fb09ab6b5bc38213b52a
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / reduction / cpx.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 "basic_2/notation/relations/pred_6.ma".
16 include "basic_2/static/sd.ma".
17 include "basic_2/reduction/cpr.ma".
18
19 (* CONTEXT-SENSITIVE EXTENDED PARALLEL REDUCTION FOR TERMS ******************)
20
21 (* avtivate genv *)
22 inductive cpx (h) (g): relation4 genv lenv term term ≝
23 | cpx_atom : ∀I,G,L. cpx h g G L (⓪{I}) (⓪{I})
24 | cpx_sort : ∀G,L,k,l. deg h g k (l+1) → cpx h g G L (⋆k) (⋆(next h k))
25 | cpx_delta: ∀I,G,L,K,V,V2,W2,i.
26              ⇩[0, i] L ≡ K.ⓑ{I}V → cpx h g G K V V2 →
27              ⇧[0, i + 1] V2 ≡ W2 → cpx h g G L (#i) W2
28 | cpx_bind : ∀a,I,G,L,V1,V2,T1,T2.
29              cpx h g G L V1 V2 → cpx h g G (L.ⓑ{I}V1) T1 T2 →
30              cpx h g G L (ⓑ{a,I}V1.T1) (ⓑ{a,I}V2.T2)
31 | cpx_flat : ∀I,G,L,V1,V2,T1,T2.
32              cpx h g G L V1 V2 → cpx h g G L T1 T2 →
33              cpx h g G L (ⓕ{I}V1.T1) (ⓕ{I}V2.T2)
34 | cpx_zeta : ∀G,L,V,T1,T,T2. cpx h g G (L.ⓓV) T1 T →
35              ⇧[0, 1] T2 ≡ T → cpx h g G L (+ⓓV.T1) T2
36 | cpx_tau  : ∀G,L,V,T1,T2. cpx h g G L T1 T2 → cpx h g G L (ⓝV.T1) T2
37 | cpx_ti   : ∀G,L,V1,V2,T. cpx h g G L V1 V2 → cpx h g G L (ⓝV1.T) V2
38 | cpx_beta : ∀a,G,L,V1,V2,W1,W2,T1,T2.
39              cpx h g G L V1 V2 → cpx h g G L W1 W2 → cpx h g G (L.ⓛW1) T1 T2 →
40              cpx h g G L (ⓐV1.ⓛ{a}W1.T1) (ⓓ{a}ⓝW2.V2.T2)
41 | cpx_theta: ∀a,G,L,V1,V,V2,W1,W2,T1,T2.
42              cpx h g G L V1 V → ⇧[0, 1] V ≡ V2 → cpx h g G L W1 W2 →
43              cpx h g G (L.ⓓW1) T1 T2 →
44              cpx h g G L (ⓐV1.ⓓ{a}W1.T1) (ⓓ{a}W2.ⓐV2.T2)
45 .
46
47 interpretation
48    "context-sensitive extended parallel reduction (term)"
49    'PRed h g G L T1 T2 = (cpx h g G L T1 T2).
50
51 (* Basic properties *********************************************************)
52
53 lemma lsubr_cpx_trans: ∀h,g,G. lsub_trans … (cpx h g G) lsubr.
54 #h #g #G #L1 #T1 #T2 #H elim H -G -L1 -T1 -T2
55 [ //
56 | /2 width=2 by cpx_sort/
57 | #I #G #L1 #K1 #V1 #V2 #W2 #i #HLK1 #_ #HVW2 #IHV12 #L2 #HL12
58   elim (lsubr_fwd_ldrop2_bind … HL12 … HLK1) -HL12 -HLK1 *
59   /4 width=7 by cpx_delta, cpx_ti/
60 |4,9: /4 width=1 by cpx_bind, cpx_beta, lsubr_bind/
61 |5,7,8: /3 width=1 by cpx_flat, cpx_tau, cpx_ti/
62 |6,10: /4 width=3 by cpx_zeta, cpx_theta, lsubr_bind/
63 ]
64 qed-.
65
66 (* Note: this is "∀h,g,L. reflexive … (cpx h g L)" *)
67 lemma cpx_refl: ∀h,g,G,T,L. ⦃G, L⦄ ⊢ T ➡[h, g] T.
68 #h #g #G #T elim T -T // * /2 width=1 by cpx_bind, cpx_flat/
69 qed.
70
71 lemma cpr_cpx: ∀h,g,G,L,T1,T2. ⦃G, L⦄ ⊢ T1 ➡ T2 → ⦃G, L⦄ ⊢ T1 ➡[h, g] T2.
72 #h #g #G #L #T1 #T2 #H elim H -L -T1 -T2
73 /2 width=7 by cpx_delta, cpx_bind, cpx_flat, cpx_zeta, cpx_tau, cpx_beta, cpx_theta/
74 qed.
75
76 lemma cpx_pair_sn: ∀h,g,I,G,L,V1,V2. ⦃G, L⦄ ⊢ V1 ➡[h, g] V2 →
77                    ∀T. ⦃G, L⦄ ⊢ ②{I}V1.T ➡[h, g] ②{I}V2.T.
78 #h #g * /2 width=1 by cpx_bind, cpx_flat/
79 qed.
80
81 lemma cpx_delift: ∀h,g,I,G,K,V,T1,L,d. ⇩[0, d] L ≡ (K.ⓑ{I}V) →
82                   ∃∃T2,T.  ⦃G, L⦄ ⊢ T1 ➡[h, g] T2 & ⇧[d, 1] T ≡ T2.
83 #h #g #I #G #K #V #T1 elim T1 -T1
84 [ * #i #L #d /2 width=4 by cpx_atom, lift_sort, lift_gref, ex2_2_intro/
85   elim (lt_or_eq_or_gt i d) #Hid [1,3: /3 width=4 by cpx_atom, lift_lref_ge_minus, lift_lref_lt, ex2_2_intro/ ]
86   destruct
87   elim (lift_total V 0 (i+1)) #W #HVW
88   elim (lift_split … HVW i i) /3 width=7 by cpx_delta, ex2_2_intro/
89 | * [ #a ] #I #W1 #U1 #IHW1 #IHU1 #L #d #HLK
90   elim (IHW1 … HLK) -IHW1 #W2 #W #HW12 #HW2
91   [ elim (IHU1 (L. ⓑ{I} W1) (d+1)) -IHU1 /3 width=9 by cpx_bind, ldrop_ldrop, lift_bind, ex2_2_intro/
92   | elim (IHU1 … HLK) -IHU1 -HLK /3 width=8 by cpx_flat, lift_flat, ex2_2_intro/
93   ]
94 ]
95 qed-.
96
97 lemma cpx_append: ∀h,g,G. l_appendable_sn … (cpx h g G).
98 #h #g #G #K #T1 #T2 #H elim H -G -K -T1 -T2
99 /2 width=3 by cpx_sort, cpx_bind, cpx_flat, cpx_zeta, cpx_tau, cpx_ti, cpx_beta, cpx_theta/
100 #I #G #K #K0 #V1 #V2 #W2 #i #HK0 #_ #HVW2 #IHV12 #L
101 lapply (ldrop_fwd_length_lt2 … HK0) #H
102 @(cpx_delta … I … (L@@K0) V1 … HVW2) // 
103 @(ldrop_O1_append_sn_le … HK0) /2 width=2 by lt_to_le/ (**) (* /3/ does not work *)
104 qed.
105
106 (* Basic inversion lemmas ***************************************************)
107
108 fact cpx_inv_atom1_aux: ∀h,g,G,L,T1,T2. ⦃G, L⦄ ⊢ T1 ➡[h, g] T2 → ∀J. T1 = ⓪{J} →
109                         ∨∨ T2 = ⓪{J}
110                          | ∃∃k,l. deg h g k (l+1) & T2 = ⋆(next h k) & J = Sort k
111                          | ∃∃I,K,V,V2,i. ⇩[O, i] L ≡ K.ⓑ{I}V & ⦃G, K⦄ ⊢ V ➡[h, g] V2 &
112                                          ⇧[O, i + 1] V2 ≡ T2 & J = LRef i.
113 #G #h #g #L #T1 #T2 * -L -T1 -T2
114 [ #I #G #L #J #H destruct /2 width=1 by or3_intro0/
115 | #G #L #k #l #Hkl #J #H destruct /3 width=5 by or3_intro1, ex3_2_intro/
116 | #I #G #L #K #V #V2 #T2 #i #HLK #HV2 #HVT2 #J #H destruct /3 width=9 by or3_intro2, ex4_5_intro/
117 | #a #I #G #L #V1 #V2 #T1 #T2 #_ #_ #J #H destruct
118 | #I #G #L #V1 #V2 #T1 #T2 #_ #_ #J #H destruct
119 | #G #L #V #T1 #T #T2 #_ #_ #J #H destruct
120 | #G #L #V #T1 #T2 #_ #J #H destruct
121 | #G #L #V1 #V2 #T #_ #J #H destruct
122 | #a #G #L #V1 #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #J #H destruct
123 | #a #G #L #V1 #V #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #_ #J #H destruct
124 ]
125 qed-.
126
127 lemma cpx_inv_atom1: ∀h,g,J,G,L,T2. ⦃G, L⦄ ⊢ ⓪{J} ➡[h, g] T2 →
128                      ∨∨ T2 = ⓪{J}
129                       | ∃∃k,l. deg h g k (l+1) & T2 = ⋆(next h k) & J = Sort k
130                       | ∃∃I,K,V,V2,i. ⇩[O, i] L ≡ K.ⓑ{I}V & ⦃G, K⦄ ⊢ V ➡[h, g] V2 &
131                                       ⇧[O, i + 1] V2 ≡ T2 & J = LRef i.
132 /2 width=3 by cpx_inv_atom1_aux/ qed-.
133
134 lemma cpx_inv_sort1: ∀h,g,G,L,T2,k. ⦃G, L⦄ ⊢ ⋆k ➡[h, g] T2 → T2 = ⋆k ∨
135                      ∃∃l. deg h g k (l+1) & T2 = ⋆(next h k).
136 #h #g #G #L #T2 #k #H
137 elim (cpx_inv_atom1 … H) -H /2 width=1 by or_introl/ *
138 [ #k0 #l0 #Hkl0 #H1 #H2 destruct /3 width=4 by ex2_intro, or_intror/
139 | #I #K #V #V2 #i #_ #_ #_ #H destruct
140 ]
141 qed-.
142
143 lemma cpx_inv_lref1: ∀h,g,G,L,T2,i. ⦃G, L⦄ ⊢ #i ➡[h, g] T2 →
144                      T2 = #i ∨
145                      ∃∃I,K,V,V2. ⇩[O, i] L ≡ K. ⓑ{I}V & ⦃G, K⦄ ⊢ V ➡[h, g] V2 &
146                                  ⇧[O, i + 1] V2 ≡ T2.
147 #h #g #G #L #T2 #i #H
148 elim (cpx_inv_atom1 … H) -H /2 width=1 by or_introl/ *
149 [ #k #l #_ #_ #H destruct
150 | #I #K #V #V2 #j #HLK #HV2 #HVT2 #H destruct /3 width=7 by ex3_4_intro, or_intror/
151 ]
152 qed-.
153
154 lemma cpx_inv_lref1_ge: ∀h,g,G,L,T2,i. ⦃G, L⦄ ⊢ #i ➡[h, g] T2 → |L| ≤ i → T2 = #i.
155 #h #g #G #L #T2 #i #H elim (cpx_inv_lref1 … H) -H // *
156 #I #K #V1 #V2 #HLK #_ #_ #HL -h -G -V2 lapply (ldrop_fwd_length_lt2 … HLK) -K -I -V1
157 #H elim (lt_refl_false i) /2 width=3 by lt_to_le_to_lt/
158 qed-.
159
160 lemma cpx_inv_gref1: ∀h,g,G,L,T2,p.  ⦃G, L⦄ ⊢ §p ➡[h, g] T2 → T2 = §p.
161 #h #g #G #L #T2 #p #H
162 elim (cpx_inv_atom1 … H) -H // *
163 [ #k #l #_ #_ #H destruct
164 | #I #K #V #V2 #i #_ #_ #_ #H destruct
165 ]
166 qed-.
167
168 fact cpx_inv_bind1_aux: ∀h,g,G,L,U1,U2. ⦃G, L⦄ ⊢ U1 ➡[h, g] U2 →
169                         ∀a,J,V1,T1. U1 = ⓑ{a,J}V1.T1 → (
170                         ∃∃V2,T2. ⦃G, L⦄ ⊢ V1 ➡[h, g] V2 & ⦃G, L.ⓑ{J}V1⦄ ⊢ T1 ➡[h, g] T2 &
171                                  U2 = ⓑ{a,J}V2.T2
172                         ) ∨
173                         ∃∃T. ⦃G, L.ⓓV1⦄ ⊢ T1 ➡[h, g] T & ⇧[0, 1] U2 ≡ T &
174                              a = true & J = Abbr.
175 #h #g #G #L #U1 #U2 * -L -U1 -U2
176 [ #I #G #L #b #J #W #U1 #H destruct
177 | #G #L #k #l #_ #b #J #W #U1 #H destruct
178 | #I #G #L #K #V #V2 #W2 #i #_ #_ #_ #b #J #W #U1 #H destruct
179 | #a #I #G #L #V1 #V2 #T1 #T2 #HV12 #HT12 #b #J #W #U1 #H destruct /3 width=5 by ex3_2_intro, or_introl/
180 | #I #G #L #V1 #V2 #T1 #T2 #_ #_ #b #J #W #U1 #H destruct
181 | #G #L #V #T1 #T #T2 #HT1 #HT2 #b #J #W #U1 #H destruct /3 width=3 by ex4_intro, or_intror/
182 | #G #L #V #T1 #T2 #_ #b #J #W #U1 #H destruct
183 | #G #L #V1 #V2 #T #_ #b #J #W #U1 #H destruct
184 | #a #G #L #V1 #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #b #J #W #U1 #H destruct
185 | #a #G #L #V1 #V #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #_ #b #J #W #U1 #H destruct
186 ]
187 qed-.
188
189 lemma cpx_inv_bind1: ∀h,g,a,I,G,L,V1,T1,U2. ⦃G, L⦄ ⊢ ⓑ{a,I}V1.T1 ➡[h, g] U2 → (
190                      ∃∃V2,T2. ⦃G, L⦄ ⊢ V1 ➡[h, g] V2 & ⦃G, L.ⓑ{I}V1⦄ ⊢ T1 ➡[h, g] T2 &
191                               U2 = ⓑ{a,I} V2. T2
192                      ) ∨
193                      ∃∃T. ⦃G, L.ⓓV1⦄ ⊢ T1 ➡[h, g] T & ⇧[0, 1] U2 ≡ T &
194                           a = true & I = Abbr.
195 /2 width=3 by cpx_inv_bind1_aux/ qed-.
196
197 lemma cpx_inv_abbr1: ∀h,g,a,G,L,V1,T1,U2. ⦃G, L⦄ ⊢ ⓓ{a}V1.T1 ➡[h, g] U2 → (
198                      ∃∃V2,T2. ⦃G, L⦄ ⊢ V1 ➡[h, g] V2 & ⦃G, L.ⓓV1⦄ ⊢ T1 ➡[h, g] T2 &
199                               U2 = ⓓ{a} V2. T2
200                      ) ∨
201                      ∃∃T. ⦃G, L.ⓓV1⦄ ⊢ T1 ➡[h, g] T & ⇧[0, 1] U2 ≡ T & a = true.
202 #h #g #a #G #L #V1 #T1 #U2 #H
203 elim (cpx_inv_bind1 … H) -H * /3 width=5 by ex3_2_intro, ex3_intro, or_introl, or_intror/
204 qed-.
205
206 lemma cpx_inv_abst1: ∀h,g,a,G,L,V1,T1,U2.  ⦃G, L⦄ ⊢ ⓛ{a}V1.T1 ➡[h, g] U2 →
207                      ∃∃V2,T2. ⦃G, L⦄ ⊢ V1 ➡[h, g] V2 &  ⦃G, L.ⓛV1⦄ ⊢ T1 ➡[h, g] T2 &
208                               U2 = ⓛ{a} V2. T2.
209 #h #g #a #G #L #V1 #T1 #U2 #H
210 elim (cpx_inv_bind1 … H) -H *
211 [ /3 width=5 by ex3_2_intro/
212 | #T #_ #_ #_ #H destruct
213 ]
214 qed-.
215
216 fact cpx_inv_flat1_aux: ∀h,g,G,L,U,U2. ⦃G, L⦄ ⊢ U ➡[h, g] U2 →
217                         ∀J,V1,U1. U = ⓕ{J}V1.U1 →
218                         ∨∨ ∃∃V2,T2. ⦃G, L⦄ ⊢ V1 ➡[h, g] V2 & ⦃G, L⦄ ⊢ U1 ➡[h, g] T2 &
219                                     U2 = ⓕ{J}V2.T2
220                          | (⦃G, L⦄ ⊢ U1 ➡[h, g] U2 ∧ J = Cast)
221                          | (⦃G, L⦄ ⊢ V1 ➡[h, g] U2 ∧ J = Cast)
222                          | ∃∃a,V2,W1,W2,T1,T2. ⦃G, L⦄ ⊢ V1 ➡[h, g] V2 & ⦃G, L⦄ ⊢ W1 ➡[h, g] W2 &
223                                                ⦃G, L.ⓛW1⦄ ⊢ T1 ➡[h, g] T2 &
224                                                U1 = ⓛ{a}W1.T1 &
225                                                U2 = ⓓ{a}ⓝW2.V2.T2 & J = Appl
226                          | ∃∃a,V,V2,W1,W2,T1,T2. ⦃G, L⦄ ⊢ V1 ➡[h, g] V & ⇧[0,1] V ≡ V2 &
227                                                  ⦃G, L⦄ ⊢ W1 ➡[h, g] W2 & ⦃G, L.ⓓW1⦄ ⊢ T1 ➡[h, g] T2 &
228                                                  U1 = ⓓ{a}W1.T1 &
229                                                  U2 = ⓓ{a}W2.ⓐV2.T2 & J = Appl.
230 #h #g #G #L #U #U2 * -L -U -U2
231 [ #I #G #L #J #W #U1 #H destruct
232 | #G #L #k #l #_ #J #W #U1 #H destruct
233 | #I #G #L #K #V #V2 #W2 #i #_ #_ #_ #J #W #U1 #H destruct
234 | #a #I #G #L #V1 #V2 #T1 #T2 #_ #_ #J #W #U1 #H destruct
235 | #I #G #L #V1 #V2 #T1 #T2 #HV12 #HT12 #J #W #U1 #H destruct /3 width=5 by or5_intro0, ex3_2_intro/
236 | #G #L #V #T1 #T #T2 #_ #_ #J #W #U1 #H destruct
237 | #G #L #V #T1 #T2 #HT12 #J #W #U1 #H destruct /3 width=1 by or5_intro1, conj/
238 | #G #L #V1 #V2 #T #HV12 #J #W #U1 #H destruct /3 width=1 by or5_intro2, conj/
239 | #a #G #L #V1 #V2 #W1 #W2 #T1 #T2 #HV12 #HW12 #HT12 #J #W #U1 #H destruct /3 width=11 by or5_intro3, ex6_6_intro/
240 | #a #G #L #V1 #V #V2 #W1 #W2 #T1 #T2 #HV1 #HV2 #HW12 #HT12 #J #W #U1 #H destruct /3 width=13 by or5_intro4, ex7_7_intro/
241 ]
242 qed-.
243
244 lemma cpx_inv_flat1: ∀h,g,I,G,L,V1,U1,U2. ⦃G, L⦄ ⊢ ⓕ{I}V1.U1 ➡[h, g] U2 →
245                      ∨∨ ∃∃V2,T2. ⦃G, L⦄ ⊢ V1 ➡[h, g] V2 & ⦃G, L⦄ ⊢ U1 ➡[h, g] T2 &
246                                  U2 = ⓕ{I} V2. T2
247                       | (⦃G, L⦄ ⊢ U1 ➡[h, g] U2 ∧ I = Cast)
248                       | (⦃G, L⦄ ⊢ V1 ➡[h, g] U2 ∧ I = Cast)
249                       | ∃∃a,V2,W1,W2,T1,T2. ⦃G, L⦄ ⊢ V1 ➡[h, g] V2 & ⦃G, L⦄ ⊢ W1 ➡[h, g] W2 &
250                                             ⦃G, L.ⓛW1⦄ ⊢ T1 ➡[h, g] T2 &
251                                             U1 = ⓛ{a}W1.T1 &
252                                             U2 = ⓓ{a}ⓝW2.V2.T2 & I = Appl
253                       | ∃∃a,V,V2,W1,W2,T1,T2. ⦃G, L⦄ ⊢ V1 ➡[h, g] V & ⇧[0,1] V ≡ V2 &
254                                               ⦃G, L⦄ ⊢ W1 ➡[h, g] W2 & ⦃G, L.ⓓW1⦄ ⊢ T1 ➡[h, g] T2 &
255                                               U1 = ⓓ{a}W1.T1 &
256                                               U2 = ⓓ{a}W2.ⓐV2.T2 & I = Appl.
257 /2 width=3 by cpx_inv_flat1_aux/ qed-.
258
259 lemma cpx_inv_appl1: ∀h,g,G,L,V1,U1,U2. ⦃G, L⦄ ⊢ ⓐ V1.U1 ➡[h, g] U2 →
260                      ∨∨ ∃∃V2,T2. ⦃G, L⦄ ⊢ V1 ➡[h, g] V2 & ⦃G, L⦄ ⊢ U1 ➡[h, g] T2 &
261                                  U2 = ⓐ V2. T2
262                       | ∃∃a,V2,W1,W2,T1,T2. ⦃G, L⦄ ⊢ V1 ➡[h, g] V2 & ⦃G, L⦄ ⊢ W1 ➡[h, g] W2 &
263                                             ⦃G, L.ⓛW1⦄ ⊢ T1 ➡[h, g] T2 &
264                                             U1 = ⓛ{a}W1.T1 & U2 = ⓓ{a}ⓝW2.V2.T2
265                       | ∃∃a,V,V2,W1,W2,T1,T2. ⦃G, L⦄ ⊢ V1 ➡[h, g] V & ⇧[0,1] V ≡ V2 &
266                                               ⦃G, L⦄ ⊢ W1 ➡[h, g] W2 & ⦃G, L.ⓓW1⦄ ⊢ T1 ➡[h, g] T2 &
267                                               U1 = ⓓ{a}W1.T1 & U2 = ⓓ{a}W2. ⓐV2. T2.
268 #h #g #G #L #V1 #U1 #U2 #H elim (cpx_inv_flat1 … H) -H *
269 [ /3 width=5 by or3_intro0, ex3_2_intro/
270 |2,3: #_ #H destruct
271 | /3 width=11 by or3_intro1, ex5_6_intro/
272 | /3 width=13 by or3_intro2, ex6_7_intro/
273 ]
274 qed-.
275
276 (* Note: the main property of simple terms *)
277 lemma cpx_inv_appl1_simple: ∀h,g,G,L,V1,T1,U. ⦃G, L⦄ ⊢ ⓐV1.T1 ➡[h, g] U → 𝐒⦃T1⦄ →
278                             ∃∃V2,T2. ⦃G, L⦄ ⊢ V1 ➡[h, g] V2 & ⦃G, L⦄ ⊢ T1 ➡[h, g] T2 &
279                                      U = ⓐV2.T2.
280 #h #g #G #L #V1 #T1 #U #H #HT1
281 elim (cpx_inv_appl1 … H) -H *
282 [ /2 width=5 by ex3_2_intro/
283 | #a #V2 #W1 #W2 #U1 #U2 #_ #_ #_ #H #_ destruct
284   elim (simple_inv_bind … HT1)
285 | #a #V #V2 #W1 #W2 #U1 #U2 #_ #_ #_ #_ #H #_ destruct
286   elim (simple_inv_bind … HT1)
287 ]
288 qed-.
289
290 lemma cpx_inv_cast1: ∀h,g,G,L,V1,U1,U2. ⦃G, L⦄ ⊢ ⓝV1.U1 ➡[h, g] U2 →
291                      ∨∨ ∃∃V2,T2. ⦃G, L⦄ ⊢ V1 ➡[h, g] V2 & ⦃G, L⦄ ⊢ U1 ➡[h, g] T2 &
292                                  U2 = ⓝ V2. T2
293                       | ⦃G, L⦄ ⊢ U1 ➡[h, g] U2
294                       | ⦃G, L⦄ ⊢ V1 ➡[h, g] U2.
295 #h #g #G #L #V1 #U1 #U2 #H elim (cpx_inv_flat1 … H) -H *
296 [ /3 width=5 by or3_intro0, ex3_2_intro/
297 |2,3: /2 width=1 by or3_intro1, or3_intro2/
298 | #a #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #_ #_ #H destruct
299 | #a #V #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #_ #_ #_ #H destruct
300 ]
301 qed-.
302
303 (* Basic forward lemmas *****************************************************)
304
305 lemma cpx_fwd_bind1_minus: ∀h,g,I,G,L,V1,T1,T. ⦃G, L⦄ ⊢ -ⓑ{I}V1.T1 ➡[h, g] T → ∀b.
306                            ∃∃V2,T2. ⦃G, L⦄ ⊢ ⓑ{b,I}V1.T1 ➡[h, g] ⓑ{b,I}V2.T2 &
307                                     T = -ⓑ{I}V2.T2.
308 #h #g #I #G #L #V1 #T1 #T #H #b
309 elim (cpx_inv_bind1 … H) -H *
310 [ #V2 #T2 #HV12 #HT12 #H destruct /3 width=4 by cpx_bind, ex2_2_intro/
311 | #T2 #_ #_ #H destruct
312 ]
313 qed-.
314
315 lemma cpx_fwd_shift1: ∀h,g,G,L1,L,T1,T. ⦃G, L⦄ ⊢ L1 @@ T1 ➡[h, g] T →
316                       ∃∃L2,T2. |L1| = |L2| & T = L2 @@ T2.
317 #h #g #G #L1 @(lenv_ind_dx … L1) -L1 normalize
318 [ #L #T1 #T #HT1
319   @(ex2_2_intro … (⋆)) // (**) (* explicit constructor *)
320 | #I #L1 #V1 #IH #L #T1 #X
321   >shift_append_assoc normalize #H
322   elim (cpx_inv_bind1 … H) -H *
323   [ #V0 #T0 #_ #HT10 #H destruct
324     elim (IH … HT10) -IH -HT10 #L2 #T2 #HL12 #H destruct
325     >append_length >HL12 -HL12
326     @(ex2_2_intro … (⋆.ⓑ{I}V0@@L2) T2) [ >append_length ] /2 width=3 by refl, trans_eq/ (**) (* explicit constructor *)
327   | #T #_ #_ #H destruct
328   ]
329 ]
330 qed-.