]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/relocation/lsuby.ma
75cc5ce57ca7d7c8dd7501b6a355523845b06cb9
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / relocation / lsuby.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 include "ground_2/ynat/ynat_plus.ma".
16 include "basic_2/notation/relations/extlrsubeq_4.ma".
17 include "basic_2/relocation/ldrop.ma".
18
19 (* LOCAL ENVIRONMENT REFINEMENT FOR EXTENDED SUBSTITUTION *******************)
20
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)
29 .
30
31 interpretation
32   "local environment refinement (extended substitution)"
33   'ExtLRSubEq L1 d e L2 = (lsuby d e L1 L2).
34
35 (* Basic properties *********************************************************)
36
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/
40 qed.
41
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/
45 qed.
46
47 lemma lsuby_refl: ∀L,d,e. L ⊑×[d, e] L.
48 #L elim L -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/
53 qed.
54
55 lemma lsuby_length: ∀L1,L2. |L2| ≤ |L1| → L1 ⊑×[yinj 0, yinj 0] L2.
56 #L1 elim L1 -L1
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/
61 ]
62 qed.
63
64 lemma lsuby_sym: ∀d,e,L1,L2. L1 ⊑×[d, e] L2 → |L1| = |L2| → L2 ⊑×[d, e] L1.
65 #d #e #L1 #L2 #H elim H -d -e -L1 -L2
66 [ #L1 #d #e #H >(length_inv_zero_dx … H) -L1 //
67 | /2 width=1 by lsuby_length/
68 | #I1 #I2 #L1 #L2 #V #e #_ #IHL12 #H lapply (injective_plus_l … H)
69   /3 width=1 by lsuby_pair/
70 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #_ #IHL12 #H lapply (injective_plus_l … H)
71   /3 width=1 by lsuby_succ/
72 ]
73 qed-.
74
75 (* Basic inversion lemmas ***************************************************)
76
77 fact lsuby_inv_atom1_aux: ∀L1,L2,d,e. L1 ⊑×[d, e] L2 → L1 = ⋆ → L2 = ⋆.
78 #L1 #L2 #d #e * -L1 -L2 -d -e //
79 [ #I1 #I2 #L1 #L2 #V1 #V2 #_ #H destruct
80 | #I1 #I2 #L1 #L2 #V #e #_ #H destruct
81 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #_ #H destruct
82 ]
83 qed-.
84
85 lemma lsuby_inv_atom1: ∀L2,d,e. ⋆ ⊑×[d, e] L2 → L2 = ⋆.
86 /2 width=5 by lsuby_inv_atom1_aux/ qed-.
87
88 fact lsuby_inv_zero1_aux: ∀L1,L2,d,e. L1 ⊑×[d, e] L2 →
89                           ∀J1,K1,W1. L1 = K1.ⓑ{J1}W1 → d = 0 → e = 0 →
90                           L2 = ⋆ ∨
91                           ∃∃J2,K2,W2. K1 ⊑×[0, 0] K2 & L2 = K2.ⓑ{J2}W2.
92 #L1 #L2 #d #e * -L1 -L2 -d -e /2 width=1 by or_introl/
93 [ #I1 #I2 #L1 #L2 #V1 #V2 #HL12 #J1 #K1 #W1 #H #_ #_ destruct
94   /3 width=5 by ex2_3_intro, or_intror/
95 | #I1 #I2 #L1 #L2 #V #e #_ #J1 #K1 #W1 #_ #_ #H
96   elim (ysucc_inv_O_dx … H)
97 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #_ #J1 #K1 #W1 #_ #H
98   elim (ysucc_inv_O_dx … H)
99 ]
100 qed-.
101
102 lemma lsuby_inv_zero1: ∀I1,K1,L2,V1. K1.ⓑ{I1}V1 ⊑×[0, 0] L2 →
103                        L2 = ⋆ ∨
104                        ∃∃I2,K2,V2. K1 ⊑×[0, 0] K2 & L2 = K2.ⓑ{I2}V2.
105 /2 width=9 by lsuby_inv_zero1_aux/ qed-.
106
107 fact lsuby_inv_pair1_aux: ∀L1,L2,d,e. L1 ⊑×[d, e] L2 →
108                           ∀J1,K1,W. L1 = K1.ⓑ{J1}W → d = 0 → 0 < e →
109                           L2 = ⋆ ∨
110                           ∃∃J2,K2. K1 ⊑×[0, ⫰e] K2 & L2 = K2.ⓑ{J2}W.
111 #L1 #L2 #d #e * -L1 -L2 -d -e /2 width=1 by or_introl/
112 [ #I1 #I2 #L1 #L2 #V1 #V2 #_ #J1 #K1 #W #_ #_ #H
113   elim (ylt_yle_false … H) //
114 | #I1 #I2 #L1 #L2 #V #e #HL12 #J1 #K1 #W #H #_ #_ destruct
115   /3 width=4 by ex2_2_intro, or_intror/
116 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #_ #J1 #K1 #W #_ #H
117   elim (ysucc_inv_O_dx … H)
118 ]
119 qed-.
120
121 lemma lsuby_inv_pair1: ∀I1,K1,L2,V,e. K1.ⓑ{I1}V ⊑×[0, e] L2 → 0 < e →
122                        L2 = ⋆ ∨
123                        ∃∃I2,K2. K1 ⊑×[0, ⫰e] K2 & L2 = K2.ⓑ{I2}V.
124 /2 width=6 by lsuby_inv_pair1_aux/ qed-.
125
126 fact lsuby_inv_succ1_aux: ∀L1,L2,d,e. L1 ⊑×[d, e] L2 →
127                           ∀J1,K1,W1. L1 = K1.ⓑ{J1}W1 → 0 < d →
128                           L2 = ⋆ ∨
129                           ∃∃J2,K2,W2. K1 ⊑×[⫰d, e] K2 & L2 = K2.ⓑ{J2}W2.
130 #L1 #L2 #d #e * -L1 -L2 -d -e /2 width=1 by or_introl/
131 [ #I1 #I2 #L1 #L2 #V1 #V2 #_ #J1 #K1 #W1 #_ #H
132   elim (ylt_yle_false … H) //
133 | #I1 #I2 #L1 #L2 #V #e #_ #J1 #K1 #W1 #_ #H
134   elim (ylt_yle_false … H) //
135 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #HL12 #J1 #K1 #W1 #H #_ destruct
136   /3 width=5 by ex2_3_intro, or_intror/
137 ]
138 qed-.
139
140 lemma lsuby_inv_succ1: ∀I1,K1,L2,V1,d,e. K1.ⓑ{I1}V1 ⊑×[d, e] L2 → 0 < d →
141                        L2 = ⋆ ∨
142                        ∃∃I2,K2,V2. K1 ⊑×[⫰d, e] K2 & L2 = K2.ⓑ{I2}V2.
143 /2 width=5 by lsuby_inv_succ1_aux/ qed-.
144
145 fact lsuby_inv_zero2_aux: ∀L1,L2,d,e. L1 ⊑×[d, e] L2 →
146                           ∀J2,K2,W2. L2 = K2.ⓑ{J2}W2 → d = 0 → e = 0 →
147                           ∃∃J1,K1,W1. K1 ⊑×[0, 0] K2 & L1 = K1.ⓑ{J1}W1.
148 #L1 #L2 #d #e * -L1 -L2 -d -e
149 [ #L1 #d #e #J2 #K2 #W1 #H destruct
150 | #I1 #I2 #L1 #L2 #V1 #V2 #HL12 #J2 #K2 #W2 #H #_ #_ destruct
151   /2 width=5 by ex2_3_intro/
152 | #I1 #I2 #L1 #L2 #V #e #_ #J2 #K2 #W2 #_ #_ #H
153   elim (ysucc_inv_O_dx … H)
154 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #_ #J2 #K2 #W2 #_ #H
155   elim (ysucc_inv_O_dx … H)
156 ]
157 qed-.
158
159 lemma lsuby_inv_zero2: ∀I2,K2,L1,V2. L1 ⊑×[0, 0] K2.ⓑ{I2}V2 →
160                        ∃∃I1,K1,V1. K1 ⊑×[0, 0] K2 & L1 = K1.ⓑ{I1}V1.
161 /2 width=9 by lsuby_inv_zero2_aux/ qed-.
162
163 fact lsuby_inv_pair2_aux: ∀L1,L2,d,e. L1 ⊑×[d, e] L2 →
164                           ∀J2,K2,W. L2 = K2.ⓑ{J2}W → d = 0 → 0 < e →
165                           ∃∃J1,K1. K1 ⊑×[0, ⫰e] K2 & L1 = K1.ⓑ{J1}W.
166 #L1 #L2 #d #e * -L1 -L2 -d -e
167 [ #L1 #d #e #J2 #K2 #W #H destruct
168 | #I1 #I2 #L1 #L2 #V1 #V2 #_ #J2 #K2 #W #_ #_ #H
169   elim (ylt_yle_false … H) //
170 | #I1 #I2 #L1 #L2 #V #e #HL12 #J2 #K2 #W #H #_ #_ destruct
171   /2 width=4 by ex2_2_intro/
172 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #_ #J2 #K2 #W #_ #H
173   elim (ysucc_inv_O_dx … H)
174 ]
175 qed-.
176
177 lemma lsuby_inv_pair2: ∀I2,K2,L1,V,e. L1 ⊑×[0, e] K2.ⓑ{I2}V → 0 < e →
178                        ∃∃I1,K1. K1 ⊑×[0, ⫰e] K2 & L1 = K1.ⓑ{I1}V.
179 /2 width=6 by lsuby_inv_pair2_aux/ qed-.
180
181 fact lsuby_inv_succ2_aux: ∀L1,L2,d,e. L1 ⊑×[d, e] L2 →
182                           ∀J2,K2,W2. L2 = K2.ⓑ{J2}W2 → 0 < d →
183                           ∃∃J1,K1,W1. K1 ⊑×[⫰d, e] K2 & L1 = K1.ⓑ{J1}W1.
184 #L1 #L2 #d #e * -L1 -L2 -d -e
185 [ #L1 #d #e #J2 #K2 #W2 #H destruct
186 | #I1 #I2 #L1 #L2 #V1 #V2 #_ #J2 #K2 #W2 #_ #H
187   elim (ylt_yle_false … H) //
188 | #I1 #I2 #L1 #L2 #V #e #_ #J2 #K1 #W2 #_ #H
189   elim (ylt_yle_false … H) //
190 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #HL12 #J2 #K2 #W2 #H #_ destruct
191   /2 width=5 by ex2_3_intro/
192 ]
193 qed-.
194
195 lemma lsuby_inv_succ2: ∀I2,K2,L1,V2,d,e. L1 ⊑×[d, e] K2.ⓑ{I2}V2 → 0 < d →
196                        ∃∃I1,K1,V1. K1 ⊑×[⫰d, e] K2 & L1 = K1.ⓑ{I1}V1.
197 /2 width=5 by lsuby_inv_succ2_aux/ qed-.
198
199 (* Basic forward lemmas *****************************************************)
200
201 lemma lsuby_fwd_length: ∀L1,L2,d,e. L1 ⊑×[d, e] L2 → |L2| ≤ |L1|.
202 #L1 #L2 #d #e #H elim H -L1 -L2 -d -e normalize /2 width=1 by le_S_S/
203 qed-.
204
205 lemma lsuby_fwd_ldrop2_be: ∀L1,L2,d,e. L1 ⊑×[d, e] L2 →
206                            ∀I2,K2,W,i. ⇩[0, i] L2 ≡ K2.ⓑ{I2}W →
207                            d ≤ i → i < d + e →
208                            ∃∃I1,K1. K1 ⊑×[0, ⫰(d+e-i)] K2 & ⇩[0, i] L1 ≡ K1.ⓑ{I1}W.
209 #L1 #L2 #d #e #H elim H -L1 -L2 -d -e
210 [ #L1 #d #e #J2 #K2 #W #i #H
211   elim (ldrop_inv_atom1 … H) -H #H destruct
212 | #I1 #I2 #L1 #L2 #V1 #V2 #_ #_ #J2 #K2 #W #i #_ #_ #H
213   elim (ylt_yle_false … H) //
214 | #I1 #I2 #L1 #L2 #V #e #HL12 #IHL12 #J2 #K2 #W #i #H #_ >yplus_O1
215   elim (ldrop_inv_O1_pair1 … H) -H * #Hi #HLK1 [ -IHL12 | -HL12 ]
216   [ #_ destruct -I2 >ypred_succ
217     /2 width=4 by ldrop_pair, ex2_2_intro/
218   | lapply (ylt_inv_O1 i ?) /2 width=1 by ylt_inj/
219     #H <H -H #H lapply (ylt_inv_succ … H) -H
220     #Hie elim (IHL12 … HLK1) -IHL12 -HLK1 // -Hie
221     >yminus_succ <yminus_inj /3 width=4 by ldrop_ldrop_lt, ex2_2_intro/
222   ]
223 | #I1 #I2 #L1 #L2 #V1 #V2 #d #e #_ #IHL12 #J2 #K2 #W #i #HLK2 #Hdi
224   elim (yle_inv_succ1 … Hdi) -Hdi
225   #Hdi #Hi <Hi >yplus_succ1 #H lapply (ylt_inv_succ … H) -H
226   #Hide lapply (ldrop_inv_ldrop1_lt … HLK2 ?) -HLK2 /2 width=1 by ylt_O/
227   #HLK1 elim (IHL12 … HLK1) -IHL12 -HLK1 <yminus_inj >yminus_SO2
228   /4 width=4 by ylt_O, ldrop_ldrop_lt, ex2_2_intro/
229 ]
230 qed-.