]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2A/substitution/drop_lreq.ma
update in lambdadelta
[helm.git] / matita / matita / contribs / lambdadelta / basic_2A / substitution / drop_lreq.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 "basic_2A/grammar/lreq_lreq.ma".
16 include "basic_2A/substitution/drop.ma".
17
18 (* BASIC SLICING FOR LOCAL ENVIRONMENTS *************************************)
19
20 definition dedropable_sn: predicate (relation lenv) ≝
21                           λR. ∀L1,K1,s,l,m. ⬇[s, l, m] L1 ≡ K1 → ∀K2. R K1 K2 →
22                           ∃∃L2. R L1 L2 & ⬇[s, l, m] L2 ≡ K2 & L1 ⩬[l, m] L2.
23
24 (* Properties on equivalence ************************************************)
25
26 lemma lreq_drop_trans_be: ∀L1,L2,l,m. L1 ⩬[l, m] L2 →
27                           ∀I,K2,W,s,i. ⬇[s, 0, i] L2 ≡ K2.ⓑ{I}W →
28                           l ≤ i → i < l + m →
29                           ∃∃K1. K1 ⩬[0, ⫰(l+m-i)] K2 & ⬇[s, 0, i] L1 ≡ K1.ⓑ{I}W.
30 #L1 #L2 #l #m #H elim H -L1 -L2 -l -m
31 [ #l #m #J #K2 #W #s #i #H
32   elim (drop_inv_atom1 … H) -H #H destruct
33 | #I1 #I2 #L1 #L2 #V1 #V2 #_ #_ #J #K2 #W #s #i #_ #_ #H
34   elim (ylt_yle_false … H) //
35 | #I #L1 #L2 #V #m #HL12 #IHL12 #J #K2 #W #s #i #H #_ >yplus_O1
36   elim (drop_inv_O1_pair1 … H) -H * #Hi #HLK1 [ -IHL12 | -HL12 ]
37   [ #_ destruct >ypred_succ
38     /2 width=3 by drop_pair, ex2_intro/
39   | lapply (ylt_inv_O1 i ?) /2 width=1 by ylt_inj/
40     #H <H -H #H lapply (ylt_inv_succ … H) -H
41     #Him elim (IHL12 … HLK1) -IHL12 -HLK1 // -Him
42     >yminus_succ <yminus_inj /3 width=3 by drop_drop_lt, ex2_intro/
43   ]
44 | #I1 #I2 #L1 #L2 #V1 #V2 #l #m #_ #IHL12 #J #K2 #W #s #i #HLK2 #Hli
45   elim (yle_inv_succ1 … Hli) -Hli
46   #Hli #Hi <Hi >yplus_succ1 #H lapply (ylt_inv_succ … H) -H
47   #Hilm lapply (drop_inv_drop1_lt … HLK2 ?) -HLK2 /2 width=1 by ylt_O/
48   #HLK1 elim (IHL12 … HLK1) -IHL12 -HLK1 <yminus_inj >yminus_SO2
49   /4 width=3 by ylt_O, drop_drop_lt, ex2_intro/
50 ]
51 qed-.
52
53 lemma lreq_drop_conf_be: ∀L1,L2,l,m. L1 ⩬[l, m] L2 →
54                          ∀I,K1,W,s,i. ⬇[s, 0, i] L1 ≡ K1.ⓑ{I}W →
55                          l ≤ i → i < l + m →
56                          ∃∃K2. K1 ⩬[0, ⫰(l+m-i)] K2 & ⬇[s, 0, i] L2 ≡ K2.ⓑ{I}W.
57 #L1 #L2 #l #m #HL12 #I #K1 #W #s #i #HLK1 #Hli #Hilm
58 elim (lreq_drop_trans_be … (lreq_sym … HL12) … HLK1) // -L1 -Hli -Hilm
59 /3 width=3 by lreq_sym, ex2_intro/
60 qed-.
61
62 lemma drop_O1_ex: ∀K2,i,L1. |L1| = |K2| + i →
63                   ∃∃L2. L1 ⩬[0, i] L2 & ⬇[i] L2 ≡ K2.
64 #K2 #i @(nat_ind_plus … i) -i
65 [ /3 width=3 by lreq_O2, ex2_intro/
66 | #i #IHi #Y #Hi elim (drop_O1_lt (Ⓕ) Y 0) //
67   #I #L1 #V #H lapply (drop_inv_O2 … H) -H #H destruct
68   normalize in Hi; elim (IHi L1) -IHi
69   /3 width=5 by drop_drop, lreq_pair, injective_plus_l, ex2_intro/
70 ]
71 qed-.
72
73 lemma dedropable_sn_TC: ∀R. dedropable_sn R → dedropable_sn (TC … R).
74 #R #HR #L1 #K1 #s #l #m #HLK1 #K2 #H elim H -K2
75 [ #K2 #HK12 elim (HR … HLK1 … HK12) -HR -K1
76   /3 width=4 by inj, ex3_intro/
77 | #K #K2 #_ #HK2 * #L #H1L1 #HLK #H2L1 elim (HR … HLK … HK2) -HR -K
78   /3 width=6 by lreq_trans, step, ex3_intro/
79 ]
80 qed-.
81
82 (* Inversion lemmas on equivalence ******************************************)
83
84 lemma drop_O1_inj: ∀i,L1,L2,K. ⬇[i] L1 ≡ K → ⬇[i] L2 ≡ K → L1 ⩬[i, ∞] L2.
85 #i @(nat_ind_plus … i) -i
86 [ #L1 #L2 #K #H <(drop_inv_O2 … H) -K #H <(drop_inv_O2 … H) -L1 //
87 | #i #IHi * [2: #L1 #I1 #V1 ] * [2,4: #L2 #I2 #V2 ] #K #HLK1 #HLK2 //
88   lapply (drop_fwd_length … HLK1)
89   <(drop_fwd_length … HLK2) [ /4 width=5 by drop_inv_drop1, lreq_succ/ ]
90   normalize <plus_n_Sm #H destruct
91 ]
92 qed-.