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