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