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 "basic_2/notation/relations/predty_5.ma".
16 include "basic_2/rt_transition/cpg.ma".
18 (* UNBOUND CONTEXT-SENSITIVE PARALLEL RT-TRANSITION FOR TERMS ***************)
20 definition cpx (h): relation4 genv lenv term term ≝
21 λG,L,T1,T2. ∃c. ⦃G,L⦄ ⊢ T1 ⬈[eq_f,c,h] T2.
24 "unbound context-sensitive parallel rt-transition (term)"
25 'PRedTy h G L T1 T2 = (cpx h G L T1 T2).
27 (* Basic properties *********************************************************)
29 (* Basic_2A1: was: cpx_st *)
30 lemma cpx_ess: ∀h,G,L,s. ⦃G,L⦄ ⊢ ⋆s ⬈[h] ⋆(⫯[h]s).
31 /2 width=2 by cpg_ess, ex_intro/ qed.
33 lemma cpx_delta: ∀h,I,G,K,V1,V2,W2. ⦃G,K⦄ ⊢ V1 ⬈[h] V2 →
34 ⇧*[1] V2 ≘ W2 → ⦃G,K.ⓑ{I}V1⦄ ⊢ #0 ⬈[h] W2.
35 #h * #G #K #V1 #V2 #W2 *
36 /3 width=4 by cpg_delta, cpg_ell, ex_intro/
39 lemma cpx_lref: ∀h,I,G,K,T,U,i. ⦃G,K⦄ ⊢ #i ⬈[h] T →
40 ⇧*[1] T ≘ U → ⦃G,K.ⓘ{I}⦄ ⊢ #↑i ⬈[h] U.
41 #h #I #G #K #T #U #i *
42 /3 width=4 by cpg_lref, ex_intro/
45 lemma cpx_bind: ∀h,p,I,G,L,V1,V2,T1,T2.
46 ⦃G,L⦄ ⊢ V1 ⬈[h] V2 → ⦃G,L.ⓑ{I}V1⦄ ⊢ T1 ⬈[h] T2 →
47 ⦃G,L⦄ ⊢ ⓑ{p,I}V1.T1 ⬈[h] ⓑ{p,I}V2.T2.
48 #h #p #I #G #L #V1 #V2 #T1 #T2 * #cV #HV12 *
49 /3 width=2 by cpg_bind, ex_intro/
52 lemma cpx_flat: ∀h,I,G,L,V1,V2,T1,T2.
53 ⦃G,L⦄ ⊢ V1 ⬈[h] V2 → ⦃G,L⦄ ⊢ T1 ⬈[h] T2 →
54 ⦃G,L⦄ ⊢ ⓕ{I}V1.T1 ⬈[h] ⓕ{I}V2.T2.
55 #h * #G #L #V1 #V2 #T1 #T2 * #cV #HV12 *
56 /3 width=5 by cpg_appl, cpg_cast, ex_intro/
59 lemma cpx_zeta (h) (G) (L):
60 ∀T1,T. ⇧*[1] T ≘ T1 → ∀T2. ⦃G,L⦄ ⊢ T ⬈[h] T2 →
61 ∀V. ⦃G,L⦄ ⊢ +ⓓV.T1 ⬈[h] T2.
62 #h #G #L #T1 #T #HT1 #T2 *
63 /3 width=4 by cpg_zeta, ex_intro/
66 lemma cpx_eps: ∀h,G,L,V,T1,T2. ⦃G,L⦄ ⊢ T1 ⬈[h] T2 → ⦃G,L⦄ ⊢ ⓝV.T1 ⬈[h] T2.
68 /3 width=2 by cpg_eps, ex_intro/
71 (* Basic_2A1: was: cpx_ct *)
72 lemma cpx_ee: ∀h,G,L,V1,V2,T. ⦃G,L⦄ ⊢ V1 ⬈[h] V2 → ⦃G,L⦄ ⊢ ⓝV1.T ⬈[h] V2.
74 /3 width=2 by cpg_ee, ex_intro/
77 lemma cpx_beta: ∀h,p,G,L,V1,V2,W1,W2,T1,T2.
78 ⦃G,L⦄ ⊢ V1 ⬈[h] V2 → ⦃G,L⦄ ⊢ W1 ⬈[h] W2 → ⦃G,L.ⓛW1⦄ ⊢ T1 ⬈[h] T2 →
79 ⦃G,L⦄ ⊢ ⓐV1.ⓛ{p}W1.T1 ⬈[h] ⓓ{p}ⓝW2.V2.T2.
80 #h #p #G #L #V1 #V2 #W1 #W2 #T1 #T2 * #cV #HV12 * #cW #HW12 *
81 /3 width=2 by cpg_beta, ex_intro/
84 lemma cpx_theta: ∀h,p,G,L,V1,V,V2,W1,W2,T1,T2.
85 ⦃G,L⦄ ⊢ V1 ⬈[h] V → ⇧*[1] V ≘ V2 → ⦃G,L⦄ ⊢ W1 ⬈[h] W2 →
86 ⦃G,L.ⓓW1⦄ ⊢ T1 ⬈[h] T2 →
87 ⦃G,L⦄ ⊢ ⓐV1.ⓓ{p}W1.T1 ⬈[h] ⓓ{p}W2.ⓐV2.T2.
88 #h #p #G #L #V1 #V #V2 #W1 #W2 #T1 #T2 * #cV #HV1 #HV2 * #cW #HW12 *
89 /3 width=4 by cpg_theta, ex_intro/
92 (* Basic_2A1: includes: cpx_atom *)
93 lemma cpx_refl: ∀h,G,L. reflexive … (cpx h G L).
94 /3 width=2 by cpg_refl, ex_intro/ qed.
96 (* Advanced properties ******************************************************)
98 lemma cpx_pair_sn: ∀h,I,G,L,V1,V2. ⦃G,L⦄ ⊢ V1 ⬈[h] V2 →
99 ∀T. ⦃G,L⦄ ⊢ ②{I}V1.T ⬈[h] ②{I}V2.T.
100 #h * /2 width=2 by cpx_flat, cpx_bind/
103 lemma cpg_cpx (h) (Rt) (c) (G) (L):
104 ∀T1,T2. ⦃G,L⦄ ⊢ T1 ⬈[Rt,c,h] T2 → ⦃G,L⦄ ⊢ T1 ⬈[h] T2.
105 #h #Rt #c #G #L #T1 #T2 #H elim H -c -G -L -T1 -T2
106 /2 width=3 by cpx_theta, cpx_beta, cpx_ee, cpx_eps, cpx_zeta, cpx_flat, cpx_bind, cpx_lref, cpx_delta/
109 (* Basic inversion lemmas ***************************************************)
111 lemma cpx_inv_atom1: ∀h,J,G,L,T2. ⦃G,L⦄ ⊢ ⓪{J} ⬈[h] T2 →
113 | ∃∃s. T2 = ⋆(⫯[h]s) & J = Sort s
114 | ∃∃I,K,V1,V2. ⦃G,K⦄ ⊢ V1 ⬈[h] V2 & ⇧*[1] V2 ≘ T2 &
115 L = K.ⓑ{I}V1 & J = LRef 0
116 | ∃∃I,K,T,i. ⦃G,K⦄ ⊢ #i ⬈[h] T & ⇧*[1] T ≘ T2 &
117 L = K.ⓘ{I} & J = LRef (↑i).
118 #h #J #G #L #T2 * #c #H elim (cpg_inv_atom1 … H) -H *
119 /4 width=8 by or4_intro0, or4_intro1, or4_intro2, or4_intro3, ex4_4_intro, ex2_intro, ex_intro/
122 lemma cpx_inv_sort1: ∀h,G,L,T2,s. ⦃G,L⦄ ⊢ ⋆s ⬈[h] T2 →
123 ∨∨ T2 = ⋆s | T2 = ⋆(⫯[h]s).
124 #h #G #L #T2 #s * #c #H elim (cpg_inv_sort1 … H) -H *
125 /2 width=1 by or_introl, or_intror/
128 lemma cpx_inv_zero1: ∀h,G,L,T2. ⦃G,L⦄ ⊢ #0 ⬈[h] T2 →
130 | ∃∃I,K,V1,V2. ⦃G,K⦄ ⊢ V1 ⬈[h] V2 & ⇧*[1] V2 ≘ T2 &
132 #h #G #L #T2 * #c #H elim (cpg_inv_zero1 … H) -H *
133 /4 width=7 by ex3_4_intro, ex_intro, or_introl, or_intror/
136 lemma cpx_inv_lref1: ∀h,G,L,T2,i. ⦃G,L⦄ ⊢ #↑i ⬈[h] T2 →
138 | ∃∃I,K,T. ⦃G,K⦄ ⊢ #i ⬈[h] T & ⇧*[1] T ≘ T2 & L = K.ⓘ{I}.
139 #h #G #L #T2 #i * #c #H elim (cpg_inv_lref1 … H) -H *
140 /4 width=6 by ex3_3_intro, ex_intro, or_introl, or_intror/
143 lemma cpx_inv_gref1: ∀h,G,L,T2,l. ⦃G,L⦄ ⊢ §l ⬈[h] T2 → T2 = §l.
144 #h #G #L #T2 #l * #c #H elim (cpg_inv_gref1 … H) -H //
147 lemma cpx_inv_bind1: ∀h,p,I,G,L,V1,T1,U2. ⦃G,L⦄ ⊢ ⓑ{p,I}V1.T1 ⬈[h] U2 →
148 ∨∨ ∃∃V2,T2. ⦃G,L⦄ ⊢ V1 ⬈[h] V2 & ⦃G,L.ⓑ{I}V1⦄ ⊢ T1 ⬈[h] T2 &
150 | ∃∃T. ⇧*[1] T ≘ T1 & ⦃G,L⦄ ⊢ T ⬈[h] U2 &
152 #h #p #I #G #L #V1 #T1 #U2 * #c #H elim (cpg_inv_bind1 … H) -H *
153 /4 width=5 by ex4_intro, ex3_2_intro, ex_intro, or_introl, or_intror/
156 lemma cpx_inv_abbr1: ∀h,p,G,L,V1,T1,U2. ⦃G,L⦄ ⊢ ⓓ{p}V1.T1 ⬈[h] U2 →
157 ∨∨ ∃∃V2,T2. ⦃G,L⦄ ⊢ V1 ⬈[h] V2 & ⦃G,L.ⓓV1⦄ ⊢ T1 ⬈[h] T2 &
159 | ∃∃T. ⇧*[1] T ≘ T1 & ⦃G,L⦄ ⊢ T ⬈[h] U2 & p = true.
160 #h #p #G #L #V1 #T1 #U2 * #c #H elim (cpg_inv_abbr1 … H) -H *
161 /4 width=5 by ex3_2_intro, ex3_intro, ex_intro, or_introl, or_intror/
164 lemma cpx_inv_abst1: ∀h,p,G,L,V1,T1,U2. ⦃G,L⦄ ⊢ ⓛ{p}V1.T1 ⬈[h] U2 →
165 ∃∃V2,T2. ⦃G,L⦄ ⊢ V1 ⬈[h] V2 & ⦃G,L.ⓛV1⦄ ⊢ T1 ⬈[h] T2 &
167 #h #p #G #L #V1 #T1 #U2 * #c #H elim (cpg_inv_abst1 … H) -H
168 /3 width=5 by ex3_2_intro, ex_intro/
171 lemma cpx_inv_appl1: ∀h,G,L,V1,U1,U2. ⦃G,L⦄ ⊢ ⓐ V1.U1 ⬈[h] U2 →
172 ∨∨ ∃∃V2,T2. ⦃G,L⦄ ⊢ V1 ⬈[h] V2 & ⦃G,L⦄ ⊢ U1 ⬈[h] T2 &
174 | ∃∃p,V2,W1,W2,T1,T2. ⦃G,L⦄ ⊢ V1 ⬈[h] V2 & ⦃G,L⦄ ⊢ W1 ⬈[h] W2 &
175 ⦃G,L.ⓛW1⦄ ⊢ T1 ⬈[h] T2 &
176 U1 = ⓛ{p}W1.T1 & U2 = ⓓ{p}ⓝW2.V2.T2
177 | ∃∃p,V,V2,W1,W2,T1,T2. ⦃G,L⦄ ⊢ V1 ⬈[h] V & ⇧*[1] V ≘ V2 &
178 ⦃G,L⦄ ⊢ W1 ⬈[h] W2 & ⦃G,L.ⓓW1⦄ ⊢ T1 ⬈[h] T2 &
179 U1 = ⓓ{p}W1.T1 & U2 = ⓓ{p}W2.ⓐV2.T2.
180 #h #G #L #V1 #U1 #U2 * #c #H elim (cpg_inv_appl1 … H) -H *
181 /4 width=13 by or3_intro0, or3_intro1, or3_intro2, ex6_7_intro, ex5_6_intro, ex3_2_intro, ex_intro/
184 lemma cpx_inv_cast1: ∀h,G,L,V1,U1,U2. ⦃G,L⦄ ⊢ ⓝV1.U1 ⬈[h] U2 →
185 ∨∨ ∃∃V2,T2. ⦃G,L⦄ ⊢ V1 ⬈[h] V2 & ⦃G,L⦄ ⊢ U1 ⬈[h] T2 &
188 | ⦃G,L⦄ ⊢ V1 ⬈[h] U2.
189 #h #G #L #V1 #U1 #U2 * #c #H elim (cpg_inv_cast1 … H) -H *
190 /4 width=5 by or3_intro0, or3_intro1, or3_intro2, ex3_2_intro, ex_intro/
193 (* Advanced inversion lemmas ************************************************)
195 lemma cpx_inv_zero1_pair: ∀h,I,G,K,V1,T2. ⦃G,K.ⓑ{I}V1⦄ ⊢ #0 ⬈[h] T2 →
197 | ∃∃V2. ⦃G,K⦄ ⊢ V1 ⬈[h] V2 & ⇧*[1] V2 ≘ T2.
198 #h #I #G #L #V1 #T2 * #c #H elim (cpg_inv_zero1_pair … H) -H *
199 /4 width=3 by ex2_intro, ex_intro, or_intror, or_introl/
202 lemma cpx_inv_lref1_bind: ∀h,I,G,K,T2,i. ⦃G,K.ⓘ{I}⦄ ⊢ #↑i ⬈[h] T2 →
204 | ∃∃T. ⦃G,K⦄ ⊢ #i ⬈[h] T & ⇧*[1] T ≘ T2.
205 #h #I #G #L #T2 #i * #c #H elim (cpg_inv_lref1_bind … H) -H *
206 /4 width=3 by ex2_intro, ex_intro, or_introl, or_intror/
209 lemma cpx_inv_flat1: ∀h,I,G,L,V1,U1,U2. ⦃G,L⦄ ⊢ ⓕ{I}V1.U1 ⬈[h] U2 →
210 ∨∨ ∃∃V2,T2. ⦃G,L⦄ ⊢ V1 ⬈[h] V2 & ⦃G,L⦄ ⊢ U1 ⬈[h] T2 &
212 | (⦃G,L⦄ ⊢ U1 ⬈[h] U2 ∧ I = Cast)
213 | (⦃G,L⦄ ⊢ V1 ⬈[h] U2 ∧ I = Cast)
214 | ∃∃p,V2,W1,W2,T1,T2. ⦃G,L⦄ ⊢ V1 ⬈[h] V2 & ⦃G,L⦄ ⊢ W1 ⬈[h] W2 &
215 ⦃G,L.ⓛW1⦄ ⊢ T1 ⬈[h] T2 &
217 U2 = ⓓ{p}ⓝW2.V2.T2 & I = Appl
218 | ∃∃p,V,V2,W1,W2,T1,T2. ⦃G,L⦄ ⊢ V1 ⬈[h] V & ⇧*[1] V ≘ V2 &
219 ⦃G,L⦄ ⊢ W1 ⬈[h] W2 & ⦃G,L.ⓓW1⦄ ⊢ T1 ⬈[h] T2 &
221 U2 = ⓓ{p}W2.ⓐV2.T2 & I = Appl.
222 #h * #G #L #V1 #U1 #U2 #H
223 [ elim (cpx_inv_appl1 … H) -H *
224 /3 width=14 by or5_intro0, or5_intro3, or5_intro4, ex7_7_intro, ex6_6_intro, ex3_2_intro/
225 | elim (cpx_inv_cast1 … H) -H [ * ]
226 /3 width=14 by or5_intro0, or5_intro1, or5_intro2, ex3_2_intro, conj/
230 (* Basic forward lemmas *****************************************************)
232 lemma cpx_fwd_bind1_minus: ∀h,I,G,L,V1,T1,T. ⦃G,L⦄ ⊢ -ⓑ{I}V1.T1 ⬈[h] T → ∀p.
233 ∃∃V2,T2. ⦃G,L⦄ ⊢ ⓑ{p,I}V1.T1 ⬈[h] ⓑ{p,I}V2.T2 &
235 #h #I #G #L #V1 #T1 #T * #c #H #p elim (cpg_fwd_bind1_minus … H p) -H
236 /3 width=4 by ex2_2_intro, ex_intro/
239 (* Basic eliminators ********************************************************)
241 lemma cpx_ind: ∀h. ∀Q:relation4 genv lenv term term.
242 (∀I,G,L. Q G L (⓪{I}) (⓪{I})) →
243 (∀G,L,s. Q G L (⋆s) (⋆(⫯[h]s))) →
244 (∀I,G,K,V1,V2,W2. ⦃G,K⦄ ⊢ V1 ⬈[h] V2 → Q G K V1 V2 →
245 ⇧*[1] V2 ≘ W2 → Q G (K.ⓑ{I}V1) (#0) W2
246 ) → (∀I,G,K,T,U,i. ⦃G,K⦄ ⊢ #i ⬈[h] T → Q G K (#i) T →
247 ⇧*[1] T ≘ U → Q G (K.ⓘ{I}) (#↑i) (U)
248 ) → (∀p,I,G,L,V1,V2,T1,T2. ⦃G,L⦄ ⊢ V1 ⬈[h] V2 → ⦃G,L.ⓑ{I}V1⦄ ⊢ T1 ⬈[h] T2 →
249 Q G L V1 V2 → Q G (L.ⓑ{I}V1) T1 T2 → Q G L (ⓑ{p,I}V1.T1) (ⓑ{p,I}V2.T2)
250 ) → (∀I,G,L,V1,V2,T1,T2. ⦃G,L⦄ ⊢ V1 ⬈[h] V2 → ⦃G,L⦄ ⊢ T1 ⬈[h] T2 →
251 Q G L V1 V2 → Q G L T1 T2 → Q G L (ⓕ{I}V1.T1) (ⓕ{I}V2.T2)
252 ) → (∀G,L,V,T1,T,T2. ⇧*[1] T ≘ T1 → ⦃G,L⦄ ⊢ T ⬈[h] T2 → Q G L T T2 →
254 ) → (∀G,L,V,T1,T2. ⦃G,L⦄ ⊢ T1 ⬈[h] T2 → Q G L T1 T2 →
256 ) → (∀G,L,V1,V2,T. ⦃G,L⦄ ⊢ V1 ⬈[h] V2 → Q G L V1 V2 →
258 ) → (∀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 →
259 Q G L V1 V2 → Q G L W1 W2 → Q G (L.ⓛW1) T1 T2 →
260 Q G L (ⓐV1.ⓛ{p}W1.T1) (ⓓ{p}ⓝW2.V2.T2)
261 ) → (∀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 →
262 Q G L V1 V → Q G L W1 W2 → Q G (L.ⓓW1) T1 T2 →
263 ⇧*[1] V ≘ V2 → Q G L (ⓐV1.ⓓ{p}W1.T1) (ⓓ{p}W2.ⓐV2.T2)
265 ∀G,L,T1,T2. ⦃G,L⦄ ⊢ T1 ⬈[h] T2 → Q G L T1 T2.
266 #h #Q #IH1 #IH2 #IH3 #IH4 #IH5 #IH6 #IH7 #IH8 #IH9 #IH10 #IH11 #G #L #T1 #T2
267 * #c #H elim H -c -G -L -T1 -T2 /3 width=4 by ex_intro/