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_weight.ma".
16 include "Basic_2/grammar/lsubs.ma".
17 include "Basic_2/substitution/lift.ma".
19 (* LOCAL ENVIRONMENT SLICING ************************************************)
21 (* Basic_1: includes: ldrop_skip_bind *)
22 inductive ldrop: nat → nat → relation lenv ≝
23 | ldrop_atom : ∀d,e. ldrop d e (⋆) (⋆)
24 | ldrop_pair : ∀L,I,V. ldrop 0 0 (L. ⓑ{I} V) (L. ⓑ{I} V)
25 | ldrop_ldrop: ∀L1,L2,I,V,e. ldrop 0 e L1 L2 → ldrop 0 (e + 1) (L1. ⓑ{I} V) L2
26 | ldrop_skip : ∀L1,L2,I,V1,V2,d,e.
27 ldrop d e L1 L2 → ⇧[d,e] V2 ≡ V1 →
28 ldrop (d + 1) e (L1. ⓑ{I} V1) (L2. ⓑ{I} V2)
31 interpretation "local slicing" 'RDrop d e L1 L2 = (ldrop d e L1 L2).
33 (* Basic inversion lemmas ***************************************************)
35 fact ldrop_inv_refl_aux: ∀d,e,L1,L2. ⇩[d, e] L1 ≡ L2 → d = 0 → e = 0 → L1 = L2.
36 #d #e #L1 #L2 * -d -e -L1 -L2
39 | #L1 #L2 #I #V #e #_ #_ >commutative_plus normalize #H destruct
40 | #L1 #L2 #I #V1 #V2 #d #e #_ #_ >commutative_plus normalize #H destruct
44 (* Basic_1: was: ldrop_gen_refl *)
45 lemma ldrop_inv_refl: ∀L1,L2. ⇩[0, 0] L1 ≡ L2 → L1 = L2.
48 fact ldrop_inv_atom1_aux: ∀d,e,L1,L2. ⇩[d, e] L1 ≡ L2 → L1 = ⋆ →
50 #d #e #L1 #L2 * -d -e -L1 -L2
52 | #L #I #V #H destruct
53 | #L1 #L2 #I #V #e #_ #H destruct
54 | #L1 #L2 #I #V1 #V2 #d #e #_ #_ #H destruct
58 (* Basic_1: was: ldrop_gen_sort *)
59 lemma ldrop_inv_atom1: ∀d,e,L2. ⇩[d, e] ⋆ ≡ L2 → L2 = ⋆.
62 fact ldrop_inv_O1_aux: ∀d,e,L1,L2. ⇩[d, e] L1 ≡ L2 → d = 0 →
63 ∀K,I,V. L1 = K. ⓑ{I} V →
64 (e = 0 ∧ L2 = K. ⓑ{I} V) ∨
65 (0 < e ∧ ⇩[d, e - 1] K ≡ L2).
66 #d #e #L1 #L2 * -d -e -L1 -L2
67 [ #d #e #_ #K #I #V #H destruct
68 | #L #I #V #_ #K #J #W #HX destruct /3 width=1/
69 | #L1 #L2 #I #V #e #HL12 #_ #K #J #W #H destruct /3 width=1/
70 | #L1 #L2 #I #V1 #V2 #d #e #_ #_ >commutative_plus normalize #H destruct
74 lemma ldrop_inv_O1: ∀e,K,I,V,L2. ⇩[0, e] K. ⓑ{I} V ≡ L2 →
75 (e = 0 ∧ L2 = K. ⓑ{I} V) ∨
76 (0 < e ∧ ⇩[0, e - 1] K ≡ L2).
79 (* Basic_1: was: ldrop_gen_ldrop *)
80 lemma ldrop_inv_ldrop1: ∀e,K,I,V,L2.
81 ⇩[0, e] K. ⓑ{I} V ≡ L2 → 0 < e → ⇩[0, e - 1] K ≡ L2.
82 #e #K #I #V #L2 #H #He
83 elim (ldrop_inv_O1 … H) -H * // #H destruct
84 elim (lt_refl_false … He)
87 fact ldrop_inv_skip1_aux: ∀d,e,L1,L2. ⇩[d, e] L1 ≡ L2 → 0 < d →
88 ∀I,K1,V1. L1 = K1. ⓑ{I} V1 →
89 ∃∃K2,V2. ⇩[d - 1, e] K1 ≡ K2 &
92 #d #e #L1 #L2 * -d -e -L1 -L2
93 [ #d #e #_ #I #K #V #H destruct
94 | #L #I #V #H elim (lt_refl_false … H)
95 | #L1 #L2 #I #V #e #_ #H elim (lt_refl_false … H)
96 | #X #L2 #Y #Z #V2 #d #e #HL12 #HV12 #_ #I #L1 #V1 #H destruct /2 width=5/
100 (* Basic_1: was: ldrop_gen_skip_l *)
101 lemma ldrop_inv_skip1: ∀d,e,I,K1,V1,L2. ⇩[d, e] K1. ⓑ{I} V1 ≡ L2 → 0 < d →
102 ∃∃K2,V2. ⇩[d - 1, e] K1 ≡ K2 &
103 ⇧[d - 1, e] V2 ≡ V1 &
107 fact ldrop_inv_skip2_aux: ∀d,e,L1,L2. ⇩[d, e] L1 ≡ L2 → 0 < d →
108 ∀I,K2,V2. L2 = K2. ⓑ{I} V2 →
109 ∃∃K1,V1. ⇩[d - 1, e] K1 ≡ K2 &
110 ⇧[d - 1, e] V2 ≡ V1 &
112 #d #e #L1 #L2 * -d -e -L1 -L2
113 [ #d #e #_ #I #K #V #H destruct
114 | #L #I #V #H elim (lt_refl_false … H)
115 | #L1 #L2 #I #V #e #_ #H elim (lt_refl_false … H)
116 | #L1 #X #Y #V1 #Z #d #e #HL12 #HV12 #_ #I #L2 #V2 #H destruct /2 width=5/
120 (* Basic_1: was: ldrop_gen_skip_r *)
121 lemma ldrop_inv_skip2: ∀d,e,I,L1,K2,V2. ⇩[d, e] L1 ≡ K2. ⓑ{I} V2 → 0 < d →
122 ∃∃K1,V1. ⇩[d - 1, e] K1 ≡ K2 & ⇧[d - 1, e] V2 ≡ V1 &
126 (* Basic properties *********************************************************)
128 (* Basic_1: was by definition: ldrop_refl *)
129 lemma ldrop_refl: ∀L. ⇩[0, 0] L ≡ L.
133 lemma ldrop_ldrop_lt: ∀L1,L2,I,V,e.
134 ⇩[0, e - 1] L1 ≡ L2 → 0 < e → ⇩[0, e] L1. ⓑ{I} V ≡ L2.
135 #L1 #L2 #I #V #e #HL12 #He >(plus_minus_m_m e 1) // /2 width=1/
138 lemma ldrop_lsubs_ldrop1_abbr: ∀L1,L2,d,e. L1 [d, e] ≼ L2 →
139 ∀K1,V,i. ⇩[0, i] L1 ≡ K1. ⓓV →
141 ∃∃K2. K1 [0, d + e - i - 1] ≼ K2 &
143 #L1 #L2 #d #e #H elim H -L1 -L2 -d -e
145 lapply (ldrop_inv_atom1 … H) -H #H destruct
146 | #L1 #L2 #K1 #V #i #_ #_ #H
147 elim (lt_zero_false … H)
148 | #L1 #L2 #V #e #HL12 #IHL12 #K1 #W #i #H #_ #Hie
149 elim (ldrop_inv_O1 … H) -H * #Hi #HLK1
150 [ -IHL12 -Hie destruct
151 <minus_n_O <minus_plus_m_m // /2 width=3/
153 elim (IHL12 … HLK1 ? ?) -IHL12 -HLK1 // /2 width=1/ -Hie >minus_minus_comm >arith_b1 // /4 width=3/
155 | #L1 #L2 #I #V1 #V2 #e #_ #IHL12 #K1 #W #i #H #_ #Hie
156 elim (ldrop_inv_O1 … H) -H * #Hi #HLK1
157 [ -IHL12 -Hie -Hi destruct
158 | elim (IHL12 … HLK1 ? ?) -IHL12 -HLK1 // /2 width=1/ -Hie >minus_minus_comm >arith_b1 // /3 width=3/
160 | #L1 #L2 #I1 #I2 #V1 #V2 #d #e #_ #IHL12 #K1 #V #i #H #Hdi >plus_plus_comm_23 #Hide
161 elim (le_inv_plus_l … Hdi) #Hdim #Hi
162 lapply (ldrop_inv_ldrop1 … H ?) -H // #HLK1
163 elim (IHL12 … HLK1 ? ?) -IHL12 -HLK1 // /2 width=1/ -Hdi -Hide >minus_minus_comm >arith_b1 // /3 width=3/
167 (* Basic forvard lemmas *****************************************************)
169 (* Basic_1: was: ldrop_S *)
170 lemma ldrop_fwd_ldrop2: ∀L1,I2,K2,V2,e. ⇩[O, e] L1 ≡ K2. ⓑ{I2} V2 →
173 [ #I2 #K2 #V2 #e #H lapply (ldrop_inv_atom1 … H) -H #H destruct
174 | #K1 #I1 #V1 #IHL1 #I2 #K2 #V2 #e #H
175 elim (ldrop_inv_O1 … H) -H * #He #H
176 [ -IHL1 destruct /2 width=1/
177 | @ldrop_ldrop >(plus_minus_m_m e 1) // /2 width=3/
182 lemma ldrop_fwd_lw: ∀L1,L2,d,e. ⇩[d, e] L1 ≡ L2 → #[L2] ≤ #[L1].
183 #L1 #L2 #d #e #H elim H -L1 -L2 -d -e // normalize
185 | #L1 #L2 #I #V1 #V2 #d #e #_ #HV21 #IHL12
186 >(tw_lift … HV21) -HV21 /2 width=1/
190 lemma ldrop_fwd_ldrop2_length: ∀L1,I2,K2,V2,e.
191 ⇩[0, e] L1 ≡ K2. ⓑ{I2} V2 → e < |L1|.
193 [ #I2 #K2 #V2 #e #H lapply (ldrop_inv_atom1 … H) -H #H destruct
194 | #K1 #I1 #V1 #IHL1 #I2 #K2 #V2 #e #H
195 elim (ldrop_inv_O1 … H) -H * #He #H
197 | lapply (IHL1 … H) -IHL1 -H #HeK1 whd in ⊢ (? ? %); /2 width=1/
202 lemma ldrop_fwd_O1_length: ∀L1,L2,e. ⇩[0, e] L1 ≡ L2 → |L2| = |L1| - e.
204 [ #L2 #e #H >(ldrop_inv_atom1 … H) -H //
205 | #K1 #I1 #V1 #IHL1 #L2 #e #H
206 elim (ldrop_inv_O1 … H) -H * #He #H
208 | lapply (IHL1 … H) -IHL1 -H #H >H -H normalize
209 >minus_le_minus_minus_comm //
214 (* Basic_1: removed theorems 49:
216 cimp_flat_sx cimp_flat_dx cimp_bind cimp_getl_conf
217 ldrop_clear ldrop_clear_O ldrop_clear_S
218 clear_gen_sort clear_gen_bind clear_gen_flat clear_gen_flat_r
219 clear_gen_all clear_clear clear_mono clear_trans clear_ctail clear_cle
220 getl_ctail_clen getl_gen_tail clear_getl_trans getl_clear_trans
221 getl_clear_bind getl_clear_conf getl_dec getl_ldrop getl_ldrop_conf_lt
222 getl_ldrop_conf_ge getl_conf_ge_ldrop getl_ldrop_conf_rev
223 ldrop_getl_trans_lt ldrop_getl_trans_le ldrop_getl_trans_ge
224 getl_ldrop_trans getl_flt getl_gen_all getl_gen_sort getl_gen_O
225 getl_gen_S getl_gen_2 getl_gen_flat getl_gen_bind getl_conf_le
226 getl_trans getl_refl getl_head getl_flat getl_ctail getl_mono