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/substitution/ldrop_ldrop.ma".
16 include "Basic_2/substitution/tps.ma".
18 (* PARTIAL SUBSTITUTION ON TERMS ********************************************)
20 (* Advanced inversion lemmas ************************************************)
22 fact tps_inv_refl_SO2_aux: ∀L,T1,T2,d,e. L ⊢ T1 [d, e] ≫ T2 → e = 1 →
23 ∀K,V. ↓[0, d] L ≡ K. 𝕓{Abst} V → T1 = T2.
24 #L #T1 #T2 #d #e #H elim H -H L T1 T2 d e
26 | #L #K0 #V0 #W #i #d #e #Hdi #Hide #HLK0 #_ #H destruct -e;
27 >(le_to_le_to_eq … Hdi ?) /2/ -d #K #V #HLK
28 lapply (ldrop_mono … HLK0 … HLK) #H destruct
29 | #L #I #V1 #V2 #T1 #T2 #d #e #_ #_ #IHV12 #IHT12 #H1 #K #V #HLK
30 >(IHV12 H1 … HLK) -IHV12 >(IHT12 H1 K V) -IHT12 // /2/
31 | #L #I #V1 #V2 #T1 #T2 #d #e #_ #_ #IHV12 #IHT12 #H1 #K #V #HLK
32 >(IHV12 H1 … HLK) -IHV12 >(IHT12 H1 … HLK) -IHT12 //
36 lemma tps_inv_refl_SO2: ∀L,T1,T2,d. L ⊢ T1 [d, 1] ≫ T2 →
37 ∀K,V. ↓[0, d] L ≡ K. 𝕓{Abst} V → T1 = T2.
40 (* Relocation properties ****************************************************)
42 (* Basic_1: was: subst1_lift_lt *)
43 lemma tps_lift_le: ∀K,T1,T2,dt,et. K ⊢ T1 [dt, et] ≫ T2 →
44 ∀L,U1,U2,d,e. ↓[d, e] L ≡ K →
45 ↑[d, e] T1 ≡ U1 → ↑[d, e] T2 ≡ U2 →
48 #K #T1 #T2 #dt #et #H elim H -H K T1 T2 dt et
49 [ #K #I #dt #et #L #U1 #U2 #d #e #_ #H1 #H2 #_
50 >(lift_mono … H1 … H2) -H1 H2 //
51 | #K #KV #V #W #i #dt #et #Hdti #Hidet #HKV #HVW #L #U1 #U2 #d #e #HLK #H #HWU2 #Hdetd
52 lapply (lt_to_le_to_lt … Hidet … Hdetd) -Hdetd #Hid
53 lapply (lift_inv_lref1_lt … H … Hid) -H #H destruct -U1;
54 elim (lift_trans_ge … HVW … HWU2 ?) -HVW HWU2 W // <minus_plus #W #HVW #HWU2
55 elim (ldrop_trans_le … HLK … HKV ?) -HLK HKV K [2: /2/] #X #HLK #H
56 elim (ldrop_inv_skip2 … H ?) -H [2: /2/] -Hid #K #Y #_ #HVY
57 >(lift_mono … HVY … HVW) -HVY HVW Y #H destruct -X /2/
58 | #K #I #V1 #V2 #T1 #T2 #dt #et #_ #_ #IHV12 #IHT12 #L #U1 #U2 #d #e #HLK #H1 #H2 #Hdetd
59 elim (lift_inv_bind1 … H1) -H1 #VV1 #TT1 #HVV1 #HTT1 #H1
60 elim (lift_inv_bind1 … H2) -H2 #VV2 #TT2 #HVV2 #HTT2 #H2 destruct -U1 U2;
61 @tps_bind [ /2 width=6/ | @IHT12 [4,5: // |1,2: skip | /2/ | /2/ ] ] (**) (* /3 width=6/ is too slow, arith3 needed to avoid crash *)
62 | #K #I #V1 #V2 #T1 #T2 #dt #et #_ #_ #IHV12 #IHT12 #L #U1 #U2 #d #e #HLK #H1 #H2 #Hdetd
63 elim (lift_inv_flat1 … H1) -H1 #VV1 #TT1 #HVV1 #HTT1 #H1
64 elim (lift_inv_flat1 … H2) -H2 #VV2 #TT2 #HVV2 #HTT2 #H2 destruct -U1 U2;
69 lemma tps_lift_be: ∀K,T1,T2,dt,et. K ⊢ T1 [dt, et] ≫ T2 →
70 ∀L,U1,U2,d,e. ↓[d, e] L ≡ K →
71 ↑[d, e] T1 ≡ U1 → ↑[d, e] T2 ≡ U2 →
72 dt ≤ d → d ≤ dt + et →
73 L ⊢ U1 [dt, et + e] ≫ U2.
74 #K #T1 #T2 #dt #et #H elim H -H K T1 T2 dt et
75 [ #K #I #dt #et #L #U1 #U2 #d #e #_ #H1 #H2 #_ #_
76 >(lift_mono … H1 … H2) -H1 H2 //
77 | #K #KV #V #W #i #dt #et #Hdti #Hidet #HKV #HVW #L #U1 #U2 #d #e #HLK #H #HWU2 #Hdtd #_
78 elim (lift_inv_lref1 … H) -H * #Hid #H destruct -U1;
80 lapply (lt_to_le_to_lt … (dt+et+e) Hidet ?) // -Hidet #Hidete
81 elim (lift_trans_ge … HVW … HWU2 ?) -W // <minus_plus #W #HVW #HWU2
82 elim (ldrop_trans_le … HLK … HKV ?) -K [2: /2/] #X #HLK #H
83 elim (ldrop_inv_skip2 … H ?) -H [2: /2/] -Hid #K #Y #_ #HVY
84 >(lift_mono … HVY … HVW) -V #H destruct -X /2/
86 lapply (transitive_le … Hdtd Hid) -Hdtd #Hdti
87 lapply (lift_trans_be … HVW … HWU2 ? ?) -W // [ /2/ ] >plus_plus_comm_23 #HVU2
88 lapply (ldrop_trans_ge_comm … HLK … HKV ?) -K // -Hid /3/
90 | #K #I #V1 #V2 #T1 #T2 #dt #et #_ #_ #IHV12 #IHT12 #L #U1 #U2 #d #e #HLK #H1 #H2 #Hdtd #Hddet
91 elim (lift_inv_bind1 … H1) -H1 #VV1 #TT1 #HVV1 #HTT1 #H1
92 elim (lift_inv_bind1 … H2) -H2 #VV2 #TT2 #HVV2 #HTT2 #H2 destruct -U1 U2;
93 @tps_bind [ /2 width=6/ | @IHT12 [3,4: // | skip |5,6: /2/ | /2/ ] ] (**) (* /3 width=6/ is too slow, arith3 needed to avoid crash *)
94 | #K #I #V1 #V2 #T1 #T2 #dt #et #_ #_ #IHV12 #IHT12 #L #U1 #U2 #d #e #HLK #H1 #H2 #Hdetd
95 elim (lift_inv_flat1 … H1) -H1 #VV1 #TT1 #HVV1 #HTT1 #H1
96 elim (lift_inv_flat1 … H2) -H2 #VV2 #TT2 #HVV2 #HTT2 #H2 destruct -U1 U2;
101 (* Basic_1: was: subst1_lift_ge *)
102 lemma tps_lift_ge: ∀K,T1,T2,dt,et. K ⊢ T1 [dt, et] ≫ T2 →
103 ∀L,U1,U2,d,e. ↓[d, e] L ≡ K →
104 ↑[d, e] T1 ≡ U1 → ↑[d, e] T2 ≡ U2 →
106 L ⊢ U1 [dt + e, et] ≫ U2.
107 #K #T1 #T2 #dt #et #H elim H -H K T1 T2 dt et
108 [ #K #I #dt #et #L #U1 #U2 #d #e #_ #H1 #H2 #_
109 >(lift_mono … H1 … H2) -H1 H2 //
110 | #K #KV #V #W #i #dt #et #Hdti #Hidet #HKV #HVW #L #U1 #U2 #d #e #HLK #H #HWU2 #Hddt
111 lapply (transitive_le … Hddt … Hdti) -Hddt #Hid
112 lapply (lift_inv_lref1_ge … H … Hid) -H #H destruct -U1;
113 lapply (lift_trans_be … HVW … HWU2 ? ?) -HVW HWU2 W // [ /2/ ] >plus_plus_comm_23 #HVU2
114 lapply (ldrop_trans_ge_comm … HLK … HKV ?) -HLK HKV K // -Hid /3/
115 | #K #I #V1 #V2 #T1 #T2 #dt #et #_ #_ #IHV12 #IHT12 #L #U1 #U2 #d #e #HLK #H1 #H2 #Hddt
116 elim (lift_inv_bind1 … H1) -H1 #VV1 #TT1 #HVV1 #HTT1 #H1
117 elim (lift_inv_bind1 … H2) -H2 #VV2 #TT2 #HVV2 #HTT2 #H2 destruct -U1 U2;
118 @tps_bind [ /2 width=5/ | /3 width=5/ ] (**) (* explicit constructor *)
119 | #K #I #V1 #V2 #T1 #T2 #dt #et #_ #_ #IHV12 #IHT12 #L #U1 #U2 #d #e #HLK #H1 #H2 #Hddt
120 elim (lift_inv_flat1 … H1) -H1 #VV1 #TT1 #HVV1 #HTT1 #H1
121 elim (lift_inv_flat1 … H2) -H2 #VV2 #TT2 #HVV2 #HTT2 #H2 destruct -U1 U2;
126 (* Basic_1: was: subst1_gen_lift_lt *)
127 lemma tps_inv_lift1_le: ∀L,U1,U2,dt,et. L ⊢ U1 [dt, et] ≫ U2 →
128 ∀K,d,e. ↓[d, e] L ≡ K → ∀T1. ↑[d, e] T1 ≡ U1 →
130 ∃∃T2. K ⊢ T1 [dt, et] ≫ T2 & ↑[d, e] T2 ≡ U2.
131 #L #U1 #U2 #dt #et #H elim H -H L U1 U2 dt et
132 [ #L * #i #dt #et #K #d #e #_ #T1 #H #_
133 [ lapply (lift_inv_sort2 … H) -H #H destruct -T1 /2/
134 | elim (lift_inv_lref2 … H) -H * #Hid #H destruct -T1 /3/
135 | lapply (lift_inv_gref2 … H) -H #H destruct -T1 /2/
137 | #L #KV #V #W #i #dt #et #Hdti #Hidet #HLKV #HVW #K #d #e #HLK #T1 #H #Hdetd
138 lapply (lt_to_le_to_lt … Hidet … Hdetd) -Hdetd #Hid
139 lapply (lift_inv_lref2_lt … H … Hid) -H #H destruct -T1;
140 elim (ldrop_conf_lt … HLK … HLKV ?) -HLK HLKV L // #L #U #HKL #_ #HUV
141 elim (lift_trans_le … HUV … HVW ?) -HUV HVW V // >arith_a2 // -Hid /3/
142 | #L #I #V1 #V2 #U1 #U2 #dt #et #_ #_ #IHV12 #IHU12 #K #d #e #HLK #X #H #Hdetd
143 elim (lift_inv_bind2 … H) -H #W1 #T1 #HWV1 #HTU1 #H destruct -X;
144 elim (IHV12 … HLK … HWV1 ?) -IHV12 HWV1 // #W2 #HW12 #HWV2
145 elim (IHU12 … HTU1 ?) -IHU12 HTU1 [3: /2/ |4: @ldrop_skip // |2: skip ] -HLK Hdetd (**) (* /3 width=5/ is too slow *)
147 | #L #I #V1 #V2 #U1 #U2 #dt #et #_ #_ #IHV12 #IHU12 #K #d #e #HLK #X #H #Hdetd
148 elim (lift_inv_flat2 … H) -H #W1 #T1 #HWV1 #HTU1 #H destruct -X;
149 elim (IHV12 … HLK … HWV1 ?) -IHV12 HWV1 //
150 elim (IHU12 … HLK … HTU1 ?) -IHU12 HLK HTU1 // /3 width=5/
154 lemma tps_inv_lift1_be: ∀L,U1,U2,dt,et. L ⊢ U1 [dt, et] ≫ U2 →
155 ∀K,d,e. ↓[d, e] L ≡ K → ∀T1. ↑[d, e] T1 ≡ U1 →
156 dt ≤ d → d + e ≤ dt + et →
157 ∃∃T2. K ⊢ T1 [dt, et - e] ≫ T2 & ↑[d, e] T2 ≡ U2.
158 #L #U1 #U2 #dt #et #H elim H -H L U1 U2 dt et
159 [ #L * #i #dt #et #K #d #e #_ #T1 #H #_
160 [ lapply (lift_inv_sort2 … H) -H #H destruct -T1 /2/
161 | elim (lift_inv_lref2 … H) -H * #Hid #H destruct -T1 /3/
162 | lapply (lift_inv_gref2 … H) -H #H destruct -T1 /2/
164 | #L #KV #V #W #i #dt #et #Hdti #Hidet #HLKV #HVW #K #d #e #HLK #T1 #H #Hdtd #Hdedet
165 lapply (le_fwd_plus_plus_ge … Hdtd … Hdedet) #Heet
166 elim (lift_inv_lref2 … H) -H * #Hid #H destruct -T1
168 lapply (lt_to_le_to_lt … (dt + (et - e)) Hid ?) [ <le_plus_minus /2/ ] -Hdedet #Hidete
169 elim (ldrop_conf_lt … HLK … HLKV ?) -L // #L #U #HKL #_ #HUV
170 elim (lift_trans_le … HUV … HVW ?) -V // >arith_a2 // -Hid /3/
172 lapply (transitive_le … (i - e) Hdtd ?) [ /2/ ] -Hdtd #Hdtie
173 lapply (plus_le_weak … Hid) #Hei
174 lapply (ldrop_conf_ge … HLK … HLKV ?) -L // #HKV
175 elim (lift_split … HVW d (i - e + 1) ? ? ?) -HVW; [4: // |2,3: /2/ ] -Hid >arith_e2 // /4/
177 | #L #I #V1 #V2 #U1 #U2 #dt #et #_ #_ #IHV12 #IHU12 #K #d #e #HLK #X #H #Hdtd #Hdedet
178 elim (lift_inv_bind2 … H) -H #W1 #T1 #HWV1 #HTU1 #H destruct -X;
179 elim (IHV12 … HLK … HWV1 ? ?) -IHV12 HWV1 // #W2 #HW12 #HWV2
180 elim (IHU12 … HTU1 ? ?) -IHU12 HTU1 [5: @ldrop_skip // |2: skip |3: >plus_plus_comm_23 >(plus_plus_comm_23 dt) /2/ ]
182 | #L #I #V1 #V2 #U1 #U2 #dt #et #_ #_ #IHV12 #IHU12 #K #d #e #HLK #X #H #Hdtd #Hdedet
183 elim (lift_inv_flat2 … H) -H #W1 #T1 #HWV1 #HTU1 #H destruct -X;
184 elim (IHV12 … HLK … HWV1 ? ?) -IHV12 HWV1 //
185 elim (IHU12 … HLK … HTU1 ? ?) -IHU12 HLK HTU1 // /3 width=5/
189 (* Basic_1: was: subst1_gen_lift_ge *)
190 lemma tps_inv_lift1_ge: ∀L,U1,U2,dt,et. L ⊢ U1 [dt, et] ≫ U2 →
191 ∀K,d,e. ↓[d, e] L ≡ K → ∀T1. ↑[d, e] T1 ≡ U1 →
193 ∃∃T2. K ⊢ T1 [dt - e, et] ≫ T2 & ↑[d, e] T2 ≡ U2.
194 #L #U1 #U2 #dt #et #H elim H -H L U1 U2 dt et
195 [ #L * #i #dt #et #K #d #e #_ #T1 #H #_
196 [ lapply (lift_inv_sort2 … H) -H #H destruct -T1 /2/
197 | elim (lift_inv_lref2 … H) -H * #Hid #H destruct -T1 /3/
198 | lapply (lift_inv_gref2 … H) -H #H destruct -T1 /2/
200 | #L #KV #V #W #i #dt #et #Hdti #Hidet #HLKV #HVW #K #d #e #HLK #T1 #H #Hdedt
201 lapply (transitive_le … Hdedt … Hdti) #Hdei
202 lapply (plus_le_weak … Hdedt) -Hdedt #Hedt
203 lapply (plus_le_weak … Hdei) #Hei
204 lapply (lift_inv_lref2_ge … H … Hdei) -H #H destruct -T1;
205 lapply (ldrop_conf_ge … HLK … HLKV ?) -HLK HLKV L // #HKV
206 elim (lift_split … HVW d (i - e + 1) ? ? ?) -HVW; [4: // | 2,3: normalize /2/ ] -Hdei >arith_e2 // #V0 #HV10 #HV02
208 [2: @tps_subst [3: /2/ |5,6: // |1,2: skip |4: @arith5 // ]
211 ] (**) (* explicitc constructors *)
212 | #L #I #V1 #V2 #U1 #U2 #dt #et #_ #_ #IHV12 #IHU12 #K #d #e #HLK #X #H #Hdetd
213 elim (lift_inv_bind2 … H) -H #W1 #T1 #HWV1 #HTU1 #H destruct -X;
214 lapply (plus_le_weak … Hdetd) #Hedt
215 elim (IHV12 … HLK … HWV1 ?) -IHV12 HWV1 // #W2 #HW12 #HWV2
216 elim (IHU12 … HTU1 ?) -IHU12 HTU1 [4: @ldrop_skip // |2: skip |3: /2/ ]
217 <plus_minus // /3 width=5/
218 | #L #I #V1 #V2 #U1 #U2 #dt #et #_ #_ #IHV12 #IHU12 #K #d #e #HLK #X #H #Hdetd
219 elim (lift_inv_flat2 … H) -H #W1 #T1 #HWV1 #HTU1 #H destruct -X;
220 elim (IHV12 … HLK … HWV1 ?) -IHV12 HWV1 //
221 elim (IHU12 … HLK … HTU1 ?) -IHU12 HLK HTU1 // /3 width=5/
225 (* Basic_1: was: subst1_gen_lift_eq *)
226 lemma tps_inv_lift1_eq: ∀L,U1,U2,d,e.
227 L ⊢ U1 [d, e] ≫ U2 → ∀T1. ↑[d, e] T1 ≡ U1 → U1 = U2.
228 #L #U1 #U2 #d #e #H elim H -H L U1 U2 d e
230 | #L #K #V #W #i #d #e #Hdi #Hide #_ #_ #T1 #H
231 elim (lift_inv_lref2 … H) -H * #H
232 [ lapply (le_to_lt_to_lt … Hdi … H) -Hdi H #H
233 elim (lt_refl_false … H)
234 | lapply (lt_to_le_to_lt … Hide … H) -Hide H #H
235 elim (lt_refl_false … H)
237 | #L #I #V1 #V2 #T1 #T2 #d #e #_ #_ #IHV12 #IHT12 #X #HX
238 elim (lift_inv_bind2 … HX) -HX #V #T #HV1 #HT1 #H destruct -X
240 | #L #I #V1 #V2 #T1 #T2 #d #e #_ #_ #IHV12 #IHT12 #X #HX
241 elim (lift_inv_flat2 … HX) -HX #V #T #HV1 #HT1 #H destruct -X
246 Theorem subst0_gen_lift_rev_ge: (t1,v,u2:?; i,h,d:?)
247 (subst0 i v t1 (lift h d u2)) ->
249 (EX u1 | (subst0 (minus i h) v u1 u2) &
254 Theorem subst0_gen_lift_rev_lelt: (t1,v,u2:?; i,h,d:?)
255 (subst0 i v t1 (lift h d u2)) ->
256 (le d i) -> (lt i (plus d h)) ->
257 (EX u1 | t1 = (lift (minus (plus d h) (S i)) (S i) u1)).
259 lemma tps_inv_lift1_up: ∀L,U1,U2,dt,et. L ⊢ U1 [dt, et] ≫ U2 →
260 ∀K,d,e. ↓[d, e] L ≡ K → ∀T1. ↑[d, e] T1 ≡ U1 →
261 d ≤ dt → dt ≤ d + e → d + e ≤ dt + et →
262 ∃∃T2. K ⊢ T1 [d, dt + et - (d + e)] ≫ T2 & ↑[d, e] T2 ≡ U2.
263 #L #U1 #U2 #dt #et #HU12 #K #d #e #HLK #T1 #HTU1 #Hddt #Hdtde #Hdedet
264 elim (tps_split_up … HU12 (d + e) ? ?) -HU12 // -Hdedet #U #HU1 #HU2
265 lapply (tps_weak … HU1 d e ? ?) -HU1 // <plus_minus_m_m_comm // -Hddt Hdtde #HU1
266 lapply (tps_inv_lift1_eq … HU1 … HTU1) -HU1 #HU1 destruct -U1;
267 elim (tps_inv_lift1_ge … HU2 … HLK … HTU1 ?) -HU2 HLK HTU1 // <minus_plus_m_m /2/
270 lemma tps_inv_lift1_be_up: ∀L,U1,U2,dt,et. L ⊢ U1 [dt, et] ≫ U2 →
271 ∀K,d,e. ↓[d, e] L ≡ K → ∀T1. ↑[d, e] T1 ≡ U1 →
272 dt ≤ d → dt + et ≤ d + e →
273 ∃∃T2. K ⊢ T1 [dt, d - dt] ≫ T2 & ↑[d, e] T2 ≡ U2.
274 #L #U1 #U2 #dt #et #HU12 #K #d #e #HLK #T1 #HTU1 #Hdtd #Hdetde
275 lapply (tps_weak … HU12 dt (d + e - dt) ? ?) -HU12 // [ /2/ ] -Hdetde #HU12
276 elim (tps_inv_lift1_be … HU12 … HLK … HTU1 ? ?) -U1 L /2/