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/extlrsubeq_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 'ExtLRSubEq 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_refl: ∀L,d,e. L ⊑×[d, e] L.
49 #L #I #V #IHL #d elim (ynat_cases … d) [| * #x ]
50 #Hd destruct /2 width=1 by lsuby_succ/
51 #e elim (ynat_cases … e) [| * #x ]
52 #He destruct /2 width=1 by lsuby_zero, lsuby_pair/
55 lemma lsuby_length: ∀L1,L2. |L2| ≤ |L1| → L1 ⊑×[yinj 0, yinj 0] L2.
57 [ #X #H lapply (le_n_O_to_eq … H) -H
58 #H lapply (length_inv_zero_sn … H) #H destruct /2 width=1 by lsuby_atom/
59 | #L1 #I1 #V1 #IHL1 * normalize
60 /4 width=2 by lsuby_zero, le_S_S_to_le/
64 (* Basic inversion lemmas ***************************************************)
66 fact lsuby_inv_atom1_aux: ∀L1,L2,d,e. L1 ⊑×[d, e] L2 → L1 = ⋆ → L2 = ⋆.
67 #L1 #L2 #d #e * -L1 -L2 -d -e //
68 [ #I1 #I2 #L1 #L2 #V1 #V2 #_ #H destruct
69 | #I1 #I2 #L1 #L2 #V #e #_ #H destruct
70 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #_ #H destruct
74 lemma lsuby_inv_atom1: ∀L2,d,e. ⋆ ⊑×[d, e] L2 → L2 = ⋆.
75 /2 width=5 by lsuby_inv_atom1_aux/ qed-.
77 fact lsuby_inv_zero1_aux: ∀L1,L2,d,e. L1 ⊑×[d, e] L2 →
78 ∀J1,K1,W1. L1 = K1.ⓑ{J1}W1 → d = 0 → e = 0 →
80 ∃∃J2,K2,W2. K1 ⊑×[0, 0] K2 & L2 = K2.ⓑ{J2}W2.
81 #L1 #L2 #d #e * -L1 -L2 -d -e /2 width=1 by or_introl/
82 [ #I1 #I2 #L1 #L2 #V1 #V2 #HL12 #J1 #K1 #W1 #H #_ #_ destruct
83 /3 width=5 by ex2_3_intro, or_intror/
84 | #I1 #I2 #L1 #L2 #V #e #_ #J1 #K1 #W1 #_ #_ #H
85 elim (ysucc_inv_O_dx … H)
86 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #_ #J1 #K1 #W1 #_ #H
87 elim (ysucc_inv_O_dx … H)
91 lemma lsuby_inv_zero1: ∀I1,K1,L2,V1. K1.ⓑ{I1}V1 ⊑×[0, 0] L2 →
93 ∃∃I2,K2,V2. K1 ⊑×[0, 0] K2 & L2 = K2.ⓑ{I2}V2.
94 /2 width=9 by lsuby_inv_zero1_aux/ qed-.
96 fact lsuby_inv_pair1_aux: ∀L1,L2,d,e. L1 ⊑×[d, e] L2 →
97 ∀J1,K1,W. L1 = K1.ⓑ{J1}W → d = 0 → 0 < e →
99 ∃∃J2,K2. K1 ⊑×[0, ⫰e] K2 & L2 = K2.ⓑ{J2}W.
100 #L1 #L2 #d #e * -L1 -L2 -d -e /2 width=1 by or_introl/
101 [ #I1 #I2 #L1 #L2 #V1 #V2 #_ #J1 #K1 #W #_ #_ #H
102 elim (ylt_yle_false … H) //
103 | #I1 #I2 #L1 #L2 #V #e #HL12 #J1 #K1 #W #H #_ #_ destruct
104 /3 width=4 by ex2_2_intro, or_intror/
105 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #_ #J1 #K1 #W #_ #H
106 elim (ysucc_inv_O_dx … H)
110 lemma lsuby_inv_pair1: ∀I1,K1,L2,V,e. K1.ⓑ{I1}V ⊑×[0, e] L2 → 0 < e →
112 ∃∃I2,K2. K1 ⊑×[0, ⫰e] K2 & L2 = K2.ⓑ{I2}V.
113 /2 width=6 by lsuby_inv_pair1_aux/ qed-.
115 fact lsuby_inv_succ1_aux: ∀L1,L2,d,e. L1 ⊑×[d, e] L2 →
116 ∀J1,K1,W1. L1 = K1.ⓑ{J1}W1 → 0 < d →
118 ∃∃J2,K2,W2. K1 ⊑×[⫰d, e] K2 & L2 = K2.ⓑ{J2}W2.
119 #L1 #L2 #d #e * -L1 -L2 -d -e /2 width=1 by or_introl/
120 [ #I1 #I2 #L1 #L2 #V1 #V2 #_ #J1 #K1 #W1 #_ #H
121 elim (ylt_yle_false … H) //
122 | #I1 #I2 #L1 #L2 #V #e #_ #J1 #K1 #W1 #_ #H
123 elim (ylt_yle_false … H) //
124 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #HL12 #J1 #K1 #W1 #H #_ destruct
125 /3 width=5 by ex2_3_intro, or_intror/
129 lemma lsuby_inv_succ1: ∀I1,K1,L2,V1,d,e. K1.ⓑ{I1}V1 ⊑×[d, e] L2 → 0 < d →
131 ∃∃I2,K2,V2. K1 ⊑×[⫰d, e] K2 & L2 = K2.ⓑ{I2}V2.
132 /2 width=5 by lsuby_inv_succ1_aux/ qed-.
134 fact lsuby_inv_zero2_aux: ∀L1,L2,d,e. L1 ⊑×[d, e] L2 →
135 ∀J2,K2,W2. L2 = K2.ⓑ{J2}W2 → d = 0 → e = 0 →
136 ∃∃J1,K1,W1. K1 ⊑×[0, 0] K2 & L1 = K1.ⓑ{J1}W1.
137 #L1 #L2 #d #e * -L1 -L2 -d -e
138 [ #L1 #d #e #J2 #K2 #W1 #H destruct
139 | #I1 #I2 #L1 #L2 #V1 #V2 #HL12 #J2 #K2 #W2 #H #_ #_ destruct
140 /2 width=5 by ex2_3_intro/
141 | #I1 #I2 #L1 #L2 #V #e #_ #J2 #K2 #W2 #_ #_ #H
142 elim (ysucc_inv_O_dx … H)
143 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #_ #J2 #K2 #W2 #_ #H
144 elim (ysucc_inv_O_dx … H)
148 lemma lsuby_inv_zero2: ∀I2,K2,L1,V2. L1 ⊑×[0, 0] K2.ⓑ{I2}V2 →
149 ∃∃I1,K1,V1. K1 ⊑×[0, 0] K2 & L1 = K1.ⓑ{I1}V1.
150 /2 width=9 by lsuby_inv_zero2_aux/ qed-.
152 fact lsuby_inv_pair2_aux: ∀L1,L2,d,e. L1 ⊑×[d, e] L2 →
153 ∀J2,K2,W. L2 = K2.ⓑ{J2}W → d = 0 → 0 < e →
154 ∃∃J1,K1. K1 ⊑×[0, ⫰e] K2 & L1 = K1.ⓑ{J1}W.
155 #L1 #L2 #d #e * -L1 -L2 -d -e
156 [ #L1 #d #e #J2 #K2 #W #H destruct
157 | #I1 #I2 #L1 #L2 #V1 #V2 #_ #J2 #K2 #W #_ #_ #H
158 elim (ylt_yle_false … H) //
159 | #I1 #I2 #L1 #L2 #V #e #HL12 #J2 #K2 #W #H #_ #_ destruct
160 /2 width=4 by ex2_2_intro/
161 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #_ #J2 #K2 #W #_ #H
162 elim (ysucc_inv_O_dx … H)
166 lemma lsuby_inv_pair2: ∀I2,K2,L1,V,e. L1 ⊑×[0, e] K2.ⓑ{I2}V → 0 < e →
167 ∃∃I1,K1. K1 ⊑×[0, ⫰e] K2 & L1 = K1.ⓑ{I1}V.
168 /2 width=6 by lsuby_inv_pair2_aux/ qed-.
170 fact lsuby_inv_succ2_aux: ∀L1,L2,d,e. L1 ⊑×[d, e] L2 →
171 ∀J2,K2,W2. L2 = K2.ⓑ{J2}W2 → 0 < d →
172 ∃∃J1,K1,W1. K1 ⊑×[⫰d, e] K2 & L1 = K1.ⓑ{J1}W1.
173 #L1 #L2 #d #e * -L1 -L2 -d -e
174 [ #L1 #d #e #J2 #K2 #W2 #H destruct
175 | #I1 #I2 #L1 #L2 #V1 #V2 #_ #J2 #K2 #W2 #_ #H
176 elim (ylt_yle_false … H) //
177 | #I1 #I2 #L1 #L2 #V #e #_ #J2 #K1 #W2 #_ #H
178 elim (ylt_yle_false … H) //
179 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #HL12 #J2 #K2 #W2 #H #_ destruct
180 /2 width=5 by ex2_3_intro/
184 lemma lsuby_inv_succ2: ∀I2,K2,L1,V2,d,e. L1 ⊑×[d, e] K2.ⓑ{I2}V2 → 0 < d →
185 ∃∃I1,K1,V1. K1 ⊑×[⫰d, e] K2 & L1 = K1.ⓑ{I1}V1.
186 /2 width=5 by lsuby_inv_succ2_aux/ qed-.
188 (* Basic forward lemmas *****************************************************)
190 lemma lsuby_fwd_length: ∀L1,L2,d,e. L1 ⊑×[d, e] L2 → |L2| ≤ |L1|.
191 #L1 #L2 #d #e #H elim H -L1 -L2 -d -e normalize /2 width=1 by le_S_S/
194 lemma lsuby_fwd_ldrop2_be: ∀L1,L2,d,e. L1 ⊑×[d, e] L2 →
195 ∀I2,K2,W,i. ⇩[0, i] L2 ≡ K2.ⓑ{I2}W →
197 ∃∃I1,K1. K1 ⊑×[0, ⫰(d+e-i)] K2 & ⇩[0, i] L1 ≡ K1.ⓑ{I1}W.
198 #L1 #L2 #d #e #H elim H -L1 -L2 -d -e
199 [ #L1 #d #e #J2 #K2 #W #i #H
200 elim (ldrop_inv_atom1 … H) -H #H destruct
201 | #I1 #I2 #L1 #L2 #V1 #V2 #_ #_ #J2 #K2 #W #i #_ #_ #H
202 elim (ylt_yle_false … H) //
203 | #I1 #I2 #L1 #L2 #V #e #HL12 #IHL12 #J2 #K2 #W #i #H #_ >yplus_O1
204 elim (ldrop_inv_O1_pair1 … H) -H * #Hi #HLK1 [ -IHL12 | -HL12 ]
205 [ #_ destruct -I2 >ypred_succ
206 /2 width=4 by ldrop_pair, ex2_2_intro/
207 | lapply (ylt_inv_O1 i ?) /2 width=1 by ylt_inj/
208 #H <H -H #H lapply (ylt_inv_succ … H) -H
209 #Hie elim (IHL12 … HLK1) -IHL12 -HLK1 // -Hie
210 >yminus_succ <yminus_inj /3 width=4 by ldrop_ldrop_lt, ex2_2_intro/
212 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #_ #IHL12 #J2 #K2 #W #i #HLK2 #Hdi
213 elim (yle_inv_succ1 … Hdi) -Hdi
214 #Hdi #Hi <Hi >yplus_succ1 #H lapply (ylt_inv_succ … H) -H
215 #Hide lapply (ldrop_inv_ldrop1_lt … HLK2 ?) -HLK2 /2 width=1 by ylt_O/
216 #HLK1 elim (IHL12 … HLK1) -IHL12 -HLK1 <yminus_inj >yminus_SO2
217 /4 width=4 by ylt_O, ldrop_ldrop_lt, ex2_2_intro/