]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/rt_transition/cpx.ma
milestone update in basic_2
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / rt_transition / 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 "ground/xoa/ex_3_4.ma".
16 include "ground/xoa/ex_4_1.ma".
17 include "ground/xoa/ex_5_6.ma".
18 include "ground/xoa/ex_6_6.ma".
19 include "ground/xoa/ex_6_7.ma".
20 include "ground/xoa/ex_7_7.ma".
21 include "ground/xoa/or_4.ma".
22 include "basic_2/notation/relations/predty_4.ma".
23 include "basic_2/rt_transition/cpg.ma".
24
25 (* EXTENDED CONTEXT-SENSITIVE PARALLEL RT-TRANSITION FOR TERMS **************)
26
27 definition cpx (G) (L): relation2 term term ≝
28            λT1,T2. ∃c. ❪G,L❫ ⊢ T1 ⬈[sfull,rtc_eq_f,c] T2.
29
30 interpretation
31   "extended context-sensitive parallel rt-transition (term)"
32   'PRedTy G L T1 T2 = (cpx G L T1 T2).
33
34 (* Basic properties *********************************************************)
35
36 (* Basic_2A1: uses: cpx_st *)
37 lemma cpx_qu (G) (L): ∀s1,s2. ❪G,L❫ ⊢ ⋆s1 ⬈ ⋆s2.
38 /3 width=2 by cpg_ess, ex_intro/ qed.
39
40 lemma cpx_delta (G) (K):
41       ∀I,V1,V2,W2. ❪G,K❫ ⊢ V1 ⬈ V2 →
42       ⇧[1] V2 ≘ W2 → ❪G,K.ⓑ[I]V1❫ ⊢ #0 ⬈ W2.
43 #G #K * #V1 #V2 #W2 *
44 /3 width=4 by cpg_delta, cpg_ell, ex_intro/
45 qed.
46
47 lemma cpx_lref (G) (K):
48       ∀I,T,U,i. ❪G,K❫ ⊢ #i ⬈ T →
49       ⇧[1] T ≘ U → ❪G,K.ⓘ[I]❫ ⊢ #↑i ⬈ U.
50 #G #K #I #T #U #i *
51 /3 width=4 by cpg_lref, ex_intro/
52 qed.
53
54 lemma cpx_bind (G) (L):
55       ∀p,I,V1,V2,T1,T2.
56       ❪G,L❫ ⊢ V1 ⬈ V2 → ❪G,L.ⓑ[I]V1❫ ⊢ T1 ⬈ T2 →
57       ❪G,L❫ ⊢ ⓑ[p,I]V1.T1 ⬈ ⓑ[p,I]V2.T2.
58 #G #L #p #I #V1 #V2 #T1 #T2 * #cV #HV12 *
59 /3 width=2 by cpg_bind, ex_intro/
60 qed.
61
62 lemma cpx_flat (G) (L):
63       ∀I,V1,V2,T1,T2.
64       ❪G,L❫ ⊢ V1 ⬈ V2 → ❪G,L❫ ⊢ T1 ⬈ T2 →
65       ❪G,L❫ ⊢ ⓕ[I]V1.T1 ⬈ ⓕ[I]V2.T2.
66 #G #L * #V1 #V2 #T1 #T2 * #cV #HV12 *
67 /3 width=5 by cpg_appl, cpg_cast, ex_intro/
68 qed.
69
70 lemma cpx_zeta (G) (L):
71       ∀T1,T. ⇧[1] T ≘ T1 → ∀T2. ❪G,L❫ ⊢ T ⬈ T2 →
72       ∀V. ❪G,L❫ ⊢ +ⓓV.T1 ⬈ T2.
73 #G #L #T1 #T #HT1 #T2 *
74 /3 width=4 by cpg_zeta, ex_intro/
75 qed.
76
77 lemma cpx_eps (G) (L):
78       ∀V,T1,T2. ❪G,L❫ ⊢ T1 ⬈ T2 → ❪G,L❫ ⊢ ⓝV.T1 ⬈ T2.
79 #G #L #V #T1 #T2 *
80 /3 width=2 by cpg_eps, ex_intro/
81 qed.
82
83 (* Basic_2A1: was: cpx_ct *)
84 lemma cpx_ee (G) (L):
85       ∀V1,V2,T. ❪G,L❫ ⊢ V1 ⬈ V2 → ❪G,L❫ ⊢ ⓝV1.T ⬈ V2.
86 #G #L #V1 #V2 #T *
87 /3 width=2 by cpg_ee, ex_intro/
88 qed.
89
90 lemma cpx_beta (G) (L):
91       ∀p,V1,V2,W1,W2,T1,T2.
92       ❪G,L❫ ⊢ V1 ⬈ V2 → ❪G,L❫ ⊢ W1 ⬈ W2 → ❪G,L.ⓛW1❫ ⊢ T1 ⬈ T2 →
93       ❪G,L❫ ⊢ ⓐV1.ⓛ[p]W1.T1 ⬈ ⓓ[p]ⓝW2.V2.T2.
94 #G #L #p #V1 #V2 #W1 #W2 #T1 #T2 * #cV #HV12 * #cW #HW12 *
95 /3 width=2 by cpg_beta, ex_intro/
96 qed.
97
98 lemma cpx_theta (G) (L):
99       ∀p,V1,V,V2,W1,W2,T1,T2.
100       ❪G,L❫ ⊢ V1 ⬈ V → ⇧[1] V ≘ V2 → ❪G,L❫ ⊢ W1 ⬈ W2 → ❪G,L.ⓓW1❫ ⊢ T1 ⬈ T2 →
101       ❪G,L❫ ⊢ ⓐV1.ⓓ[p]W1.T1 ⬈ ⓓ[p]W2.ⓐV2.T2.
102 #G #L #p #V1 #V #V2 #W1 #W2 #T1 #T2 * #cV #HV1 #HV2 * #cW #HW12 *
103 /3 width=4 by cpg_theta, ex_intro/
104 qed.
105
106 (* Basic_2A1: includes: cpx_atom *)
107 lemma cpx_refl (G) (L): reflexive … (cpx G L).
108 /3 width=2 by cpg_refl, ex_intro/ qed.
109
110 (* Advanced properties ******************************************************)
111
112 lemma cpx_pair_sn (G) (L):
113       ∀I,V1,V2. ❪G,L❫ ⊢ V1 ⬈ V2 →
114       ∀T. ❪G,L❫ ⊢ ②[I]V1.T ⬈ ②[I]V2.T.
115 #G #L * /2 width=2 by cpx_flat, cpx_bind/
116 qed.
117
118 lemma cpg_cpx (Rs) (Rk) (c) (G) (L):
119       ∀T1,T2. ❪G,L❫ ⊢ T1 ⬈[Rs,Rk,c] T2 → ❪G,L❫ ⊢ T1 ⬈ T2.
120 #Rs #Rk #c #G #L #T1 #T2 #H elim H -c -G -L -T1 -T2
121 /2 width=3 by cpx_theta, cpx_beta, cpx_ee, cpx_eps, cpx_zeta, cpx_flat, cpx_bind, cpx_lref, cpx_delta/
122 qed.
123
124 (* Basic inversion lemmas ***************************************************)
125
126 lemma cpx_inv_atom1 (G) (L):
127       ∀J,T2. ❪G,L❫ ⊢ ⓪[J] ⬈ T2 →
128       ∨∨ T2 = ⓪[J]
129        | ∃∃s1,s2. T2 = ⋆s2 & J = Sort s1
130        | ∃∃I,K,V1,V2. ❪G,K❫ ⊢ V1 ⬈ V2 & ⇧[1] V2 ≘ T2 & L = K.ⓑ[I]V1 & J = LRef 0
131        | ∃∃I,K,T,i. ❪G,K❫ ⊢ #i ⬈ T & ⇧[1] T ≘ T2 & L = K.ⓘ[I] & J = LRef (↑i).
132 #G #L #J #T2 * #c #H elim (cpg_inv_atom1 … H) -H *
133 /4 width=8 by or4_intro0, or4_intro1, or4_intro2, or4_intro3, ex4_4_intro, ex2_2_intro, ex_intro/
134 qed-.
135
136 lemma cpx_inv_sort1 (G) (L):
137       ∀T2,s1. ❪G,L❫ ⊢ ⋆s1 ⬈ T2 →
138       ∃s2. T2 = ⋆s2.
139 #G #L #T2 #s1 * #c #H elim (cpg_inv_sort1 … H) -H *
140 /2 width=2 by ex_intro/
141 qed-.
142
143 lemma cpx_inv_zero1 (G) (L):
144       ∀T2. ❪G,L❫ ⊢ #0 ⬈ T2 →
145       ∨∨ T2 = #0
146        | ∃∃I,K,V1,V2. ❪G,K❫ ⊢ V1 ⬈ V2 & ⇧[1] V2 ≘ T2 & L = K.ⓑ[I]V1.
147 #G #L #T2 * #c #H elim (cpg_inv_zero1 … H) -H *
148 /4 width=7 by ex3_4_intro, ex_intro, or_introl, or_intror/
149 qed-.
150
151 lemma cpx_inv_lref1 (G) (L):
152       ∀T2,i. ❪G,L❫ ⊢ #↑i ⬈ T2 →
153       ∨∨ T2 = #(↑i)
154        | ∃∃I,K,T. ❪G,K❫ ⊢ #i ⬈ T & ⇧[1] T ≘ T2 & L = K.ⓘ[I].
155 #G #L #T2 #i * #c #H elim (cpg_inv_lref1 … H) -H *
156 /4 width=6 by ex3_3_intro, ex_intro, or_introl, or_intror/
157 qed-.
158
159 lemma cpx_inv_gref1 (G) (L):
160       ∀T2,l. ❪G,L❫ ⊢ §l ⬈ T2 → T2 = §l.
161 #G #L #T2 #l * #c #H elim (cpg_inv_gref1 … H) -H //
162 qed-.
163
164 lemma cpx_inv_bind1 (G) (L):
165       ∀p,I,V1,T1,U2. ❪G,L❫ ⊢ ⓑ[p,I]V1.T1 ⬈ U2 →
166       ∨∨ ∃∃V2,T2. ❪G,L❫ ⊢ V1 ⬈ V2 & ❪G,L.ⓑ[I]V1❫ ⊢ T1 ⬈ T2 & U2 = ⓑ[p,I]V2.T2
167        | ∃∃T. ⇧[1] T ≘ T1 & ❪G,L❫ ⊢ T ⬈ U2 & p = true & I = Abbr.
168 #G #L #p #I #V1 #T1 #U2 * #c #H elim (cpg_inv_bind1 … H) -H *
169 /4 width=5 by ex4_intro, ex3_2_intro, ex_intro, or_introl, or_intror/
170 qed-.
171
172 lemma cpx_inv_abbr1 (G) (L):
173       ∀p,V1,T1,U2. ❪G,L❫ ⊢ ⓓ[p]V1.T1 ⬈ U2 →
174       ∨∨ ∃∃V2,T2. ❪G,L❫ ⊢ V1 ⬈ V2 & ❪G,L.ⓓV1❫ ⊢ T1 ⬈ T2 & U2 = ⓓ[p]V2.T2
175        | ∃∃T. ⇧[1] T ≘ T1 & ❪G,L❫ ⊢ T ⬈ U2 & p = true.
176 #G #L #p #V1 #T1 #U2 * #c #H elim (cpg_inv_abbr1 … H) -H *
177 /4 width=5 by ex3_2_intro, ex3_intro, ex_intro, or_introl, or_intror/
178 qed-.
179
180 lemma cpx_inv_abst1 (G) (L):
181       ∀p,V1,T1,U2. ❪G,L❫ ⊢ ⓛ[p]V1.T1 ⬈ U2 →
182       ∃∃V2,T2. ❪G,L❫ ⊢ V1 ⬈ V2 & ❪G,L.ⓛV1❫ ⊢ T1 ⬈ T2 & U2 = ⓛ[p]V2.T2.
183 #G #L #p #V1 #T1 #U2 * #c #H elim (cpg_inv_abst1 … H) -H
184 /3 width=5 by ex3_2_intro, ex_intro/
185 qed-.
186
187 lemma cpx_inv_appl1 (G) (L):
188       ∀V1,U1,U2. ❪G,L❫ ⊢ ⓐ V1.U1 ⬈ U2 →
189       ∨∨ ∃∃V2,T2. ❪G,L❫ ⊢ V1 ⬈ V2 & ❪G,L❫ ⊢ U1 ⬈ T2 & U2 = ⓐV2.T2
190        | ∃∃p,V2,W1,W2,T1,T2. ❪G,L❫ ⊢ V1 ⬈ V2 & ❪G,L❫ ⊢ W1 ⬈ W2 & ❪G,L.ⓛW1❫ ⊢ T1 ⬈ T2 & U1 = ⓛ[p]W1.T1 & U2 = ⓓ[p]ⓝW2.V2.T2
191        | ∃∃p,V,V2,W1,W2,T1,T2. ❪G,L❫ ⊢ V1 ⬈ V & ⇧[1] V ≘ V2 & ❪G,L❫ ⊢ W1 ⬈ W2 & ❪G,L.ⓓW1❫ ⊢ T1 ⬈ T2 & U1 = ⓓ[p]W1.T1 & U2 = ⓓ[p]W2.ⓐV2.T2.
192 #G #L #V1 #U1 #U2 * #c #H elim (cpg_inv_appl1 … H) -H *
193 /4 width=13 by or3_intro0, or3_intro1, or3_intro2, ex6_7_intro, ex5_6_intro, ex3_2_intro, ex_intro/
194 qed-.
195
196 lemma cpx_inv_cast1 (G) (L):
197       ∀V1,U1,U2. ❪G,L❫ ⊢ ⓝV1.U1 ⬈ U2 →
198       ∨∨ ∃∃V2,T2. ❪G,L❫ ⊢ V1 ⬈ V2 & ❪G,L❫ ⊢ U1 ⬈ T2 & U2 = ⓝV2.T2
199        | ❪G,L❫ ⊢ U1 ⬈ U2
200        | ❪G,L❫ ⊢ V1 ⬈ U2.
201 #G #L #V1 #U1 #U2 * #c #H elim (cpg_inv_cast1 … H) -H *
202 /4 width=5 by or3_intro0, or3_intro1, or3_intro2, ex3_2_intro, ex_intro/
203 qed-.
204
205 (* Advanced inversion lemmas ************************************************)
206
207 lemma cpx_inv_zero1_pair (G) (K):
208       ∀I,V1,T2. ❪G,K.ⓑ[I]V1❫ ⊢ #0 ⬈ T2 →
209       ∨∨ T2 = #0
210        | ∃∃V2. ❪G,K❫ ⊢ V1 ⬈ V2 & ⇧[1] V2 ≘ T2.
211 #G #K #I #V1 #T2 * #c #H elim (cpg_inv_zero1_pair … H) -H *
212 /4 width=3 by ex2_intro, ex_intro, or_intror, or_introl/
213 qed-.
214
215 lemma cpx_inv_lref1_bind (G) (K):
216       ∀I,T2,i. ❪G,K.ⓘ[I]❫ ⊢ #↑i ⬈ T2 →
217       ∨∨ T2 = #(↑i)
218        | ∃∃T. ❪G,K❫ ⊢ #i ⬈ T & ⇧[1] T ≘ T2.
219 #G #K #I #T2 #i * #c #H elim (cpg_inv_lref1_bind … H) -H *
220 /4 width=3 by ex2_intro, ex_intro, or_introl, or_intror/
221 qed-.
222
223 lemma cpx_inv_flat1 (G) (L):
224       ∀I,V1,U1,U2. ❪G,L❫ ⊢ ⓕ[I]V1.U1 ⬈ U2 →
225       ∨∨ ∃∃V2,T2. ❪G,L❫ ⊢ V1 ⬈ V2 & ❪G,L❫ ⊢ U1 ⬈ T2 & U2 = ⓕ[I]V2.T2
226        | (❪G,L❫ ⊢ U1 ⬈ U2 ∧ I = Cast)
227        | (❪G,L❫ ⊢ V1 ⬈ U2 ∧ I = Cast)
228        | ∃∃p,V2,W1,W2,T1,T2. ❪G,L❫ ⊢ V1 ⬈ V2 & ❪G,L❫ ⊢ W1 ⬈ W2 & ❪G,L.ⓛW1❫ ⊢ T1 ⬈ T2 & U1 = ⓛ[p]W1.T1 & U2 = ⓓ[p]ⓝW2.V2.T2 & I = Appl
229        | ∃∃p,V,V2,W1,W2,T1,T2. ❪G,L❫ ⊢ V1 ⬈ V & ⇧[1] V ≘ V2 & ❪G,L❫ ⊢ W1 ⬈ W2 & ❪G,L.ⓓW1❫ ⊢ T1 ⬈ T2 & U1 = ⓓ[p]W1.T1 & U2 = ⓓ[p]W2.ⓐV2.T2 & I = Appl.
230 #G #L * #V1 #U1 #U2 #H
231 [ elim (cpx_inv_appl1 … H) -H *
232   /3 width=14 by or5_intro0, or5_intro3, or5_intro4, ex7_7_intro, ex6_6_intro, ex3_2_intro/
233 | elim (cpx_inv_cast1 … H) -H [ * ]
234   /3 width=14 by or5_intro0, or5_intro1, or5_intro2, ex3_2_intro, conj/
235 ]
236 qed-.
237
238 (* Basic forward lemmas *****************************************************)
239
240 lemma cpx_fwd_bind1_minus (G) (L):
241       ∀I,V1,T1,T. ❪G,L❫ ⊢ -ⓑ[I]V1.T1 ⬈ T → ∀p.
242       ∃∃V2,T2. ❪G,L❫ ⊢ ⓑ[p,I]V1.T1 ⬈ ⓑ[p,I]V2.T2 & T = -ⓑ[I]V2.T2.
243 #G #L #I #V1 #T1 #T * #c #H #p elim (cpg_fwd_bind1_minus … H p) -H
244 /3 width=4 by ex2_2_intro, ex_intro/
245 qed-.
246
247 (* Basic eliminators ********************************************************)
248
249 lemma cpx_ind (Q:relation4 …):
250       (∀I,G,L. Q G L (⓪[I]) (⓪[I])) →
251       (∀G,L,s1,s2. Q G L (⋆s1) (⋆s2)) →
252       (∀I,G,K,V1,V2,W2. ❪G,K❫ ⊢ V1 ⬈ V2 → Q G K V1 V2 →
253         ⇧[1] V2 ≘ W2 → Q G (K.ⓑ[I]V1) (#0) W2
254       ) → (∀I,G,K,T,U,i. ❪G,K❫ ⊢ #i ⬈ T → Q G K (#i) T →
255         ⇧[1] T ≘ U → Q G (K.ⓘ[I]) (#↑i) (U)
256       ) → (∀p,I,G,L,V1,V2,T1,T2. ❪G,L❫ ⊢ V1 ⬈ V2 → ❪G,L.ⓑ[I]V1❫ ⊢ T1 ⬈ T2 →
257         Q G L V1 V2 → Q G (L.ⓑ[I]V1) T1 T2 → Q G L (ⓑ[p,I]V1.T1) (ⓑ[p,I]V2.T2)
258       ) → (∀I,G,L,V1,V2,T1,T2. ❪G,L❫ ⊢ V1 ⬈ V2 → ❪G,L❫ ⊢ T1 ⬈ T2 →
259         Q G L V1 V2 → Q G L T1 T2 → Q G L (ⓕ[I]V1.T1) (ⓕ[I]V2.T2)
260       ) → (∀G,L,V,T1,T,T2. ⇧[1] T ≘ T1 → ❪G,L❫ ⊢ T ⬈ T2 → Q G L T T2 →
261         Q G L (+ⓓV.T1) T2
262       ) → (∀G,L,V,T1,T2. ❪G,L❫ ⊢ T1 ⬈ T2 → Q G L T1 T2 →
263         Q G L (ⓝV.T1) T2
264       ) → (∀G,L,V1,V2,T. ❪G,L❫ ⊢ V1 ⬈ V2 → Q G L V1 V2 →
265         Q G L (ⓝV1.T) V2
266       ) → (∀p,G,L,V1,V2,W1,W2,T1,T2. ❪G,L❫ ⊢ V1 ⬈ V2 → ❪G,L❫ ⊢ W1 ⬈ W2 → ❪G,L.ⓛW1❫ ⊢ T1 ⬈ T2 →
267         Q G L V1 V2 → Q G L W1 W2 → Q G (L.ⓛW1) T1 T2 →
268         Q G L (ⓐV1.ⓛ[p]W1.T1) (ⓓ[p]ⓝW2.V2.T2)
269       ) → (∀p,G,L,V1,V,V2,W1,W2,T1,T2. ❪G,L❫ ⊢ V1 ⬈ V → ❪G,L❫ ⊢ W1 ⬈ W2 → ❪G,L.ⓓW1❫ ⊢ T1 ⬈ T2 →
270         Q G L V1 V → Q G L W1 W2 → Q G (L.ⓓW1) T1 T2 →
271         ⇧[1] V ≘ V2 → Q G L (ⓐV1.ⓓ[p]W1.T1) (ⓓ[p]W2.ⓐV2.T2)
272       ) →
273       ∀G,L,T1,T2. ❪G,L❫ ⊢ T1 ⬈ T2 → Q G L T1 T2.
274 #Q #IH1 #IH2 #IH3 #IH4 #IH5 #IH6 #IH7 #IH8 #IH9 #IH10 #IH11 #G #L #T1 #T2
275 * #c #H elim H -c -G -L -T1 -T2 /3 width=4 by ex_intro/
276 qed-.