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 -L -T1 -T2 -d -e
26 | #L #K0 #V0 #W #i #d #e #Hdi #Hide #HLK0 #_ #H destruct
27 >(le_to_le_to_eq … Hdi ?) /2 width=1/ -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 width=1/
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 -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
54 elim (lift_trans_ge … HVW … HWU2 ?) -W // <minus_plus #W #HVW #HWU2
55 elim (ldrop_trans_le … HLK … HKV ?) -K /2 width=1/ #X #HLK #H
56 elim (ldrop_inv_skip2 … H ?) -H /2 width=1/ -Hid #K #Y #_ #HVY
57 >(lift_mono … HVY … HVW) -Y -HVW #H destruct /2 width=4/
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
61 @tps_bind [ /2 width=6/ | @IHT12 /2 width=6/ ] (**) (* /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 /3 width=6/
68 lemma tps_lift_be: ∀K,T1,T2,dt,et. K ⊢ T1 [dt, et] ≫ T2 →
69 ∀L,U1,U2,d,e. ↓[d, e] L ≡ K →
70 ↑[d, e] T1 ≡ U1 → ↑[d, e] T2 ≡ U2 →
71 dt ≤ d → d ≤ dt + et →
72 L ⊢ U1 [dt, et + e] ≫ U2.
73 #K #T1 #T2 #dt #et #H elim H -K -T1 -T2 -dt -et
74 [ #K #I #dt #et #L #U1 #U2 #d #e #_ #H1 #H2 #_ #_
75 >(lift_mono … H1 … H2) -H1 -H2 //
76 | #K #KV #V #W #i #dt #et #Hdti #Hidet #HKV #HVW #L #U1 #U2 #d #e #HLK #H #HWU2 #Hdtd #_
77 elim (lift_inv_lref1 … H) -H * #Hid #H destruct
79 lapply (lt_to_le_to_lt … (dt+et+e) Hidet ?) // -Hidet #Hidete
80 elim (lift_trans_ge … HVW … HWU2 ?) -W // <minus_plus #W #HVW #HWU2
81 elim (ldrop_trans_le … HLK … HKV ?) -K /2 width=1/ #X #HLK #H
82 elim (ldrop_inv_skip2 … H ?) -H /2 width=1/ -Hid #K #Y #_ #HVY
83 >(lift_mono … HVY … HVW) -V #H destruct /2 width=4/
85 lapply (transitive_le … Hdtd Hid) -Hdtd #Hdti
86 lapply (lift_trans_be … HVW … HWU2 ? ?) -W // /2 width=1/ >plus_plus_comm_23 #HVU2
87 lapply (ldrop_trans_ge_comm … HLK … HKV ?) -K // -Hid /3 width=4/
89 | #K #I #V1 #V2 #T1 #T2 #dt #et #_ #_ #IHV12 #IHT12 #L #U1 #U2 #d #e #HLK #H1 #H2 #Hdtd #Hddet
90 elim (lift_inv_bind1 … H1) -H1 #VV1 #TT1 #HVV1 #HTT1 #H1
91 elim (lift_inv_bind1 … H2) -H2 #VV2 #TT2 #HVV2 #HTT2 #H2 destruct
92 @tps_bind [ /2 width=6/ | @IHT12 [3,4: // | skip |5,6: /2 width=1/ | /2 width=1/ ]
93 ] (**) (* /3 width=6/ is too slow, arith3 needed to avoid crash, simplification like tps_lift_le is too slow *)
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 /3 width=6/
100 (* Basic_1: was: subst1_lift_ge *)
101 lemma tps_lift_ge: ∀K,T1,T2,dt,et. K ⊢ T1 [dt, et] ≫ T2 →
102 ∀L,U1,U2,d,e. ↓[d, e] L ≡ K →
103 ↑[d, e] T1 ≡ U1 → ↑[d, e] T2 ≡ U2 →
105 L ⊢ U1 [dt + e, et] ≫ U2.
106 #K #T1 #T2 #dt #et #H elim H -K -T1 -T2 -dt -et
107 [ #K #I #dt #et #L #U1 #U2 #d #e #_ #H1 #H2 #_
108 >(lift_mono … H1 … H2) -H1 -H2 //
109 | #K #KV #V #W #i #dt #et #Hdti #Hidet #HKV #HVW #L #U1 #U2 #d #e #HLK #H #HWU2 #Hddt
110 lapply (transitive_le … Hddt … Hdti) -Hddt #Hid
111 lapply (lift_inv_lref1_ge … H … Hid) -H #H destruct
112 lapply (lift_trans_be … HVW … HWU2 ? ?) -W // /2 width=1/ >plus_plus_comm_23 #HVU2
113 lapply (ldrop_trans_ge_comm … HLK … HKV ?) -K // -Hid /3 width=4/
114 | #K #I #V1 #V2 #T1 #T2 #dt #et #_ #_ #IHV12 #IHT12 #L #U1 #U2 #d #e #HLK #H1 #H2 #Hddt
115 elim (lift_inv_bind1 … H1) -H1 #VV1 #TT1 #HVV1 #HTT1 #H1
116 elim (lift_inv_bind1 … H2) -H2 #VV2 #TT2 #HVV2 #HTT2 #H2 destruct
117 @tps_bind [ /2 width=5/ | /3 width=5/ ] (**) (* explicit constructor *)
118 | #K #I #V1 #V2 #T1 #T2 #dt #et #_ #_ #IHV12 #IHT12 #L #U1 #U2 #d #e #HLK #H1 #H2 #Hddt
119 elim (lift_inv_flat1 … H1) -H1 #VV1 #TT1 #HVV1 #HTT1 #H1
120 elim (lift_inv_flat1 … H2) -H2 #VV2 #TT2 #HVV2 #HTT2 #H2 destruct /3 width=5/
124 (* Basic_1: was: subst1_gen_lift_lt *)
125 lemma tps_inv_lift1_le: ∀L,U1,U2,dt,et. L ⊢ U1 [dt, et] ≫ U2 →
126 ∀K,d,e. ↓[d, e] L ≡ K → ∀T1. ↑[d, e] T1 ≡ U1 →
128 ∃∃T2. K ⊢ T1 [dt, et] ≫ T2 & ↑[d, e] T2 ≡ U2.
129 #L #U1 #U2 #dt #et #H elim H -L -U1 -U2 -dt -et
130 [ #L * #i #dt #et #K #d #e #_ #T1 #H #_
131 [ lapply (lift_inv_sort2 … H) -H #H destruct /2 width=3/
132 | elim (lift_inv_lref2 … H) -H * #Hid #H destruct /3 width=3/
133 | lapply (lift_inv_gref2 … H) -H #H destruct /2 width=3/
135 | #L #KV #V #W #i #dt #et #Hdti #Hidet #HLKV #HVW #K #d #e #HLK #T1 #H #Hdetd
136 lapply (lt_to_le_to_lt … Hidet … Hdetd) -Hdetd #Hid
137 lapply (lift_inv_lref2_lt … H … Hid) -H #H destruct
138 elim (ldrop_conf_lt … HLK … HLKV ?) -L // #L #U #HKL #_ #HUV
139 elim (lift_trans_le … HUV … HVW ?) -V // >arith_a2 // -Hid /3 width=4/
140 | #L #I #V1 #V2 #U1 #U2 #dt #et #_ #_ #IHV12 #IHU12 #K #d #e #HLK #X #H #Hdetd
141 elim (lift_inv_bind2 … H) -H #W1 #T1 #HWV1 #HTU1 #H destruct
142 elim (IHV12 … HLK … HWV1 ?) -V1 // #W2 #HW12 #HWV2
143 elim (IHU12 … HTU1 ?) -IHU12 -HTU1 [3: /2 width=1/ |4: @ldrop_skip // |2: skip ] -HLK -Hdetd (**) (* /3 width=5/ is too slow *)
145 | #L #I #V1 #V2 #U1 #U2 #dt #et #_ #_ #IHV12 #IHU12 #K #d #e #HLK #X #H #Hdetd
146 elim (lift_inv_flat2 … H) -H #W1 #T1 #HWV1 #HTU1 #H destruct
147 elim (IHV12 … HLK … HWV1 ?) -V1 //
148 elim (IHU12 … HLK … HTU1 ?) -U1 -HLK // /3 width=5/
152 lemma tps_inv_lift1_be: ∀L,U1,U2,dt,et. L ⊢ U1 [dt, et] ≫ U2 →
153 ∀K,d,e. ↓[d, e] L ≡ K → ∀T1. ↑[d, e] T1 ≡ U1 →
154 dt ≤ d → d + e ≤ dt + et →
155 ∃∃T2. K ⊢ T1 [dt, et - e] ≫ T2 & ↑[d, e] T2 ≡ U2.
156 #L #U1 #U2 #dt #et #H elim H -L -U1 -U2 -dt -et
157 [ #L * #i #dt #et #K #d #e #_ #T1 #H #_
158 [ lapply (lift_inv_sort2 … H) -H #H destruct /2 width=3/
159 | elim (lift_inv_lref2 … H) -H * #Hid #H destruct /3 width=3/
160 | lapply (lift_inv_gref2 … H) -H #H destruct /2 width=3/
162 | #L #KV #V #W #i #dt #et #Hdti #Hidet #HLKV #HVW #K #d #e #HLK #T1 #H #Hdtd #Hdedet
163 lapply (le_fwd_plus_plus_ge … Hdtd … Hdedet) #Heet
164 elim (lift_inv_lref2 … H) -H * #Hid #H destruct
166 lapply (lt_to_le_to_lt … (dt + (et - e)) Hid ?) [ <le_plus_minus /2 width=1/ ] -Hdedet #Hidete
167 elim (ldrop_conf_lt … HLK … HLKV ?) -L // #L #U #HKL #_ #HUV
168 elim (lift_trans_le … HUV … HVW ?) -V // >arith_a2 // -Hid /3 width=4/
170 lapply (transitive_le … (i - e) Hdtd ?) /2 width=1/ -Hdtd #Hdtie
171 lapply (plus_le_weak … Hid) #Hei
172 lapply (ldrop_conf_ge … HLK … HLKV ?) -L // #HKV
173 elim (lift_split … HVW d (i - e + 1) ? ? ?) -HVW [4: // |2,3: /2 width=1/ ] -Hid >arith_e2 // /4 width=4/
175 | #L #I #V1 #V2 #U1 #U2 #dt #et #_ #_ #IHV12 #IHU12 #K #d #e #HLK #X #H #Hdtd #Hdedet
176 elim (lift_inv_bind2 … H) -H #W1 #T1 #HWV1 #HTU1 #H destruct
177 elim (IHV12 … HLK … HWV1 ? ?) -V1 // #W2 #HW12 #HWV2
178 elim (IHU12 … HTU1 ? ?) -U1 [5: @ldrop_skip // |2: skip |3: >plus_plus_comm_23 >(plus_plus_comm_23 dt) /2 width=1/ |4: /2 width=1/ ]
180 | #L #I #V1 #V2 #U1 #U2 #dt #et #_ #_ #IHV12 #IHU12 #K #d #e #HLK #X #H #Hdtd #Hdedet
181 elim (lift_inv_flat2 … H) -H #W1 #T1 #HWV1 #HTU1 #H destruct
182 elim (IHV12 … HLK … HWV1 ? ?) -V1 //
183 elim (IHU12 … HLK … HTU1 ? ?) -U1 -HLK // /3 width=5/
187 (* Basic_1: was: subst1_gen_lift_ge *)
188 lemma tps_inv_lift1_ge: ∀L,U1,U2,dt,et. L ⊢ U1 [dt, et] ≫ U2 →
189 ∀K,d,e. ↓[d, e] L ≡ K → ∀T1. ↑[d, e] T1 ≡ U1 →
191 ∃∃T2. K ⊢ T1 [dt - e, et] ≫ T2 & ↑[d, e] T2 ≡ U2.
192 #L #U1 #U2 #dt #et #H elim H -L -U1 -U2 -dt -et
193 [ #L * #i #dt #et #K #d #e #_ #T1 #H #_
194 [ lapply (lift_inv_sort2 … H) -H #H destruct /2 width=3/
195 | elim (lift_inv_lref2 … H) -H * #Hid #H destruct /3 width=3/
196 | lapply (lift_inv_gref2 … H) -H #H destruct /2 width=3/
198 | #L #KV #V #W #i #dt #et #Hdti #Hidet #HLKV #HVW #K #d #e #HLK #T1 #H #Hdedt
199 lapply (transitive_le … Hdedt … Hdti) #Hdei
200 lapply (plus_le_weak … Hdedt) -Hdedt #Hedt
201 lapply (plus_le_weak … Hdei) #Hei
202 lapply (lift_inv_lref2_ge … H … Hdei) -H #H destruct
203 lapply (ldrop_conf_ge … HLK … HLKV ?) -L // #HKV
204 elim (lift_split … HVW d (i - e + 1) ? ? ?) -HVW [4: // |2,3: normalize /2 width=1/ ] -Hdei >arith_e2 // #V0 #HV10 #HV02
205 @ex2_1_intro /3 width=4/ (**) (* explicitc constructors *)
206 | #L #I #V1 #V2 #U1 #U2 #dt #et #_ #_ #IHV12 #IHU12 #K #d #e #HLK #X #H #Hdetd
207 elim (lift_inv_bind2 … H) -H #W1 #T1 #HWV1 #HTU1 #H destruct
208 lapply (plus_le_weak … Hdetd) #Hedt
209 elim (IHV12 … HLK … HWV1 ?) -V1 // #W2 #HW12 #HWV2
210 elim (IHU12 … HTU1 ?) -U1 [4: @ldrop_skip // |2: skip |3: /2 width=1/ ]
211 <plus_minus // /3 width=5/
212 | #L #I #V1 #V2 #U1 #U2 #dt #et #_ #_ #IHV12 #IHU12 #K #d #e #HLK #X #H #Hdetd
213 elim (lift_inv_flat2 … H) -H #W1 #T1 #HWV1 #HTU1 #H destruct
214 elim (IHV12 … HLK … HWV1 ?) -V1 //
215 elim (IHU12 … HLK … HTU1 ?) -U1 -HLK // /3 width=5/
219 (* Basic_1: was: subst1_gen_lift_eq *)
220 lemma tps_inv_lift1_eq: ∀L,U1,U2,d,e.
221 L ⊢ U1 [d, e] ≫ U2 → ∀T1. ↑[d, e] T1 ≡ U1 → U1 = U2.
222 #L #U1 #U2 #d #e #H elim H -L -U1 -U2 -d -e
224 | #L #K #V #W #i #d #e #Hdi #Hide #_ #_ #T1 #H
225 elim (lift_inv_lref2 … H) -H * #H
226 [ lapply (le_to_lt_to_lt … Hdi … H) -Hdi -H #H
227 elim (lt_refl_false … H)
228 | lapply (lt_to_le_to_lt … Hide … H) -Hide -H #H
229 elim (lt_refl_false … H)
231 | #L #I #V1 #V2 #T1 #T2 #d #e #_ #_ #IHV12 #IHT12 #X #HX
232 elim (lift_inv_bind2 … HX) -HX #V #T #HV1 #HT1 #H destruct
234 | #L #I #V1 #V2 #T1 #T2 #d #e #_ #_ #IHV12 #IHT12 #X #HX
235 elim (lift_inv_flat2 … HX) -HX #V #T #HV1 #HT1 #H destruct
240 Theorem subst0_gen_lift_rev_ge: (t1,v,u2,i,h,d:?)
241 (subst0 i v t1 (lift h d u2)) ->
243 (EX u1 | (subst0 (minus i h) v u1 u2) &
248 Theorem subst0_gen_lift_rev_lelt: (t1,v,u2,i,h,d:?)
249 (subst0 i v t1 (lift h d u2)) ->
250 (le d i) -> (lt i (plus d h)) ->
251 (EX u1 | t1 = (lift (minus (plus d h) (S i)) (S i) u1)).
253 lemma tps_inv_lift1_up: ∀L,U1,U2,dt,et. L ⊢ U1 [dt, et] ≫ U2 →
254 ∀K,d,e. ↓[d, e] L ≡ K → ∀T1. ↑[d, e] T1 ≡ U1 →
255 d ≤ dt → dt ≤ d + e → d + e ≤ dt + et →
256 ∃∃T2. K ⊢ T1 [d, dt + et - (d + e)] ≫ T2 & ↑[d, e] T2 ≡ U2.
257 #L #U1 #U2 #dt #et #HU12 #K #d #e #HLK #T1 #HTU1 #Hddt #Hdtde #Hdedet
258 elim (tps_split_up … HU12 (d + e) ? ?) -HU12 // -Hdedet #U #HU1 #HU2
259 lapply (tps_weak … HU1 d e ? ?) -HU1 // <plus_minus_m_m_comm // -Hddt -Hdtde #HU1
260 lapply (tps_inv_lift1_eq … HU1 … HTU1) -HU1 #HU1 destruct
261 elim (tps_inv_lift1_ge … HU2 … HLK … HTU1 ?) -U -L // <minus_plus_m_m /2 width=3/
264 lemma tps_inv_lift1_be_up: ∀L,U1,U2,dt,et. L ⊢ U1 [dt, et] ≫ U2 →
265 ∀K,d,e. ↓[d, e] L ≡ K → ∀T1. ↑[d, e] T1 ≡ U1 →
266 dt ≤ d → dt + et ≤ d + e →
267 ∃∃T2. K ⊢ T1 [dt, d - dt] ≫ T2 & ↑[d, e] T2 ≡ U2.
268 #L #U1 #U2 #dt #et #HU12 #K #d #e #HLK #T1 #HTU1 #Hdtd #Hdetde
269 lapply (tps_weak … HU12 dt (d + e - dt) ? ?) -HU12 // /2 width=3/ -Hdetde #HU12
270 elim (tps_inv_lift1_be … HU12 … HLK … HTU1 ? ?) -U1 -L // /2 width=3/