1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "ground_2/xoa/ex_3_4.ma".
16 include "ground_2/xoa/ex_4_1.ma".
17 include "ground_2/xoa/ex_5_6.ma".
18 include "ground_2/xoa/ex_6_6.ma".
19 include "ground_2/xoa/ex_6_7.ma".
20 include "ground_2/xoa/ex_7_7.ma".
21 include "ground_2/xoa/or_4.ma".
22 include "basic_2/notation/relations/predty_5.ma".
23 include "basic_2/rt_transition/cpg.ma".
25 (* UNBOUND CONTEXT-SENSITIVE PARALLEL RT-TRANSITION FOR TERMS ***************)
27 definition cpx (h): relation4 genv lenv term term ≝
28 λG,L,T1,T2. ∃c. ❪G,L❫ ⊢ T1 ⬈[eq_f,c,h] T2.
31 "unbound context-sensitive parallel rt-transition (term)"
32 'PRedTy h G L T1 T2 = (cpx h G L T1 T2).
34 (* Basic properties *********************************************************)
36 (* Basic_2A1: was: cpx_st *)
37 lemma cpx_ess: ∀h,G,L,s. ❪G,L❫ ⊢ ⋆s ⬈[h] ⋆(⫯[h]s).
38 /2 width=2 by cpg_ess, ex_intro/ qed.
40 lemma cpx_delta: ∀h,I,G,K,V1,V2,W2. ❪G,K❫ ⊢ V1 ⬈[h] V2 →
41 ⇧[1] V2 ≘ W2 → ❪G,K.ⓑ[I]V1❫ ⊢ #0 ⬈[h] W2.
42 #h * #G #K #V1 #V2 #W2 *
43 /3 width=4 by cpg_delta, cpg_ell, ex_intro/
46 lemma cpx_lref: ∀h,I,G,K,T,U,i. ❪G,K❫ ⊢ #i ⬈[h] T →
47 ⇧[1] T ≘ U → ❪G,K.ⓘ[I]❫ ⊢ #↑i ⬈[h] U.
48 #h #I #G #K #T #U #i *
49 /3 width=4 by cpg_lref, ex_intro/
52 lemma cpx_bind: ∀h,p,I,G,L,V1,V2,T1,T2.
53 ❪G,L❫ ⊢ V1 ⬈[h] V2 → ❪G,L.ⓑ[I]V1❫ ⊢ T1 ⬈[h] T2 →
54 ❪G,L❫ ⊢ ⓑ[p,I]V1.T1 ⬈[h] ⓑ[p,I]V2.T2.
55 #h #p #I #G #L #V1 #V2 #T1 #T2 * #cV #HV12 *
56 /3 width=2 by cpg_bind, ex_intro/
59 lemma cpx_flat: ∀h,I,G,L,V1,V2,T1,T2.
60 ❪G,L❫ ⊢ V1 ⬈[h] V2 → ❪G,L❫ ⊢ T1 ⬈[h] T2 →
61 ❪G,L❫ ⊢ ⓕ[I]V1.T1 ⬈[h] ⓕ[I]V2.T2.
62 #h * #G #L #V1 #V2 #T1 #T2 * #cV #HV12 *
63 /3 width=5 by cpg_appl, cpg_cast, ex_intro/
66 lemma cpx_zeta (h) (G) (L):
67 ∀T1,T. ⇧[1] T ≘ T1 → ∀T2. ❪G,L❫ ⊢ T ⬈[h] T2 →
68 ∀V. ❪G,L❫ ⊢ +ⓓV.T1 ⬈[h] T2.
69 #h #G #L #T1 #T #HT1 #T2 *
70 /3 width=4 by cpg_zeta, ex_intro/
73 lemma cpx_eps: ∀h,G,L,V,T1,T2. ❪G,L❫ ⊢ T1 ⬈[h] T2 → ❪G,L❫ ⊢ ⓝV.T1 ⬈[h] T2.
75 /3 width=2 by cpg_eps, ex_intro/
78 (* Basic_2A1: was: cpx_ct *)
79 lemma cpx_ee: ∀h,G,L,V1,V2,T. ❪G,L❫ ⊢ V1 ⬈[h] V2 → ❪G,L❫ ⊢ ⓝV1.T ⬈[h] V2.
81 /3 width=2 by cpg_ee, ex_intro/
84 lemma cpx_beta: ∀h,p,G,L,V1,V2,W1,W2,T1,T2.
85 ❪G,L❫ ⊢ V1 ⬈[h] V2 → ❪G,L❫ ⊢ W1 ⬈[h] W2 → ❪G,L.ⓛW1❫ ⊢ T1 ⬈[h] T2 →
86 ❪G,L❫ ⊢ ⓐV1.ⓛ[p]W1.T1 ⬈[h] ⓓ[p]ⓝW2.V2.T2.
87 #h #p #G #L #V1 #V2 #W1 #W2 #T1 #T2 * #cV #HV12 * #cW #HW12 *
88 /3 width=2 by cpg_beta, ex_intro/
91 lemma cpx_theta: ∀h,p,G,L,V1,V,V2,W1,W2,T1,T2.
92 ❪G,L❫ ⊢ V1 ⬈[h] V → ⇧[1] V ≘ V2 → ❪G,L❫ ⊢ W1 ⬈[h] W2 →
93 ❪G,L.ⓓW1❫ ⊢ T1 ⬈[h] T2 →
94 ❪G,L❫ ⊢ ⓐV1.ⓓ[p]W1.T1 ⬈[h] ⓓ[p]W2.ⓐV2.T2.
95 #h #p #G #L #V1 #V #V2 #W1 #W2 #T1 #T2 * #cV #HV1 #HV2 * #cW #HW12 *
96 /3 width=4 by cpg_theta, ex_intro/
99 (* Basic_2A1: includes: cpx_atom *)
100 lemma cpx_refl: ∀h,G,L. reflexive … (cpx h G L).
101 /3 width=2 by cpg_refl, ex_intro/ qed.
103 (* Advanced properties ******************************************************)
105 lemma cpx_pair_sn: ∀h,I,G,L,V1,V2. ❪G,L❫ ⊢ V1 ⬈[h] V2 →
106 ∀T. ❪G,L❫ ⊢ ②[I]V1.T ⬈[h] ②[I]V2.T.
107 #h * /2 width=2 by cpx_flat, cpx_bind/
110 lemma cpg_cpx (h) (Rt) (c) (G) (L):
111 ∀T1,T2. ❪G,L❫ ⊢ T1 ⬈[Rt,c,h] T2 → ❪G,L❫ ⊢ T1 ⬈[h] T2.
112 #h #Rt #c #G #L #T1 #T2 #H elim H -c -G -L -T1 -T2
113 /2 width=3 by cpx_theta, cpx_beta, cpx_ee, cpx_eps, cpx_zeta, cpx_flat, cpx_bind, cpx_lref, cpx_delta/
116 (* Basic inversion lemmas ***************************************************)
118 lemma cpx_inv_atom1: ∀h,J,G,L,T2. ❪G,L❫ ⊢ ⓪[J] ⬈[h] T2 →
120 | ∃∃s. T2 = ⋆(⫯[h]s) & J = Sort s
121 | ∃∃I,K,V1,V2. ❪G,K❫ ⊢ V1 ⬈[h] V2 & ⇧[1] V2 ≘ T2 &
122 L = K.ⓑ[I]V1 & J = LRef 0
123 | ∃∃I,K,T,i. ❪G,K❫ ⊢ #i ⬈[h] T & ⇧[1] T ≘ T2 &
124 L = K.ⓘ[I] & J = LRef (↑i).
125 #h #J #G #L #T2 * #c #H elim (cpg_inv_atom1 … H) -H *
126 /4 width=8 by or4_intro0, or4_intro1, or4_intro2, or4_intro3, ex4_4_intro, ex2_intro, ex_intro/
129 lemma cpx_inv_sort1: ∀h,G,L,T2,s. ❪G,L❫ ⊢ ⋆s ⬈[h] T2 →
130 ∨∨ T2 = ⋆s | T2 = ⋆(⫯[h]s).
131 #h #G #L #T2 #s * #c #H elim (cpg_inv_sort1 … H) -H *
132 /2 width=1 by or_introl, or_intror/
135 lemma cpx_inv_zero1: ∀h,G,L,T2. ❪G,L❫ ⊢ #0 ⬈[h] T2 →
137 | ∃∃I,K,V1,V2. ❪G,K❫ ⊢ V1 ⬈[h] V2 & ⇧[1] V2 ≘ T2 &
139 #h #G #L #T2 * #c #H elim (cpg_inv_zero1 … H) -H *
140 /4 width=7 by ex3_4_intro, ex_intro, or_introl, or_intror/
143 lemma cpx_inv_lref1: ∀h,G,L,T2,i. ❪G,L❫ ⊢ #↑i ⬈[h] T2 →
145 | ∃∃I,K,T. ❪G,K❫ ⊢ #i ⬈[h] T & ⇧[1] T ≘ T2 & L = K.ⓘ[I].
146 #h #G #L #T2 #i * #c #H elim (cpg_inv_lref1 … H) -H *
147 /4 width=6 by ex3_3_intro, ex_intro, or_introl, or_intror/
150 lemma cpx_inv_gref1: ∀h,G,L,T2,l. ❪G,L❫ ⊢ §l ⬈[h] T2 → T2 = §l.
151 #h #G #L #T2 #l * #c #H elim (cpg_inv_gref1 … H) -H //
154 lemma cpx_inv_bind1: ∀h,p,I,G,L,V1,T1,U2. ❪G,L❫ ⊢ ⓑ[p,I]V1.T1 ⬈[h] U2 →
155 ∨∨ ∃∃V2,T2. ❪G,L❫ ⊢ V1 ⬈[h] V2 & ❪G,L.ⓑ[I]V1❫ ⊢ T1 ⬈[h] T2 &
157 | ∃∃T. ⇧[1] T ≘ T1 & ❪G,L❫ ⊢ T ⬈[h] U2 &
159 #h #p #I #G #L #V1 #T1 #U2 * #c #H elim (cpg_inv_bind1 … H) -H *
160 /4 width=5 by ex4_intro, ex3_2_intro, ex_intro, or_introl, or_intror/
163 lemma cpx_inv_abbr1: ∀h,p,G,L,V1,T1,U2. ❪G,L❫ ⊢ ⓓ[p]V1.T1 ⬈[h] U2 →
164 ∨∨ ∃∃V2,T2. ❪G,L❫ ⊢ V1 ⬈[h] V2 & ❪G,L.ⓓV1❫ ⊢ T1 ⬈[h] T2 &
166 | ∃∃T. ⇧[1] T ≘ T1 & ❪G,L❫ ⊢ T ⬈[h] U2 & p = true.
167 #h #p #G #L #V1 #T1 #U2 * #c #H elim (cpg_inv_abbr1 … H) -H *
168 /4 width=5 by ex3_2_intro, ex3_intro, ex_intro, or_introl, or_intror/
171 lemma cpx_inv_abst1: ∀h,p,G,L,V1,T1,U2. ❪G,L❫ ⊢ ⓛ[p]V1.T1 ⬈[h] U2 →
172 ∃∃V2,T2. ❪G,L❫ ⊢ V1 ⬈[h] V2 & ❪G,L.ⓛV1❫ ⊢ T1 ⬈[h] T2 &
174 #h #p #G #L #V1 #T1 #U2 * #c #H elim (cpg_inv_abst1 … H) -H
175 /3 width=5 by ex3_2_intro, ex_intro/
178 lemma cpx_inv_appl1: ∀h,G,L,V1,U1,U2. ❪G,L❫ ⊢ ⓐ V1.U1 ⬈[h] U2 →
179 ∨∨ ∃∃V2,T2. ❪G,L❫ ⊢ V1 ⬈[h] V2 & ❪G,L❫ ⊢ U1 ⬈[h] T2 &
181 | ∃∃p,V2,W1,W2,T1,T2. ❪G,L❫ ⊢ V1 ⬈[h] V2 & ❪G,L❫ ⊢ W1 ⬈[h] W2 &
182 ❪G,L.ⓛW1❫ ⊢ T1 ⬈[h] T2 &
183 U1 = ⓛ[p]W1.T1 & U2 = ⓓ[p]ⓝW2.V2.T2
184 | ∃∃p,V,V2,W1,W2,T1,T2. ❪G,L❫ ⊢ V1 ⬈[h] V & ⇧[1] V ≘ V2 &
185 ❪G,L❫ ⊢ W1 ⬈[h] W2 & ❪G,L.ⓓW1❫ ⊢ T1 ⬈[h] T2 &
186 U1 = ⓓ[p]W1.T1 & U2 = ⓓ[p]W2.ⓐV2.T2.
187 #h #G #L #V1 #U1 #U2 * #c #H elim (cpg_inv_appl1 … H) -H *
188 /4 width=13 by or3_intro0, or3_intro1, or3_intro2, ex6_7_intro, ex5_6_intro, ex3_2_intro, ex_intro/
191 lemma cpx_inv_cast1: ∀h,G,L,V1,U1,U2. ❪G,L❫ ⊢ ⓝV1.U1 ⬈[h] U2 →
192 ∨∨ ∃∃V2,T2. ❪G,L❫ ⊢ V1 ⬈[h] V2 & ❪G,L❫ ⊢ U1 ⬈[h] T2 &
195 | ❪G,L❫ ⊢ V1 ⬈[h] U2.
196 #h #G #L #V1 #U1 #U2 * #c #H elim (cpg_inv_cast1 … H) -H *
197 /4 width=5 by or3_intro0, or3_intro1, or3_intro2, ex3_2_intro, ex_intro/
200 (* Advanced inversion lemmas ************************************************)
202 lemma cpx_inv_zero1_pair: ∀h,I,G,K,V1,T2. ❪G,K.ⓑ[I]V1❫ ⊢ #0 ⬈[h] T2 →
204 | ∃∃V2. ❪G,K❫ ⊢ V1 ⬈[h] V2 & ⇧[1] V2 ≘ T2.
205 #h #I #G #L #V1 #T2 * #c #H elim (cpg_inv_zero1_pair … H) -H *
206 /4 width=3 by ex2_intro, ex_intro, or_intror, or_introl/
209 lemma cpx_inv_lref1_bind: ∀h,I,G,K,T2,i. ❪G,K.ⓘ[I]❫ ⊢ #↑i ⬈[h] T2 →
211 | ∃∃T. ❪G,K❫ ⊢ #i ⬈[h] T & ⇧[1] T ≘ T2.
212 #h #I #G #L #T2 #i * #c #H elim (cpg_inv_lref1_bind … H) -H *
213 /4 width=3 by ex2_intro, ex_intro, or_introl, or_intror/
216 lemma cpx_inv_flat1: ∀h,I,G,L,V1,U1,U2. ❪G,L❫ ⊢ ⓕ[I]V1.U1 ⬈[h] U2 →
217 ∨∨ ∃∃V2,T2. ❪G,L❫ ⊢ V1 ⬈[h] V2 & ❪G,L❫ ⊢ U1 ⬈[h] T2 &
219 | (❪G,L❫ ⊢ U1 ⬈[h] U2 ∧ I = Cast)
220 | (❪G,L❫ ⊢ V1 ⬈[h] U2 ∧ I = Cast)
221 | ∃∃p,V2,W1,W2,T1,T2. ❪G,L❫ ⊢ V1 ⬈[h] V2 & ❪G,L❫ ⊢ W1 ⬈[h] W2 &
222 ❪G,L.ⓛW1❫ ⊢ T1 ⬈[h] T2 &
224 U2 = ⓓ[p]ⓝW2.V2.T2 & I = Appl
225 | ∃∃p,V,V2,W1,W2,T1,T2. ❪G,L❫ ⊢ V1 ⬈[h] V & ⇧[1] V ≘ V2 &
226 ❪G,L❫ ⊢ W1 ⬈[h] W2 & ❪G,L.ⓓW1❫ ⊢ T1 ⬈[h] T2 &
228 U2 = ⓓ[p]W2.ⓐV2.T2 & I = Appl.
229 #h * #G #L #V1 #U1 #U2 #H
230 [ elim (cpx_inv_appl1 … H) -H *
231 /3 width=14 by or5_intro0, or5_intro3, or5_intro4, ex7_7_intro, ex6_6_intro, ex3_2_intro/
232 | elim (cpx_inv_cast1 … H) -H [ * ]
233 /3 width=14 by or5_intro0, or5_intro1, or5_intro2, ex3_2_intro, conj/
237 (* Basic forward lemmas *****************************************************)
239 lemma cpx_fwd_bind1_minus: ∀h,I,G,L,V1,T1,T. ❪G,L❫ ⊢ -ⓑ[I]V1.T1 ⬈[h] T → ∀p.
240 ∃∃V2,T2. ❪G,L❫ ⊢ ⓑ[p,I]V1.T1 ⬈[h] ⓑ[p,I]V2.T2 &
242 #h #I #G #L #V1 #T1 #T * #c #H #p elim (cpg_fwd_bind1_minus … H p) -H
243 /3 width=4 by ex2_2_intro, ex_intro/
246 (* Basic eliminators ********************************************************)
248 lemma cpx_ind: ∀h. ∀Q:relation4 genv lenv term term.
249 (∀I,G,L. Q G L (⓪[I]) (⓪[I])) →
250 (∀G,L,s. Q G L (⋆s) (⋆(⫯[h]s))) →
251 (∀I,G,K,V1,V2,W2. ❪G,K❫ ⊢ V1 ⬈[h] V2 → Q G K V1 V2 →
252 ⇧[1] V2 ≘ W2 → Q G (K.ⓑ[I]V1) (#0) W2
253 ) → (∀I,G,K,T,U,i. ❪G,K❫ ⊢ #i ⬈[h] T → Q G K (#i) T →
254 ⇧[1] T ≘ U → Q G (K.ⓘ[I]) (#↑i) (U)
255 ) → (∀p,I,G,L,V1,V2,T1,T2. ❪G,L❫ ⊢ V1 ⬈[h] V2 → ❪G,L.ⓑ[I]V1❫ ⊢ T1 ⬈[h] T2 →
256 Q G L V1 V2 → Q G (L.ⓑ[I]V1) T1 T2 → Q G L (ⓑ[p,I]V1.T1) (ⓑ[p,I]V2.T2)
257 ) → (∀I,G,L,V1,V2,T1,T2. ❪G,L❫ ⊢ V1 ⬈[h] V2 → ❪G,L❫ ⊢ T1 ⬈[h] T2 →
258 Q G L V1 V2 → Q G L T1 T2 → Q G L (ⓕ[I]V1.T1) (ⓕ[I]V2.T2)
259 ) → (∀G,L,V,T1,T,T2. ⇧[1] T ≘ T1 → ❪G,L❫ ⊢ T ⬈[h] T2 → Q G L T T2 →
261 ) → (∀G,L,V,T1,T2. ❪G,L❫ ⊢ T1 ⬈[h] T2 → Q G L T1 T2 →
263 ) → (∀G,L,V1,V2,T. ❪G,L❫ ⊢ V1 ⬈[h] V2 → Q G L V1 V2 →
265 ) → (∀p,G,L,V1,V2,W1,W2,T1,T2. ❪G,L❫ ⊢ V1 ⬈[h] V2 → ❪G,L❫ ⊢ W1 ⬈[h] W2 → ❪G,L.ⓛW1❫ ⊢ T1 ⬈[h] T2 →
266 Q G L V1 V2 → Q G L W1 W2 → Q G (L.ⓛW1) T1 T2 →
267 Q G L (ⓐV1.ⓛ[p]W1.T1) (ⓓ[p]ⓝW2.V2.T2)
268 ) → (∀p,G,L,V1,V,V2,W1,W2,T1,T2. ❪G,L❫ ⊢ V1 ⬈[h] V → ❪G,L❫ ⊢ W1 ⬈[h] W2 → ❪G,L.ⓓW1❫ ⊢ T1 ⬈[h] T2 →
269 Q G L V1 V → Q G L W1 W2 → Q G (L.ⓓW1) T1 T2 →
270 ⇧[1] V ≘ V2 → Q G L (ⓐV1.ⓓ[p]W1.T1) (ⓓ[p]W2.ⓐV2.T2)
272 ∀G,L,T1,T2. ❪G,L❫ ⊢ T1 ⬈[h] T2 → Q G L T1 T2.
273 #h #Q #IH1 #IH2 #IH3 #IH4 #IH5 #IH6 #IH7 #IH8 #IH9 #IH10 #IH11 #G #L #T1 #T2
274 * #c #H elim H -c -G -L -T1 -T2 /3 width=4 by ex_intro/