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/cpy_lift.ma".
16 include "basic_2/multiple/cpys.ma".
18 (* CONTEXT-SENSITIVE EXTENDED MULTIPLE SUBSTITUTION FOR TERMS ***************)
20 (* Advanced properties ******************************************************)
22 lemma cpys_subst: ∀I,G,L,K,V,U1,i,l,m.
23 l ≤ yinj i → i < l + m →
24 ⬇[i] L ≡ K.ⓑ{I}V → ⦃G, K⦄ ⊢ V ▶*[0, ⫰(l+m-i)] U1 →
25 ∀U2. ⬆[0, i+1] U1 ≡ U2 → ⦃G, L⦄ ⊢ #i ▶*[l, m] U2.
26 #I #G #L #K #V #U1 #i #l #m #Hli #Hilm #HLK #H @(cpys_ind … H) -U1
27 [ /3 width=5 by cpy_cpys, cpy_subst/
28 | #U #U1 #_ #HU1 #IHU #U2 #HU12
29 elim (lift_total U 0 (i+1)) #U0 #HU0
30 lapply (IHU … HU0) -IHU #H
31 lapply (drop_fwd_drop2 … HLK) -HLK #HLK
32 lapply (cpy_lift_ge … HU1 … HLK HU0 HU12 ?) -HU1 -HLK -HU0 -HU12 // #HU02
33 lapply (cpy_weak … HU02 l m ? ?) -HU02
34 [2,3: /2 width=3 by cpys_strap1, yle_succ_dx/ ]
35 >yplus_O1 <yplus_inj >ymax_pre_sn_comm /2 width=1 by ylt_fwd_le_succ1/
39 lemma cpys_subst_Y2: ∀I,G,L,K,V,U1,i,l.
41 ⬇[i] L ≡ K.ⓑ{I}V → ⦃G, K⦄ ⊢ V ▶*[0, ∞] U1 →
42 ∀U2. ⬆[0, i+1] U1 ≡ U2 → ⦃G, L⦄ ⊢ #i ▶*[l, ∞] U2.
43 #I #G #L #K #V #U1 #i #l #Hli #HLK #HVU1 #U2 #HU12
44 @(cpys_subst … HLK … HU12) >yminus_Y_inj //
47 (* Advanced inversion lemmas *************************************************)
49 lemma cpys_inv_atom1: ∀I,G,L,T2,l,m. ⦃G, L⦄ ⊢ ⓪{I} ▶*[l, m] T2 →
51 ∃∃J,K,V1,V2,i. l ≤ yinj i & i < l + m &
53 ⦃G, K⦄ ⊢ V1 ▶*[0, ⫰(l+m-i)] V2 &
56 #I #G #L #T2 #l #m #H @(cpys_ind … H) -T2
57 [ /2 width=1 by or_introl/
60 elim (cpy_inv_atom1 … HT2) -HT2 [ /2 width=1 by or_introl/ | * /3 width=11 by ex6_5_intro, or_intror/ ]
61 | * #J #K #V1 #V #i #Hli #Hilm #HLK #HV1 #HVT #HI
62 lapply (drop_fwd_drop2 … HLK) #H
63 elim (cpy_inv_lift1_ge_up … HT2 … H … HVT) -HT2 -H -HVT
64 [2,3,4: /2 width=1 by ylt_fwd_le_succ1, yle_succ_dx/ ]
65 /4 width=11 by cpys_strap1, ex6_5_intro, or_intror/
70 lemma cpys_inv_lref1: ∀G,L,T2,i,l,m. ⦃G, L⦄ ⊢ #i ▶*[l, m] T2 →
72 ∃∃I,K,V1,V2. l ≤ i & i < l + m &
74 ⦃G, K⦄ ⊢ V1 ▶*[0, ⫰(l+m-i)] V2 &
76 #G #L #T2 #i #l #m #H elim (cpys_inv_atom1 … H) -H /2 width=1 by or_introl/
77 * #I #K #V1 #V2 #j #Hlj #Hjlm #HLK #HV12 #HVT2 #H destruct /3 width=7 by ex5_4_intro, or_intror/
80 lemma cpys_inv_lref1_Y2: ∀G,L,T2,i,l. ⦃G, L⦄ ⊢ #i ▶*[l, ∞] T2 →
82 ∃∃I,K,V1,V2. l ≤ i & ⬇[i] L ≡ K.ⓑ{I}V1 &
83 ⦃G, K⦄ ⊢ V1 ▶*[0, ∞] V2 & ⬆[O, i+1] V2 ≡ T2.
84 #G #L #T2 #i #l #H elim (cpys_inv_lref1 … H) -H /2 width=1 by or_introl/
85 * >yminus_Y_inj /3 width=7 by or_intror, ex4_4_intro/
88 lemma cpys_inv_lref1_drop: ∀G,L,T2,i,l,m. ⦃G, L⦄ ⊢ #i ▶*[l, m] T2 →
89 ∀I,K,V1. ⬇[i] L ≡ K.ⓑ{I}V1 →
90 ∀V2. ⬆[O, i+1] V2 ≡ T2 →
91 ∧∧ ⦃G, K⦄ ⊢ V1 ▶*[0, ⫰(l+m-i)] V2
94 #G #L #T2 #i #l #m #H #I #K #V1 #HLK #V2 #HVT2 elim (cpys_inv_lref1 … H) -H
95 [ #H destruct elim (lift_inv_lref2_be … HVT2) -HVT2 -HLK /2 width=1 by ylt_inj/
96 | * #Z #Y #X1 #X2 #Hli #Hilm #HLY #HX12 #HXT2
97 lapply (lift_inj … HXT2 … HVT2) -T2 #H destruct
98 lapply (drop_mono … HLY … HLK) -L #H destruct
99 /2 width=1 by and3_intro/
103 (* Properties on relocation *************************************************)
105 lemma cpys_lift_le: ∀G,K,T1,T2,lt,mt. ⦃G, K⦄ ⊢ T1 ▶*[lt, mt] T2 →
106 ∀L,U1,s,l,m. lt + mt ≤ l → ⬇[s, l, m] L ≡ K →
107 ⬆[l, m] T1 ≡ U1 → ∀U2. ⬆[l, m] T2 ≡ U2 →
108 ⦃G, L⦄ ⊢ U1 ▶*[lt, mt] U2.
109 #G #K #T1 #T2 #lt #mt #H #L #U1 #s #l #m #Hlmtl #HLK #HTU1 @(cpys_ind … H) -T2
110 [ #U2 #H >(lift_mono … HTU1 … H) -H //
111 | -HTU1 #T #T2 #_ #HT2 #IHT #U2 #HTU2
112 elim (lift_total T l m) #U #HTU
113 lapply (IHT … HTU) -IHT #HU1
114 lapply (cpy_lift_le … HT2 … HLK HTU HTU2 ?) -HT2 -HLK -HTU -HTU2 /2 width=3 by cpys_strap1/
118 lemma cpys_lift_be: ∀G,K,T1,T2,lt,mt. ⦃G, K⦄ ⊢ T1 ▶*[lt, mt] T2 →
119 ∀L,U1,s,l,m. lt ≤ l → l ≤ lt + mt →
120 ⬇[s, l, m] L ≡ K → ⬆[l, m] T1 ≡ U1 →
121 ∀U2. ⬆[l, m] T2 ≡ U2 → ⦃G, L⦄ ⊢ U1 ▶*[lt, mt + m] U2.
122 #G #K #T1 #T2 #lt #mt #H #L #U1 #s #l #m #Hltl #Hllmt #HLK #HTU1 @(cpys_ind … H) -T2
123 [ #U2 #H >(lift_mono … HTU1 … H) -H //
124 | -HTU1 #T #T2 #_ #HT2 #IHT #U2 #HTU2
125 elim (lift_total T l m) #U #HTU
126 lapply (IHT … HTU) -IHT #HU1
127 lapply (cpy_lift_be … HT2 … HLK HTU HTU2 ? ?) -HT2 -HLK -HTU -HTU2 /2 width=3 by cpys_strap1/
131 lemma cpys_lift_ge: ∀G,K,T1,T2,lt,mt. ⦃G, K⦄ ⊢ T1 ▶*[lt, mt] T2 →
132 ∀L,U1,s,l,m. l ≤ lt → ⬇[s, l, m] L ≡ K →
133 ⬆[l, m] T1 ≡ U1 → ∀U2. ⬆[l, m] T2 ≡ U2 →
134 ⦃G, L⦄ ⊢ U1 ▶*[lt+m, mt] U2.
135 #G #K #T1 #T2 #lt #mt #H #L #U1 #s #l #m #Hllt #HLK #HTU1 @(cpys_ind … H) -T2
136 [ #U2 #H >(lift_mono … HTU1 … H) -H //
137 | -HTU1 #T #T2 #_ #HT2 #IHT #U2 #HTU2
138 elim (lift_total T l m) #U #HTU
139 lapply (IHT … HTU) -IHT #HU1
140 lapply (cpy_lift_ge … HT2 … HLK HTU HTU2 ?) -HT2 -HLK -HTU -HTU2 /2 width=3 by cpys_strap1/
144 (* Inversion lemmas for relocation ******************************************)
146 lemma cpys_inv_lift1_le: ∀G,L,U1,U2,lt,mt. ⦃G, L⦄ ⊢ U1 ▶*[lt, mt] U2 →
147 ∀K,s,l,m. ⬇[s, l, m] L ≡ K → ∀T1. ⬆[l, m] T1 ≡ U1 →
149 ∃∃T2. ⦃G, K⦄ ⊢ T1 ▶*[lt, mt] T2 & ⬆[l, m] T2 ≡ U2.
150 #G #L #U1 #U2 #lt #mt #H #K #s #l #m #HLK #T1 #HTU1 #Hlmtl @(cpys_ind … H) -U2
151 [ /2 width=3 by ex2_intro/
152 | -HTU1 #U #U2 #_ #HU2 * #T #HT1 #HTU
153 elim (cpy_inv_lift1_le … HU2 … HLK … HTU) -HU2 -HLK -HTU /3 width=3 by cpys_strap1, ex2_intro/
157 lemma cpys_inv_lift1_be: ∀G,L,U1,U2,lt,mt. ⦃G, L⦄ ⊢ U1 ▶*[lt, mt] U2 →
158 ∀K,s,l,m. ⬇[s, l, m] L ≡ K → ∀T1. ⬆[l, m] T1 ≡ U1 →
159 lt ≤ l → l + m ≤ lt + mt →
160 ∃∃T2. ⦃G, K⦄ ⊢ T1 ▶*[lt, mt - m] T2 & ⬆[l, m] T2 ≡ U2.
161 #G #L #U1 #U2 #lt #mt #H #K #s #l #m #HLK #T1 #HTU1 #Hltl #Hlmlmt @(cpys_ind … H) -U2
162 [ /2 width=3 by ex2_intro/
163 | -HTU1 #U #U2 #_ #HU2 * #T #HT1 #HTU
164 elim (cpy_inv_lift1_be … HU2 … HLK … HTU) -HU2 -HLK -HTU /3 width=3 by cpys_strap1, ex2_intro/
168 lemma cpys_inv_lift1_ge: ∀G,L,U1,U2,lt,mt. ⦃G, L⦄ ⊢ U1 ▶*[lt, mt] U2 →
169 ∀K,s,l,m. ⬇[s, l, m] L ≡ K → ∀T1. ⬆[l, m] T1 ≡ U1 →
171 ∃∃T2. ⦃G, K⦄ ⊢ T1 ▶*[lt - m, mt] T2 & ⬆[l, m] T2 ≡ U2.
172 #G #L #U1 #U2 #lt #mt #H #K #s #l #m #HLK #T1 #HTU1 #Hlmlt @(cpys_ind … H) -U2
173 [ /2 width=3 by ex2_intro/
174 | -HTU1 #U #U2 #_ #HU2 * #T #HT1 #HTU
175 elim (cpy_inv_lift1_ge … HU2 … HLK … HTU) -HU2 -HLK -HTU /3 width=3 by cpys_strap1, ex2_intro/
179 (* Advanced inversion lemmas on relocation **********************************)
181 lemma cpys_inv_lift1_ge_up: ∀G,L,U1,U2,lt,mt. ⦃G, L⦄ ⊢ U1 ▶*[lt, mt] U2 →
182 ∀K,s,l,m. ⬇[s, l, m] L ≡ K → ∀T1. ⬆[l, m] T1 ≡ U1 →
183 l ≤ lt → lt ≤ l + m → l + m ≤ lt + mt →
184 ∃∃T2. ⦃G, K⦄ ⊢ T1 ▶*[l, lt + mt - (l + m)] T2 &
186 #G #L #U1 #U2 #lt #mt #H #K #s #l #m #HLK #T1 #HTU1 #Hllt #Hltlm #Hlmlmt @(cpys_ind … H) -U2
187 [ /2 width=3 by ex2_intro/
188 | -HTU1 #U #U2 #_ #HU2 * #T #HT1 #HTU
189 elim (cpy_inv_lift1_ge_up … HU2 … HLK … HTU) -HU2 -HLK -HTU /3 width=3 by cpys_strap1, ex2_intro/
193 lemma cpys_inv_lift1_be_up: ∀G,L,U1,U2,lt,mt. ⦃G, L⦄ ⊢ U1 ▶*[lt, mt] U2 →
194 ∀K,s,l,m. ⬇[s, l, m] L ≡ K → ∀T1. ⬆[l, m] T1 ≡ U1 →
195 lt ≤ l → lt + mt ≤ l + m →
196 ∃∃T2. ⦃G, K⦄ ⊢ T1 ▶*[lt, l - lt] T2 & ⬆[l, m] T2 ≡ U2.
197 #G #L #U1 #U2 #lt #mt #H #K #s #l #m #HLK #T1 #HTU1 #Hltl #Hlmtlm @(cpys_ind … H) -U2
198 [ /2 width=3 by ex2_intro/
199 | -HTU1 #U #U2 #_ #HU2 * #T #HT1 #HTU
200 elim (cpy_inv_lift1_be_up … HU2 … HLK … HTU) -HU2 -HLK -HTU /3 width=3 by cpys_strap1, ex2_intro/
204 lemma cpys_inv_lift1_le_up: ∀G,L,U1,U2,lt,mt. ⦃G, L⦄ ⊢ U1 ▶*[lt, mt] U2 →
205 ∀K,s,l,m. ⬇[s, l, m] L ≡ K → ∀T1. ⬆[l, m] T1 ≡ U1 →
206 lt ≤ l → l ≤ lt + mt → lt + mt ≤ l + m →
207 ∃∃T2. ⦃G, K⦄ ⊢ T1 ▶*[lt, l - lt] T2 & ⬆[l, m] T2 ≡ U2.
208 #G #L #U1 #U2 #lt #mt #H #K #s #l #m #HLK #T1 #HTU1 #Hltl #Hllmt #Hlmtlm @(cpys_ind … H) -U2
209 [ /2 width=3 by ex2_intro/
210 | -HTU1 #U #U2 #_ #HU2 * #T #HT1 #HTU
211 elim (cpy_inv_lift1_le_up … HU2 … HLK … HTU) -HU2 -HLK -HTU /3 width=3 by cpys_strap1, ex2_intro/
215 lemma cpys_inv_lift1_subst: ∀G,L,W1,W2,l,m. ⦃G, L⦄ ⊢ W1 ▶*[l, m] W2 →
216 ∀K,V1,i. ⬇[i+1] L ≡ K → ⬆[O, i+1] V1 ≡ W1 →
217 l ≤ yinj i → i < l + m →
218 ∃∃V2. ⦃G, K⦄ ⊢ V1 ▶*[O, ⫰(l+m-i)] V2 & ⬆[O, i+1] V2 ≡ W2.
219 #G #L #W1 #W2 #l #m #HW12 #K #V1 #i #HLK #HVW1 #Hli #Hilm
220 elim (cpys_inv_lift1_ge_up … HW12 … HLK … HVW1 ? ? ?) //
221 >yplus_O1 <yplus_inj >yplus_SO2
222 [ >yminus_succ2 /2 width=3 by ex2_intro/
223 | /2 width=1 by ylt_fwd_le_succ1/
224 | /2 width=3 by yle_trans/