]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/substitution/ldrop.ma
- some refactoring and minor additions
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / substitution / ldrop.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 ldrop (s:bool): relation4 nat nat lenv lenv ≝
28 | ldrop_atom: ∀d,e. (s = Ⓕ → e = 0) → ldrop s d e (⋆) (⋆)
29 | ldrop_pair: ∀I,L,V. ldrop s 0 0 (L.ⓑ{I}V) (L.ⓑ{I}V)
30 | ldrop_drop: ∀I,L1,L2,V,e. ldrop s 0 e L1 L2 → ldrop s 0 (e+1) (L1.ⓑ{I}V) L2
31 | ldrop_skip: ∀I,L1,L2,V1,V2,d,e.
32               ldrop s d e L1 L2 → ⇧[d, e] V2 ≡ V1 →
33               ldrop 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 = (ldrop s d e L1 L2).
39 (*
40 interpretation
41    "basic slicing (local environment) general"
42    'RDrop d e L1 L2 = (ldrop true d e L1 L2).
43 *)
44 interpretation
45    "basic slicing (local environment) lget"
46    'RDrop e L1 L2 = (ldrop 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 ldrop_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 ldrop_inv_atom1: ∀L2,s,d,e. ⇩[s, d, e] ⋆ ≡ L2 → L2 = ⋆ ∧ (s = Ⓕ → e = 0).
79 /2 width=4 by ldrop_inv_atom1_aux/ qed-.
80
81 fact ldrop_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 ldrop_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 ldrop_inv_O1_pair1_aux/ qed-.
97
98 lemma ldrop_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 (ldrop_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 ldrop_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 (ldrop_inv_O1_pair1 … H) -H * // #H destruct
109 elim (lt_refl_false … He)
110 qed-.
111
112 lemma ldrop_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 (ldrop_inv_drop1_lt … H ?) -H //
115 qed-.
116
117 fact ldrop_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 ldrop_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 ldrop_inv_skip1_aux/ qed-.
136
137 lemma ldrop_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 (ldrop_inv_atom1 … H) -H #H destruct
142 | #L1 #I1 #V1 #H
143   elim (ldrop_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 ldrop_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 ldrop_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 ldrop_inv_skip2_aux/ qed-.
168
169 lemma ldrop_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 (ldrop_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 (ldrop_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 ldrop_refl_atom_O2: ∀s,d. ⇩[s, d, O] ⋆ ≡ ⋆.
184 /2 width=1 by ldrop_atom/ qed.
185
186 (* Basic_1: was by definition: drop_refl *)
187 lemma ldrop_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 ldrop_pair, ldrop_skip/
190 qed.
191
192 lemma ldrop_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 ldrop_drop/
195 qed.
196
197 lemma ldrop_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 ldrop_skip/
201 qed.
202
203 lemma ldrop_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 ldrop_drop, monotonic_pred, ex_intro/
208 ]
209 qed-.
210
211 lemma ldrop_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 ldrop_pair, ex1_3_intro/
215   #e #_ normalize #H elim (IHL e) -IHL /3 width=4 by ldrop_drop, lt_plus_to_minus_r, lt_plus_to_lt_l, ex1_3_intro/
216 ]
217 qed-.
218
219 lemma ldrop_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 (ldrop_inv_atom1 … H) -H #H <(le_n_O_to_eq … He) -e
223   #Hs destruct /2 width=3 by ex1_2_intro/
224 | elim (ldrop_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 ldrop_drop_lt, le_plus_to_minus, ex1_2_intro/
227 ]
228 qed-.
229
230 lemma ldrop_O1_ge: ∀L,e. |L| ≤ e → ⇩[Ⓣ, 0, e] L ≡ ⋆.
231 #L elim L -L [ #e #_ @ldrop_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 ldrop_drop, monotonic_pred/
234 qed.
235
236 lemma ldrop_split: ∀L1,L2,d,e2,s. ⇩[s, d, e2] L1 ≡ L2 → ∀e1. e1 ≤ e2 →
237                    ∃∃L. ⇩[s, d, e2 - e1] L1 ≡ L & ⇩[s, d, e1] L ≡ L2.
238 #L1 #L2 #d #e2 #s #H elim H -L1 -L2 -d -e2
239 [ #d #e2 #Hs #e1 #He12 @(ex2_intro … (⋆))
240   @ldrop_atom #H lapply (Hs H) -s #H destruct /2 width=1 by le_n_O_to_eq/
241 | #I #L1 #V #e1 #He1 lapply (le_n_O_to_eq … He1) -He1
242   #H destruct /2 width=3 by ex2_intro/
243 | #I #L1 #L2 #V #e2 #HL12 #IHL12 #e1 @(nat_ind_plus … e1) -e1
244   [ /3 width=3 by ldrop_drop, ex2_intro/
245   | -HL12 #e1 #_ #He12 lapply (le_plus_to_le_r … He12) -He12
246     #He12 elim (IHL12 … He12) -IHL12 >minus_plus_plus_l
247     #L #HL1 #HL2 elim (lt_or_ge (|L1|) (e2-e1)) #H0
248     [ elim (ldrop_inv_O1_gt … HL1 H0) -HL1 #H1 #H2 destruct
249       elim (ldrop_inv_atom1 … HL2) -HL2 #H #_ destruct
250       @(ex2_intro … (⋆)) [ @ldrop_O1_ge normalize // ]
251       @ldrop_atom #H destruct
252     | elim (ldrop_O1_pair … HL1 H0 I V) -HL1 -H0 /3 width=5 by ldrop_drop, ex2_intro/
253     ]
254   ]
255 | #I #L1 #L2 #V1 #V2 #d #e2 #_ #HV21 #IHL12 #e1 #He12 elim (IHL12 … He12) -IHL12
256   #L #HL1 #HL2 elim (lift_split … HV21 d e1) -HV21 /3 width=5 by ldrop_skip, ex2_intro/
257 ]
258 qed-.
259
260 lemma ldrop_FT: ∀L1,L2,d,e. ⇩[Ⓕ, d, e] L1 ≡ L2 → ⇩[Ⓣ, d, e] L1 ≡ L2.
261 #L1 #L2 #d #e #H elim H -L1 -L2 -d -e
262 /3 width=1 by ldrop_atom, ldrop_drop, ldrop_skip/
263 qed.
264
265 lemma ldrop_gen: ∀L1,L2,s,d,e. ⇩[Ⓕ, d, e] L1 ≡ L2 → ⇩[s, d, e] L1 ≡ L2.
266 #L1 #L2 * /2 width=1 by ldrop_FT/
267 qed-.
268
269 lemma ldrop_T: ∀L1,L2,s,d,e. ⇩[s, d, e] L1 ≡ L2 → ⇩[Ⓣ, d, e] L1 ≡ L2.
270 #L1 #L2 * /2 width=1 by ldrop_FT/
271 qed-.
272
273 lemma l_liftable_LTC: ∀R. l_liftable R → l_liftable (LTC … R).
274 #R #HR #K #T1 #T2 #H elim H -T2
275 [ /3 width=10 by inj/
276 | #T #T2 #_ #HT2 #IHT1 #L #s #d #e #HLK #U1 #HTU1 #U2 #HTU2
277   elim (lift_total T d e) /4 width=12 by step/
278 ]
279 qed-.
280
281 lemma l_deliftable_sn_LTC: ∀R. l_deliftable_sn R → l_deliftable_sn (LTC … R).
282 #R #HR #L #U1 #U2 #H elim H -U2
283 [ #U2 #HU12 #K #s #d #e #HLK #T1 #HTU1
284   elim (HR … HU12 … HLK … HTU1) -HR -L -U1 /3 width=3 by inj, ex2_intro/
285 | #U #U2 #_ #HU2 #IHU1 #K #s #d #e #HLK #T1 #HTU1
286   elim (IHU1 … HLK … HTU1) -IHU1 -U1 #T #HTU #HT1
287   elim (HR … HU2 … HLK … HTU) -HR -L -U /3 width=5 by step, ex2_intro/
288 ]
289 qed-.
290
291 lemma dropable_sn_TC: ∀R. dropable_sn R → dropable_sn (TC … R).
292 #R #HR #L1 #K1 #s #d #e #HLK1 #L2 #H elim H -L2
293 [ #L2 #HL12 elim (HR … HLK1 … HL12) -HR -L1
294   /3 width=3 by inj, ex2_intro/
295 | #L #L2 #_ #HL2 * #K #HK1 #HLK elim (HR … HLK … HL2) -HR -L
296   /3 width=3 by step, ex2_intro/
297 ]
298 qed-.
299
300 lemma dropable_dx_TC: ∀R. dropable_dx R → dropable_dx (TC … R).
301 #R #HR #L1 #L2 #H elim H -L2
302 [ #L2 #HL12 #K2 #s #e #HLK2 elim (HR … HL12 … HLK2) -HR -L2
303   /3 width=3 by inj, ex2_intro/
304 | #L #L2 #_ #HL2 #IHL1 #K2 #s #e #HLK2 elim (HR … HL2 … HLK2) -HR -L2
305   #K #HLK #HK2 elim (IHL1 … HLK) -L
306   /3 width=5 by step, ex2_intro/
307 ]
308 qed-.
309
310 lemma l_deliftable_sn_llstar: ∀R. l_deliftable_sn R →
311                               ∀l. l_deliftable_sn (llstar … R l).
312 #R #HR #l #L #U1 #U2 #H @(lstar_ind_r … l U2 H) -l -U2
313 [ /2 width=3 by lstar_O, ex2_intro/
314 | #l #U #U2 #_ #HU2 #IHU1 #K #s #d #e #HLK #T1 #HTU1
315   elim (IHU1 … HLK … HTU1) -IHU1 -U1 #T #HTU #HT1
316   elim (HR … HU2 … HLK … HTU) -HR -L -U /3 width=5 by lstar_dx, ex2_intro/
317 ]
318 qed-.
319
320 (* Basic forvard lemmas *****************************************************)
321
322 (* Basic_1: was: drop_S *)
323 lemma ldrop_fwd_drop2: ∀L1,I2,K2,V2,s,e. ⇩[s, O, e] L1 ≡ K2. ⓑ{I2} V2 →
324                        ⇩[s, O, e + 1] L1 ≡ K2.
325 #L1 elim L1 -L1
326 [ #I2 #K2 #V2 #s #e #H lapply (ldrop_inv_atom1 … H) -H * #H destruct
327 | #K1 #I1 #V1 #IHL1 #I2 #K2 #V2 #s #e #H
328   elim (ldrop_inv_O1_pair1 … H) -H * #He #H
329   [ -IHL1 destruct /2 width=1 by ldrop_drop/
330   | @ldrop_drop >(plus_minus_m_m e 1) /2 width=3 by/
331   ]
332 ]
333 qed-.
334
335 lemma ldrop_fwd_length_ge: ∀L1,L2,d,e,s. ⇩[s, d, e] L1 ≡ L2 → |L1| ≤ d → |L2| = |L1|.
336 #L1 #L2 #d #e #s #H elim H -L1 -L2 -d -e // normalize
337 [ #I #L1 #L2 #V #e #_ #_ #H elim (le_plus_xSy_O_false … H)
338 | /4 width=2 by le_plus_to_le_r, eq_f/
339 ]
340 qed-.
341
342 lemma ldrop_fwd_length_le_le: ∀L1,L2,d,e,s. ⇩[s, d, e] L1 ≡ L2 → d ≤ |L1| → e ≤ |L1| - d → |L2| = |L1| - e.
343 #L1 #L2 #d #e #s #H elim H -L1 -L2 -d -e // normalize
344 [ /3 width=2 by le_plus_to_le_r/
345 | #I #L1 #L2 #V1 #V2 #d #e #_ #_ #IHL12 >minus_plus_plus_l
346   #Hd #He lapply (le_plus_to_le_r … Hd) -Hd
347   #Hd >IHL12 // -L2 >plus_minus /2 width=3 by transitive_le/
348 ]
349 qed-.
350
351 lemma ldrop_fwd_length_le_ge: ∀L1,L2,d,e,s. ⇩[s, d, e] L1 ≡ L2 → d ≤ |L1| → |L1| - d ≤ e → |L2| = d.
352 #L1 #L2 #d #e #s #H elim H -L1 -L2 -d -e normalize
353 [ /2 width=1 by le_n_O_to_eq/
354 | #I #L #V #_ <minus_n_O #H elim (le_plus_xSy_O_false … H)
355 | /3 width=2 by le_plus_to_le_r/
356 | /4 width=2 by le_plus_to_le_r, eq_f/
357 ]
358 qed-.
359
360 lemma ldrop_fwd_length: ∀L1,L2,d,e. ⇩[Ⓕ, d, e] L1 ≡ L2 → |L1| = |L2| + e.
361 #L1 #L2 #d #e #H elim H -L1 -L2 -d -e // normalize /2 width=1 by/
362 qed-.
363
364 lemma ldrop_fwd_length_minus2: ∀L1,L2,d,e. ⇩[Ⓕ, d, e] L1 ≡ L2 → |L2| = |L1| - e.
365 #L1 #L2 #d #e #H lapply (ldrop_fwd_length … H) -H /2 width=1 by plus_minus, le_n/
366 qed-.
367
368 lemma ldrop_fwd_length_minus4: ∀L1,L2,d,e. ⇩[Ⓕ, d, e] L1 ≡ L2 → e = |L1| - |L2|.
369 #L1 #L2 #d #e #H lapply (ldrop_fwd_length … H) -H //
370 qed-.
371
372 lemma ldrop_fwd_length_le2: ∀L1,L2,d,e. ⇩[Ⓕ, d, e] L1 ≡ L2 → e ≤ |L1|.
373 #L1 #L2 #d #e #H lapply (ldrop_fwd_length … H) -H //
374 qed-.
375
376 lemma ldrop_fwd_length_le4: ∀L1,L2,d,e. ⇩[Ⓕ, d, e] L1 ≡ L2 → |L2| ≤ |L1|.
377 #L1 #L2 #d #e #H lapply (ldrop_fwd_length … H) -H //
378 qed-.
379
380 lemma ldrop_fwd_length_lt2: ∀L1,I2,K2,V2,d,e.
381                             ⇩[Ⓕ, d, e] L1 ≡ K2. ⓑ{I2} V2 → e < |L1|.
382 #L1 #I2 #K2 #V2 #d #e #H
383 lapply (ldrop_fwd_length … H) normalize in ⊢ (%→?); -I2 -V2 //
384 qed-.
385
386 lemma ldrop_fwd_length_lt4: ∀L1,L2,d,e. ⇩[Ⓕ, d, e] L1 ≡ L2 → 0 < e → |L2| < |L1|.
387 #L1 #L2 #d #e #H lapply (ldrop_fwd_length … H) -H /2 width=1 by lt_minus_to_plus_r/
388 qed-.
389
390 lemma ldrop_fwd_length_eq1: ∀L1,L2,K1,K2,d,e. ⇩[Ⓕ, d, e] L1 ≡ K1 → ⇩[Ⓕ, d, e] L2 ≡ K2 →
391                             |L1| = |L2| → |K1| = |K2|.
392 #L1 #L2 #K1 #K2 #d #e #HLK1 #HLK2 #HL12
393 lapply (ldrop_fwd_length … HLK1) -HLK1
394 lapply (ldrop_fwd_length … HLK2) -HLK2
395 /2 width=2 by injective_plus_r/
396 qed-.
397
398 lemma ldrop_fwd_length_eq2: ∀L1,L2,K1,K2,d,e. ⇩[Ⓕ, d, e] L1 ≡ K1 → ⇩[Ⓕ, d, e] L2 ≡ K2 →
399                             |K1| = |K2| → |L1| = |L2|.
400 #L1 #L2 #K1 #K2 #d #e #HLK1 #HLK2 #HL12
401 lapply (ldrop_fwd_length … HLK1) -HLK1
402 lapply (ldrop_fwd_length … HLK2) -HLK2 //
403 qed-.
404
405 lemma ldrop_fwd_lw: ∀L1,L2,s,d,e. ⇩[s, d, e] L1 ≡ L2 → ♯{L2} ≤ ♯{L1}.
406 #L1 #L2 #s #d #e #H elim H -L1 -L2 -d -e // normalize
407 [ /2 width=3 by transitive_le/
408 | #I #L1 #L2 #V1 #V2 #d #e #_ #HV21 #IHL12
409   >(lift_fwd_tw … HV21) -HV21 /2 width=1 by monotonic_le_plus_l/
410 ]
411 qed-.
412
413 lemma ldrop_fwd_lw_lt: ∀L1,L2,d,e. ⇩[Ⓕ, d, e] L1 ≡ L2 → 0 < e → ♯{L2} < ♯{L1}.
414 #L1 #L2 #d #e #H elim H -L1 -L2 -d -e
415 [ #d #e #H >H -H //
416 | #I #L #V #H elim (lt_refl_false … H)
417 | #I #L1 #L2 #V #e #HL12 #_ #_
418   lapply (ldrop_fwd_lw … HL12) -HL12 #HL12
419   @(le_to_lt_to_lt … HL12) -HL12 //
420 | #I #L1 #L2 #V1 #V2 #d #e #_ #HV21 #IHL12 #H normalize in ⊢ (?%%); -I
421   >(lift_fwd_tw … HV21) -V2 /3 by lt_minus_to_plus/
422 ]
423 qed-.
424
425 lemma ldrop_fwd_rfw: ∀I,L,K,V,i. ⇩[i] L ≡ K.ⓑ{I}V → ∀T. ♯{K, V} < ♯{L, T}.
426 #I #L #K #V #i #HLK lapply (ldrop_fwd_lw … HLK) -HLK
427 normalize in ⊢ (%→?→?%%); /3 width=3 by le_to_lt_to_lt/
428 qed-.
429
430 (* Advanced inversion lemmas ************************************************)
431
432 fact ldrop_inv_O2_aux: ∀L1,L2,s,d,e. ⇩[s, d, e] L1 ≡ L2 → e = 0 → L1 = L2.
433 #L1 #L2 #s #d #e #H elim H -L1 -L2 -d -e
434 [ //
435 | //
436 | #I #L1 #L2 #V #e #_ #_ >commutative_plus normalize #H destruct
437 | #I #L1 #L2 #V1 #V2 #d #e #_ #HV21 #IHL12 #H
438   >(IHL12 H) -L1 >(lift_inv_O2_aux … HV21 … H) -V2 -d -e //
439 ]
440 qed-.
441
442 (* Basic_1: was: drop_gen_refl *)
443 lemma ldrop_inv_O2: ∀L1,L2,s,d. ⇩[s, d, 0] L1 ≡ L2 → L1 = L2.
444 /2 width=5 by ldrop_inv_O2_aux/ qed-.
445
446 lemma ldrop_inv_length_eq: ∀L1,L2,d,e. ⇩[Ⓕ, d, e] L1 ≡ L2 → |L1| = |L2| → e = 0.
447 #L1 #L2 #d #e #H #HL12 lapply (ldrop_fwd_length_minus4 … H) //
448 qed-.
449
450 lemma ldrop_inv_refl: ∀L,d,e. ⇩[Ⓕ, d, e] L ≡ L → e = 0.
451 /2 width=5 by ldrop_inv_length_eq/ qed-.
452
453 fact ldrop_inv_FT_aux: ∀L1,L2,s,d,e. ⇩[s, d, e] L1 ≡ L2 →
454                        ∀I,K,V. L2 = K.ⓑ{I}V → s = Ⓣ → d = 0 →
455                        ⇩[Ⓕ, d, e] L1 ≡ K.ⓑ{I}V.
456 #L1 #L2 #s #d #e #H elim H -L1 -L2 -d -e
457 [ #d #e #_ #J #K #W #H destruct
458 | #I #L #V #J #K #W #H destruct //
459 | #I #L1 #L2 #V #e #_ #IHL12 #J #K #W #H1 #H2 destruct
460   /3 width=1 by ldrop_drop/
461 | #I #L1 #L2 #V1 #V2 #d #e #_ #_ #_ #J #K #W #_ #_
462   <plus_n_Sm #H destruct
463 ]
464 qed-.
465
466 lemma ldrop_inv_FT: ∀I,L,K,V,e. ⇩[Ⓣ, 0, e] L ≡ K.ⓑ{I}V → ⇩[e] L ≡ K.ⓑ{I}V.
467 /2 width=5 by ldrop_inv_FT_aux/ qed.
468
469 lemma ldrop_inv_gen: ∀I,L,K,V,s,e. ⇩[s, 0, e] L ≡ K.ⓑ{I}V → ⇩[e] L ≡ K.ⓑ{I}V.
470 #I #L #K #V * /2 width=1 by ldrop_inv_FT/
471 qed-.
472
473 lemma ldrop_inv_T: ∀I,L,K,V,s,e. ⇩[Ⓣ, 0, e] L ≡ K.ⓑ{I}V → ⇩[s, 0, e] L ≡ K.ⓑ{I}V.
474 #I #L #K #V * /2 width=1 by ldrop_inv_FT/
475 qed-.
476
477 (* Basic_1: removed theorems 50:
478             drop_ctail drop_skip_flat
479             cimp_flat_sx cimp_flat_dx cimp_bind cimp_getl_conf
480             drop_clear drop_clear_O drop_clear_S
481             clear_gen_sort clear_gen_bind clear_gen_flat clear_gen_flat_r
482             clear_gen_all clear_clear clear_mono clear_trans clear_ctail clear_cle
483             getl_ctail_clen getl_gen_tail clear_getl_trans getl_clear_trans
484             getl_clear_bind getl_clear_conf getl_dec getl_drop getl_drop_conf_lt
485             getl_drop_conf_ge getl_conf_ge_drop getl_drop_conf_rev
486             drop_getl_trans_lt drop_getl_trans_le drop_getl_trans_ge
487             getl_drop_trans getl_flt getl_gen_all getl_gen_sort getl_gen_O
488             getl_gen_S getl_gen_2 getl_gen_flat getl_gen_bind getl_conf_le
489             getl_trans getl_refl getl_head getl_flat getl_ctail getl_mono
490 *)