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/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".
25 (* EXTENDED CONTEXT-SENSITIVE PARALLEL RT-TRANSITION FOR TERMS **************)
27 definition sort_eq_f: relation nat ≝ λs1,s2. ⊤.
29 definition cpx (G) (L): relation2 term term ≝
30 λT1,T2. ∃c. ❪G,L❫ ⊢ T1 ⬈[sort_eq_f,rtc_eq_f,c] T2.
33 "extended context-sensitive parallel rt-transition (term)"
34 'PRedTy G L T1 T2 = (cpx G L T1 T2).
36 (* Basic properties *********************************************************)
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.
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.
46 /3 width=4 by cpg_delta, cpg_ell, ex_intro/
49 lemma cpx_lref (G) (K):
50 ∀I,T,U,i. ❪G,K❫ ⊢ #i ⬈ T →
51 ⇧[1] T ≘ U → ❪G,K.ⓘ[I]❫ ⊢ #↑i ⬈ U.
53 /3 width=4 by cpg_lref, ex_intro/
56 lemma cpx_bind (G) (L):
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/
64 lemma cpx_flat (G) (L):
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/
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/
79 lemma cpx_eps (G) (L):
80 ∀V,T1,T2. ❪G,L❫ ⊢ T1 ⬈ T2 → ❪G,L❫ ⊢ ⓝV.T1 ⬈ T2.
82 /3 width=2 by cpg_eps, ex_intro/
85 (* Basic_2A1: was: cpx_ct *)
87 ∀V1,V2,T. ❪G,L❫ ⊢ V1 ⬈ V2 → ❪G,L❫ ⊢ ⓝV1.T ⬈ V2.
89 /3 width=2 by cpg_ee, ex_intro/
92 lemma cpx_beta (G) (L):
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/
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/
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.
112 (* Advanced properties ******************************************************)
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/
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/
126 (* Basic inversion lemmas ***************************************************)
128 lemma cpx_inv_atom1 (G) (L):
129 ∀J,T2. ❪G,L❫ ⊢ ⓪[J] ⬈ T2 →
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/
138 lemma cpx_inv_sort1 (G) (L):
139 ∀T2,s1. ❪G,L❫ ⊢ ⋆s1 ⬈ T2 →
141 #G #L #T2 #s1 * #c #H elim (cpg_inv_sort1 … H) -H *
142 /2 width=2 by ex_intro/
145 lemma cpx_inv_zero1 (G) (L):
146 ∀T2. ❪G,L❫ ⊢ #0 ⬈ T2 →
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/
153 lemma cpx_inv_lref1 (G) (L):
154 ∀T2,i. ❪G,L❫ ⊢ #↑i ⬈ T2 →
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/
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 //
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/
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/
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/
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/
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
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/
207 (* Advanced inversion lemmas ************************************************)
209 lemma cpx_inv_zero1_pair (G) (K):
210 ∀I,V1,T2. ❪G,K.ⓑ[I]V1❫ ⊢ #0 ⬈ T2 →
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/
217 lemma cpx_inv_lref1_bind (G) (K):
218 ∀I,T2,i. ❪G,K.ⓘ[I]❫ ⊢ #↑i ⬈ T2 →
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/
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/
240 (* Basic forward lemmas *****************************************************)
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/
249 (* Basic eliminators ********************************************************)
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 →
264 ) → (∀G,L,V,T1,T2. ❪G,L❫ ⊢ T1 ⬈ T2 → Q G L T1 T2 →
266 ) → (∀G,L,V1,V2,T. ❪G,L❫ ⊢ V1 ⬈ V2 → Q G L V1 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)
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/