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/relocation/ldrop_ldrop.ma".
16 include "basic_2/relocation/cpy.ma".
18 (* CONTEXT-SENSITIVE EXTENDED ORDINARY SUBSTITUTION FOR TERMS ***************)
20 (* Relocation properties ****************************************************)
22 lemma cpy_lift_le: ∀G,K,T1,T2,dt,et. ⦃G, K⦄ ⊢ T1 ▶×[dt, et] T2 →
23 ∀L,U1,U2,d,e. ⇩[d, e] L ≡ K →
24 ⇧[d, e] T1 ≡ U1 → ⇧[d, e] T2 ≡ U2 →
25 dt + et ≤ d → ⦃G, L⦄ ⊢ U1 ▶×[dt, et] U2.
26 #G #K #T1 #T2 #dt #et #H elim H -G -K -T1 -T2 -dt -et
27 [ #I #G #K #dt #et #L #U1 #U2 #d #e #_ #H1 #H2 #_
28 >(lift_mono … H1 … H2) -H1 -H2 //
29 | #I #G #K #KV #V #W #i #dt #et #Hdti #Hidet #HKV #HVW #L #U1 #U2 #d #e #HLK #H #HWU2 #Hdetd
30 lapply (ylt_yle_trans … Hdetd … Hidet) -Hdetd #Hid
31 lapply (ylt_inv_inj … Hid) -Hid #Hid
32 lapply (lift_inv_lref1_lt … H … Hid) -H #H destruct
33 elim (lift_trans_ge … HVW … HWU2) -W // <minus_plus #W #HVW #HWU2
34 elim (ldrop_trans_le … HLK … HKV) -K /2 width=2 by lt_to_le/ #X #HLK #H
35 elim (ldrop_inv_skip2 … H) -H /2 width=1 by lt_plus_to_minus_r/ -Hid #K #Y #_ #HVY
36 >(lift_mono … HVY … HVW) -Y -HVW #H destruct /2 width=5 by cpy_subst/
37 | #a #I #G #K #V1 #V2 #T1 #T2 #dt #et #_ #_ #IHV12 #IHT12 #L #U1 #U2 #d #e #HLK #H1 #H2 #Hdetd
38 elim (lift_inv_bind1 … H1) -H1 #VV1 #TT1 #HVV1 #HTT1 #H1
39 elim (lift_inv_bind1 … H2) -H2 #VV2 #TT2 #HVV2 #HTT2 #H2 destruct
40 /4 width=6 by cpy_bind, ldrop_skip, yle_succ/
41 | #G #I #K #V1 #V2 #T1 #T2 #dt #et #_ #_ #IHV12 #IHT12 #L #U1 #U2 #d #e #HLK #H1 #H2 #Hdetd
42 elim (lift_inv_flat1 … H1) -H1 #VV1 #TT1 #HVV1 #HTT1 #H1
43 elim (lift_inv_flat1 … H2) -H2 #VV2 #TT2 #HVV2 #HTT2 #H2 destruct
44 /3 width=6 by cpy_flat/
48 lemma cpy_lift_be: ∀G,K,T1,T2,dt,et. ⦃G, K⦄ ⊢ T1 ▶×[dt, et] T2 →
49 ∀L,U1,U2,d,e. ⇩[d, e] L ≡ K →
50 ⇧[d, e] T1 ≡ U1 → ⇧[d, e] T2 ≡ U2 →
51 dt ≤ d → d ≤ dt + et → ⦃G, L⦄ ⊢ U1 ▶×[dt, et + e] U2.
52 #G #K #T1 #T2 #dt #et #H elim H -G -K -T1 -T2 -dt -et
53 [ #I #G #K #dt #et #L #U1 #U2 #d #e #_ #H1 #H2 #_ #_
54 >(lift_mono … H1 … H2) -H1 -H2 //
55 | #I #G #K #KV #V #W #i #dt #et #Hdti #Hidet #HKV #HVW #L #U1 #U2 #d #e #HLK #H #HWU2 #Hdtd #_
56 elim (lift_inv_lref1 … H) -H * #Hid #H destruct
58 lapply (ylt_yle_trans … (dt+et+e) … Hidet) // -Hidet #Hidete
59 elim (lift_trans_ge … HVW … HWU2) -W // <minus_plus #W #HVW #HWU2
60 elim (ldrop_trans_le … HLK … HKV) -K /2 width=2 by lt_to_le/ #X #HLK #H
61 elim (ldrop_inv_skip2 … H) -H /2 width=1 by lt_plus_to_minus_r/ -Hid #K #Y #_ #HVY
62 >(lift_mono … HVY … HVW) -V #H destruct /2 width=5 by cpy_subst/
64 elim (yle_inv_inj2 … Hdtd) -Hdtd #dtt #Hdtd #H destruct
65 lapply (transitive_le … Hdtd Hid) -Hdtd #Hdti
66 lapply (lift_trans_be … HVW … HWU2 ? ?) -W /2 width=1 by le_S/ >plus_plus_comm_23 #HVU2
67 lapply (ldrop_trans_ge_comm … HLK … HKV ?) -K // -Hid
68 /4 width=5 by cpy_subst, monotonic_ylt_plus_dx, yle_plus_dx1_trans, yle_inj/
70 | #a #I #G #K #V1 #V2 #T1 #T2 #dt #et #_ #_ #IHV12 #IHT12 #L #U1 #U2 #d #e #HLK #H1 #H2 #Hdtd #Hddet
71 elim (lift_inv_bind1 … H1) -H1 #VV1 #TT1 #HVV1 #HTT1 #H1
72 elim (lift_inv_bind1 … H2) -H2 #VV2 #TT2 #HVV2 #HTT2 #H2 destruct
73 /4 width=6 by cpy_bind, ldrop_skip, yle_succ/
74 | #I #G #K #V1 #V2 #T1 #T2 #dt #et #_ #_ #IHV12 #IHT12 #L #U1 #U2 #d #e #HLK #H1 #H2 #Hdetd
75 elim (lift_inv_flat1 … H1) -H1 #VV1 #TT1 #HVV1 #HTT1 #H1
76 elim (lift_inv_flat1 … H2) -H2 #VV2 #TT2 #HVV2 #HTT2 #H2 destruct
77 /3 width=6 by cpy_flat/
81 lemma cpy_lift_ge: ∀G,K,T1,T2,dt,et. ⦃G, K⦄ ⊢ T1 ▶×[dt, et] T2 →
82 ∀L,U1,U2,d,e. ⇩[d, e] L ≡ K →
83 ⇧[d, e] T1 ≡ U1 → ⇧[d, e] T2 ≡ U2 →
84 d ≤ dt → ⦃G, L⦄ ⊢ U1 ▶×[dt+e, et] U2.
85 #G #K #T1 #T2 #dt #et #H elim H -G -K -T1 -T2 -dt -et
86 [ #I #G #K #dt #et #L #U1 #U2 #d #e #_ #H1 #H2 #_
87 >(lift_mono … H1 … H2) -H1 -H2 //
88 | #I #G #K #KV #V #W #i #dt #et #Hdti #Hidet #HKV #HVW #L #U1 #U2 #d #e #HLK #H #HWU2 #Hddt
89 lapply (yle_trans … Hddt … Hdti) -Hddt #Hid
90 elim (yle_inv_inj2 … Hid) -Hid #dd #Hddi #H0 destruct
91 lapply (lift_inv_lref1_ge … H … Hddi) -H #H destruct
92 lapply (lift_trans_be … HVW … HWU2 ? ?) -W /2 width=1 by le_S/ >plus_plus_comm_23 #HVU2
93 lapply (ldrop_trans_ge_comm … HLK … HKV ?) -K // -Hddi
94 /3 width=5 by cpy_subst, monotonic_ylt_plus_dx, monotonic_yle_plus_dx/
95 | #a #I #G #K #V1 #V2 #T1 #T2 #dt #et #_ #_ #IHV12 #IHT12 #L #U1 #U2 #d #e #HLK #H1 #H2 #Hddt
96 elim (lift_inv_bind1 … H1) -H1 #VV1 #TT1 #HVV1 #HTT1 #H1
97 elim (lift_inv_bind1 … H2) -H2 #VV2 #TT2 #HVV2 #HTT2 #H2 destruct
98 /4 width=5 by cpy_bind, ldrop_skip, yle_succ/
99 | #I #G #K #V1 #V2 #T1 #T2 #dt #et #_ #_ #IHV12 #IHT12 #L #U1 #U2 #d #e #HLK #H1 #H2 #Hddt
100 elim (lift_inv_flat1 … H1) -H1 #VV1 #TT1 #HVV1 #HTT1 #H1
101 elim (lift_inv_flat1 … H2) -H2 #VV2 #TT2 #HVV2 #HTT2 #H2 destruct
102 /3 width=5 by cpy_flat/
106 lemma cpy_inv_lift1_le: ∀G,L,U1,U2,dt,et. ⦃G, L⦄ ⊢ U1 ▶×[dt, et] U2 →
107 ∀K,d,e. ⇩[d, e] L ≡ K → ∀T1. ⇧[d, e] T1 ≡ U1 →
109 ∃∃T2. ⦃G, K⦄ ⊢ T1 ▶×[dt, et] T2 & ⇧[d, e] T2 ≡ U2.
110 #G #L #U1 #U2 #dt #et #H elim H -G -L -U1 -U2 -dt -et
111 [ * #G #L #i #dt #et #K #d #e #_ #T1 #H #_
112 [ lapply (lift_inv_sort2 … H) -H #H destruct /2 width=3 by cpy_atom, lift_sort, ex2_intro/
113 | elim (lift_inv_lref2 … H) -H * #Hid #H destruct /3 width=3 by cpy_atom, lift_lref_ge_minus, lift_lref_lt, ex2_intro/
114 | lapply (lift_inv_gref2 … H) -H #H destruct /2 width=3 by cpy_atom, lift_gref, ex2_intro/
116 | #I #G #L #KV #V #W #i #dt #et #Hdti #Hidet #HLKV #HVW #K #d #e #HLK #T1 #H #Hdetd
117 lapply (ylt_yle_trans … Hdetd … Hidet) -Hdetd #Hid
118 lapply (ylt_inv_inj … Hid) -Hid #Hid
119 lapply (lift_inv_lref2_lt … H … Hid) -H #H destruct
120 elim (ldrop_conf_lt … HLK … HLKV) -L // #L #U #HKL #_ #HUV
121 elim (lift_trans_le … HUV … HVW) -V // >minus_plus <plus_minus_m_m // -Hid /3 width=5 by cpy_subst, ex2_intro/
122 | #a #I #G #L #V1 #V2 #U1 #U2 #dt #et #_ #_ #IHV12 #IHU12 #K #d #e #HLK #X #H #Hdetd
123 elim (lift_inv_bind2 … H) -H #W1 #T1 #HWV1 #HTU1 #H destruct
124 elim (IHV12 … HLK … HWV1) -V1 // #W2 #HW12 #HWV2
125 elim (IHU12 … HTU1) -IHU12 -HTU1
126 /3 width=5 by cpy_bind, yle_succ, ldrop_skip, lift_bind, ex2_intro/
127 | #I #G #L #V1 #V2 #U1 #U2 #dt #et #_ #_ #IHV12 #IHU12 #K #d #e #HLK #X #H #Hdetd
128 elim (lift_inv_flat2 … H) -H #W1 #T1 #HWV1 #HTU1 #H destruct
129 elim (IHV12 … HLK … HWV1) -V1 //
130 elim (IHU12 … HLK … HTU1) -U1 -HLK
131 /3 width=5 by cpy_flat, lift_flat, ex2_intro/
135 lemma cpy_inv_lift1_be: ∀G,L,U1,U2,dt,et. ⦃G, L⦄ ⊢ U1 ▶×[dt, et] U2 →
136 ∀K,d,e. ⇩[d, e] L ≡ K → ∀T1. ⇧[d, e] T1 ≡ U1 →
137 dt ≤ d → d + e ≤ dt + et →
138 ∃∃T2. ⦃G, K⦄ ⊢ T1 ▶×[dt, et-e] T2 & ⇧[d, e] T2 ≡ U2.
139 #G #L #U1 #U2 #dt #et #H elim H -G -L -U1 -U2 -dt -et
140 [ * #G #L #i #dt #et #K #d #e #_ #T1 #H #_
141 [ lapply (lift_inv_sort2 … H) -H #H destruct /2 width=3 by cpy_atom, lift_sort, ex2_intro/
142 | elim (lift_inv_lref2 … H) -H * #Hid #H destruct /3 width=3 by cpy_atom, lift_lref_ge_minus, lift_lref_lt, ex2_intro/
143 | lapply (lift_inv_gref2 … H) -H #H destruct /2 width=3 by cpy_atom, lift_gref, ex2_intro/
145 | #I #G #L #KV #V #W #i #dt #et #Hdti #Hidet #HLKV #HVW #K #d #e #HLK #T1 #H #Hdtd #Hdedet
146 lapply (yle_fwd_plus_ge_inj … Hdtd Hdedet) #Heet
147 elim (lift_inv_lref2 … H) -H * #Hid #H destruct [ -Hdtd -Hidet | -Hdti -Hdedet ]
148 [ lapply (ylt_yle_trans i d (dt+(et-e)) ? ?) /2 width=1 by ylt_inj/
149 [ >yplus_minus_assoc_inj /2 width=1 by yle_plus_to_minus_inj2/ ] -Hdedet #Hidete
150 elim (ldrop_conf_lt … HLK … HLKV) -L // #L #U #HKL #_ #HUV
151 elim (lift_trans_le … HUV … HVW) -V // >minus_plus <plus_minus_m_m // -Hid
152 /3 width=5 by cpy_subst, ex2_intro/
153 | elim (le_inv_plus_l … Hid) #Hdie #Hei
154 lapply (yle_trans … Hdtd (i-e) ?) /2 width=1 by yle_inj/ -Hdtd #Hdtie
155 lapply (ldrop_conf_ge … HLK … HLKV ?) -L // #HKV
156 elim (lift_split … HVW d (i-e+1)) -HVW [2,3,4: /2 width=1 by le_S_S, le_S/ ] -Hid -Hdie
157 #V1 #HV1 >plus_minus // <minus_minus /2 width=1 by le_S/ <minus_n_n <plus_n_O #H
158 @(ex2_intro … H) @(cpy_subst … HKV HV1) // (**) (* explicit constructor *)
159 >yplus_minus_assoc_inj /3 width=1 by monotonic_ylt_minus_dx, yle_inj/
161 | #a #I #G #L #V1 #V2 #U1 #U2 #dt #et #_ #_ #IHV12 #IHU12 #K #d #e #HLK #X #H #Hdtd #Hdedet
162 elim (lift_inv_bind2 … H) -H #W1 #T1 #HWV1 #HTU1 #H destruct
163 elim (IHV12 … HLK … HWV1) -V1 // #W2 #HW12 #HWV2
164 elim (IHU12 … HTU1) -U1
165 /3 width=5 by cpy_bind, ldrop_skip, lift_bind, yle_succ, ex2_intro/
166 | #I #G #L #V1 #V2 #U1 #U2 #dt #et #_ #_ #IHV12 #IHU12 #K #d #e #HLK #X #H #Hdtd #Hdedet
167 elim (lift_inv_flat2 … H) -H #W1 #T1 #HWV1 #HTU1 #H destruct
168 elim (IHV12 … HLK … HWV1) -V1 //
169 elim (IHU12 … HLK … HTU1) -U1 -HLK //
170 /3 width=5 by cpy_flat, lift_flat, ex2_intro/
174 lemma cpy_inv_lift1_ge: ∀G,L,U1,U2,dt,et. ⦃G, L⦄ ⊢ U1 ▶×[dt, et] U2 →
175 ∀K,d,e. ⇩[d, e] L ≡ K → ∀T1. ⇧[d, e] T1 ≡ U1 →
177 ∃∃T2. ⦃G, K⦄ ⊢ T1 ▶×[dt-e, et] T2 & ⇧[d, e] T2 ≡ U2.
178 #G #L #U1 #U2 #dt #et #H elim H -G -L -U1 -U2 -dt -et
179 [ * #G #L #i #dt #et #K #d #e #_ #T1 #H #_
180 [ lapply (lift_inv_sort2 … H) -H #H destruct /2 width=3 by cpy_atom, lift_sort, ex2_intro/
181 | elim (lift_inv_lref2 … H) -H * #Hid #H destruct /3 width=3 by cpy_atom, lift_lref_ge_minus, lift_lref_lt, ex2_intro/
182 | lapply (lift_inv_gref2 … H) -H #H destruct /2 width=3 by cpy_atom, lift_gref, ex2_intro/
184 | #I #G #L #KV #V #W #i #dt #et #Hdti #Hidet #HLKV #HVW #K #d #e #HLK #T1 #H #Hdedt
185 lapply (yle_trans … Hdedt … Hdti) #Hdei
186 elim (yle_inv_plus_inj2 … Hdedt) -Hdedt #_ #Hedt
187 elim (yle_inv_plus_inj2 … Hdei) #Hdie #Hei
188 lapply (lift_inv_lref2_ge … H ?) -H /2 width=1 by yle_inv_inj/ #H destruct
189 lapply (ldrop_conf_ge … HLK … HLKV ?) -L /2 width=1 by yle_inv_inj/ #HKV
190 elim (lift_split … HVW d (i-e+1)) -HVW [2,3,4: /3 width=1 by yle_inv_inj, le_S_S, le_S/ ] -Hdei -Hdie
191 #V0 #HV10 >plus_minus /2 width=1 by yle_inv_inj/ <minus_minus /3 width=1 by yle_inv_inj, le_S/ <minus_n_n <plus_n_O #H
192 @(ex2_intro … H) @(cpy_subst … HKV HV10) (**) (* explicit constructor *)
193 [ /2 width=1 by monotonic_yle_minus_dx/
194 | <yplus_minus_comm_inj /2 width=1 by monotonic_ylt_minus_dx/
196 | #a #I #G #L #V1 #V2 #U1 #U2 #dt #et #_ #_ #IHV12 #IHU12 #K #d #e #HLK #X #H #Hdetd
197 elim (lift_inv_bind2 … H) -H #W1 #T1 #HWV1 #HTU1 #H destruct
198 elim (yle_inv_plus_inj2 … Hdetd) #_ #Hedt
199 elim (IHV12 … HLK … HWV1) -V1 // #W2 #HW12 #HWV2
200 elim (IHU12 … HTU1) -U1 [4: @ldrop_skip // |2: skip |3: /2 width=1 by yle_succ/ ]
201 >yminus_succ1_inj /3 width=5 by cpy_bind, lift_bind, ex2_intro/
202 | #I #G #L #V1 #V2 #U1 #U2 #dt #et #_ #_ #IHV12 #IHU12 #K #d #e #HLK #X #H #Hdetd
203 elim (lift_inv_flat2 … H) -H #W1 #T1 #HWV1 #HTU1 #H destruct
204 elim (IHV12 … HLK … HWV1) -V1 //
205 elim (IHU12 … HLK … HTU1) -U1 -HLK /3 width=5 by cpy_flat, lift_flat, ex2_intro/
209 lemma cpy_inv_lift1_eq: ∀G,T1,U1,d,e. ⇧[d, e] T1 ≡ U1 →
210 ∀L,U2. ⦃G, L⦄ ⊢ U1 ▶×[d, e] U2 → U1 = U2.
211 #G #T1 #U1 #d #e #H elim H -T1 -U1 -d -e
212 [ #k #d #e #L #X #H >(cpy_inv_sort1 … H) -H //
213 | #i #d #e #Hid #L #X #H elim (cpy_inv_lref1 … H) -H //
214 * #I #K #V #H elim (ylt_yle_false … H) -H /2 width=1 by ylt_inj/
215 | #i #d #e #Hdi #L #X #H elim (cpy_inv_lref1 … H) -H //
216 * #I #K #V #_ #H elim (ylt_yle_false i d)
217 /2 width=2 by ylt_inv_monotonic_plus_dx, yle_inj/
218 | #p #d #e #L #X #H >(cpy_inv_gref1 … H) -H //
219 | #a #I #V1 #W1 #T1 #U1 #d #e #_ #_ #IHVW1 #IHTU1 #L #X #H elim (cpy_inv_bind1 … H) -H
220 #W2 #U2 #HW12 #HU12 #H destruct /3 width=2 by eq_f2/
221 | #I #V1 #W1 #T1 #U1 #d #e #_ #_ #IHVW1 #IHTU1 #L #X #H elim (cpy_inv_flat1 … H) -H
222 #W2 #U2 #HW12 #HU12 #H destruct /3 width=2 by eq_f2/
226 lemma cpy_inv_lift1_ge_up: ∀G,L,U1,U2,dt,et. ⦃G, L⦄ ⊢ U1 ▶×[dt, et] U2 →
227 ∀K,d,e. ⇩[d, e] L ≡ K → ∀T1. ⇧[d, e] T1 ≡ U1 →
228 d ≤ dt → dt ≤ d + e → d + e ≤ dt + et →
229 ∃∃T2. ⦃G, K⦄ ⊢ T1 ▶×[d, dt + et - (d + e)] T2 & ⇧[d, e] T2 ≡ U2.
230 #G #L #U1 #U2 #dt #et #HU12 #K #d #e #HLK #T1 #HTU1 #Hddt #Hdtde #Hdedet
231 elim (cpy_split_up … HU12 (d + e)) -HU12 // -Hdedet #U #HU1 #HU2
232 lapply (cpy_weak … HU1 d e ? ?) -HU1 // [ >ymax_pre_sn_comm // ] -Hddt -Hdtde #HU1
233 lapply (cpy_inv_lift1_eq … HTU1 … HU1) -HU1 #HU1 destruct
234 elim (cpy_inv_lift1_ge … HU2 … HLK … HTU1) -U -L /2 width=3 by ex2_intro/
237 lemma cpy_inv_lift1_be_up: ∀G,L,U1,U2,dt,et. ⦃G, L⦄ ⊢ U1 ▶×[dt, et] U2 →
238 ∀K,d,e. ⇩[d, e] L ≡ K → ∀T1. ⇧[d, e] T1 ≡ U1 →
239 dt ≤ d → dt + et ≤ d + e →
240 ∃∃T2. ⦃G, K⦄ ⊢ T1 ▶×[dt, d-dt] T2 & ⇧[d, e] T2 ≡ U2.
241 #G #L #U1 #U2 #dt #et #HU12 #K #d #e #HLK #T1 #HTU1 #Hdtd #Hdetde
242 lapply (cpy_weak … HU12 dt (d+e-dt) ? ?) -HU12 //
243 [ >ymax_pre_sn_comm /2 width=1 by yle_plus_dx1_trans/ ] -Hdetde #HU12
244 elim (cpy_inv_lift1_be … HU12 … HLK … HTU1) -U1 -L /2 width=3 by ex2_intro/
247 lemma cpy_inv_lift1_le_up: ∀G,L,U1,U2,dt,et. ⦃G, L⦄ ⊢ U1 ▶×[dt, et] U2 →
248 ∀K,d,e. ⇩[d, e] L ≡ K → ∀T1. ⇧[d, e] T1 ≡ U1 →
249 dt ≤ d → d ≤ dt + et → dt + et ≤ d + e →
250 ∃∃T2. ⦃G, K⦄ ⊢ T1 ▶×[dt, d - dt] T2 & ⇧[d, e] T2 ≡ U2.
251 #G #L #U1 #U2 #dt #et #HU12 #K #d #e #HLK #T1 #HTU1 #Hdtd #Hddet #Hdetde
252 elim (cpy_split_up … HU12 d) -HU12 // #U #HU1 #HU2
253 elim (cpy_inv_lift1_le … HU1 … HLK … HTU1) -U1
254 [2: >ymax_pre_sn_comm // ] -Hdtd #T #HT1 #HTU
255 lapply (cpy_weak … HU2 d e ? ?) -HU2 //
256 [ >ymax_pre_sn_comm // ] -Hddet -Hdetde #HU2
257 lapply (cpy_inv_lift1_eq … HTU … HU2) -L #H destruct /2 width=3 by ex2_intro/