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 "ground_2/ynat/ynat_plus.ma".
16 include "basic_2/notation/relations/lrsubeq_4.ma".
17 include "basic_2/relocation/ldrop.ma".
19 (* LOCAL ENVIRONMENT REFINEMENT FOR EXTENDED SUBSTITUTION *******************)
21 inductive lsuby: relation4 ynat ynat lenv lenv ≝
22 | lsuby_atom: ∀L,d,e. lsuby d e L (⋆)
23 | lsuby_zero: ∀I1,I2,L1,L2,V1,V2.
24 lsuby 0 0 L1 L2 → lsuby 0 0 (L1.ⓑ{I1}V1) (L2.ⓑ{I2}V2)
25 | lsuby_pair: ∀I1,I2,L1,L2,V,e. lsuby 0 e L1 L2 →
26 lsuby 0 (⫯e) (L1.ⓑ{I1}V) (L2.ⓑ{I2}V)
27 | lsuby_succ: ∀I1,I2,L1,L2,V1,V2,d,e.
28 lsuby d e L1 L2 → lsuby (⫯d) e (L1.ⓑ{I1}V1) (L2.ⓑ{I2}V2)
32 "local environment refinement (extended substitution)"
33 'LRSubEq L1 d e L2 = (lsuby d e L1 L2).
35 (* Basic properties *********************************************************)
37 lemma lsuby_pair_lt: ∀I1,I2,L1,L2,V,e. L1 ⊆[0, ⫰e] L2 → 0 < e →
38 L1.ⓑ{I1}V ⊆[0, e] L2.ⓑ{I2}V.
39 #I1 #I2 #L1 #L2 #V #e #HL12 #He <(ylt_inv_O1 … He) /2 width=1 by lsuby_pair/
42 lemma lsuby_succ_lt: ∀I1,I2,L1,L2,V1,V2,d,e. L1 ⊆[⫰d, e] L2 → 0 < d →
43 L1.ⓑ{I1}V1 ⊆[d, e] L2. ⓑ{I2}V2.
44 #I1 #I2 #L1 #L2 #V1 #V2 #d #e #HL12 #Hd <(ylt_inv_O1 … Hd) /2 width=1 by lsuby_succ/
47 lemma lsuby_pair_O_Y: ∀L1,L2. L1 ⊆[0, ∞] L2 →
48 ∀I1,I2,V. L1.ⓑ{I1}V ⊆[0,∞] L2.ⓑ{I2}V.
49 #L1 #L2 #HL12 #I1 #I2 #V lapply (lsuby_pair I1 I2 … V … HL12) -HL12 //
52 lemma lsuby_refl: ∀L,d,e. L ⊆[d, e] L.
54 #L #I #V #IHL #d elim (ynat_cases … d) [| * #x ]
55 #Hd destruct /2 width=1 by lsuby_succ/
56 #e elim (ynat_cases … e) [| * #x ]
57 #He destruct /2 width=1 by lsuby_zero, lsuby_pair/
60 lemma lsuby_O2: ∀L2,L1,d. |L2| ≤ |L1| → L1 ⊆[d, yinj 0] L2.
61 #L2 elim L2 -L2 // #L2 #I2 #V2 #IHL2 * normalize
62 [ #d #H elim (le_plus_xSy_O_false … H)
63 | #L1 #I1 #V1 #d #H lapply (le_plus_to_le_r … H) -H #HL12
64 elim (ynat_cases d) /3 width=1 by lsuby_zero/
65 * /3 width=1 by lsuby_succ/
69 lemma lsuby_sym: ∀d,e,L1,L2. L1 ⊆[d, e] L2 → |L1| = |L2| → L2 ⊆[d, e] L1.
70 #d #e #L1 #L2 #H elim H -d -e -L1 -L2
71 [ #L1 #d #e #H >(length_inv_zero_dx … H) -L1 //
72 | /2 width=1 by lsuby_O2/
73 | #I1 #I2 #L1 #L2 #V #e #_ #IHL12 #H lapply (injective_plus_l … H)
74 /3 width=1 by lsuby_pair/
75 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #_ #IHL12 #H lapply (injective_plus_l … H)
76 /3 width=1 by lsuby_succ/
80 (* Basic inversion lemmas ***************************************************)
82 fact lsuby_inv_atom1_aux: ∀L1,L2,d,e. L1 ⊆[d, e] L2 → L1 = ⋆ → L2 = ⋆.
83 #L1 #L2 #d #e * -L1 -L2 -d -e //
84 [ #I1 #I2 #L1 #L2 #V1 #V2 #_ #H destruct
85 | #I1 #I2 #L1 #L2 #V #e #_ #H destruct
86 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #_ #H destruct
90 lemma lsuby_inv_atom1: ∀L2,d,e. ⋆ ⊆[d, e] L2 → L2 = ⋆.
91 /2 width=5 by lsuby_inv_atom1_aux/ qed-.
93 fact lsuby_inv_zero1_aux: ∀L1,L2,d,e. L1 ⊆[d, e] L2 →
94 ∀J1,K1,W1. L1 = K1.ⓑ{J1}W1 → d = 0 → e = 0 →
96 ∃∃J2,K2,W2. K1 ⊆[0, 0] K2 & L2 = K2.ⓑ{J2}W2.
97 #L1 #L2 #d #e * -L1 -L2 -d -e /2 width=1 by or_introl/
98 [ #I1 #I2 #L1 #L2 #V1 #V2 #HL12 #J1 #K1 #W1 #H #_ #_ destruct
99 /3 width=5 by ex2_3_intro, or_intror/
100 | #I1 #I2 #L1 #L2 #V #e #_ #J1 #K1 #W1 #_ #_ #H
101 elim (ysucc_inv_O_dx … H)
102 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #_ #J1 #K1 #W1 #_ #H
103 elim (ysucc_inv_O_dx … H)
107 lemma lsuby_inv_zero1: ∀I1,K1,L2,V1. K1.ⓑ{I1}V1 ⊆[0, 0] L2 →
109 ∃∃I2,K2,V2. K1 ⊆[0, 0] K2 & L2 = K2.ⓑ{I2}V2.
110 /2 width=9 by lsuby_inv_zero1_aux/ qed-.
112 fact lsuby_inv_pair1_aux: ∀L1,L2,d,e. L1 ⊆[d, e] L2 →
113 ∀J1,K1,W. L1 = K1.ⓑ{J1}W → d = 0 → 0 < e →
115 ∃∃J2,K2. K1 ⊆[0, ⫰e] K2 & L2 = K2.ⓑ{J2}W.
116 #L1 #L2 #d #e * -L1 -L2 -d -e /2 width=1 by or_introl/
117 [ #I1 #I2 #L1 #L2 #V1 #V2 #_ #J1 #K1 #W #_ #_ #H
118 elim (ylt_yle_false … H) //
119 | #I1 #I2 #L1 #L2 #V #e #HL12 #J1 #K1 #W #H #_ #_ destruct
120 /3 width=4 by ex2_2_intro, or_intror/
121 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #_ #J1 #K1 #W #_ #H
122 elim (ysucc_inv_O_dx … H)
126 lemma lsuby_inv_pair1: ∀I1,K1,L2,V,e. K1.ⓑ{I1}V ⊆[0, e] L2 → 0 < e →
128 ∃∃I2,K2. K1 ⊆[0, ⫰e] K2 & L2 = K2.ⓑ{I2}V.
129 /2 width=6 by lsuby_inv_pair1_aux/ qed-.
131 fact lsuby_inv_succ1_aux: ∀L1,L2,d,e. L1 ⊆[d, e] L2 →
132 ∀J1,K1,W1. L1 = K1.ⓑ{J1}W1 → 0 < d →
134 ∃∃J2,K2,W2. K1 ⊆[⫰d, e] K2 & L2 = K2.ⓑ{J2}W2.
135 #L1 #L2 #d #e * -L1 -L2 -d -e /2 width=1 by or_introl/
136 [ #I1 #I2 #L1 #L2 #V1 #V2 #_ #J1 #K1 #W1 #_ #H
137 elim (ylt_yle_false … H) //
138 | #I1 #I2 #L1 #L2 #V #e #_ #J1 #K1 #W1 #_ #H
139 elim (ylt_yle_false … H) //
140 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #HL12 #J1 #K1 #W1 #H #_ destruct
141 /3 width=5 by ex2_3_intro, or_intror/
145 lemma lsuby_inv_succ1: ∀I1,K1,L2,V1,d,e. K1.ⓑ{I1}V1 ⊆[d, e] L2 → 0 < d →
147 ∃∃I2,K2,V2. K1 ⊆[⫰d, e] K2 & L2 = K2.ⓑ{I2}V2.
148 /2 width=5 by lsuby_inv_succ1_aux/ qed-.
150 fact lsuby_inv_zero2_aux: ∀L1,L2,d,e. L1 ⊆[d, e] L2 →
151 ∀J2,K2,W2. L2 = K2.ⓑ{J2}W2 → d = 0 → e = 0 →
152 ∃∃J1,K1,W1. K1 ⊆[0, 0] K2 & L1 = K1.ⓑ{J1}W1.
153 #L1 #L2 #d #e * -L1 -L2 -d -e
154 [ #L1 #d #e #J2 #K2 #W1 #H destruct
155 | #I1 #I2 #L1 #L2 #V1 #V2 #HL12 #J2 #K2 #W2 #H #_ #_ destruct
156 /2 width=5 by ex2_3_intro/
157 | #I1 #I2 #L1 #L2 #V #e #_ #J2 #K2 #W2 #_ #_ #H
158 elim (ysucc_inv_O_dx … H)
159 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #_ #J2 #K2 #W2 #_ #H
160 elim (ysucc_inv_O_dx … H)
164 lemma lsuby_inv_zero2: ∀I2,K2,L1,V2. L1 ⊆[0, 0] K2.ⓑ{I2}V2 →
165 ∃∃I1,K1,V1. K1 ⊆[0, 0] K2 & L1 = K1.ⓑ{I1}V1.
166 /2 width=9 by lsuby_inv_zero2_aux/ qed-.
168 fact lsuby_inv_pair2_aux: ∀L1,L2,d,e. L1 ⊆[d, e] L2 →
169 ∀J2,K2,W. L2 = K2.ⓑ{J2}W → d = 0 → 0 < e →
170 ∃∃J1,K1. K1 ⊆[0, ⫰e] K2 & L1 = K1.ⓑ{J1}W.
171 #L1 #L2 #d #e * -L1 -L2 -d -e
172 [ #L1 #d #e #J2 #K2 #W #H destruct
173 | #I1 #I2 #L1 #L2 #V1 #V2 #_ #J2 #K2 #W #_ #_ #H
174 elim (ylt_yle_false … H) //
175 | #I1 #I2 #L1 #L2 #V #e #HL12 #J2 #K2 #W #H #_ #_ destruct
176 /2 width=4 by ex2_2_intro/
177 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #_ #J2 #K2 #W #_ #H
178 elim (ysucc_inv_O_dx … H)
182 lemma lsuby_inv_pair2: ∀I2,K2,L1,V,e. L1 ⊆[0, e] K2.ⓑ{I2}V → 0 < e →
183 ∃∃I1,K1. K1 ⊆[0, ⫰e] K2 & L1 = K1.ⓑ{I1}V.
184 /2 width=6 by lsuby_inv_pair2_aux/ qed-.
186 fact lsuby_inv_succ2_aux: ∀L1,L2,d,e. L1 ⊆[d, e] L2 →
187 ∀J2,K2,W2. L2 = K2.ⓑ{J2}W2 → 0 < d →
188 ∃∃J1,K1,W1. K1 ⊆[⫰d, e] K2 & L1 = K1.ⓑ{J1}W1.
189 #L1 #L2 #d #e * -L1 -L2 -d -e
190 [ #L1 #d #e #J2 #K2 #W2 #H destruct
191 | #I1 #I2 #L1 #L2 #V1 #V2 #_ #J2 #K2 #W2 #_ #H
192 elim (ylt_yle_false … H) //
193 | #I1 #I2 #L1 #L2 #V #e #_ #J2 #K1 #W2 #_ #H
194 elim (ylt_yle_false … H) //
195 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #HL12 #J2 #K2 #W2 #H #_ destruct
196 /2 width=5 by ex2_3_intro/
200 lemma lsuby_inv_succ2: ∀I2,K2,L1,V2,d,e. L1 ⊆[d, e] K2.ⓑ{I2}V2 → 0 < d →
201 ∃∃I1,K1,V1. K1 ⊆[⫰d, e] K2 & L1 = K1.ⓑ{I1}V1.
202 /2 width=5 by lsuby_inv_succ2_aux/ qed-.
204 (* Basic forward lemmas *****************************************************)
206 lemma lsuby_fwd_length: ∀L1,L2,d,e. L1 ⊆[d, e] L2 → |L2| ≤ |L1|.
207 #L1 #L2 #d #e #H elim H -L1 -L2 -d -e normalize /2 width=1 by le_S_S/
210 (* Properties on basic slicing **********************************************)
212 lemma lsuby_ldrop_trans_be: ∀L1,L2,d,e. L1 ⊆[d, e] L2 →
213 ∀I2,K2,W,s,i. ⇩[s, 0, i] L2 ≡ K2.ⓑ{I2}W →
215 ∃∃I1,K1. K1 ⊆[0, ⫰(d+e-i)] K2 & ⇩[s, 0, i] L1 ≡ K1.ⓑ{I1}W.
216 #L1 #L2 #d #e #H elim H -L1 -L2 -d -e
217 [ #L1 #d #e #J2 #K2 #W #s #i #H
218 elim (ldrop_inv_atom1 … H) -H #H destruct
219 | #I1 #I2 #L1 #L2 #V1 #V2 #_ #_ #J2 #K2 #W #s #i #_ #_ #H
220 elim (ylt_yle_false … H) //
221 | #I1 #I2 #L1 #L2 #V #e #HL12 #IHL12 #J2 #K2 #W #s #i #H #_ >yplus_O1
222 elim (ldrop_inv_O1_pair1 … H) -H * #Hi #HLK1 [ -IHL12 | -HL12 ]
223 [ #_ destruct -I2 >ypred_succ
224 /2 width=4 by ldrop_pair, ex2_2_intro/
225 | lapply (ylt_inv_O1 i ?) /2 width=1 by ylt_inj/
226 #H <H -H #H lapply (ylt_inv_succ … H) -H
227 #Hie elim (IHL12 … HLK1) -IHL12 -HLK1 // -Hie
228 >yminus_succ <yminus_inj /3 width=4 by ldrop_drop_lt, ex2_2_intro/
230 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #_ #IHL12 #J2 #K2 #W #s #i #HLK2 #Hdi
231 elim (yle_inv_succ1 … Hdi) -Hdi
232 #Hdi #Hi <Hi >yplus_succ1 #H lapply (ylt_inv_succ … H) -H
233 #Hide lapply (ldrop_inv_drop1_lt … HLK2 ?) -HLK2 /2 width=1 by ylt_O/
234 #HLK1 elim (IHL12 … HLK1) -IHL12 -HLK1 <yminus_inj >yminus_SO2
235 /4 width=4 by ylt_O, ldrop_drop_lt, ex2_2_intro/