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 @{ 'PSubstStar $L $T1 $T2 }.
19 include "basic_2/grammar/cl_shift.ma".
20 include "basic_2/relocation/ldrop_append.ma".
21 include "basic_2/substitution/lsubr.ma".
23 (* CONTEXT-SENSITIVE PARALLEL SUBSTITUTION FOR TERMS ************************)
25 inductive cpss: lenv → relation term ≝
26 | cpss_atom : ∀I,L. cpss L (⓪{I}) (⓪{I})
27 | cpss_delta: ∀L,K,V,V2,W2,i.
28 ⇩[0, i] L ≡ K. ⓓV → cpss K V V2 →
29 ⇧[0, i + 1] V2 ≡ W2 → cpss L (#i) W2
30 | cpss_bind : ∀a,I,L,V1,V2,T1,T2.
31 cpss L V1 V2 → cpss (L. ⓑ{I} V1) T1 T2 →
32 cpss L (ⓑ{a,I} V1. T1) (ⓑ{a,I} V2. T2)
33 | cpss_flat : ∀I,L,V1,V2,T1,T2.
34 cpss L V1 V2 → cpss L T1 T2 →
35 cpss L (ⓕ{I} V1. T1) (ⓕ{I} V2. T2)
38 interpretation "context-sensitive parallel substitution (term)"
39 'PSubstStar L T1 T2 = (cpss L T1 T2).
41 (* Basic properties *********************************************************)
43 lemma cpss_lsubr_trans: lsub_trans … cpss lsubr.
44 #L1 #T1 #T2 #H elim H -L1 -T1 -T2
46 | #L1 #K1 #V1 #V2 #W2 #i #HLK1 #_ #HVW2 #IHV12 #L2 #HL12
47 elim (lsubr_fwd_ldrop2_abbr … HL12 … HLK1) -HL12 -HLK1 /3 width=6/
53 (* Basic_1: was by definition: subst1_refl *)
54 lemma cpss_refl: ∀T,L. L ⊢ T ▶* T.
56 #I elim I -I /2 width=1/
59 (* Basic_1: was only: subst1_ex *)
60 lemma cpss_delift: ∀K,V,T1,L,d. ⇩[0, d] L ≡ (K. ⓓV) →
61 ∃∃T2,T. L ⊢ T1 ▶* T2 & ⇧[d, 1] T ≡ T2.
63 [ * #i #L #d #HLK /2 width=4/
64 elim (lt_or_eq_or_gt i d) #Hid /3 width=4/
66 elim (lift_total V 0 (i+1)) #W #HVW
67 elim (lift_split … HVW i i) // /3 width=6/
68 | * [ #a ] #I #W1 #U1 #IHW1 #IHU1 #L #d #HLK
69 elim (IHW1 … HLK) -IHW1 #W2 #W #HW12 #HW2
70 [ elim (IHU1 (L. ⓑ{I} W1) (d+1)) -IHU1 /2 width=1/ -HLK /3 width=9/
71 | elim (IHU1 … HLK) -IHU1 -HLK /3 width=8/
76 lemma cpss_append: l_appendable_sn … cpss.
77 #K #T1 #T2 #H elim H -K -T1 -T2 // /2 width=1/
78 #K #K0 #V1 #V2 #W2 #i #HK0 #_ #HVW2 #IHV12 #L
79 lapply (ldrop_fwd_length_lt2 … HK0) #H
80 @(cpss_delta … (L@@K0) V1 … HVW2) //
81 @(ldrop_O1_append_sn_le … HK0) /2 width=2/ (**) (* /3/ does not work *)
84 (* Basic inversion lemmas ***************************************************)
86 fact cpss_inv_atom1_aux: ∀L,T1,T2. L ⊢ T1 ▶* T2 → ∀I. T1 = ⓪{I} →
88 ∃∃K,V,V2,i. ⇩[O, i] L ≡ K. ⓓV &
92 #L #T1 #T2 * -L -T1 -T2
93 [ #I #L #J #H destruct /2 width=1/
94 | #L #K #V #V2 #T2 #i #HLK #HV2 #HVT2 #I #H destruct /3 width=8/
95 | #a #I #L #V1 #V2 #T1 #T2 #_ #_ #J #H destruct
96 | #I #L #V1 #V2 #T1 #T2 #_ #_ #J #H destruct
100 lemma cpss_inv_atom1: ∀I,L,T2. L ⊢ ⓪{I} ▶* T2 →
102 ∃∃K,V,V2,i. ⇩[O, i] L ≡ K. ⓓV &
104 ⇧[O, i + 1] V2 ≡ T2 &
106 /2 width=3 by cpss_inv_atom1_aux/ qed-.
108 (* Basic_1: was only: subst1_gen_sort *)
109 lemma cpss_inv_sort1: ∀L,T2,k. L ⊢ ⋆k ▶* T2 → T2 = ⋆k.
111 elim (cpss_inv_atom1 … H) -H //
112 * #K #V #V2 #i #_ #_ #_ #H destruct
115 (* Basic_1: was only: subst1_gen_lref *)
116 lemma cpss_inv_lref1: ∀L,T2,i. L ⊢ #i ▶* T2 →
118 ∃∃K,V,V2. ⇩[O, i] L ≡ K. ⓓV &
122 elim (cpss_inv_atom1 … H) -H /2 width=1/
123 * #K #V #V2 #j #HLK #HV2 #HVT2 #H destruct /3 width=6/
126 lemma cpss_inv_gref1: ∀L,T2,p. L ⊢ §p ▶* T2 → T2 = §p.
128 elim (cpss_inv_atom1 … H) -H //
129 * #K #V #V2 #i #_ #_ #_ #H destruct
132 fact cpss_inv_bind1_aux: ∀L,U1,U2. L ⊢ U1 ▶* U2 →
133 ∀a,I,V1,T1. U1 = ⓑ{a,I} V1. T1 →
134 ∃∃V2,T2. L ⊢ V1 ▶* V2 &
135 L. ⓑ{I} V1 ⊢ T1 ▶* T2 &
137 #L #U1 #U2 * -L -U1 -U2
138 [ #I #L #b #J #W1 #U1 #H destruct
139 | #L #K #V #V2 #W2 #i #_ #_ #_ #b #J #W1 #U1 #H destruct
140 | #a #I #L #V1 #V2 #T1 #T2 #HV12 #HT12 #b #J #W1 #U1 #H destruct /2 width=5/
141 | #I #L #V1 #V2 #T1 #T2 #_ #_ #b #J #W1 #U1 #H destruct
145 lemma cpss_inv_bind1: ∀a,I,L,V1,T1,U2. L ⊢ ⓑ{a,I} V1. T1 ▶* U2 →
146 ∃∃V2,T2. L ⊢ V1 ▶* V2 &
147 L. ⓑ{I} V1 ⊢ T1 ▶* T2 &
149 /2 width=3 by cpss_inv_bind1_aux/ qed-.
151 fact cpss_inv_flat1_aux: ∀L,U1,U2. L ⊢ U1 ▶* U2 →
152 ∀I,V1,T1. U1 = ⓕ{I} V1. T1 →
153 ∃∃V2,T2. L ⊢ V1 ▶* V2 & L ⊢ T1 ▶* T2 &
155 #L #U1 #U2 * -L -U1 -U2
156 [ #I #L #J #W1 #U1 #H destruct
157 | #L #K #V #V2 #W2 #i #_ #_ #_ #J #W1 #U1 #H destruct
158 | #a #I #L #V1 #V2 #T1 #T2 #_ #_ #J #W1 #U1 #H destruct
159 | #I #L #V1 #V2 #T1 #T2 #HV12 #HT12 #J #W1 #U1 #H destruct /2 width=5/
163 lemma cpss_inv_flat1: ∀I,L,V1,T1,U2. L ⊢ ⓕ{I} V1. T1 ▶* U2 →
164 ∃∃V2,T2. L ⊢ V1 ▶* V2 & L ⊢ T1 ▶* T2 &
166 /2 width=3 by cpss_inv_flat1_aux/ qed-.
168 (* Basic forward lemmas *****************************************************)
170 lemma cpss_fwd_tw: ∀L,T1,T2. L ⊢ T1 ▶* T2 → ♯{T1} ≤ ♯{T2}.
171 #L #T1 #T2 #H elim H -L -T1 -T2 normalize
172 /3 width=1 by monotonic_le_plus_l, le_plus/ (**) (* auto is too slow without trace *)
175 lemma cpss_fwd_shift1: ∀L1,L,T1,T. L ⊢ L1 @@ T1 ▶* T →
176 ∃∃L2,T2. |L1| = |L2| & T = L2 @@ T2.
177 #L1 @(lenv_ind_dx … L1) -L1 normalize
179 @(ex2_2_intro … (⋆)) // (**) (* explicit constructor *)
180 | #I #L1 #V1 #IH #L #T1 #X
181 >shift_append_assoc normalize #H
182 elim (cpss_inv_bind1 … H) -H
183 #V0 #T0 #_ #HT10 #H destruct
184 elim (IH … HT10) -IH -HT10 #L2 #T2 #HL12 #H destruct
185 >append_length >HL12 -HL12
186 @(ex2_2_intro … (⋆.ⓑ{I}V0@@L2) T2) [ >append_length ] // /2 width=3/ (**) (* explicit constructor *)
190 (* Basic_1: removed theorems 27:
191 subst0_gen_sort subst0_gen_lref subst0_gen_head subst0_gen_lift_lt
192 subst0_gen_lift_false subst0_gen_lift_ge subst0_refl subst0_trans
193 subst0_lift_lt subst0_lift_ge subst0_lift_ge_S subst0_lift_ge_s
194 subst0_subst0 subst0_subst0_back subst0_weight_le subst0_weight_lt
195 subst0_confluence_neq subst0_confluence_eq subst0_tlt_head
196 subst0_confluence_lift subst0_tlt
197 subst1_head subst1_gen_head subst1_lift_S subst1_confluence_lift
198 subst1_gen_lift_eq subst1_confluence_neq