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/notation/relations/lrsubeq_4.ma".
16 include "basic_2/substitution/drop.ma".
18 (* LOCAL ENVIRONMENT REFINEMENT FOR EXTENDED SUBSTITUTION *******************)
20 inductive lsuby: relation4 ynat ynat lenv lenv ≝
21 | lsuby_atom: ∀L,l,m. lsuby l m L (⋆)
22 | lsuby_zero: ∀I1,I2,L1,L2,V1,V2.
23 lsuby 0 0 L1 L2 → lsuby 0 0 (L1.ⓑ{I1}V1) (L2.ⓑ{I2}V2)
24 | lsuby_pair: ∀I1,I2,L1,L2,V,m. lsuby 0 m L1 L2 →
25 lsuby 0 (⫯m) (L1.ⓑ{I1}V) (L2.ⓑ{I2}V)
26 | lsuby_succ: ∀I1,I2,L1,L2,V1,V2,l,m.
27 lsuby l m L1 L2 → lsuby (⫯l) m (L1.ⓑ{I1}V1) (L2.ⓑ{I2}V2)
31 "local environment refinement (extended substitution)"
32 'LRSubEq L1 l m L2 = (lsuby l m L1 L2).
34 (* Basic properties *********************************************************)
36 lemma lsuby_pair_lt: ∀I1,I2,L1,L2,V,m. L1 ⊆[0, ⫰m] L2 → 0 < m →
37 L1.ⓑ{I1}V ⊆[0, m] L2.ⓑ{I2}V.
38 #I1 #I2 #L1 #L2 #V #m #HL12 #Hm <(ylt_inv_O1 … Hm) /2 width=1 by lsuby_pair/
41 lemma lsuby_succ_lt: ∀I1,I2,L1,L2,V1,V2,l,m. L1 ⊆[⫰l, m] L2 → 0 < l →
42 L1.ⓑ{I1}V1 ⊆[l, m] L2. ⓑ{I2}V2.
43 #I1 #I2 #L1 #L2 #V1 #V2 #l #m #HL12 #Hl <(ylt_inv_O1 … Hl) /2 width=1 by lsuby_succ/
46 lemma lsuby_pair_O_Y: ∀L1,L2. L1 ⊆[0, ∞] L2 →
47 ∀I1,I2,V. L1.ⓑ{I1}V ⊆[0,∞] L2.ⓑ{I2}V.
48 #L1 #L2 #HL12 #I1 #I2 #V lapply (lsuby_pair I1 I2 … V … HL12) -HL12 //
51 lemma lsuby_refl: ∀L,l,m. L ⊆[l, m] L.
53 #L #I #V #IHL #l elim (ynat_cases … l) [| * #x ]
54 #Hl destruct /2 width=1 by lsuby_succ/
55 #m elim (ynat_cases … m) [| * #x ]
56 #Hm destruct /2 width=1 by lsuby_zero, lsuby_pair/
59 lemma lsuby_O2: ∀L2,L1,l. |L2| ≤ |L1| → L1 ⊆[l, 0] L2.
60 #L2 elim L2 -L2 // #L2 #I2 #V2 #IHL2 *
61 [ #l #H elim (ylt_yle_false … H) -H //
63 #H lapply (yle_inv_succ … H) -H #HL12
64 elim (ynat_cases l) /3 width=1 by lsuby_zero/
65 * /3 width=1 by lsuby_succ/
69 lemma lsuby_sym: ∀l,m,L1,L2. L1 ⊆[l, m] L2 → |L1| = |L2| → L2 ⊆[l, m] L1.
70 #l #m #L1 #L2 #H elim H -l -m -L1 -L2
71 [ #L1 #l #m #H >(length_inv_zero_dx … H) -L1 //
72 | /2 width=1 by lsuby_O2/
73 | #I1 #I2 #L1 #L2 #V #m #_ #IHL12 #H lapply (ysucc_inv_inj … H) -H
74 /3 width=1 by lsuby_pair/
75 | #I1 #I2 #L1 #L2 #V1 #V2 #l #m #_ #IHL12 #H lapply (ysucc_inv_inj … H) -H
76 /3 width=1 by lsuby_succ/
80 (* Basic inversion lemmas ***************************************************)
82 fact lsuby_inv_atom1_aux: ∀L1,L2,l,m. L1 ⊆[l, m] L2 → L1 = ⋆ → L2 = ⋆.
83 #L1 #L2 #l #m * -L1 -L2 -l -m //
84 [ #I1 #I2 #L1 #L2 #V1 #V2 #_ #H destruct
85 | #I1 #I2 #L1 #L2 #V #m #_ #H destruct
86 | #I1 #I2 #L1 #L2 #V1 #V2 #l #m #_ #H destruct
90 lemma lsuby_inv_atom1: ∀L2,l,m. ⋆ ⊆[l, m] L2 → L2 = ⋆.
91 /2 width=5 by lsuby_inv_atom1_aux/ qed-.
93 fact lsuby_inv_zero1_aux: ∀L1,L2,l,m. L1 ⊆[l, m] L2 →
94 ∀J1,K1,W1. L1 = K1.ⓑ{J1}W1 → l = 0 → m = 0 →
96 ∃∃J2,K2,W2. K1 ⊆[0, 0] K2 & L2 = K2.ⓑ{J2}W2.
97 #L1 #L2 #l #m * -L1 -L2 -l -m /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 #m #_ #J1 #K1 #W1 #_ #_ #H
101 elim (ysucc_inv_O_dx … H)
102 | #I1 #I2 #L1 #L2 #V1 #V2 #l #m #_ #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,l,m. L1 ⊆[l, m] L2 →
113 ∀J1,K1,W. L1 = K1.ⓑ{J1}W → l = 0 → 0 < m →
115 ∃∃J2,K2. K1 ⊆[0, ⫰m] K2 & L2 = K2.ⓑ{J2}W.
116 #L1 #L2 #l #m * -L1 -L2 -l -m /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 #m #HL12 #J1 #K1 #W #H #_ #_ destruct
120 /3 width=4 by ex2_2_intro, or_intror/
121 | #I1 #I2 #L1 #L2 #V1 #V2 #l #m #_ #J1 #K1 #W #_ #H
122 elim (ysucc_inv_O_dx … H)
126 lemma lsuby_inv_pair1: ∀I1,K1,L2,V,m. K1.ⓑ{I1}V ⊆[0, m] L2 → 0 < m →
128 ∃∃I2,K2. K1 ⊆[0, ⫰m] K2 & L2 = K2.ⓑ{I2}V.
129 /2 width=6 by lsuby_inv_pair1_aux/ qed-.
131 fact lsuby_inv_succ1_aux: ∀L1,L2,l,m. L1 ⊆[l, m] L2 →
132 ∀J1,K1,W1. L1 = K1.ⓑ{J1}W1 → 0 < l →
134 ∃∃J2,K2,W2. K1 ⊆[⫰l, m] K2 & L2 = K2.ⓑ{J2}W2.
135 #L1 #L2 #l #m * -L1 -L2 -l -m /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 #m #_ #J1 #K1 #W1 #_ #H
139 elim (ylt_yle_false … H) //
140 | #I1 #I2 #L1 #L2 #V1 #V2 #l #m #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,l,m. K1.ⓑ{I1}V1 ⊆[l, m] L2 → 0 < l →
147 ∃∃I2,K2,V2. K1 ⊆[⫰l, m] K2 & L2 = K2.ⓑ{I2}V2.
148 /2 width=5 by lsuby_inv_succ1_aux/ qed-.
150 fact lsuby_inv_zero2_aux: ∀L1,L2,l,m. L1 ⊆[l, m] L2 →
151 ∀J2,K2,W2. L2 = K2.ⓑ{J2}W2 → l = 0 → m = 0 →
152 ∃∃J1,K1,W1. K1 ⊆[0, 0] K2 & L1 = K1.ⓑ{J1}W1.
153 #L1 #L2 #l #m * -L1 -L2 -l -m
154 [ #L1 #l #m #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 #m #_ #J2 #K2 #W2 #_ #_ #H
158 elim (ysucc_inv_O_dx … H)
159 | #I1 #I2 #L1 #L2 #V1 #V2 #l #m #_ #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,l,m. L1 ⊆[l, m] L2 →
169 ∀J2,K2,W. L2 = K2.ⓑ{J2}W → l = 0 → 0 < m →
170 ∃∃J1,K1. K1 ⊆[0, ⫰m] K2 & L1 = K1.ⓑ{J1}W.
171 #L1 #L2 #l #m * -L1 -L2 -l -m
172 [ #L1 #l #m #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 #m #HL12 #J2 #K2 #W #H #_ #_ destruct
176 /2 width=4 by ex2_2_intro/
177 | #I1 #I2 #L1 #L2 #V1 #V2 #l #m #_ #J2 #K2 #W #_ #H
178 elim (ysucc_inv_O_dx … H)
182 lemma lsuby_inv_pair2: ∀I2,K2,L1,V,m. L1 ⊆[0, m] K2.ⓑ{I2}V → 0 < m →
183 ∃∃I1,K1. K1 ⊆[0, ⫰m] K2 & L1 = K1.ⓑ{I1}V.
184 /2 width=6 by lsuby_inv_pair2_aux/ qed-.
186 fact lsuby_inv_succ2_aux: ∀L1,L2,l,m. L1 ⊆[l, m] L2 →
187 ∀J2,K2,W2. L2 = K2.ⓑ{J2}W2 → 0 < l →
188 ∃∃J1,K1,W1. K1 ⊆[⫰l, m] K2 & L1 = K1.ⓑ{J1}W1.
189 #L1 #L2 #l #m * -L1 -L2 -l -m
190 [ #L1 #l #m #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 #m #_ #J2 #K1 #W2 #_ #H
194 elim (ylt_yle_false … H) //
195 | #I1 #I2 #L1 #L2 #V1 #V2 #l #m #HL12 #J2 #K2 #W2 #H #_ destruct
196 /2 width=5 by ex2_3_intro/
200 lemma lsuby_inv_succ2: ∀I2,K2,L1,V2,l,m. L1 ⊆[l, m] K2.ⓑ{I2}V2 → 0 < l →
201 ∃∃I1,K1,V1. K1 ⊆[⫰l, m] 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,l,m. L1 ⊆[l, m] L2 → |L2| ≤ |L1|.
207 #L1 #L2 #l #m #H elim H -L1 -L2 -l -m /2 width=1 by yle_succ/
210 (* Properties on basic slicing **********************************************)
212 lemma lsuby_drop_trans_be: ∀L1,L2,l,m. L1 ⊆[l, m] L2 →
213 ∀I2,K2,W,s,i. ⬇[s, 0, i] L2 ≡ K2.ⓑ{I2}W →
214 l ≤ i → ∀m0. i + ⫯m0 = l + m →
215 ∃∃I1,K1. K1 ⊆[0, m0] K2 & ⬇[s, 0, i] L1 ≡ K1.ⓑ{I1}W.
216 #L1 #L2 #l #m #H elim H -L1 -L2 -l -m
217 [ #L1 #l #m #J2 #K2 #W #s #i #H
218 elim (drop_inv_atom1 … H) -H #H destruct
219 | #I1 #I2 #L1 #L2 #V1 #V2 #_ #_ #J2 #K2 #W #s #i #_ #_ #m0
220 >yplus_O2 >yplus_succ2 #H elim (ysucc_inv_O_dx … H)
221 | #I1 #I2 #L1 #L2 #V #m #HL12 #IHL12 #J2 #K2 #W #s #i #H #_ #m0
222 >yplus_succ2 >yplus_succ2 #H0 lapply (ysucc_inv_inj … H0) -H0
223 elim (drop_inv_O1_pair1 … H) -H * #Hi #HLK1 [ -IHL12 | -HL12 ]
224 [ destruct -I2 /2 width=4 by drop_pair, ex2_2_intro/
225 | lapply (ylt_inv_O1 … Hi)
226 #H <H -H <yplus_succ_swap #Him elim (IHL12 … HLK1 … Him) -IHL12 -HLK1 -Him
227 /3 width=4 by drop_drop_lt, ex2_2_intro/
229 | #I1 #I2 #L1 #L2 #V1 #V2 #l #m #_ #IHL12 #J2 #K2 #W #s #i #HLK2 #Hli #m0
230 elim (yle_inv_succ1 … Hli) -Hli #Hli #Hi
231 lapply (drop_inv_drop1_lt … HLK2 ?) -HLK2 /2 width=1 by ylt_O1/ #HLK2
232 >yplus_succ1 >yplus_succ2 #H lapply (ysucc_inv_inj … H) -H
233 <Hi <yplus_succ_swap #H elim (IHL12 … HLK2 … H) -IHL12 -HLK2 -H
234 /3 width=4 by drop_drop, ex2_2_intro/