]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/rt_transition/cpm.ma
6893cf19e6ef4ca8ae4e4a85c0c38fdf5161db58
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / rt_transition / cpm.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/notation/relations/pred_5.ma".
17 include "basic_2/rt_transition/cpg.ma".
18
19 (* T-BOUND CONTEXT-SENSITIVE PARALLEL RT-TRANSITION FOR TERMS ***************)
20
21 (* Basic_2A1: includes: cpr *)
22 definition cpm (h) (G) (L) (n): relation2 term term ≝
23                                 λT1,T2. ∃∃c. 𝐑𝐓⦃n,c⦄ & ⦃G,L⦄ ⊢ T1 ⬈[eq_t,c,h] T2.
24
25 interpretation
26    "t-bound context-sensitive parallel rt-transition (term)"
27    'PRed n h G L T1 T2 = (cpm h G L n T1 T2).
28
29 interpretation
30    "context-sensitive parallel r-transition (term)"
31    'PRed h G L T1 T2 = (cpm h G L O T1 T2).
32
33 (* Basic properties *********************************************************)
34
35 lemma cpm_ess: ∀h,G,L,s. ⦃G,L⦄ ⊢ ⋆s ➡[1,h] ⋆(⫯[h]s).
36 /2 width=3 by cpg_ess, ex2_intro/ qed.
37
38 lemma cpm_delta: ∀n,h,G,K,V1,V2,W2. ⦃G,K⦄ ⊢ V1 ➡[n,h] V2 →
39                  ⇧*[1] V2 ≘ W2 → ⦃G,K.ⓓV1⦄ ⊢ #0 ➡[n,h] W2.
40 #n #h #G #K #V1 #V2 #W2 *
41 /3 width=5 by cpg_delta, ex2_intro/
42 qed.
43
44 lemma cpm_ell: ∀n,h,G,K,V1,V2,W2. ⦃G,K⦄ ⊢ V1 ➡[n,h] V2 →
45                ⇧*[1] V2 ≘ W2 → ⦃G,K.ⓛV1⦄ ⊢ #0 ➡[↑n,h] W2.
46 #n #h #G #K #V1 #V2 #W2 *
47 /3 width=5 by cpg_ell, ex2_intro, isrt_succ/
48 qed.
49
50 lemma cpm_lref: ∀n,h,I,G,K,T,U,i. ⦃G,K⦄ ⊢ #i ➡[n,h] T →
51                 ⇧*[1] T ≘ U → ⦃G,K.ⓘ{I}⦄ ⊢ #↑i ➡[n,h] U.
52 #n #h #I #G #K #T #U #i *
53 /3 width=5 by cpg_lref, ex2_intro/
54 qed.
55
56 (* Basic_2A1: includes: cpr_bind *)
57 lemma cpm_bind: ∀n,h,p,I,G,L,V1,V2,T1,T2.
58                 ⦃G,L⦄ ⊢ V1 ➡[h] V2 → ⦃G,L.ⓑ{I}V1⦄ ⊢ T1 ➡[n,h] T2 →
59                 ⦃G,L⦄ ⊢ ⓑ{p,I}V1.T1 ➡[n,h] ⓑ{p,I}V2.T2.
60 #n #h #p #I #G #L #V1 #V2 #T1 #T2 * #cV #HcV #HV12 *
61 /5 width=5 by cpg_bind, isrt_max_O1, isr_shift, ex2_intro/
62 qed.
63
64 lemma cpm_appl: ∀n,h,G,L,V1,V2,T1,T2.
65                 ⦃G,L⦄ ⊢ V1 ➡[h] V2 → ⦃G,L⦄ ⊢ T1 ➡[n,h] T2 →
66                 ⦃G,L⦄ ⊢ ⓐV1.T1 ➡[n,h] ⓐV2.T2.
67 #n #h #G #L #V1 #V2 #T1 #T2 * #cV #HcV #HV12 *
68 /5 width=5 by isrt_max_O1, isr_shift, cpg_appl, ex2_intro/
69 qed.
70
71 lemma cpm_cast: ∀n,h,G,L,U1,U2,T1,T2.
72                 ⦃G,L⦄ ⊢ U1 ➡[n,h] U2 → ⦃G,L⦄ ⊢ T1 ➡[n,h] T2 →
73                 ⦃G,L⦄ ⊢ ⓝU1.T1 ➡[n,h] ⓝU2.T2.
74 #n #h #G #L #U1 #U2 #T1 #T2 * #cU #HcU #HU12 *
75 /4 width=6 by cpg_cast, isrt_max_idem1, isrt_mono, ex2_intro/
76 qed.
77
78 (* Basic_2A1: includes: cpr_zeta *)
79 lemma cpm_zeta (n) (h) (G) (L):
80                ∀T1,T. ⇧*[1] T ≘ T1 → ∀T2. ⦃G,L⦄ ⊢ T ➡[n,h] T2 →
81                ∀V. ⦃G,L⦄ ⊢ +ⓓV.T1 ➡[n,h] T2.
82 #n #h #G #L #T1 #T #HT1 #T2 *
83 /3 width=5 by cpg_zeta, isrt_plus_O2, ex2_intro/
84 qed.
85
86 (* Basic_2A1: includes: cpr_eps *)
87 lemma cpm_eps: ∀n,h,G,L,V,T1,T2. ⦃G,L⦄ ⊢ T1 ➡[n,h] T2 → ⦃G,L⦄ ⊢ ⓝV.T1 ➡[n,h] T2.
88 #n #h #G #L #V #T1 #T2 *
89 /3 width=3 by cpg_eps, isrt_plus_O2, ex2_intro/
90 qed.
91
92 lemma cpm_ee: ∀n,h,G,L,V1,V2,T. ⦃G,L⦄ ⊢ V1 ➡[n,h] V2 → ⦃G,L⦄ ⊢ ⓝV1.T ➡[↑n,h] V2.
93 #n #h #G #L #V1 #V2 #T *
94 /3 width=3 by cpg_ee, isrt_succ, ex2_intro/
95 qed.
96
97 (* Basic_2A1: includes: cpr_beta *)
98 lemma cpm_beta: ∀n,h,p,G,L,V1,V2,W1,W2,T1,T2.
99                 ⦃G,L⦄ ⊢ V1 ➡[h] V2 → ⦃G,L⦄ ⊢ W1 ➡[h] W2 → ⦃G,L.ⓛW1⦄ ⊢ T1 ➡[n,h] T2 →
100                 ⦃G,L⦄ ⊢ ⓐV1.ⓛ{p}W1.T1 ➡[n,h] ⓓ{p}ⓝW2.V2.T2.
101 #n #h #p #G #L #V1 #V2 #W1 #W2 #T1 #T2 * #riV #rhV #HV12 * #riW #rhW #HW12 *
102 /6 width=7 by cpg_beta, isrt_plus_O2, isrt_max, isr_shift, ex2_intro/
103 qed.
104
105 (* Basic_2A1: includes: cpr_theta *)
106 lemma cpm_theta: ∀n,h,p,G,L,V1,V,V2,W1,W2,T1,T2.
107                  ⦃G,L⦄ ⊢ V1 ➡[h] V → ⇧*[1] V ≘ V2 → ⦃G,L⦄ ⊢ W1 ➡[h] W2 →
108                  ⦃G,L.ⓓW1⦄ ⊢ T1 ➡[n,h] T2 →
109                  ⦃G,L⦄ ⊢ ⓐV1.ⓓ{p}W1.T1 ➡[n,h] ⓓ{p}W2.ⓐV2.T2.
110 #n #h #p #G #L #V1 #V #V2 #W1 #W2 #T1 #T2 * #riV #rhV #HV1 #HV2 * #riW #rhW #HW12 *
111 /6 width=9 by cpg_theta, isrt_plus_O2, isrt_max, isr_shift, ex2_intro/
112 qed.
113
114 (* Basic properties with r-transition ***************************************)
115
116 (* Note: this is needed by cpms_ind_sn and cpms_ind_dx *)
117 (* Basic_1: includes by definition: pr0_refl *)
118 (* Basic_2A1: includes: cpr_atom *)
119 lemma cpr_refl: ∀h,G,L. reflexive … (cpm h G L 0).
120 /3 width=3 by cpg_refl, ex2_intro/ qed.
121
122 (* Advanced properties ******************************************************)
123
124 lemma cpm_sort (h) (G) (L):
125                ∀n. n ≤ 1 → ∀s. ⦃G,L⦄ ⊢ ⋆s ➡[n,h] ⋆((next h)^n s).
126 #h #G #L * //
127 #n #H #s <(le_n_O_to_eq n) /2 width=1 by le_S_S_to_le/
128 qed.
129
130 (* Basic inversion lemmas ***************************************************)
131
132 lemma cpm_inv_atom1: ∀n,h,J,G,L,T2. ⦃G,L⦄ ⊢ ⓪{J} ➡[n,h] T2 →
133                      ∨∨ T2 = ⓪{J} ∧ n = 0
134                       | ∃∃s. T2 = ⋆(⫯[h]s) & J = Sort s & n = 1
135                       | ∃∃K,V1,V2. ⦃G,K⦄ ⊢ V1 ➡[n,h] V2 & ⇧*[1] V2 ≘ T2 &
136                                    L = K.ⓓV1 & J = LRef 0
137                       | ∃∃m,K,V1,V2. ⦃G,K⦄ ⊢ V1 ➡[m,h] V2 & ⇧*[1] V2 ≘ T2 &
138                                      L = K.ⓛV1 & J = LRef 0 & n = ↑m
139                       | ∃∃I,K,T,i. ⦃G,K⦄ ⊢ #i ➡[n,h] T & ⇧*[1] T ≘ T2 &
140                                    L = K.ⓘ{I} & J = LRef (↑i).
141 #n #h #J #G #L #T2 * #c #Hc #H elim (cpg_inv_atom1 … H) -H *
142 [ #H1 #H2 destruct /4 width=1 by isrt_inv_00, or5_intro0, conj/
143 | #s #H1 #H2 #H3 destruct /4 width=3 by isrt_inv_01, or5_intro1, ex3_intro/
144 | #cV #K #V1 #V2 #HV12 #HVT2 #H1 #H2 #H3 destruct
145   /4 width=6 by or5_intro2, ex4_3_intro, ex2_intro/
146 | #cV #K #V1 #V2 #HV12 #HVT2 #H1 #H2 #H3 destruct
147   elim (isrt_inv_plus_SO_dx … Hc) -Hc // #m #Hc #H destruct
148   /4 width=9 by or5_intro3, ex5_4_intro, ex2_intro/
149 | #I #K #V2 #i #HV2 #HVT2 #H1 #H2 destruct
150   /4 width=8 by or5_intro4, ex4_4_intro, ex2_intro/
151 ]
152 qed-.
153
154 lemma cpm_inv_sort1: ∀n,h,G,L,T2,s. ⦃G,L⦄ ⊢ ⋆s ➡[n,h] T2 →
155                      ∧∧ T2 = ⋆(((next h)^n) s) & n ≤ 1.
156 #n #h #G #L #T2 #s * #c #Hc #H
157 elim (cpg_inv_sort1 … H) -H * #H1 #H2 destruct
158 [ lapply (isrt_inv_00 … Hc) | lapply (isrt_inv_01 … Hc) ] -Hc
159 #H destruct /2 width=1 by conj/
160 qed-.
161
162 lemma cpm_inv_zero1: ∀n,h,G,L,T2. ⦃G,L⦄ ⊢ #0 ➡[n,h] T2 →
163                      ∨∨ T2 = #0 ∧ n = 0
164                       | ∃∃K,V1,V2. ⦃G,K⦄ ⊢ V1 ➡[n,h] V2 & ⇧*[1] V2 ≘ T2 &
165                                    L = K.ⓓV1
166                       | ∃∃m,K,V1,V2. ⦃G,K⦄ ⊢ V1 ➡[m,h] V2 & ⇧*[1] V2 ≘ T2 &
167                                      L = K.ⓛV1 & n = ↑m.
168 #n #h #G #L #T2 * #c #Hc #H elim (cpg_inv_zero1 … H) -H *
169 [ #H1 #H2 destruct /4 width=1 by isrt_inv_00, or3_intro0, conj/
170 | #cV #K #V1 #V2 #HV12 #HVT2 #H1 #H2 destruct
171   /4 width=8 by or3_intro1, ex3_3_intro, ex2_intro/
172 | #cV #K #V1 #V2 #HV12 #HVT2 #H1 #H2 destruct
173   elim (isrt_inv_plus_SO_dx … Hc) -Hc // #m #Hc #H destruct
174   /4 width=8 by or3_intro2, ex4_4_intro, ex2_intro/
175 ]
176 qed-.
177
178 lemma cpm_inv_zero1_unit (n) (h) (I) (K) (G):
179       ∀X2. ⦃G,K.ⓤ{I}⦄ ⊢ #0 ➡[n,h] X2 → ∧∧ X2 = #0 & n = 0.
180 #n #h #I #G #K #X2 #H
181 elim (cpm_inv_zero1 … H) -H *
182 [ #H1 #H2 destruct /2 width=1 by conj/
183 | #Y #X1 #X2 #_ #_ #H destruct
184 | #m #Y #X1 #X2 #_ #_ #H destruct
185 ]
186 qed.
187
188 lemma cpm_inv_lref1: ∀n,h,G,L,T2,i. ⦃G,L⦄ ⊢ #↑i ➡[n,h] T2 →
189                      ∨∨ T2 = #(↑i) ∧ n = 0
190                       | ∃∃I,K,T. ⦃G,K⦄ ⊢ #i ➡[n,h] T & ⇧*[1] T ≘ T2 & L = K.ⓘ{I}.
191 #n #h #G #L #T2 #i * #c #Hc #H elim (cpg_inv_lref1 … H) -H *
192 [ #H1 #H2 destruct /4 width=1 by isrt_inv_00, or_introl, conj/
193 | #I #K #V2 #HV2 #HVT2 #H destruct
194  /4 width=6 by ex3_3_intro, ex2_intro, or_intror/
195 ]
196 qed-.
197
198 lemma cpm_inv_lref1_ctop (n) (h) (G):
199       ∀X2,i. ⦃G,⋆⦄ ⊢ #i ➡[n,h] X2 → ∧∧ X2 = #i & n = 0.
200 #n #h #G #X2 * [| #i ] #H
201 [ elim (cpm_inv_zero1 … H) -H *
202   [ #H1 #H2 destruct /2 width=1 by conj/
203   | #Y #X1 #X2 #_ #_ #H destruct
204   | #m #Y #X1 #X2 #_ #_ #H destruct
205   ]
206 | elim (cpm_inv_lref1 … H) -H *
207   [ #H1 #H2 destruct /2 width=1 by conj/
208   | #Z #Y #X0 #_ #_ #H destruct
209   ]
210 ]
211 qed.
212
213 lemma cpm_inv_gref1: ∀n,h,G,L,T2,l. ⦃G,L⦄ ⊢ §l ➡[n,h] T2 → T2 = §l ∧ n = 0.
214 #n #h #G #L #T2 #l * #c #Hc #H elim (cpg_inv_gref1 … H) -H
215 #H1 #H2 destruct /3 width=1 by isrt_inv_00, conj/
216 qed-.
217
218 (* Basic_2A1: includes: cpr_inv_bind1 *)
219 lemma cpm_inv_bind1: ∀n,h,p,I,G,L,V1,T1,U2. ⦃G,L⦄ ⊢ ⓑ{p,I}V1.T1 ➡[n,h] U2 →
220                      ∨∨ ∃∃V2,T2. ⦃G,L⦄ ⊢ V1 ➡[h] V2 & ⦃G,L.ⓑ{I}V1⦄ ⊢ T1 ➡[n,h] T2 &
221                                  U2 = ⓑ{p,I}V2.T2
222                       | ∃∃T. ⇧*[1] T ≘ T1 & ⦃G,L⦄ ⊢ T ➡[n,h] U2 &
223                              p = true & I = Abbr.
224 #n #h #p #I #G #L #V1 #T1 #U2 * #c #Hc #H elim (cpg_inv_bind1 … H) -H *
225 [ #cV #cT #V2 #T2 #HV12 #HT12 #H1 #H2 destruct
226   elim (isrt_inv_max … Hc) -Hc #nV #nT #HcV #HcT #H destruct
227   elim (isrt_inv_shift … HcV) -HcV #HcV #H destruct
228   /4 width=5 by ex3_2_intro, ex2_intro, or_introl/
229 | #cT #T2 #HT21 #HTU2 #H1 #H2 #H3 destruct
230   /5 width=5 by isrt_inv_plus_O_dx, ex4_intro, ex2_intro, or_intror/
231 ]
232 qed-.
233
234 (* Basic_1: includes: pr0_gen_abbr pr2_gen_abbr *)
235 (* Basic_2A1: includes: cpr_inv_abbr1 *)
236 lemma cpm_inv_abbr1: ∀n,h,p,G,L,V1,T1,U2. ⦃G,L⦄ ⊢ ⓓ{p}V1.T1 ➡[n,h] U2 →
237                      ∨∨ ∃∃V2,T2. ⦃G,L⦄ ⊢ V1 ➡[h] V2 & ⦃G,L.ⓓV1⦄ ⊢ T1 ➡[n,h] T2 &
238                                  U2 = ⓓ{p}V2.T2
239                       | ∃∃T. ⇧*[1] T ≘ T1 & ⦃G,L⦄ ⊢ T ➡[n,h] U2 & p = true.
240 #n #h #p #G #L #V1 #T1 #U2 #H
241 elim (cpm_inv_bind1 … H) -H
242 [ /3 width=1 by or_introl/
243 | * /3 width=3 by ex3_intro, or_intror/
244 ]
245 qed-.
246
247 (* Basic_1: includes: pr0_gen_abst pr2_gen_abst *)
248 (* Basic_2A1: includes: cpr_inv_abst1 *)
249 lemma cpm_inv_abst1: ∀n,h,p,G,L,V1,T1,U2. ⦃G,L⦄ ⊢ ⓛ{p}V1.T1 ➡[n,h] U2 →
250                      ∃∃V2,T2. ⦃G,L⦄ ⊢ V1 ➡[h] V2 & ⦃G,L.ⓛV1⦄ ⊢ T1 ➡[n,h] T2 &
251                               U2 = ⓛ{p}V2.T2.
252 #n #h #p #G #L #V1 #T1 #U2 #H
253 elim (cpm_inv_bind1 … H) -H
254 [ /3 width=1 by or_introl/
255 | * #T #_ #_ #_ #H destruct
256 ]
257 qed-.
258
259 lemma cpm_inv_abst_bi: ∀n,h,p1,p2,G,L,V1,V2,T1,T2. ⦃G,L⦄ ⊢ ⓛ{p1}V1.T1 ➡[n,h] ⓛ{p2}V2.T2 →
260                        ∧∧ ⦃G,L⦄ ⊢ V1 ➡[h] V2 & ⦃G,L.ⓛV1⦄ ⊢ T1 ➡[n,h] T2 & p1 = p2.
261 #n #h #p1 #p2 #G #L #V1 #V2 #T1 #T2 #H
262 elim (cpm_inv_abst1 … H) -H #XV #XT #HV #HT #H destruct
263 /2 width=1 by and3_intro/
264 qed-.
265
266 (* Basic_1: includes: pr0_gen_appl pr2_gen_appl *)
267 (* Basic_2A1: includes: cpr_inv_appl1 *)
268 lemma cpm_inv_appl1: ∀n,h,G,L,V1,U1,U2. ⦃G,L⦄ ⊢ ⓐ V1.U1 ➡[n,h] U2 →
269                      ∨∨ ∃∃V2,T2. ⦃G,L⦄ ⊢ V1 ➡[h] V2 & ⦃G,L⦄ ⊢ U1 ➡[n,h] T2 &
270                                  U2 = ⓐV2.T2
271                       | ∃∃p,V2,W1,W2,T1,T2. ⦃G,L⦄ ⊢ V1 ➡[h] V2 & ⦃G,L⦄ ⊢ W1 ➡[h] W2 &
272                                             ⦃G,L.ⓛW1⦄ ⊢ T1 ➡[n,h] T2 &
273                                             U1 = ⓛ{p}W1.T1 & U2 = ⓓ{p}ⓝW2.V2.T2
274                       | ∃∃p,V,V2,W1,W2,T1,T2. ⦃G,L⦄ ⊢ V1 ➡[h] V & ⇧*[1] V ≘ V2 &
275                                               ⦃G,L⦄ ⊢ W1 ➡[h] W2 & ⦃G,L.ⓓW1⦄ ⊢ T1 ➡[n,h] T2 &
276                                               U1 = ⓓ{p}W1.T1 & U2 = ⓓ{p}W2.ⓐV2.T2.
277 #n #h #G #L #V1 #U1 #U2 * #c #Hc #H elim (cpg_inv_appl1 … H) -H *
278 [ #cV #cT #V2 #T2 #HV12 #HT12 #H1 #H2 destruct
279   elim (isrt_inv_max … Hc) -Hc #nV #nT #HcV #HcT #H destruct
280   elim (isrt_inv_shift … HcV) -HcV #HcV #H destruct
281   /4 width=5 by or3_intro0, ex3_2_intro, ex2_intro/
282 | #cV #cW #cT #p #V2 #W1 #W2 #T1 #T2 #HV12 #HW12 #HT12 #H1 #H2 #H3 destruct
283   lapply (isrt_inv_plus_O_dx … Hc ?) -Hc // #Hc
284   elim (isrt_inv_max … Hc) -Hc #n0 #nT #Hc #HcT #H destruct
285   elim (isrt_inv_max … Hc) -Hc #nV #nW #HcV #HcW #H destruct
286   elim (isrt_inv_shift … HcV) -HcV #HcV #H destruct
287   elim (isrt_inv_shift … HcW) -HcW #HcW #H destruct
288   /4 width=11 by or3_intro1, ex5_6_intro, ex2_intro/
289 | #cV #cW #cT #p #V #V2 #W1 #W2 #T1 #T2 #HV1 #HV2 #HW12 #HT12 #H1 #H2 #H3 destruct
290   lapply (isrt_inv_plus_O_dx … Hc ?) -Hc // #Hc
291   elim (isrt_inv_max … Hc) -Hc #n0 #nT #Hc #HcT #H destruct
292   elim (isrt_inv_max … Hc) -Hc #nV #nW #HcV #HcW #H destruct
293   elim (isrt_inv_shift … HcV) -HcV #HcV #H destruct
294   elim (isrt_inv_shift … HcW) -HcW #HcW #H destruct
295   /4 width=13 by or3_intro2, ex6_7_intro, ex2_intro/
296 ]
297 qed-.
298
299 lemma cpm_inv_cast1: ∀n,h,G,L,V1,U1,U2. ⦃G,L⦄ ⊢ ⓝV1.U1 ➡[n,h] U2 →
300                      ∨∨ ∃∃V2,T2. ⦃G,L⦄ ⊢ V1 ➡[n,h] V2 & ⦃G,L⦄ ⊢ U1 ➡[n,h] T2 &
301                                  U2 = ⓝV2.T2
302                       | ⦃G,L⦄ ⊢ U1 ➡[n,h] U2
303                       | ∃∃m. ⦃G,L⦄ ⊢ V1 ➡[m,h] U2 & n = ↑m.
304 #n #h #G #L #V1 #U1 #U2 * #c #Hc #H elim (cpg_inv_cast1 … H) -H *
305 [ #cV #cT #V2 #T2 #HV12 #HT12 #HcVT #H1 #H2 destruct
306   elim (isrt_inv_max … Hc) -Hc #nV #nT #HcV #HcT #H destruct
307   lapply (isrt_eq_t_trans … HcV HcVT) -HcVT #H
308   lapply (isrt_inj … H HcT) -H #H destruct <idempotent_max
309   /4 width=5 by or3_intro0, ex3_2_intro, ex2_intro/
310 | #cU #U12 #H destruct
311   /4 width=3 by isrt_inv_plus_O_dx, or3_intro1, ex2_intro/
312 | #cU #H12 #H destruct
313   elim (isrt_inv_plus_SO_dx … Hc) -Hc // #m #Hc #H destruct
314   /4 width=3 by or3_intro2, ex2_intro/
315 ]
316 qed-.
317
318 (* Basic forward lemmas *****************************************************)
319
320 (* Basic_2A1: includes: cpr_fwd_bind1_minus *)
321 lemma cpm_fwd_bind1_minus: ∀n,h,I,G,L,V1,T1,T. ⦃G,L⦄ ⊢ -ⓑ{I}V1.T1 ➡[n,h] T → ∀p.
322                            ∃∃V2,T2. ⦃G,L⦄ ⊢ ⓑ{p,I}V1.T1 ➡[n,h] ⓑ{p,I}V2.T2 &
323                                     T = -ⓑ{I}V2.T2.
324 #n #h #I #G #L #V1 #T1 #T * #c #Hc #H #p elim (cpg_fwd_bind1_minus … H p) -H
325 /3 width=4 by ex2_2_intro, ex2_intro/
326 qed-.
327
328 (* Basic eliminators ********************************************************)
329
330 lemma cpm_ind (h): ∀Q:relation5 nat genv lenv term term.
331                    (∀I,G,L. Q 0 G L (⓪{I}) (⓪{I})) →
332                    (∀G,L,s. Q 1 G L (⋆s) (⋆(⫯[h]s))) →
333                    (∀n,G,K,V1,V2,W2. ⦃G,K⦄ ⊢ V1 ➡[n,h] V2 → Q n G K V1 V2 →
334                      ⇧*[1] V2 ≘ W2 → Q n G (K.ⓓV1) (#0) W2
335                    ) → (∀n,G,K,V1,V2,W2. ⦃G,K⦄ ⊢ V1 ➡[n,h] V2 → Q n G K V1 V2 →
336                      ⇧*[1] V2 ≘ W2 → Q (↑n) G (K.ⓛV1) (#0) W2
337                    ) → (∀n,I,G,K,T,U,i. ⦃G,K⦄ ⊢ #i ➡[n,h] T → Q n G K (#i) T →
338                      ⇧*[1] T ≘ U → Q n G (K.ⓘ{I}) (#↑i) (U)
339                    ) → (∀n,p,I,G,L,V1,V2,T1,T2. ⦃G,L⦄ ⊢ V1 ➡[h] V2 → ⦃G,L.ⓑ{I}V1⦄ ⊢ T1 ➡[n,h] T2 →
340                      Q 0 G L V1 V2 → Q n G (L.ⓑ{I}V1) T1 T2 → Q n G L (ⓑ{p,I}V1.T1) (ⓑ{p,I}V2.T2)
341                    ) → (∀n,G,L,V1,V2,T1,T2. ⦃G,L⦄ ⊢ V1 ➡[h] V2 → ⦃G,L⦄ ⊢ T1 ➡[n,h] T2 →
342                      Q 0 G L V1 V2 → Q n G L T1 T2 → Q n G L (ⓐV1.T1) (ⓐV2.T2)
343                    ) → (∀n,G,L,V1,V2,T1,T2. ⦃G,L⦄ ⊢ V1 ➡[n,h] V2 → ⦃G,L⦄ ⊢ T1 ➡[n,h] T2 →
344                      Q n G L V1 V2 → Q n G L T1 T2 → Q n G L (ⓝV1.T1) (ⓝV2.T2)
345                    ) → (∀n,G,L,V,T1,T,T2. ⇧*[1] T ≘ T1 → ⦃G,L⦄ ⊢ T ➡[n,h] T2 →
346                      Q n G L T T2 → Q n G L (+ⓓV.T1) T2
347                    ) → (∀n,G,L,V,T1,T2. ⦃G,L⦄ ⊢ T1 ➡[n,h] T2 →
348                      Q n G L T1 T2 → Q n G L (ⓝV.T1) T2
349                    ) → (∀n,G,L,V1,V2,T. ⦃G,L⦄ ⊢ V1 ➡[n,h] V2 →
350                      Q n G L V1 V2 → Q (↑n) G L (ⓝV1.T) V2
351                    ) → (∀n,p,G,L,V1,V2,W1,W2,T1,T2. ⦃G,L⦄ ⊢ V1 ➡[h] V2 → ⦃G,L⦄ ⊢ W1 ➡[h] W2 → ⦃G,L.ⓛW1⦄ ⊢ T1 ➡[n,h] T2 →
352                      Q 0 G L V1 V2 → Q 0 G L W1 W2 → Q n G (L.ⓛW1) T1 T2 →
353                      Q n G L (ⓐV1.ⓛ{p}W1.T1) (ⓓ{p}ⓝW2.V2.T2)
354                    ) → (∀n,p,G,L,V1,V,V2,W1,W2,T1,T2. ⦃G,L⦄ ⊢ V1 ➡[h] V → ⦃G,L⦄ ⊢ W1 ➡[h] W2 → ⦃G,L.ⓓW1⦄ ⊢ T1 ➡[n,h] T2 →
355                      Q 0 G L V1 V → Q 0 G L W1 W2 → Q n G (L.ⓓW1) T1 T2 →
356                      ⇧*[1] V ≘ V2 → Q n G L (ⓐV1.ⓓ{p}W1.T1) (ⓓ{p}W2.ⓐV2.T2)
357                    ) →
358                    ∀n,G,L,T1,T2. ⦃G,L⦄ ⊢ T1 ➡[n,h] T2 → Q n G L T1 T2.
359 #h #Q #IH1 #IH2 #IH3 #IH4 #IH5 #IH6 #IH7 #IH8 #IH9 #IH10 #IH11 #IH12 #IH13 #n #G #L #T1 #T2
360 * #c #HC #H generalize in match HC; -HC generalize in match n; -n
361 elim H -c -G -L -T1 -T2
362 [ #I #G #L #n #H <(isrt_inv_00 … H) -H //
363 | #G #L #s #n #H <(isrt_inv_01 … H) -H //
364 | /3 width=4 by ex2_intro/
365 | #c #G #L #V1 #V2 #W2 #HV12 #HVW2 #IH #x #H
366   elim (isrt_inv_plus_SO_dx … H) -H // #n #Hc #H destruct
367   /3 width=4 by ex2_intro/
368 | /3 width=4 by ex2_intro/
369 | #cV #cT #p #I #G #L #V1 #V2 #T1 #T2 #HV12 #HT12 #IHV #IHT #n #H
370   elim (isrt_inv_max_shift_sn … H) -H #HcV #HcT
371   /3 width=3 by ex2_intro/
372 | #cV #cT #G #L #V1 #V2 #T1 #T2 #HV12 #HT12 #IHV #IHT #n #H
373   elim (isrt_inv_max_shift_sn … H) -H #HcV #HcT
374   /3 width=3 by ex2_intro/
375 | #cU #cT #G #L #U1 #U2 #T1 #T2 #HUT #HU12 #HT12 #IHU #IHT #n #H
376   elim (isrt_inv_max_eq_t … H) -H // #HcV #HcT
377   /3 width=3 by ex2_intro/
378 | #c #G #L #V #T1 #T #T2 #HT1 #HT2 #IH #n #H
379   lapply (isrt_inv_plus_O_dx … H ?) -H // #Hc
380   /3 width=4 by ex2_intro/
381 | #c #G #L #U #T1 #T2 #HT12 #IH #n #H
382   lapply (isrt_inv_plus_O_dx … H ?) -H // #Hc
383   /3 width=3 by ex2_intro/
384 | #c #G #L #U1 #U2 #T #HU12 #IH #x #H
385   elim (isrt_inv_plus_SO_dx … H) -H // #n #Hc #H destruct
386   /3 width=3 by ex2_intro/
387 | #cV #cW #cT #p #G #L #V1 #V2 #W1 #W2 #T1 #T2 #HV12 #HW12 #HT12 #IHV #IHW #IHT #n #H
388   lapply (isrt_inv_plus_O_dx … H ?) -H // >max_shift #H
389   elim (isrt_inv_max_shift_sn … H) -H #H #HcT
390   elim (isrt_O_inv_max … H) -H #HcV #HcW
391   /3 width=3 by ex2_intro/
392 | #cV #cW #cT #p #G #L #V1 #V #V2 #W1 #W2 #T1 #T2 #HV1 #HV2 #HW12 #HT12 #IHV #IHW #IHT #n #H
393   lapply (isrt_inv_plus_O_dx … H ?) -H // >max_shift #H
394   elim (isrt_inv_max_shift_sn … H) -H #H #HcT
395   elim (isrt_O_inv_max … H) -H #HcV #HcW
396   /3 width=4 by ex2_intro/
397 ]
398 qed-.