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/unfold/tpss.ma".
17 (* DX PARALLEL UNFOLD ON LOCAL ENVIRONMENTS *********************************)
19 (* Basic_1: includes: csubst1_bind *)
20 inductive ltpss_dx: nat → nat → relation lenv ≝
21 | ltpss_dx_atom : ∀d,e. ltpss_dx d e (⋆) (⋆)
22 | ltpss_dx_pair : ∀L,I,V. ltpss_dx 0 0 (L. ⓑ{I} V) (L. ⓑ{I} V)
23 | ltpss_dx_tpss2: ∀L1,L2,I,V1,V2,e.
24 ltpss_dx 0 e L1 L2 → L2 ⊢ V1 ▶* [0, e] V2 →
25 ltpss_dx 0 (e + 1) (L1. ⓑ{I} V1) (L2. ⓑ{I} V2)
26 | ltpss_dx_tpss1: ∀L1,L2,I,V1,V2,d,e.
27 ltpss_dx d e L1 L2 → L2 ⊢ V1 ▶* [d, e] V2 →
28 ltpss_dx (d + 1) e (L1. ⓑ{I} V1) (L2. ⓑ{I} V2)
31 interpretation "parallel unfold (local environment, dx variant)"
32 'PSubstStar L1 d e L2 = (ltpss_dx d e L1 L2).
34 (* Basic inversion lemmas ***************************************************)
36 fact ltpss_dx_inv_refl_O2_aux: ∀d,e,L1,L2. L1 ▶* [d, e] L2 → e = 0 → L1 = L2.
37 #d #e #L1 #L2 #H elim H -d -e -L1 -L2 //
38 [ #L1 #L2 #I #V1 #V2 #e #_ #_ #_ >commutative_plus normalize #H destruct
39 | #L1 #L2 #I #V1 #V2 #d #e #_ #HV12 #IHL12 #He destruct
40 >(IHL12 ?) -IHL12 // >(tpss_inv_refl_O2 … HV12) //
44 lemma ltpss_dx_inv_refl_O2: ∀d,L1,L2. L1 ▶* [d, 0] L2 → L1 = L2.
47 fact ltpss_dx_inv_atom1_aux: ∀d,e,L1,L2.
48 L1 ▶* [d, e] L2 → L1 = ⋆ → L2 = ⋆.
49 #d #e #L1 #L2 * -d -e -L1 -L2
51 | #L #I #V #H destruct
52 | #L1 #L2 #I #V1 #V2 #e #_ #_ #H destruct
53 | #L1 #L2 #I #V1 #V2 #d #e #_ #_ #H destruct
57 lemma ltpss_dx_inv_atom1: ∀d,e,L2. ⋆ ▶* [d, e] L2 → L2 = ⋆.
60 fact ltpss_dx_inv_tpss21_aux: ∀d,e,L1,L2. L1 ▶* [d, e] L2 → d = 0 → 0 < e →
61 ∀K1,I,V1. L1 = K1. ⓑ{I} V1 →
62 ∃∃K2,V2. K1 ▶* [0, e - 1] K2 &
63 K2 ⊢ V1 ▶* [0, e - 1] V2 &
65 #d #e #L1 #L2 * -d -e -L1 -L2
66 [ #d #e #_ #_ #K1 #I #V1 #H destruct
67 | #L1 #I #V #_ #H elim (lt_refl_false … H)
68 | #L1 #L2 #I #V1 #V2 #e #HL12 #HV12 #_ #_ #K1 #J #W1 #H destruct /2 width=5/
69 | #L1 #L2 #I #V1 #V2 #d #e #_ #_ >commutative_plus normalize #H destruct
73 lemma ltpss_dx_inv_tpss21: ∀e,K1,I,V1,L2. K1. ⓑ{I} V1 ▶* [0, e] L2 → 0 < e →
74 ∃∃K2,V2. K1 ▶* [0, e - 1] K2 &
75 K2 ⊢ V1 ▶* [0, e - 1] V2 &
79 fact ltpss_dx_inv_tpss11_aux: ∀d,e,L1,L2. L1 ▶* [d, e] L2 → 0 < d →
80 ∀I,K1,V1. L1 = K1. ⓑ{I} V1 →
81 ∃∃K2,V2. K1 ▶* [d - 1, e] K2 &
82 K2 ⊢ V1 ▶* [d - 1, e] V2 &
84 #d #e #L1 #L2 * -d -e -L1 -L2
85 [ #d #e #_ #I #K1 #V1 #H destruct
86 | #L #I #V #H elim (lt_refl_false … H)
87 | #L1 #L2 #I #V1 #V2 #e #_ #_ #H elim (lt_refl_false … H)
88 | #L1 #L2 #I #V1 #V2 #d #e #HL12 #HV12 #_ #J #K1 #W1 #H destruct /2 width=5/
92 lemma ltpss_dx_inv_tpss11: ∀d,e,I,K1,V1,L2. K1. ⓑ{I} V1 ▶* [d, e] L2 → 0 < d →
93 ∃∃K2,V2. K1 ▶* [d - 1, e] K2 &
94 K2 ⊢ V1 ▶* [d - 1, e] V2 &
98 fact ltpss_dx_inv_atom2_aux: ∀d,e,L1,L2.
99 L1 ▶* [d, e] L2 → L2 = ⋆ → L1 = ⋆.
100 #d #e #L1 #L2 * -d -e -L1 -L2
102 | #L #I #V #H destruct
103 | #L1 #L2 #I #V1 #V2 #e #_ #_ #H destruct
104 | #L1 #L2 #I #V1 #V2 #d #e #_ #_ #H destruct
108 lemma ltpss_dx_inv_atom2: ∀d,e,L1. L1 ▶* [d, e] ⋆ → L1 = ⋆.
111 fact ltpss_dx_inv_tpss22_aux: ∀d,e,L1,L2. L1 ▶* [d, e] L2 → d = 0 → 0 < e →
112 ∀K2,I,V2. L2 = K2. ⓑ{I} V2 →
113 ∃∃K1,V1. K1 ▶* [0, e - 1] K2 &
114 K2 ⊢ V1 ▶* [0, e - 1] V2 &
116 #d #e #L1 #L2 * -d -e -L1 -L2
117 [ #d #e #_ #_ #K1 #I #V1 #H destruct
118 | #L1 #I #V #_ #H elim (lt_refl_false … H)
119 | #L1 #L2 #I #V1 #V2 #e #HL12 #HV12 #_ #_ #K2 #J #W2 #H destruct /2 width=5/
120 | #L1 #L2 #I #V1 #V2 #d #e #_ #_ >commutative_plus normalize #H destruct
124 lemma ltpss_dx_inv_tpss22: ∀e,L1,K2,I,V2. L1 ▶* [0, e] K2. ⓑ{I} V2 → 0 < e →
125 ∃∃K1,V1. K1 ▶* [0, e - 1] K2 &
126 K2 ⊢ V1 ▶* [0, e - 1] V2 &
130 fact ltpss_dx_inv_tpss12_aux: ∀d,e,L1,L2. L1 ▶* [d, e] L2 → 0 < d →
131 ∀I,K2,V2. L2 = K2. ⓑ{I} V2 →
132 ∃∃K1,V1. K1 ▶* [d - 1, e] K2 &
133 K2 ⊢ V1 ▶* [d - 1, e] V2 &
135 #d #e #L1 #L2 * -d -e -L1 -L2
136 [ #d #e #_ #I #K2 #V2 #H destruct
137 | #L #I #V #H elim (lt_refl_false … H)
138 | #L1 #L2 #I #V1 #V2 #e #_ #_ #H elim (lt_refl_false … H)
139 | #L1 #L2 #I #V1 #V2 #d #e #HL12 #HV12 #_ #J #K2 #W2 #H destruct /2 width=5/
143 lemma ltpss_dx_inv_tpss12: ∀L1,K2,I,V2,d,e. L1 ▶* [d, e] K2. ⓑ{I} V2 → 0 < d →
144 ∃∃K1,V1. K1 ▶* [d - 1, e] K2 &
145 K2 ⊢ V1 ▶* [d - 1, e] V2 &
149 (* Basic properties *********************************************************)
151 lemma ltpss_dx_tps2: ∀L1,L2,I,V1,V2,e.
152 L1 ▶* [0, e] L2 → L2 ⊢ V1 ▶ [0, e] V2 →
153 L1. ⓑ{I} V1 ▶* [0, e + 1] L2. ⓑ{I} V2.
156 lemma ltpss_dx_tps1: ∀L1,L2,I,V1,V2,d,e.
157 L1 ▶* [d, e] L2 → L2 ⊢ V1 ▶ [d, e] V2 →
158 L1. ⓑ{I} V1 ▶* [d + 1, e] L2. ⓑ{I} V2.
161 lemma ltpss_dx_tpss2_lt: ∀L1,L2,I,V1,V2,e.
162 L1 ▶* [0, e - 1] L2 → L2 ⊢ V1 ▶* [0, e - 1] V2 →
163 0 < e → L1. ⓑ{I} V1 ▶* [0, e] L2. ⓑ{I} V2.
164 #L1 #L2 #I #V1 #V2 #e #HL12 #HV12 #He
165 >(plus_minus_m_m e 1) /2 width=1/
168 lemma ltpss_dx_tpss1_lt: ∀L1,L2,I,V1,V2,d,e.
169 L1 ▶* [d - 1, e] L2 → L2 ⊢ V1 ▶* [d - 1, e] V2 →
170 0 < d → L1. ⓑ{I} V1 ▶* [d, e] L2. ⓑ{I} V2.
171 #L1 #L2 #I #V1 #V2 #d #e #HL12 #HV12 #Hd
172 >(plus_minus_m_m d 1) /2 width=1/
175 lemma ltpss_dx_tps2_lt: ∀L1,L2,I,V1,V2,e.
176 L1 ▶* [0, e - 1] L2 → L2 ⊢ V1 ▶ [0, e - 1] V2 →
177 0 < e → L1. ⓑ{I} V1 ▶* [0, e] L2. ⓑ{I} V2.
180 lemma ltpss_dx_tps1_lt: ∀L1,L2,I,V1,V2,d,e.
181 L1 ▶* [d - 1, e] L2 → L2 ⊢ V1 ▶ [d - 1, e] V2 →
182 0 < d → L1. ⓑ{I} V1 ▶* [d, e] L2. ⓑ{I} V2.
185 (* Basic_1: was by definition: csubst1_refl *)
186 lemma ltpss_dx_refl: ∀L,d,e. L ▶* [d, e] L.
188 #L #I #V #IHL * /2 width=1/ * /2 width=1/
191 lemma ltpss_dx_weak: ∀L1,L2,d1,e1. L1 ▶* [d1, e1] L2 →
192 ∀d2,e2. d2 ≤ d1 → d1 + e1 ≤ d2 + e2 → L1 ▶* [d2, e2] L2.
193 #L1 #L2 #d1 #e1 #H elim H -L1 -L2 -d1 -e1 //
194 [ #L1 #L2 #I #V1 #V2 #e1 #_ #HV12 #IHL12 #d2 #e2 #Hd2 #Hde2
195 lapply (le_n_O_to_eq … Hd2) #H destruct normalize in Hde2;
196 lapply (lt_to_le_to_lt 0 … Hde2) // #He2
197 lapply (le_plus_to_minus_r … Hde2) -Hde2 /3 width=5/
198 | #L1 #L2 #I #V1 #V2 #d1 #e1 #_ #HV12 #IHL12 #d2 #e2 #Hd21 #Hde12
199 >plus_plus_comm_23 in Hde12; #Hde12
200 elim (le_to_or_lt_eq 0 d2 ?) // #H destruct
201 [ lapply (le_plus_to_minus_r … Hde12) -Hde12 <plus_minus // #Hde12
202 lapply (le_plus_to_minus … Hd21) -Hd21 #Hd21 /3 width=5/
203 | -Hd21 normalize in Hde12;
204 lapply (lt_to_le_to_lt 0 … Hde12) // #He2
205 lapply (le_plus_to_minus_r … Hde12) -Hde12
206 /3 width=5 by ltpss_dx_tpss2_lt, tpss_weak/ (**) (* /3 width=5/ used to work *)
211 lemma ltpss_dx_weak_all: ∀L1,L2,d,e. L1 ▶* [d, e] L2 → L1 ▶* [0, |L2|] L2.
212 #L1 #L2 #d #e #H elim H -L1 -L2 -d -e
213 // /3 width=2/ /3 width=3/
216 fact ltpss_dx_append_le_aux: ∀K1,K2,d,x. K1 ▶* [d, x] K2 → x = |K1| - d →
217 ∀L1,L2,e. L1 ▶* [0, e] L2 → d ≤ |K1| →
218 L1 @@ K1 ▶* [d, x + e] L2 @@ K2.
219 #K1 #K2 #d #x #H elim H -K1 -K2 -d -x
220 [ #d #x #H1 #L1 #L2 #e #HL12 #H2 destruct
221 lapply (le_n_O_to_eq … H2) -H2 #H destruct //
222 | #K #I #V <minus_n_O normalize <plus_n_Sm #H destruct
223 | #K1 #K2 #I #V1 #V2 #x #_ #HV12 <minus_n_O #IHK12 <minus_n_O #H #L1 #L2 #e #HL12 #_
224 lapply (injective_plus_l … H) -H #H destruct >plus_plus_comm_23
225 /4 width=5 by ltpss_dx_tpss2, tpss_append, tpss_weak, monotonic_le_plus_r/ (**) (* too slow without trace *)
226 | #K1 #K2 #I #V1 #V2 #d #x #_ #HV12 #IHK12 normalize <minus_le_minus_minus_comm // <minus_plus_m_m #H1 #L1 #L2 #e #HL12 #H2 destruct
227 lapply (le_plus_to_le_r … H2) -H2 #Hd
228 /4 width=5 by ltpss_dx_tpss1, tpss_append, tpss_weak, monotonic_le_plus_r/ (**) (* too slow without trace *)
232 lemma ltpss_dx_append_le: ∀K1,K2,d. K1 ▶* [d, |K1| - d] K2 →
233 ∀L1,L2,e. L1 ▶* [0, e] L2 → d ≤ |K1| →
234 L1 @@ K1 ▶* [d, |K1| - d + e] L2 @@ K2.
235 /2 width=1 by ltpss_dx_append_le_aux/ qed.
237 lemma ltpss_dx_append_zero: ∀K1,K2. K1 ▶* [0, |K1|] K2 →
238 ∀L1,L2,e. L1 ▶* [0, e] L2 →
239 L1 @@ K1 ▶* [0, |K1| + e] L2 @@ K2.
242 lemma ltpss_dx_append_ge: ∀K1,K2,d,e. K1 ▶* [d, e] K2 →
243 ∀L1,L2. L1 ▶* [d - |K1|, e] L2 → |K1| ≤ d →
244 L1 @@ K1 ▶* [d, e] L2 @@ K2.
245 #K1 #K2 #d #e #H elim H -K1 -K2 -d -e
246 [ #d #e #L1 #L2 <minus_n_O //
247 | #K #I #V #L1 #L2 #_ #H
248 lapply (le_n_O_to_eq … H) -H normalize <plus_n_Sm #H destruct
249 | #K1 #K2 #I #V1 #V2 #e #_ #_ #_ #L1 #L2 #_ #H
250 lapply (le_n_O_to_eq … H) -H normalize <plus_n_Sm #H destruct
251 | #K1 #K2 #I #V1 #V2 #d #e #_ #HV12 #IHK12 #L1 #L2
252 normalize <minus_le_minus_minus_comm // <minus_plus_m_m #HL12 #H
253 lapply (le_plus_to_le_r … H) -H /3 width=1/
257 (* Basic forward lemmas *****************************************************)
259 lemma ltpss_dx_fwd_length: ∀L1,L2,d,e. L1 ▶* [d, e] L2 → |L1| = |L2|.
260 #L1 #L2 #d #e #H elim H -L1 -L2 -d -e
264 (* Basic_1: removed theorems 28:
265 csubst0_clear_O csubst0_drop_lt csubst0_drop_gt csubst0_drop_eq
266 csubst0_clear_O_back csubst0_clear_S csubst0_clear_trans
267 csubst0_drop_gt_back csubst0_drop_eq_back csubst0_drop_lt_back
268 csubst0_gen_sort csubst0_gen_head csubst0_getl_ge csubst0_getl_lt
269 csubst0_gen_S_bind_2 csubst0_getl_ge_back csubst0_getl_lt_back
270 csubst0_snd_bind csubst0_fst_bind csubst0_both_bind
271 csubst1_head csubst1_flat csubst1_gen_head
272 csubst1_getl_ge csubst1_getl_lt csubst1_getl_ge_back getl_csubst1