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/pred_5.ma".
16 include "basic_2/rt_transition/cpg.ma".
18 (* UNCOUNTED CONTEXT-SENSITIVE PARALLEL REDUCTION FOR TERMS *****************)
20 definition cpx (h): relation4 genv lenv term term ≝
21 λG,L,T1,T2. ∃c. ⦃G, L⦄ ⊢ T1 ➡[c, h] T2.
24 "uncounted context-sensitive parallel reduction (term)"
25 'PRed h G L T1 T2 = (cpx h G L T1 T2).
27 (* Basic properties *********************************************************)
29 lemma cpx_atom: ∀h,I,G,L. ⦃G, L⦄ ⊢ ⓪{I} ➡[h] ⓪{I}.
30 /2 width=2 by cpg_atom, ex_intro/ qed.
32 (* Basic_2A1: was: cpx_st *)
33 lemma cpx_ess: ∀h,G,L,s. ⦃G, L⦄ ⊢ ⋆s ➡[h] ⋆(next h s).
34 /2 width=2 by cpg_ess, ex_intro/ qed.
36 lemma cpx_delta: ∀h,I,G,K,V1,V2,W2. ⦃G, K⦄ ⊢ V1 ➡[h] V2 →
37 ⬆*[1] V2 ≡ W2 → ⦃G, K.ⓑ{I}V1⦄ ⊢ #0 ➡[h] W2.
38 #h * #G #K #V1 #V2 #W2 *
39 /3 width=4 by cpg_delta, cpg_ell, ex_intro/
42 lemma cpx_lref: ∀h,I,G,K,V,T,U,i. ⦃G, K⦄ ⊢ #i ➡[h] T →
43 ⬆*[1] T ≡ U → ⦃G, K.ⓑ{I}V⦄ ⊢ #⫯i ➡[h] U.
44 #h #I #G #K #V #T #U #i *
45 /3 width=4 by cpg_lref, ex_intro/
48 lemma cpx_bind: ∀h,p,I,G,L,V1,V2,T1,T2.
49 ⦃G, L⦄ ⊢ V1 ➡[h] V2 → ⦃G, L.ⓑ{I}V1⦄ ⊢ T1 ➡[h] T2 →
50 ⦃G, L⦄ ⊢ ⓑ{p,I}V1.T1 ➡[h] ⓑ{p,I}V2.T2.
51 #h #p #I #G #L #V1 #V2 #T1 #T2 * #cV #HV12 *
52 /3 width=2 by cpg_bind, ex_intro/
55 lemma cpx_flat: ∀h,I,G,L,V1,V2,T1,T2.
56 ⦃G, L⦄ ⊢ V1 ➡[h] V2 → ⦃G, L⦄ ⊢ T1 ➡[h] T2 →
57 ⦃G, L⦄ ⊢ ⓕ{I}V1.T1 ➡[h] ⓕ{I}V2.T2.
58 #h #I #G #L #V1 #V2 #T1 #T2 * #cV #HV12 *
59 /3 width=2 by cpg_flat, ex_intro/
62 lemma cpx_zeta: ∀h,G,L,V,T1,T,T2. ⦃G, L.ⓓV⦄ ⊢ T1 ➡[h] T →
63 ⬆*[1] T2 ≡ T → ⦃G, L⦄ ⊢ +ⓓV.T1 ➡[h] T2.
64 #h #G #L #V #T1 #T #T2 *
65 /3 width=4 by cpg_zeta, ex_intro/
68 lemma cpx_eps: ∀h,G,L,V,T1,T2. ⦃G, L⦄ ⊢ T1 ➡[h] T2 → ⦃G, L⦄ ⊢ ⓝV.T1 ➡[h] T2.
70 /3 width=2 by cpg_eps, ex_intro/
73 (* Basic_2A1: was: cpx_ct *)
74 lemma cpx_ee: ∀h,G,L,V1,V2,T. ⦃G, L⦄ ⊢ V1 ➡[h] V2 → ⦃G, L⦄ ⊢ ⓝV1.T ➡[h] V2.
76 /3 width=2 by cpg_ee, ex_intro/
79 lemma cpx_beta: ∀h,p,G,L,V1,V2,W1,W2,T1,T2.
80 ⦃G, L⦄ ⊢ V1 ➡[h] V2 → ⦃G, L⦄ ⊢ W1 ➡[h] W2 → ⦃G, L.ⓛW1⦄ ⊢ T1 ➡[h] T2 →
81 ⦃G, L⦄ ⊢ ⓐV1.ⓛ{p}W1.T1 ➡[h] ⓓ{p}ⓝW2.V2.T2.
82 #h #p #G #L #V1 #V2 #W1 #W2 #T1 #T2 * #cV #HV12 * #cW #HW12 *
83 /3 width=2 by cpg_beta, ex_intro/
86 lemma cpx_theta: ∀h,p,G,L,V1,V,V2,W1,W2,T1,T2.
87 ⦃G, L⦄ ⊢ V1 ➡[h] V → ⬆*[1] V ≡ V2 → ⦃G, L⦄ ⊢ W1 ➡[h] W2 →
88 ⦃G, L.ⓓW1⦄ ⊢ T1 ➡[h] T2 →
89 ⦃G, L⦄ ⊢ ⓐV1.ⓓ{p}W1.T1 ➡[h] ⓓ{p}W2.ⓐV2.T2.
90 #h #p #G #L #V1 #V #V2 #W1 #W2 #T1 #T2 * #cV #HV1 #HV2 * #cW #HW12 *
91 /3 width=4 by cpg_theta, ex_intro/
94 lemma cpx_refl: ∀h,G,L. reflexive … (cpx h G L).
95 /2 width=2 by ex_intro/ qed.
97 lemma cpx_pair_sn: ∀h,I,G,L,V1,V2. ⦃G, L⦄ ⊢ V1 ➡[h] V2 →
98 ∀T. ⦃G, L⦄ ⊢ ②{I}V1.T ➡[h] ②{I}V2.T.
100 /3 width=2 by cpg_pair_sn, ex_intro/
103 (* Basic inversion lemmas ***************************************************)
105 lemma cpx_inv_atom1: ∀h,J,G,L,T2. ⦃G, L⦄ ⊢ ⓪{J} ➡[h] T2 →
107 | ∃∃s. T2 = ⋆(next h s) & J = Sort s
108 | ∃∃I,K,V1,V2. ⦃G, K⦄ ⊢ V1 ➡[h] V2 & ⬆*[1] V2 ≡ T2 &
109 L = K.ⓑ{I}V1 & J = LRef 0
110 | ∃∃I,K,V,T,i. ⦃G, K⦄ ⊢ #i ➡[h] T & ⬆*[1] T ≡ T2 &
111 L = K.ⓑ{I}V & J = LRef (⫯i).
112 #h #J #G #L #T2 * #c #H elim (cpg_inv_atom1 … H) -H *
113 /4 width=9 by or4_intro0, or4_intro1, or4_intro2, or4_intro3, ex4_5_intro, ex4_4_intro, ex2_intro, ex_intro/
116 lemma cpx_inv_sort1: ∀h,G,L,T2,s. ⦃G, L⦄ ⊢ ⋆s ➡[h] T2 →
117 T2 = ⋆s ∨ T2 = ⋆(next h s).
118 #h #G #L #T2 #s * #c #H elim (cpg_inv_sort1 … H) -H *
119 /2 width=1 by or_introl, or_intror/
122 lemma cpx_inv_zero1: ∀h,G,L,T2. ⦃G, L⦄ ⊢ #0 ➡[h] T2 →
124 ∃∃I,K,V1,V2. ⦃G, K⦄ ⊢ V1 ➡[h] V2 & ⬆*[1] V2 ≡ T2 &
126 #h #G #L #T2 * #c #H elim (cpg_inv_zero1 … H) -H *
127 /4 width=7 by ex3_4_intro, ex_intro, or_introl, or_intror/
130 lemma cpx_inv_lref1: ∀h,G,L,T2,i. ⦃G, L⦄ ⊢ #⫯i ➡[h] T2 →
132 ∃∃I,K,V,T. ⦃G, K⦄ ⊢ #i ➡[h] T & ⬆*[1] T ≡ T2 & L = K.ⓑ{I}V.
133 #h #G #L #T2 #i * #c #H elim (cpg_inv_lref1 … H) -H *
134 /4 width=7 by ex3_4_intro, ex_intro, or_introl, or_intror/
137 lemma cpx_inv_gref1: ∀h,G,L,T2,l. ⦃G, L⦄ ⊢ §l ➡[h] T2 → T2 = §l.
138 #h #G #L #T2 #l * #c #H elim (cpg_inv_gref1 … H) -H //
141 lemma cpx_inv_bind1: ∀h,p,I,G,L,V1,T1,U2. ⦃G, L⦄ ⊢ ⓑ{p,I}V1.T1 ➡[h] U2 → (
142 ∃∃V2,T2. ⦃G, L⦄ ⊢ V1 ➡[h] V2 & ⦃G, L.ⓑ{I}V1⦄ ⊢ T1 ➡[h] T2 &
145 ∃∃T. ⦃G, L.ⓓV1⦄ ⊢ T1 ➡[h] T & ⬆*[1] U2 ≡ T &
147 #h #p #I #G #L #V1 #T1 #U2 * #c #H elim (cpg_inv_bind1 … H) -H *
148 /4 width=5 by ex4_intro, ex3_2_intro, ex_intro, or_introl, or_intror/
151 lemma cpx_inv_abbr1: ∀h,p,G,L,V1,T1,U2. ⦃G, L⦄ ⊢ ⓓ{p}V1.T1 ➡[h] U2 → (
152 ∃∃V2,T2. ⦃G, L⦄ ⊢ V1 ➡[h] V2 & ⦃G, L.ⓓV1⦄ ⊢ T1 ➡[h] T2 &
155 ∃∃T. ⦃G, L.ⓓV1⦄ ⊢ T1 ➡[h] T & ⬆*[1] U2 ≡ T & p = true.
156 #h #p #G #L #V1 #T1 #U2 * #c #H elim (cpg_inv_abbr1 … H) -H *
157 /4 width=5 by ex3_2_intro, ex3_intro, ex_intro, or_introl, or_intror/
160 lemma cpx_inv_abst1: ∀h,p,G,L,V1,T1,U2. ⦃G, L⦄ ⊢ ⓛ{p}V1.T1 ➡[h] U2 →
161 ∃∃V2,T2. ⦃G, L⦄ ⊢ V1 ➡[h] V2 & ⦃G, L.ⓛV1⦄ ⊢ T1 ➡[h] T2 &
163 #h #p #G #L #V1 #T1 #U2 * #c #H elim (cpg_inv_abst1 … H) -H
164 /3 width=5 by ex3_2_intro, ex_intro/
167 lemma cpx_inv_flat1: ∀h,I,G,L,V1,U1,U2. ⦃G, L⦄ ⊢ ⓕ{I}V1.U1 ➡[h] U2 →
168 ∨∨ ∃∃V2,T2. ⦃G, L⦄ ⊢ V1 ➡[h] V2 & ⦃G, L⦄ ⊢ U1 ➡[h] T2 &
170 | (⦃G, L⦄ ⊢ U1 ➡[h] U2 ∧ I = Cast)
171 | (⦃G, L⦄ ⊢ V1 ➡[h] U2 ∧ I = Cast)
172 | ∃∃p,V2,W1,W2,T1,T2. ⦃G, L⦄ ⊢ V1 ➡[h] V2 & ⦃G, L⦄ ⊢ W1 ➡[h] W2 &
173 ⦃G, L.ⓛW1⦄ ⊢ T1 ➡[h] T2 &
175 U2 = ⓓ{p}ⓝW2.V2.T2 & I = Appl
176 | ∃∃p,V,V2,W1,W2,T1,T2. ⦃G, L⦄ ⊢ V1 ➡[h] V & ⬆*[1] V ≡ V2 &
177 ⦃G, L⦄ ⊢ W1 ➡[h] W2 & ⦃G, L.ⓓW1⦄ ⊢ T1 ➡[h] T2 &
179 U2 = ⓓ{p}W2.ⓐV2.T2 & I = Appl.
180 #h #I #G #L #V1 #U1 #U2 * #c #H elim (cpg_inv_flat1 … H) -H *
181 /4 width=14 by or5_intro0, or5_intro1, or5_intro2, or5_intro3, or5_intro4, ex7_7_intro, ex6_6_intro, ex3_2_intro, ex_intro, conj/
184 lemma cpx_inv_appl1: ∀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 &
187 | ∃∃p,V2,W1,W2,T1,T2. ⦃G, L⦄ ⊢ V1 ➡[h] V2 & ⦃G, L⦄ ⊢ W1 ➡[h] W2 &
188 ⦃G, L.ⓛW1⦄ ⊢ T1 ➡[h] T2 &
189 U1 = ⓛ{p}W1.T1 & U2 = ⓓ{p}ⓝW2.V2.T2
190 | ∃∃p,V,V2,W1,W2,T1,T2. ⦃G, L⦄ ⊢ V1 ➡[h] V & ⬆*[1] V ≡ V2 &
191 ⦃G, L⦄ ⊢ W1 ➡[h] W2 & ⦃G, L.ⓓW1⦄ ⊢ T1 ➡[h] T2 &
192 U1 = ⓓ{p}W1.T1 & U2 = ⓓ{p}W2.ⓐV2.T2.
193 #h #G #L #V1 #U1 #U2 * #c #H elim (cpg_inv_appl1 … H) -H *
194 /4 width=13 by or3_intro0, or3_intro1, or3_intro2, ex6_7_intro, ex5_6_intro, ex3_2_intro, ex_intro/
197 lemma cpx_inv_cast1: ∀h,G,L,V1,U1,U2. ⦃G, L⦄ ⊢ ⓝV1.U1 ➡[h] U2 →
198 ∨∨ ∃∃V2,T2. ⦃G, L⦄ ⊢ V1 ➡[h] V2 & ⦃G, L⦄ ⊢ U1 ➡[h] T2 &
200 | ⦃G, L⦄ ⊢ U1 ➡[h] U2
201 | ⦃G, L⦄ ⊢ V1 ➡[h] U2.
202 #h #G #L #V1 #U1 #U2 * #c #H elim (cpg_inv_cast1 … H) -H *
203 /4 width=5 by or3_intro0, or3_intro1, or3_intro2, ex3_2_intro, ex_intro/
206 (* Basic forward lemmas *****************************************************)
208 lemma cpx_fwd_bind1_minus: ∀h,I,G,L,V1,T1,T. ⦃G, L⦄ ⊢ -ⓑ{I}V1.T1 ➡[h] T → ∀p.
209 ∃∃V2,T2. ⦃G, L⦄ ⊢ ⓑ{p,I}V1.T1 ➡[h] ⓑ{p,I}V2.T2 &
211 #h #I #G #L #V1 #T1 #T * #c #H #p elim (cpg_fwd_bind1_minus … H p) -H
212 /3 width=4 by ex2_2_intro, ex_intro/