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 "basic_2/grammar/lenv_append.ma".
16 include "basic_2/substitution/drop.ma".
18 (* DROPPING *****************************************************************)
20 (* Properties on append for local environments ******************************)
22 fact drop_O1_append_sn_le_aux: ∀L1,L2,s,l,m. ⬇[s, l, m] L1 ≡ L2 →
23 l = yinj 0 → m ≤ |L1| →
24 ∀L. ⬇[s, yinj 0, m] L @@ L1 ≡ L @@ L2.
25 #L1 #L2 #s #l #m #H elim H -L1 -L2 -l -m //
26 [ #l #m #_ #_ #H <(le_n_O_to_eq … H) -H //
27 | normalize /4 width=1 by drop_drop, monotonic_pred/
28 | #I #L1 #L2 #V1 #V2 #l #m #_ #_ #_ #H elim (ysucc_inv_O_dx … H)
32 lemma drop_O1_append_sn_le: ∀L1,L2,s,m. ⬇[s, yinj 0, m] L1 ≡ L2 → m ≤ |L1| →
33 ∀L. ⬇[s, yinj 0, m] L @@ L1 ≡ L @@ L2.
34 /2 width=3 by drop_O1_append_sn_le_aux/ qed.
36 (* Inversion lemmas on append for local environments ************************)
38 lemma drop_O1_inv_append1_ge: ∀K,L1,L2,s,m. ⬇[s, yinj 0, m] L1 @@ L2 ≡ K →
39 |L2| ≤ m → ⬇[s, yinj 0, m - |L2|] L1 ≡ K.
40 #K #L1 #L2 elim L2 -L2 normalize //
41 #L2 #I #V #IHL2 #s #m #H #H1m
42 elim (drop_inv_O1_pair1 … H) -H * #H2m #HL12 destruct
43 [ lapply (le_n_O_to_eq … H1m) -H1m -IHL2 <plus_n_Sm #H destruct
44 | <minus_plus >minus_minus_comm /3 width=1 by monotonic_pred/
48 lemma drop_O1_inv_append1_le: ∀K,L1,L2,s,m. ⬇[s, yinj 0, m] L1 @@ L2 ≡ K → m ≤ |L2| →
49 ∀K2. ⬇[s, yinj 0, m] L2 ≡ K2 → K = L1 @@ K2.
50 #K #L1 #L2 elim L2 -L2 normalize
51 [ #s #m #H1 #H2 #K2 #H3 lapply (le_n_O_to_eq … H2) -H2
52 #H2 elim (drop_inv_atom1 … H3) -H3 #H3 #_ destruct
53 >(drop_inv_O2 … H1) -H1 //
54 | #L2 #I #V #IHL2 #s #m @(nat_ind_plus … m) -m [ -IHL2 ]
56 lapply (drop_inv_O2 … H1) -H1 #H1
57 lapply (drop_inv_O2 … H2) -H2 #H2 destruct //
58 | /4 width=7 by drop_inv_drop1, le_plus_to_le_r/