]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/substitution/drop.ma
parked material ...
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / substitution / drop.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/lib/lstar.ma".
16 include "basic_2/notation/relations/rdrop_5.ma".
17 include "basic_2/notation/relations/rdrop_4.ma".
18 include "basic_2/notation/relations/rdrop_3.ma".
19 include "basic_2/grammar/lenv_length.ma".
20 include "basic_2/grammar/cl_restricted_weight.ma".
21 include "basic_2/substitution/lift.ma".
22
23 (* BASIC SLICING FOR LOCAL ENVIRONMENTS *************************************)
24
25 (* Basic_1: includes: drop_skip_bind *)
26 inductive drop (s:bool): relation4 ynat nat lenv lenv ≝
27 | drop_atom: ∀l,m. (s = Ⓕ → m = 0) → drop s l m (⋆) (⋆)
28 | drop_pair: ∀I,L,V. drop s 0 0 (L.ⓑ{I}V) (L.ⓑ{I}V)
29 | drop_drop: ∀I,L1,L2,V,m. drop s 0 m L1 L2 → drop s 0 (m+1) (L1.ⓑ{I}V) L2
30 | drop_skip: ∀I,L1,L2,V1,V2,l,m.
31              drop s l m L1 L2 → ⬆[l, m] V2 ≡ V1 →
32              drop s (⫯l) m (L1.ⓑ{I}V1) (L2.ⓑ{I}V2)
33 .
34
35 interpretation
36    "basic slicing (local environment) abstract"
37    'RDrop s l m L1 L2 = (drop s l m L1 L2).
38 (*
39 interpretation
40    "basic slicing (local environment) general"
41    'RDrop d e L1 L2 = (drop true d e L1 L2).
42 *)
43 interpretation
44    "basic slicing (local environment) lget"
45    'RDrop m L1 L2 = (drop false (yinj O) m L1 L2).
46
47 definition d_liftable: predicate (lenv → relation term) ≝
48                        λR. ∀K,T1,T2. R K T1 T2 → ∀L,s,l,m. ⬇[s, l, m] L ≡ K →
49                        ∀U1. ⬆[l, m] T1 ≡ U1 → ∀U2. ⬆[l, m] T2 ≡ U2 → R L U1 U2.
50
51 definition d_deliftable_sn: predicate (lenv → relation term) ≝
52                             λR. ∀L,U1,U2. R L U1 U2 → ∀K,s,l,m. ⬇[s, l, m] L ≡ K →
53                             ∀T1. ⬆[l, m] T1 ≡ U1 →
54                             ∃∃T2. ⬆[l, m] T2 ≡ U2 & R K T1 T2.
55
56 definition dropable_sn: predicate (relation lenv) ≝
57                         λR. ∀L1,K1,s,l,m. ⬇[s, l, m] L1 ≡ K1 → ∀L2. R L1 L2 →
58                         ∃∃K2. R K1 K2 & ⬇[s, l, m] L2 ≡ K2.
59
60 definition dropable_dx: predicate (relation lenv) ≝
61                         λR. ∀L1,L2. R L1 L2 → ∀K2,s,m. ⬇[s, 0, m] L2 ≡ K2 →
62                         ∃∃K1. ⬇[s, 0, m] L1 ≡ K1 & R K1 K2.
63
64 (* Basic inversion lemmas ***************************************************)
65
66 fact drop_inv_atom1_aux: ∀L1,L2,s,l,m. ⬇[s, l, m] L1 ≡ L2 → L1 = ⋆ →
67                          L2 = ⋆ ∧ (s = Ⓕ → m = 0).
68 #L1 #L2 #s #l #m * -L1 -L2 -l -m
69 [ /3 width=1 by conj/
70 | #I #L #V #H destruct
71 | #I #L1 #L2 #V #m #_ #H destruct
72 | #I #L1 #L2 #V1 #V2 #l #m #_ #_ #H destruct
73 ]
74 qed-.
75
76 (* Basic_1: was: drop_gen_sort *)
77 lemma drop_inv_atom1: ∀L2,s,l,m. ⬇[s, l, m] ⋆ ≡ L2 → L2 = ⋆ ∧ (s = Ⓕ → m = 0).
78 /2 width=4 by drop_inv_atom1_aux/ qed-.
79
80 fact drop_inv_O1_pair1_aux: ∀L1,L2,s,l,m. ⬇[s, l, m] L1 ≡ L2 → l = yinj 0 →
81                             ∀K,I,V. L1 = K.ⓑ{I}V →
82                             (m = 0 ∧ L2 = K.ⓑ{I}V) ∨
83                             (0 < m ∧ ⬇[s, l, m-1] K ≡ L2).
84 #L1 #L2 #s #l #m * -L1 -L2 -l -m
85 [ #l #m #_ #_ #K #J #W #H destruct
86 | #I #L #V #_ #K #J #W #HX destruct /3 width=1 by or_introl, conj/
87 | #I #L1 #L2 #V #m #HL12 #_ #K #J #W #H destruct /3 width=1 by or_intror, conj/
88 | #I #L1 #L2 #V1 #V2 #l #m #_ #_ #H elim (ysucc_inv_O_dx … H)
89 ]
90 qed-.
91
92 lemma drop_inv_O1_pair1: ∀I,K,L2,V,s,m. ⬇[s, yinj 0, m] K. ⓑ{I} V ≡ L2 →
93                          (m = 0 ∧ L2 = K.ⓑ{I}V) ∨
94                          (0 < m ∧ ⬇[s, yinj 0, m-1] K ≡ L2).
95 /2 width=3 by drop_inv_O1_pair1_aux/ qed-.
96
97 lemma drop_inv_pair1: ∀I,K,L2,V,s. ⬇[s, 0, 0] K.ⓑ{I}V ≡ L2 → L2 = K.ⓑ{I}V.
98 #I #K #L2 #V #s #H
99 elim (drop_inv_O1_pair1 … H) -H * // #H destruct
100 elim (lt_refl_false … H)
101 qed-.
102
103 (* Basic_1: was: drop_gen_drop *)
104 lemma drop_inv_drop1_lt: ∀I,K,L2,V,s,m.
105                          ⬇[s, yinj 0, m] K.ⓑ{I}V ≡ L2 → 0 < m → ⬇[s, yinj 0, m-1] K ≡ L2.
106 #I #K #L2 #V #s #m #H #Hm
107 elim (drop_inv_O1_pair1 … H) -H * // #H destruct
108 elim (lt_refl_false … Hm)
109 qed-.
110
111 lemma drop_inv_drop1: ∀I,K,L2,V,s,m.
112                       ⬇[s, 0, m+1] K.ⓑ{I}V ≡ L2 → ⬇[s, 0, m] K ≡ L2.
113 #I #K #L2 #V #s #m #H lapply (drop_inv_drop1_lt … H ?) -H //
114 qed-.
115
116 fact drop_inv_skip1_aux: ∀L1,L2,s,l,m. ⬇[s, l, m] L1 ≡ L2 → 0 < l →
117                          ∀I,K1,V1. L1 = K1.ⓑ{I}V1 →
118                          ∃∃K2,V2. ⬇[s, ⫰l, m] K1 ≡ K2 &
119                                   ⬆[⫰l, m] V2 ≡ V1 &
120                                    L2 = K2.ⓑ{I}V2.
121 #L1 #L2 #s #l #m * -L1 -L2 -l -m
122 [ #l #m #_ #_ #J #K1 #W1 #H destruct
123 | #I #L #V #H elim (ylt_yle_false … H) -H //
124 | #I #L1 #L2 #V #m #_ #H elim (ylt_yle_false … H) -H //
125 | #I #L1 #L2 #V1 #V2 #l #m #HL12 #HV21 #_ #J #K1 #W1 #H destruct /2 width=5 by ex3_2_intro/
126 ]
127 qed-.
128
129 (* Basic_1: was: drop_gen_skip_l *)
130 lemma drop_inv_skip1: ∀I,K1,V1,L2,s,l,m. ⬇[s, l, m] K1.ⓑ{I}V1 ≡ L2 → 0 < l →
131                       ∃∃K2,V2. ⬇[s, ⫰l, m] K1 ≡ K2 &
132                                ⬆[⫰l, m] V2 ≡ V1 &
133                                L2 = K2.ⓑ{I}V2.
134 /2 width=3 by drop_inv_skip1_aux/ qed-.
135
136 lemma drop_inv_O1_pair2: ∀I,K,V,s,m,L1. ⬇[s, yinj 0, m] L1 ≡ K.ⓑ{I}V →
137                          (m = 0 ∧ L1 = K.ⓑ{I}V) ∨
138                          ∃∃I1,K1,V1. ⬇[s, yinj 0, m-1] K1 ≡ K.ⓑ{I}V & L1 = K1.ⓑ{I1}V1 & 0 < m.
139 #I #K #V #s #m *
140 [ #H elim (drop_inv_atom1 … H) -H #H destruct
141 | #L1 #I1 #V1 #H
142   elim (drop_inv_O1_pair1 … H) -H *
143   [ #H1 #H2 destruct /3 width=1 by or_introl, conj/
144   | /3 width=5 by ex3_3_intro, or_intror/
145   ]
146 ]
147 qed-.
148
149 fact drop_inv_skip2_aux: ∀L1,L2,s,l,m. ⬇[s, l, m] L1 ≡ L2 → 0 < l →
150                          ∀I,K2,V2. L2 = K2.ⓑ{I}V2 →
151                          ∃∃K1,V1. ⬇[s, ⫰l, m] K1 ≡ K2 &
152                                   ⬆[⫰l, m] V2 ≡ V1 &
153                                   L1 = K1.ⓑ{I}V1.
154 #L1 #L2 #s #l #m * -L1 -L2 -l -m
155 [ #l #m #_ #_ #J #K2 #W2 #H destruct
156 | #I #L #V #H elim (ylt_yle_false … H) -H //
157 | #I #L1 #L2 #V #m #_ #H elim (ylt_yle_false … H) -H //
158 | #I #L1 #L2 #V1 #V2 #l #m #HL12 #HV21 #_ #J #K2 #W2 #H destruct /2 width=5 by ex3_2_intro/
159 ]
160 qed-.
161
162 (* Basic_1: was: drop_gen_skip_r *)
163 lemma drop_inv_skip2: ∀I,L1,K2,V2,s,l,m. ⬇[s, l, m] L1 ≡ K2.ⓑ{I}V2 → 0 < l →
164                       ∃∃K1,V1. ⬇[s, ⫰l, m] K1 ≡ K2 & ⬆[⫰l, m] V2 ≡ V1 &
165                                L1 = K1.ⓑ{I}V1.
166 /2 width=3 by drop_inv_skip2_aux/ qed-.
167
168 lemma drop_inv_O1_gt: ∀L,K,m,s. ⬇[s, yinj 0, m] L ≡ K → |L| < m →
169                       s = Ⓣ ∧ K = ⋆.
170 #L elim L -L [| #L #Z #X #IHL ] #K #m #s #H normalize in ⊢ (?%?→?); #H1m
171 [ elim (drop_inv_atom1 … H) -H elim s -s /2 width=1 by conj/
172   #_ #Hs lapply (Hs ?) // -Hs #H destruct elim (lt_zero_false … H1m)
173 | elim (drop_inv_O1_pair1 … H) -H * #H2m #HLK destruct
174   [ elim (lt_zero_false … H1m)
175   | elim (IHL … HLK) -IHL -HLK /2 width=1 by lt_plus_to_minus_r, conj/
176   ]
177 ]
178 qed-.
179
180 lemma drop_inv_Y1: ∀L,K,m,s. ⬇[s, ∞, m] L ≡ K →
181                    L = K ∧ (s = Ⓕ → m = 0).
182 #L elim L -L
183 [ #Y #m #s #H elim (drop_inv_atom1 … H) -H /3 width=1 by conj/
184 | #L #I #V #IHL #Y #m #s #H elim (drop_inv_skip1 … H) -H //
185   #K #W #HLK #HWV #H destruct
186   lapply (lift_inv_Y1 … HWV) -HWV #H destruct
187   elim (IHL … HLK) -IHL -HLK /3 width=1 by conj/
188 ]
189 qed-.
190
191 (* Basic properties *********************************************************)
192
193 lemma drop_refl_atom_O2: ∀s,l. ⬇[s, l, O] ⋆ ≡ ⋆.
194 /2 width=1 by drop_atom/ qed.
195
196 lemma drop_Y1: ∀m,s. (s = Ⓕ → m = 0) → ∀L. ⬇[s, ∞, m] L ≡ L.
197 #m #s #H #L elim L -L /3 width=3 by drop_atom, drop_skip/
198 qed.
199
200 (* Basic_1: was by definition: drop_refl *)
201 lemma drop_refl: ∀L,l,s. ⬇[s, l, 0] L ≡ L.
202 #L elim L -L //
203 #L #I #V #IHL #x #s elim (ynat_cases x)
204 [ #H destruct //
205 | * #l #H destruct /2 width=1 by drop_skip/
206 ]
207 qed.
208
209 lemma drop_drop_lt: ∀I,L1,L2,V,s,m.
210                     ⬇[s, yinj 0, m-1] L1 ≡ L2 → 0 < m → ⬇[s, yinj 0, m] L1.ⓑ{I}V ≡ L2.
211 #I #L1 #L2 #V #s #m #HL12 #Hm >(plus_minus_m_m m 1) /2 width=1 by drop_drop/
212 qed.
213
214 lemma drop_skip_lt: ∀I,L1,L2,V1,V2,s,l,m.
215                     ⬇[s, ⫰l, m] L1 ≡ L2 → ⬆[⫰l, m] V2 ≡ V1 → 0 < l →
216                     ⬇[s, l, m] L1. ⓑ{I} V1 ≡ L2.ⓑ{I}V2.
217 #I #L1 #L2 #V1 #V2 #s #l #m #HL12 #HV21 #Hl <(ylt_inv_O1 … Hl) -Hl 
218 /2 width=1 by drop_skip/
219 qed.
220
221 lemma drop_O1_le: ∀s,m,L. m ≤ |L| → ∃K. ⬇[s, 0, m] L ≡ K.
222 #s #m @(nat_ind_plus … m) -m /2 width=2 by ex_intro/
223 #m #IHm *
224 [ #H elim (le_plus_xSy_O_false … H)
225 | #L #I #V normalize #H elim (IHm L) -IHm /3 width=2 by drop_drop, monotonic_pred, ex_intro/
226 ]
227 qed-.
228
229 lemma drop_O1_lt: ∀s,L,m. m < |L| → ∃∃I,K,V. ⬇[s, 0, m] L ≡ K.ⓑ{I}V.
230 #s #L elim L -L
231 [ #m #H elim (lt_zero_false … H)
232 | #L #I #V #IHL #m @(nat_ind_plus … m) -m /2 width=4 by drop_pair, ex1_3_intro/
233   #m #_ normalize #H elim (IHL m) -IHL /3 width=4 by drop_drop, lt_plus_to_minus_r, lt_plus_to_lt_l, ex1_3_intro/
234 ]
235 qed-.
236
237 lemma drop_O1_pair: ∀L,K,m,s. ⬇[s, yinj 0, m] L ≡ K → m ≤ |L| → ∀I,V.
238                     ∃∃J,W. ⬇[s, yinj 0, m] L.ⓑ{I}V ≡ K.ⓑ{J}W.
239 #L elim L -L [| #L #Z #X #IHL ] #K #m #s #H normalize #Hm #I #V
240 [ elim (drop_inv_atom1 … H) -H #H <(le_n_O_to_eq … Hm) -m
241   #Hs destruct /2 width=3 by ex1_2_intro/
242 | elim (drop_inv_O1_pair1 … H) -H * #Hm #HLK destruct /2 width=3 by ex1_2_intro/
243   elim (IHL … HLK … Z X) -IHL -HLK
244   /3 width=3 by drop_drop_lt, le_plus_to_minus, ex1_2_intro/
245 ]
246 qed-.
247
248 lemma drop_O1_ge: ∀L,m. |L| ≤ m → ⬇[Ⓣ, 0, m] L ≡ ⋆.
249 #L elim L -L [ #m #_ @drop_atom #H destruct ]
250 #L #I #V #IHL #m @(nat_ind_plus … m) -m [ #H elim (le_plus_xSy_O_false … H) ]
251 normalize /4 width=1 by drop_drop, monotonic_pred/
252 qed.
253
254 lemma drop_O1_eq: ∀L,s. ⬇[s, 0, |L|] L ≡ ⋆.
255 #L elim L -L /2 width=1 by drop_drop, drop_atom/
256 qed.
257
258 lemma drop_split: ∀L1,L2,l,m2,s. ⬇[s, l, m2] L1 ≡ L2 → ∀m1. m1 ≤ m2 →
259                   ∃∃L. ⬇[s, l, m2 - m1] L1 ≡ L & ⬇[s, l, m1] L ≡ L2.
260 #L1 #L2 #l #m2 #s #H elim H -L1 -L2 -l -m2
261 [ #l #m2 #Hs #m1 #Hm12 @(ex2_intro … (⋆))
262   @drop_atom #H lapply (Hs H) -s #H destruct /2 width=1 by le_n_O_to_eq/
263 | #I #L1 #V #m1 #Hm1 lapply (le_n_O_to_eq … Hm1) -Hm1
264   #H destruct /2 width=3 by ex2_intro/
265 | #I #L1 #L2 #V #m2 #HL12 #IHL12 #m1 @(nat_ind_plus … m1) -m1
266   [ /3 width=3 by drop_drop, ex2_intro/
267   | -HL12 #m1 #_ #Hm12 lapply (le_plus_to_le_r … Hm12) -Hm12
268     #Hm12 elim (IHL12 … Hm12) -IHL12 >minus_plus_plus_l
269     #L #HL1 #HL2 elim (lt_or_ge (|L1|) (m2-m1)) #H0
270     [ elim (drop_inv_O1_gt … HL1 H0) -HL1 #H1 #H2 destruct
271       elim (drop_inv_atom1 … HL2) -HL2 #H #_ destruct
272       @(ex2_intro … (⋆)) [ @drop_O1_ge normalize // ]
273       @drop_atom #H destruct
274     | elim (drop_O1_pair … HL1 H0 I V) -HL1 -H0 /3 width=5 by drop_drop, ex2_intro/
275     ]
276   ]
277 | #I #L1 #L2 #V1 #V2 #l #m2 #_ #HV21 #IHL12 #m1 #Hm12 elim (IHL12 … Hm12) -IHL12
278   #L #HL1 #HL2 elim (lift_split … HV21 l m1) -HV21 /3 width=5 by drop_skip, ex2_intro/
279 ]
280 qed-.
281
282 lemma drop_FT: ∀L1,L2,l,m. ⬇[Ⓕ, l, m] L1 ≡ L2 → ⬇[Ⓣ, l, m] L1 ≡ L2.
283 #L1 #L2 #l #m #H elim H -L1 -L2 -l -m
284 /3 width=1 by drop_atom, drop_drop, drop_skip/
285 qed.
286
287 lemma drop_gen: ∀L1,L2,s,l,m. ⬇[Ⓕ, l, m] L1 ≡ L2 → ⬇[s, l, m] L1 ≡ L2.
288 #L1 #L2 * /2 width=1 by drop_FT/
289 qed-.
290
291 lemma drop_T: ∀L1,L2,s,l,m. ⬇[s, l, m] L1 ≡ L2 → ⬇[Ⓣ, l, m] L1 ≡ L2.
292 #L1 #L2 * /2 width=1 by drop_FT/
293 qed-.
294
295 lemma d_liftable_LTC: ∀R. d_liftable R → d_liftable (LTC … R).
296 #R #HR #K #T1 #T2 #H elim H -T2
297 [ /3 width=10 by inj/
298 | #T #T2 #_ #HT2 #IHT1 #L #s #l #m #HLK #U1 #HTU1 #U2 #HTU2
299   elim (lift_total T l m) /4 width=12 by step/
300 ]
301 qed-.
302
303 lemma d_deliftable_sn_LTC: ∀R. d_deliftable_sn R → d_deliftable_sn (LTC … R).
304 #R #HR #L #U1 #U2 #H elim H -U2
305 [ #U2 #HU12 #K #s #l #m #HLK #T1 #HTU1
306   elim (HR … HU12 … HLK … HTU1) -HR -L -U1 /3 width=3 by inj, ex2_intro/
307 | #U #U2 #_ #HU2 #IHU1 #K #s #l #m #HLK #T1 #HTU1
308   elim (IHU1 … HLK … HTU1) -IHU1 -U1 #T #HTU #HT1
309   elim (HR … HU2 … HLK … HTU) -HR -L -U /3 width=5 by step, ex2_intro/
310 ]
311 qed-.
312
313 lemma dropable_sn_TC: ∀R. dropable_sn R → dropable_sn (TC … R).
314 #R #HR #L1 #K1 #s #l #m #HLK1 #L2 #H elim H -L2
315 [ #L2 #HL12 elim (HR … HLK1 … HL12) -HR -L1
316   /3 width=3 by inj, ex2_intro/
317 | #L #L2 #_ #HL2 * #K #HK1 #HLK elim (HR … HLK … HL2) -HR -L
318   /3 width=3 by step, ex2_intro/
319 ]
320 qed-.
321
322 lemma dropable_dx_TC: ∀R. dropable_dx R → dropable_dx (TC … R).
323 #R #HR #L1 #L2 #H elim H -L2
324 [ #L2 #HL12 #K2 #s #m #HLK2 elim (HR … HL12 … HLK2) -HR -L2
325   /3 width=3 by inj, ex2_intro/
326 | #L #L2 #_ #HL2 #IHL1 #K2 #s #m #HLK2 elim (HR … HL2 … HLK2) -HR -L2
327   #K #HLK #HK2 elim (IHL1 … HLK) -L
328   /3 width=5 by step, ex2_intro/
329 ]
330 qed-.
331
332 lemma d_deliftable_sn_llstar: ∀R. d_deliftable_sn R →
333                               ∀d. d_deliftable_sn (llstar … R d).
334 #R #HR #d #L #U1 #U2 #H @(lstar_ind_r … d U2 H) -d -U2
335 [ /2 width=3 by lstar_O, ex2_intro/
336 | #d #U #U2 #_ #HU2 #IHU1 #K #s #l #m #HLK #T1 #HTU1
337   elim (IHU1 … HLK … HTU1) -IHU1 -U1 #T #HTU #HT1
338   elim (HR … HU2 … HLK … HTU) -HR -L -U /3 width=5 by lstar_dx, ex2_intro/
339 ]
340 qed-.
341
342 (* Basic forward lemmas *****************************************************)
343
344 (* Basic_1: was: drop_S *)
345 lemma drop_fwd_drop2: ∀L1,I2,K2,V2,s,m. ⬇[s, O, m] L1 ≡ K2. ⓑ{I2} V2 →
346                       ⬇[s, O, m + 1] L1 ≡ K2.
347 #L1 elim L1 -L1
348 [ #I2 #K2 #V2 #s #m #H lapply (drop_inv_atom1 … H) -H * #H destruct
349 | #K1 #I1 #V1 #IHL1 #I2 #K2 #V2 #s #m #H
350   elim (drop_inv_O1_pair1 … H) -H * #Hm #H
351   [ -IHL1 destruct /2 width=1 by drop_drop/
352   | @drop_drop >(plus_minus_m_m m 1) /2 width=3 by/
353   ]
354 ]
355 qed-.
356
357 lemma drop_fwd_length_ge: ∀L1,L2,l,m,s. ⬇[s, l, m] L1 ≡ L2 → |L1| ≤ l → |L2| = |L1|.
358 #L1 #L2 #l #m #s #H elim H -L1 -L2 -l -m //
359 [ #I #L1 #L2 #V #m #_ #_ #H elim (ylt_yle_false … H) -H normalize //
360 | #I #L1 #L2 #V1 #V2 #l #m #_ #_ #IH <yplus_inj >yplus_SO2 #H
361   lapply (yle_inv_succ … H) -H #H normalize /3 width=1 by eq_f2/
362 ]
363 qed-.
364
365 lemma drop_fwd_length_le_le: ∀L1,L2,l,m,s. ⬇[s, l, m] L1 ≡ L2 → l ≤ |L1| → m ≤ |L1| - l → |L2| = |L1| - m.
366 #L1 #L2 #l #m #s #H elim H -L1 -L2 -l -m //
367 [ #I #L1 #L2 #V #m #_ <yplus_inj normalize #IH #_
368   >minus_plus_plus_l <yplus_inj >yplus_SO2 /3 width=1 by yle_inv_succ/
369 | #I #L1 #L2 #V1 #V2 #l #m #_ #_ #IHL12 <yplus_inj >yplus_SO2 #H
370   lapply (yle_inv_succ … H) -H #Hl1 >yminus_succ #Hml1 normalize
371   <plus_minus /3 width=3 by yle_trans, yle_inv_inj, eq_f2/
372 ]
373 qed-.
374
375 lemma drop_fwd_length_le_ge: ∀L1,L2,l,m,s. ⬇[s, l, m] L1 ≡ L2 → l ≤ |L1| → |L1| - l ≤ m → yinj (|L2|) = l.
376 #L1 #L2 #l #m #s #H elim H -L1 -L2 -l -m
377 [ #l #m #_ #H #_ normalize /2 width=1 by yle_inv_O2/
378 | #I #L #V #_ normalize <yplus_inj #H elim (ylt_yle_false … H) -H //
379 | #I #L1 #L2 #V #m #_ >yminus_inj >yminus_inj <minus_n_O <minus_n_O #IH #_ normalize
380   /3 width=2 by yle_inv_monotonic_plus_dx/
381 | #I #L1 #L2 #V1 #v2 #l #m #_ #_ #IH
382   <yplus_inj <yplus_inj >yplus_SO2 >yplus_SO2 >yminus_succ
383   /4 width=1 by yle_inv_succ, eq_f/
384 ]
385 qed-.
386
387 lemma drop_fwd_length: ∀L1,L2,l,m. ⬇[Ⓕ, l, m] L1 ≡ L2 → |L1| = |L2| + m.
388 #L1 #L2 #l #m #H elim H -L1 -L2 -l -m // normalize /2 width=1 by/
389 qed-.
390
391 lemma drop_fwd_length_minus2: ∀L1,L2,l,m. ⬇[Ⓕ, l, m] L1 ≡ L2 → |L2| = |L1| - m.
392 #L1 #L2 #l #m #H lapply (drop_fwd_length … H) -H /2 width=1 by plus_minus, le_n/
393 qed-.
394
395 lemma drop_fwd_length_minus4: ∀L1,L2,l,m. ⬇[Ⓕ, l, m] L1 ≡ L2 → m = |L1| - |L2|.
396 #L1 #L2 #l #m #H lapply (drop_fwd_length … H) -H //
397 qed-.
398
399 lemma drop_fwd_length_le2: ∀L1,L2,l,m. ⬇[Ⓕ, l, m] L1 ≡ L2 → m ≤ |L1|.
400 #L1 #L2 #l #m #H lapply (drop_fwd_length … H) -H //
401 qed-.
402
403 lemma drop_fwd_length_le4: ∀L1,L2,l,m. ⬇[Ⓕ, l, m] L1 ≡ L2 → |L2| ≤ |L1|.
404 #L1 #L2 #l #m #H lapply (drop_fwd_length … H) -H //
405 qed-.
406
407 lemma drop_fwd_length_lt2: ∀L1,I2,K2,V2,l,m.
408                            ⬇[Ⓕ, l, m] L1 ≡ K2. ⓑ{I2} V2 → m < |L1|.
409 #L1 #I2 #K2 #V2 #l #m #H
410 lapply (drop_fwd_length … H) normalize in ⊢ (%→?); -I2 -V2 //
411 qed-.
412
413 lemma drop_fwd_length_lt4: ∀L1,L2,l,m. ⬇[Ⓕ, l, m] L1 ≡ L2 → 0 < m → |L2| < |L1|.
414 #L1 #L2 #l #m #H lapply (drop_fwd_length … H) -H /2 width=1 by lt_minus_to_plus_r/
415 qed-.
416
417 lemma drop_fwd_length_eq1: ∀L1,L2,K1,K2,l,m. ⬇[Ⓕ, l, m] L1 ≡ K1 → ⬇[Ⓕ, l, m] L2 ≡ K2 →
418                            |L1| = |L2| → |K1| = |K2|.
419 #L1 #L2 #K1 #K2 #l #m #HLK1 #HLK2 #HL12
420 lapply (drop_fwd_length … HLK1) -HLK1
421 lapply (drop_fwd_length … HLK2) -HLK2
422 /2 width=2 by injective_plus_r/
423 qed-.
424
425 lemma drop_fwd_length_eq2: ∀L1,L2,K1,K2,l,m. ⬇[Ⓕ, l, m] L1 ≡ K1 → ⬇[Ⓕ, l, m] L2 ≡ K2 →
426                            |K1| = |K2| → |L1| = |L2|.
427 #L1 #L2 #K1 #K2 #l #m #HLK1 #HLK2 #HL12
428 lapply (drop_fwd_length … HLK1) -HLK1
429 lapply (drop_fwd_length … HLK2) -HLK2 //
430 qed-.
431
432 lemma drop_fwd_lw: ∀L1,L2,s,l,m. ⬇[s, l, m] L1 ≡ L2 → ♯{L2} ≤ ♯{L1}.
433 #L1 #L2 #s #l #m #H elim H -L1 -L2 -l -m // normalize
434 [ /2 width=3 by transitive_le/
435 | #I #L1 #L2 #V1 #V2 #l #m #_ #HV21 #IHL12
436   >(lift_fwd_tw … HV21) -HV21 /2 width=1 by monotonic_le_plus_l/
437 ]
438 qed-.
439
440 lemma drop_fwd_lw_lt: ∀L1,L2,l,m. ⬇[Ⓕ, l, m] L1 ≡ L2 → 0 < m → ♯{L2} < ♯{L1}.
441 #L1 #L2 #l #m #H elim H -L1 -L2 -l -m
442 [ #l #m #H >H -H //
443 | #I #L #V #H elim (lt_refl_false … H)
444 | #I #L1 #L2 #V #m #HL12 #_ #_
445   lapply (drop_fwd_lw … HL12) -HL12 #HL12
446   @(le_to_lt_to_lt … HL12) -HL12 //
447 | #I #L1 #L2 #V1 #V2 #l #m #_ #HV21 #IHL12 #H normalize in ⊢ (?%%); -I
448   >(lift_fwd_tw … HV21) -V2 /3 by lt_minus_to_plus/
449 ]
450 qed-.
451
452 lemma drop_fwd_rfw: ∀I,L,K,V,i. ⬇[i] L ≡ K.ⓑ{I}V → ∀T. ♯{K, V} < ♯{L, T}.
453 #I #L #K #V #i #HLK lapply (drop_fwd_lw … HLK) -HLK
454 normalize in ⊢ (%→?→?%%); /3 width=3 by le_to_lt_to_lt/
455 qed-.
456
457 (* Advanced inversion lemmas ************************************************)
458
459 fact drop_inv_O2_aux: ∀L1,L2,s,l,m. ⬇[s, l, m] L1 ≡ L2 → m = 0 → L1 = L2.
460 #L1 #L2 #s #l #m #H elim H -L1 -L2 -l -m
461 [ //
462 | //
463 | #I #L1 #L2 #V #m #_ #_ >commutative_plus normalize #H destruct
464 | #I #L1 #L2 #V1 #V2 #l #m #_ #HV21 #IHL12 #H
465   >(IHL12 H) -L1 >(lift_inv_O2_aux … HV21 … H) -V2 -l -m //
466 ]
467 qed-.
468
469 (* Basic_1: was: drop_gen_refl *)
470 lemma drop_inv_O2: ∀L1,L2,s,l. ⬇[s, l, 0] L1 ≡ L2 → L1 = L2.
471 /2 width=5 by drop_inv_O2_aux/ qed-.
472
473 lemma drop_inv_length_eq: ∀L1,L2,l,m. ⬇[Ⓕ, l, m] L1 ≡ L2 → |L1| = |L2| → m = 0.
474 #L1 #L2 #l #m #H #HL12 lapply (drop_fwd_length_minus4 … H) //
475 qed-.
476
477 lemma drop_inv_refl: ∀L,l,m. ⬇[Ⓕ, l, m] L ≡ L → m = 0.
478 /2 width=5 by drop_inv_length_eq/ qed-.
479
480 fact drop_inv_FT_aux: ∀L1,L2,s,l,m. ⬇[s, l, m] L1 ≡ L2 →
481                       ∀I,K,V. L2 = K.ⓑ{I}V → s = Ⓣ → l = 0 →
482                       ⬇[Ⓕ, l, m] L1 ≡ K.ⓑ{I}V.
483 #L1 #L2 #s #l #m #H elim H -L1 -L2 -l -m
484 [ #l #m #_ #J #K #W #H destruct
485 | #I #L #V #J #K #W #H destruct //
486 | #I #L1 #L2 #V #m #_ #IHL12 #J #K #W #H1 #H2 destruct
487   /3 width=1 by drop_drop/
488 | #I #L1 #L2 #V1 #V2 #l #m #_ #_ #_ #J #K #W #_ #_ #H
489   elim (ysucc_inv_O_dx … H)
490 ]
491 qed-.
492
493 lemma drop_inv_FT: ∀I,L,K,V,m. ⬇[Ⓣ, 0, m] L ≡ K.ⓑ{I}V → ⬇[m] L ≡ K.ⓑ{I}V.
494 /2 width=5 by drop_inv_FT_aux/ qed.
495
496 lemma drop_inv_gen: ∀I,L,K,V,s,m. ⬇[s, 0, m] L ≡ K.ⓑ{I}V → ⬇[m] L ≡ K.ⓑ{I}V.
497 #I #L #K #V * /2 width=1 by drop_inv_FT/
498 qed-.
499
500 lemma drop_inv_T: ∀I,L,K,V,s,m. ⬇[Ⓣ, 0, m] L ≡ K.ⓑ{I}V → ⬇[s, 0, m] L ≡ K.ⓑ{I}V.
501 #I #L #K #V * /2 width=1 by drop_inv_FT/
502 qed-.
503
504 (* Basic_1: removed theorems 50:
505             drop_ctail drop_skip_flat
506             cimp_flat_sx cimp_flat_dx cimp_bind cimp_getl_conf
507             drop_clear drop_clear_O drop_clear_S
508             clear_gen_sort clear_gen_bind clear_gen_flat clear_gen_flat_r
509             clear_gen_all clear_clear clear_mono clear_trans clear_ctail clear_cle
510             getl_ctail_clen getl_gen_tail clear_getl_trans getl_clear_trans
511             getl_clear_bind getl_clear_conf getl_dec getl_drop getl_drop_conf_lt
512             getl_drop_conf_ge getl_conf_ge_drop getl_drop_conf_rev
513             drop_getl_trans_lt drop_getl_trans_le drop_getl_trans_ge
514             getl_drop_trans getl_flt getl_gen_all getl_gen_sort getl_gen_O
515             getl_gen_S getl_gen_2 getl_gen_flat getl_gen_bind getl_conf_le
516             getl_trans getl_refl getl_head getl_flat getl_ctail getl_mono
517 *)