]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/relocation/ldrop_ldrop.ma
ce3326a9d19759daf05179eefa3ba6e0c2b089e8
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / relocation / ldrop_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 "basic_2/relocation/lift_lift.ma".
16 include "basic_2/relocation/ldrop.ma".
17
18 (* BASIC SLICING FOR LOCAL ENVIRONMENTS *************************************)
19
20 (* Main properties **********************************************************)
21
22 (* Basic_1: was: drop_mono *)
23 theorem ldrop_mono: ∀d,e,L,L1. ⇩[d, e] L ≡ L1 →
24                     ∀L2. ⇩[d, e] L ≡ L2 → L1 = L2.
25 #d #e #L #L1 #H elim H -d -e -L -L1
26 [ #d #L2 #H elim (ldrop_inv_atom1 … H) -H //
27 | #K #I #V #L2 #HL12 <(ldrop_inv_O2 … HL12) -L2 //
28 | #L #K #I #V #e #_ #IHLK #L2 #H
29   lapply (ldrop_inv_ldrop1 … H) -H /2 width=1 by/
30 | #L #K1 #I #T #V1 #d #e #_ #HVT1 #IHLK1 #X #H
31   elim (ldrop_inv_skip1 … H) -H // <minus_plus_m_m #K2 #V2 #HLK2 #HVT2 #H destruct
32   >(lift_inj … HVT1 … HVT2) -HVT1 -HVT2
33   >(IHLK1 … HLK2) -IHLK1 -HLK2 //
34 ]
35 qed-.
36
37 (* Basic_1: was: drop_conf_ge *)
38 theorem ldrop_conf_ge: ∀d1,e1,L,L1. ⇩[d1, e1] L ≡ L1 →
39                        ∀e2,L2. ⇩[0, e2] L ≡ L2 → d1 + e1 ≤ e2 →
40                        ⇩[0, e2 - e1] L1 ≡ L2.
41 #d1 #e1 #L #L1 #H elim H -d1 -e1 -L -L1 //
42 [ #L #K #I #V #e #_ #IHLK #e2 #L2 #H #He2
43   lapply (ldrop_inv_ldrop1_lt … H ?) -H /2 width=2 by ltn_to_ltO/ #HL2
44   <minus_plus >minus_minus_comm /3 width=1 by monotonic_pred/
45 | #L #K #I #V1 #V2 #d #e #_ #_ #IHLK #e2 #L2 #H #Hdee2
46   lapply (transitive_le 1 … Hdee2) // #He2
47   lapply (ldrop_inv_ldrop1_lt … H ?) -H // -He2 #HL2
48   lapply (transitive_le (1 + e) … Hdee2) // #Hee2
49   @ldrop_ldrop_lt >minus_minus_comm /3 width=1 by O, lt_minus_to_plus_r, monotonic_le_minus_r, monotonic_pred/ (**) (* explicit constructor *)
50 ]
51 qed.
52
53 (* Note: apparently this was missing in basic_1 *)
54 theorem ldrop_conf_be: ∀L0,L1,d1,e1. ⇩[d1, e1] L0 ≡ L1 →
55                        ∀L2,e2. ⇩[0, e2] L0 ≡ L2 → d1 ≤ e2 → e2 ≤ d1 + e1 →
56                        ∃∃L. ⇩[0, d1 + e1 - e2] L2 ≡ L & ⇩[0, d1] L1 ≡ L.
57 #L0 #L1 #d1 #e1 #H elim H -L0 -L1 -d1 -e1
58 [ #d1 #L2 #e2 #H #Hd1 #_ elim (ldrop_inv_atom1 … H) -H #H1 #H2 destruct
59   <(le_n_O_to_eq … Hd1) -d1 /2 width=3 by ldrop_atom, ex2_intro/
60 | normalize #L #I #V #L2 #e2 #HL2 #_ #He2
61   lapply (le_n_O_to_eq … He2) -He2 #H destruct
62   lapply (ldrop_inv_O2 … HL2) -HL2 #H destruct /2 width=3 by ldrop_pair, ex2_intro/
63 | normalize #L0 #K0 #I #V1 #e1 #HLK0 #IHLK0 #L2 #e2 #H #_ #He21
64   lapply (ldrop_inv_O1_pair1 … H) -H * * #He2 #HL20
65   [ -IHLK0 -He21 destruct <minus_n_O /3 width=3 by ldrop_ldrop, ex2_intro/
66   | -HLK0 <minus_le_minus_minus_comm //
67     elim (IHLK0 … HL20) -L0 /2 width=3 by monotonic_pred, ex2_intro/
68   ]
69 | #L0 #K0 #I #V0 #V1 #d1 #e1 >plus_plus_comm_23 #_ #_ #IHLK0 #L2 #e2 #H #Hd1e2 #He2de1
70   elim (le_inv_plus_l … Hd1e2) #_ #He2
71   <minus_le_minus_minus_comm //
72   lapply (ldrop_inv_ldrop1_lt … H ?) -H // #HL02
73   elim (IHLK0 … HL02) -L0 /3 width=3 by ldrop_ldrop, monotonic_pred, ex2_intro/
74 ]
75 qed.
76
77 (* Note: apparently this was missing in basic_1 *)
78 theorem ldrop_conf_le: ∀L0,L1,d1,e1. ⇩[d1, e1] L0 ≡ L1 →
79                        ∀L2,e2. ⇩[0, e2] L0 ≡ L2 → e2 ≤ d1 →
80                        ∃∃L. ⇩[0, e2] L1 ≡ L & ⇩[d1 - e2, e1] L2 ≡ L.
81 #L0 #L1 #d1 #e1 #H elim H -L0 -L1 -d1 -e1
82 [ #d1 #L2 #e2 #H
83   elim (ldrop_inv_atom1 … H) -H #H destruct /2 width=3 by ldrop_atom, ex2_intro/
84 | #K0 #I #V0 #L2 #e2 #H1 #H2
85   lapply (le_n_O_to_eq … H2) -H2 #H destruct
86   lapply (ldrop_inv_pair1 … H1) -H1 #H destruct /2 width=3 by ldrop_pair, ex2_intro/
87 | #K0 #K1 #I #V0 #e1 #HK01 #_ #L2 #e2 #H1 #H2
88   lapply (le_n_O_to_eq … H2) -H2 #H destruct
89   lapply (ldrop_inv_pair1 … H1) -H1 #H destruct /3 width=3 by ldrop_ldrop, ex2_intro/
90 | #K0 #K1 #I #V0 #V1 #d1 #e1 #HK01 #HV10 #IHK01 #L2 #e2 #H #He2d1
91   elim (ldrop_inv_O1_pair1 … H) -H *
92   [ -IHK01 -He2d1 #H1 #H2 destruct /3 width=5 by ldrop_pair, ldrop_skip, ex2_intro/
93   | -HK01 -HV10 #He2 #HK0L2
94     elim (IHK01 … HK0L2) -IHK01 -HK0L2 /2 width=1 by monotonic_pred/
95     >minus_le_minus_minus_comm /3 width=3 by ldrop_ldrop_lt, ex2_intro/
96   ]
97 ]
98 qed.
99
100 (* Basic_1: was: drop_trans_ge *)
101 theorem ldrop_trans_ge: ∀d1,e1,L1,L. ⇩[d1, e1] L1 ≡ L →
102                         ∀e2,L2. ⇩[0, e2] L ≡ L2 → d1 ≤ e2 → ⇩[0, e1 + e2] L1 ≡ L2.
103 #d1 #e1 #L1 #L #H elim H -d1 -e1 -L1 -L //
104 [ /3 width=1/
105 | #L1 #L2 #I #V1 #V2 #d #e #H_ #_ #IHL12 #e2 #L #H #Hde2
106   lapply (lt_to_le_to_lt 0 … Hde2) // #He2
107   lapply (lt_to_le_to_lt … (e + e2) He2 ?) // #Hee2
108   lapply (ldrop_inv_ldrop1_lt … H ?) -H // #HL2
109   @ldrop_ldrop_lt // >le_plus_minus /3 width=1 by monotonic_pred/
110 ]
111 qed.
112
113 (* Basic_1: was: drop_trans_le *)
114 theorem ldrop_trans_le: ∀d1,e1,L1,L. ⇩[d1, e1] L1 ≡ L →
115                         ∀e2,L2. ⇩[0, e2] L ≡ L2 → e2 ≤ d1 →
116                         ∃∃L0. ⇩[0, e2] L1 ≡ L0 & ⇩[d1 - e2, e1] L0 ≡ L2.
117 #d1 #e1 #L1 #L #H elim H -d1 -e1 -L1 -L
118 [ #d #e2 #L2 #H
119   elim (ldrop_inv_atom1 … H) -H /2 width=3 by ldrop_atom, ex2_intro/
120 | #K #I #V #e2 #L2 #HL2 #H
121   lapply (le_n_O_to_eq … H) -H #H destruct /2 width=3 by ldrop_pair, ex2_intro/
122 | #L1 #L2 #I #V #e #_ #IHL12 #e2 #L #HL2 #H
123   lapply (le_n_O_to_eq … H) -H #H destruct
124   elim (IHL12 … HL2) -IHL12 -HL2 // #L0 #H #HL0
125   lapply (ldrop_inv_O2 … H) -H #H destruct /3 width=5 by ldrop_pair, ldrop_ldrop, ex2_intro/
126 | #L1 #L2 #I #V1 #V2 #d #e #HL12 #HV12 #IHL12 #e2 #L #H #He2d
127   elim (ldrop_inv_O1_pair1 … H) -H *
128   [ -He2d -IHL12 #H1 #H2 destruct /3 width=5 by ldrop_pair, ldrop_skip, ex2_intro/
129   | -HL12 -HV12 #He2 #HL2
130     elim (IHL12 … HL2) -L2 [ >minus_le_minus_minus_comm // /3 width=3 by ldrop_ldrop_lt, ex2_intro/ | /2 width=1 by monotonic_pred/ ]
131   ]
132 ]
133 qed.
134
135 (* Basic_1: was: drop_conf_rev *)
136 axiom ldrop_div: ∀e1,L1,L. ⇩[0, e1] L1 ≡ L → ∀e2,L2. ⇩[0, e2] L2 ≡ L →
137                  ∃∃L0. ⇩[0, e1] L0 ≡ L2 & ⇩[e1, e2] L0 ≡ L1.
138
139 (* Advanced properties ******************************************************)
140
141 lemma l_liftable_llstar: ∀R. l_liftable R → ∀l. l_liftable (llstar … R l).
142 #R #HR #l #K #T1 #T2 #H @(lstar_ind_r … l T2 H) -l -T2
143 [ #L #d #e #_ #U1 #HTU1 #U2 #HTU2 -HR -K
144   >(lift_mono … HTU2 … HTU1) -T1 -U2 -d -e //
145 | #l #T #T2 #_ #HT2 #IHT1 #L #d #e #HLK #U1 #HTU1 #U2 #HTU2
146   elim (lift_total T d e) /3 width=11 by lstar_dx/
147 ]
148 qed.
149
150 (* Basic_1: was: drop_conf_lt *)
151 lemma ldrop_conf_lt: ∀d1,e1,L,L1. ⇩[d1, e1] L ≡ L1 →
152                      ∀e2,K2,I,V2. ⇩[0, e2] L ≡ K2. ⓑ{I} V2 →
153                      e2 < d1 → let d ≝ d1 - e2 - 1 in
154                      ∃∃K1,V1. ⇩[0, e2] L1 ≡ K1. ⓑ{I} V1 &
155                               ⇩[d, e1] K2 ≡ K1 & ⇧[d, e1] V1 ≡ V2.
156 #d1 #e1 #L #L1 #H1 #e2 #K2 #I #V2 #H2 #He2d1
157 elim (ldrop_conf_le … H1 … H2) -L /2 width=2 by lt_to_le/ #K #HL1K #HK2
158 elim (ldrop_inv_skip1 … HK2) -HK2 /2 width=1 by lt_plus_to_minus_r/ #K1 #V1 #HK21 #HV12 #H destruct /2 width=5 by ex3_2_intro/
159 qed.
160
161 (* Note: apparently this was missing in basic_1 *)
162 lemma ldrop_trans_lt: ∀d1,e1,L1,L. ⇩[d1, e1] L1 ≡ L →
163                       ∀e2,L2,I,V2. ⇩[0, e2] L ≡ L2.ⓑ{I}V2 →
164                       e2 < d1 → let d ≝ d1 - e2 - 1 in
165                       ∃∃L0,V0. ⇩[0, e2] L1 ≡ L0.ⓑ{I}V0 &
166                                ⇩[d, e1] L0 ≡ L2 & ⇧[d, e1] V2 ≡ V0.
167 #d1 #e1 #L1 #L #HL1 #e2 #L2 #I #V2 #HL2 #Hd21
168 elim (ldrop_trans_le … HL1 … HL2) -L /2 width=1 by lt_to_le/ #L0 #HL10 #HL02
169 elim (ldrop_inv_skip2 … HL02) -HL02 /2 width=1 by lt_plus_to_minus_r/ #L #V1 #HL2 #HV21 #H destruct /2 width=5 by ex3_2_intro/
170 qed-.
171
172 lemma ldrop_trans_ge_comm: ∀d1,e1,e2,L1,L2,L.
173                            ⇩[d1, e1] L1 ≡ L → ⇩[0, e2] L ≡ L2 → d1 ≤ e2 →
174                            ⇩[0, e2 + e1] L1 ≡ L2.
175 #e1 #e1 #e2 >commutative_plus /2 width=5 by ldrop_trans_ge/
176 qed.
177
178 lemma ldrop_conf_div: ∀I1,L,K,V1,e1. ⇩[0, e1] L ≡ K. ⓑ{I1} V1 →
179                       ∀I2,V2,e2. ⇩[0, e2] L ≡ K. ⓑ{I2} V2 →
180                       ∧∧ e1 = e2 & I1 = I2 & V1 = V2.
181 #I1 #L #K #V1 #e1 #HLK1 #I2 #V2 #e2 #HLK2
182 elim (le_or_ge e1 e2) #He
183 [ lapply (ldrop_conf_ge … HLK1 … HLK2 ?)
184 | lapply (ldrop_conf_ge … HLK2 … HLK1 ?)
185 ] -HLK1 -HLK2 // #HK
186 lapply (ldrop_fwd_length_minus2 … HK) #H
187 elim (discr_minus_x_xy … H) -H
188 [1,3: normalize <plus_n_Sm #H destruct ]
189 #H >H in HK; #HK
190 lapply (ldrop_inv_O2 … HK) -HK #H destruct
191 lapply (inv_eq_minus_O … H) -H /3 width=1 by le_to_le_to_eq, and3_intro/
192 qed-.
193
194 (* Advanced forward lemmas **************************************************)
195
196 lemma ldrop_fwd_be: ∀L,K,d,e,i. ⇩[d, e] L ≡ K → |K| ≤ i → i < d → |L| ≤ i.
197 #L #K #d #e #i #HLK #HK #Hd elim (lt_or_ge i (|L|)) //
198 #HL elim (ldrop_O1_lt … HL) #I #K0 #V #HLK0 -HL
199 elim (ldrop_conf_lt … HLK … HLK0) // -HLK -HLK0 -Hd
200 #K1 #V1 #HK1 #_ #_ lapply (ldrop_fwd_length_lt2 … HK1) -I -K1 -V1
201 #H elim (lt_refl_false i) /2 width=3 by lt_to_le_to_lt/
202 qed-.