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 notation "hvbox( L ⊢ break term 46 T1 ➤ * break term 46 T2 )"
16 non associative with precedence 45
17 for @{ 'PRestStar $L $T1 $T2 }.
19 include "basic_2/substitution/cpss.ma".
21 (* CONTEXT-SENSITIVE RESTRICTED PARALLEL COMPUTATION FOR TERMS **************)
23 inductive cpqs: lenv → relation term ≝
24 | cpqs_atom : ∀I,L. cpqs L (⓪{I}) (⓪{I})
25 | cpqs_delta: ∀L,K,V,V2,W2,i.
26 ⇩[0, i] L ≡ K. ⓓV → cpqs K V V2 →
27 ⇧[0, i + 1] V2 ≡ W2 → cpqs L (#i) W2
28 | cpqs_bind : ∀a,I,L,V1,V2,T1,T2.
29 cpqs L V1 V2 → cpqs (L. ⓑ{I} V1) T1 T2 →
30 cpqs L (ⓑ{a,I} V1. T1) (ⓑ{a,I} V2. T2)
31 | cpqs_flat : ∀I,L,V1,V2,T1,T2.
32 cpqs L V1 V2 → cpqs L T1 T2 →
33 cpqs L (ⓕ{I} V1. T1) (ⓕ{I} V2. T2)
34 | cpqs_zeta : ∀L,V,T1,T,T2. cpqs (L.ⓓV) T1 T →
35 ⇧[0, 1] T2 ≡ T → cpqs L (+ⓓV. T1) T2
36 | cpqs_tau : ∀L,V,T1,T2. cpqs L T1 T2 → cpqs L (ⓝV. T1) T2
39 interpretation "context-sensitive restricted parallel computation (term)"
40 'PRestStar L T1 T2 = (cpqs L T1 T2).
42 (* Basic properties *********************************************************)
44 lemma cpqs_lsubr_trans: lsub_trans … cpqs lsubr.
45 #L1 #T1 #T2 #H elim H -L1 -T1 -T2
47 | #L1 #K1 #V1 #V2 #W2 #i #HLK1 #_ #HVW2 #IHV12 #L2 #HL12
48 elim (lsubr_fwd_ldrop2_abbr … HL12 … HLK1) -HL12 -HLK1 /3 width=6/
55 lemma cpss_cpqs: ∀L,T1,T2. L ⊢ T1 ▶* T2 → L ⊢ T1 ➤* T2.
56 #L #T1 #T2 #H elim H -L -T1 -T2 // /2 width=1/ /2 width=6/
59 lemma cpqs_refl: ∀T,L. L ⊢ T ➤* T.
62 lemma cpqs_delift: ∀L,K,V,T1,d. ⇩[0, d] L ≡ (K. ⓓV) →
63 ∃∃T2,T. L ⊢ T1 ➤* T2 & ⇧[d, 1] T ≡ T2.
65 elim (cpss_delift … T1 … HLK) -HLK /3 width=4/
68 lemma cpqs_append: l_appendable_sn … cpqs.
69 #K #T1 #T2 #H elim H -K -T1 -T2 // /2 width=1/ /2 width=3/
70 #K #K0 #V1 #V2 #W2 #i #HK0 #_ #HVW2 #IHV12 #L
71 lapply (ldrop_fwd_length_lt2 … HK0) #H
72 @(cpqs_delta … (L@@K0) V1 … HVW2) //
73 @(ldrop_O1_append_sn_le … HK0) /2 width=2/ (**) (* /3/ does not work *)
76 (* Basic inversion lemmas ***************************************************)
78 fact cpqs_inv_atom1_aux: ∀L,T1,T2. L ⊢ T1 ➤* T2 → ∀I. T1 = ⓪{I} →
80 ∃∃K,V,V2,i. ⇩[O, i] L ≡ K. ⓓV &
84 #L #T1 #T2 * -L -T1 -T2
85 [ #I #L #J #H destruct /2 width=1/
86 | #L #K #V #V2 #T2 #i #HLK #HV2 #HVT2 #J #H destruct /3 width=8/
87 | #a #I #L #V1 #V2 #T1 #T2 #_ #_ #J #H destruct
88 | #I #L #V1 #V2 #T1 #T2 #_ #_ #J #H destruct
89 | #L #V #T1 #T #T2 #_ #_ #J #H destruct
90 | #L #V #T1 #T2 #_ #J #H destruct
94 lemma cpqs_inv_atom1: ∀I,L,T2. L ⊢ ⓪{I} ➤* T2 →
96 ∃∃K,V,V2,i. ⇩[O, i] L ≡ K. ⓓV &
100 /2 width=3 by cpqs_inv_atom1_aux/ qed-.
102 lemma cpqs_inv_sort1: ∀L,T2,k. L ⊢ ⋆k ➤* T2 → T2 = ⋆k.
104 elim (cpqs_inv_atom1 … H) -H //
105 * #K #V #V2 #i #_ #_ #_ #H destruct
108 lemma cpqs_inv_lref1: ∀L,T2,i. L ⊢ #i ➤* T2 →
110 ∃∃K,V,V2. ⇩[O, i] L ≡ K. ⓓV &
114 elim (cpqs_inv_atom1 … H) -H /2 width=1/
115 * #K #V #V2 #j #HLK #HV2 #HVT2 #H destruct /3 width=6/
118 lemma cpqs_inv_gref1: ∀L,T2,p. L ⊢ §p ➤* T2 → T2 = §p.
120 elim (cpqs_inv_atom1 … H) -H //
121 * #K #V #V2 #i #_ #_ #_ #H destruct
124 fact cpqs_inv_bind1_aux: ∀L,U1,U2. L ⊢ U1 ➤* U2 →
125 ∀a,I,V1,T1. U1 = ⓑ{a,I} V1. T1 → (
126 ∃∃V2,T2. L ⊢ V1 ➤* V2 &
127 L. ⓑ{I} V1 ⊢ T1 ➤* T2 &
130 ∃∃T. L.ⓓV1 ⊢ T1 ➤* T & ⇧[0, 1] U2 ≡ T & a = true & I = Abbr.
131 #L #U1 #U2 * -L -U1 -U2
132 [ #I #L #b #J #W1 #U1 #H destruct
133 | #L #K #V #V2 #W2 #i #_ #_ #_ #b #J #W1 #U1 #H destruct
134 | #a #I #L #V1 #V2 #T1 #T2 #HV12 #HT12 #b #J #W1 #U1 #H destruct /3 width=5/
135 | #I #L #V1 #V2 #T1 #T2 #_ #_ #b #J #W1 #U1 #H destruct
136 | #L #V #T1 #T #T2 #HT1 #HT2 #b #J #W1 #U1 #H destruct /3 width=3/
137 | #L #V #T1 #T2 #_ #b #J #W1 #U1 #H destruct
141 lemma cpqs_inv_bind1: ∀a,I,L,V1,T1,U2. L ⊢ ⓑ{a,I} V1. T1 ➤* U2 → (
142 ∃∃V2,T2. L ⊢ V1 ➤* V2 &
143 L. ⓑ{I} V1 ⊢ T1 ➤* T2 &
146 ∃∃T. L.ⓓV1 ⊢ T1 ➤* T & ⇧[0, 1] U2 ≡ T & a = true & I = Abbr.
147 /2 width=3 by cpqs_inv_bind1_aux/ qed-.
149 lemma cpqs_inv_abbr1: ∀a,L,V1,T1,U2. L ⊢ ⓓ{a} V1. T1 ➤* U2 → (
150 ∃∃V2,T2. L ⊢ V1 ➤* V2 &
154 ∃∃T. L.ⓓV1 ⊢ T1 ➤* T & ⇧[0, 1] U2 ≡ T & a = true.
156 elim (cpqs_inv_bind1 … H) -H * /3 width=3/ /3 width=5/
159 lemma cpqs_inv_abst1: ∀a,L,V1,T1,U2. L ⊢ ⓛ{a} V1. T1 ➤* U2 →
160 ∃∃V2,T2. L ⊢ V1 ➤* V2 &
164 elim (cpqs_inv_bind1 … H) -H *
166 | #T #_ #_ #_ #H destruct
170 fact cpqs_inv_flat1_aux: ∀L,U1,U2. L ⊢ U1 ➤* U2 →
171 ∀I,V1,T1. U1 = ⓕ{I} V1. T1 → (
172 ∃∃V2,T2. L ⊢ V1 ➤* V2 & L ⊢ T1 ➤* T2 &
175 (L ⊢ T1 ➤* U2 ∧ I = Cast).
176 #L #U1 #U2 * -L -U1 -U2
177 [ #I #L #J #W1 #U1 #H destruct
178 | #L #K #V #V2 #W2 #i #_ #_ #_ #J #W1 #U1 #H destruct
179 | #a #I #L #V1 #V2 #T1 #T2 #_ #_ #J #W1 #U1 #H destruct
180 | #I #L #V1 #V2 #T1 #T2 #HV12 #HT12 #J #W1 #U1 #H destruct /3 width=5/
181 | #L #V #T1 #T #T2 #_ #_ #J #W1 #U1 #H destruct
182 | #L #V #T1 #T2 #HT12 #J #W1 #U1 #H destruct /3 width=1/
186 lemma cpqs_inv_flat1: ∀I,L,V1,T1,U2. L ⊢ ⓕ{I} V1. T1 ➤* U2 → (
187 ∃∃V2,T2. L ⊢ V1 ➤* V2 & L ⊢ T1 ➤* T2 &
190 (L ⊢ T1 ➤* U2 ∧ I = Cast).
191 /2 width=3 by cpqs_inv_flat1_aux/ qed-.
193 lemma cpqs_inv_appl1: ∀L,V1,T1,U2. L ⊢ ⓐ V1. T1 ➤* U2 →
194 ∃∃V2,T2. L ⊢ V1 ➤* V2 & L ⊢ T1 ➤* T2 &
196 #L #V1 #T1 #U2 #H elim (cpqs_inv_flat1 … H) -H *
202 lemma cpqs_inv_cast1: ∀L,V1,T1,U2. L ⊢ ⓝ V1. T1 ➤* U2 → (
203 ∃∃V2,T2. L ⊢ V1 ➤* V2 & L ⊢ T1 ➤* T2 &
207 #L #V1 #T1 #U2 #H elim (cpqs_inv_flat1 … H) -H * /2 width=1/ /3 width=5/
210 (* Basic forward lemmas *****************************************************)
212 lemma cpqs_fwd_shift1: ∀L1,L,T1,T. L ⊢ L1 @@ T1 ➤* T →
213 ∃∃L2,T2. |L1| = |L2| & T = L2 @@ T2.
214 #L1 @(lenv_ind_dx … L1) -L1 normalize
216 @(ex2_2_intro … (⋆)) // (**) (* explicit constructor *)
217 | #I #L1 #V1 #IH #L #T1 #X
218 >shift_append_assoc normalize #H
219 elim (cpqs_inv_bind1 … H) -H *
220 [ #V0 #T0 #_ #HT10 #H destruct
221 elim (IH … HT10) -IH -HT10 #L2 #T2 #HL12 #H destruct
222 >append_length >HL12 -HL12
223 @(ex2_2_intro … (⋆.ⓑ{I}V0@@L2) T2) [ >append_length ] // /2 width=3/ (**) (* explicit constructor *)
224 | #T #_ #_ #H destruct