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 "ground_2/relocation/rtmap_isfin.ma".
16 include "basic_2/notation/relations/rdropstar_3.ma".
17 include "basic_2/notation/relations/rdropstar_4.ma".
18 include "basic_2/relocation/lreq.ma".
19 include "basic_2/relocation/lifts.ma".
21 (* GENERIC SLICING FOR LOCAL ENVIRONMENTS ***********************************)
23 (* Basic_1: includes: drop_skip_bind drop1_skip_bind *)
24 (* Basic_2A1: includes: drop_atom drop_pair drop_drop drop_skip
25 drop_refl_atom_O2 drop_drop_lt drop_skip_lt
27 inductive drops (c:bool): rtmap → relation lenv ≝
28 | drops_atom: ∀f. (c = Ⓣ → 𝐈⦃f⦄) → drops c (f) (⋆) (⋆)
29 | drops_drop: ∀I,L1,L2,V,f. drops c f L1 L2 → drops c (⫯f) (L1.ⓑ{I}V) L2
30 | drops_skip: ∀I,L1,L2,V1,V2,f.
31 drops c f L1 L2 → ⬆*[f] V2 ≡ V1 →
32 drops c (↑f) (L1.ⓑ{I}V1) (L2.ⓑ{I}V2)
35 interpretation "uniform slicing (local environment)"
36 'RDropStar i L1 L2 = (drops true (uni i) L1 L2).
38 interpretation "general slicing (local environment)"
39 'RDropStar c f L1 L2 = (drops c f L1 L2).
41 definition d_liftable1: relation2 lenv term → predicate bool ≝
42 λR,c. ∀L,K,f. ⬇*[c, f] L ≡ K →
43 ∀T,U. ⬆*[f] T ≡ U → R K T → R L U.
45 definition d_liftable2: predicate (lenv → relation term) ≝
46 λR. ∀K,T1,T2. R K T1 T2 → ∀L,c,f. ⬇*[c, f] L ≡ K →
48 ∃∃U2. ⬆*[f] T2 ≡ U2 & R L U1 U2.
50 definition d_deliftable2_sn: predicate (lenv → relation term) ≝
51 λR. ∀L,U1,U2. R L U1 U2 → ∀K,c,f. ⬇*[c, f] L ≡ K →
53 ∃∃T2. ⬆*[f] T2 ≡ U2 & R K T1 T2.
55 definition dropable_sn: predicate (rtmap → relation lenv) ≝
56 λR. ∀L1,K1,c,f. ⬇*[c, f] L1 ≡ K1 → ∀L2,f2. R f2 L1 L2 →
58 ∃∃K2. R f1 K1 K2 & ⬇*[c, f] L2 ≡ K2.
60 definition dropable_dx: predicate (rtmap → relation lenv) ≝
61 λR. ∀L1,L2,f2. R f2 L1 L2 →
62 ∀K2,c,f. ⬇*[c, f] L2 ≡ K2 → 𝐔⦃f⦄ →
64 ∃∃K1. ⬇*[c, f] L1 ≡ K1 & R f1 K1 K2.
66 definition dedropable_sn: predicate (rtmap → relation lenv) ≝
67 λR. ∀L1,K1,c,f. ⬇*[c, f] L1 ≡ K1 → ∀K2,f1. R f1 K1 K2 →
69 ∃∃L2. R f2 L1 L2 & ⬇*[c, f] L2 ≡ K2 & L1 ≡[f] L2.
71 (* Basic properties *********************************************************)
73 lemma drops_eq_repl_back: ∀L1,L2,c. eq_repl_back … (λf. ⬇*[c, f] L1 ≡ L2).
74 #L1 #L2 #c #f1 #H elim H -L1 -L2 -f1
75 [ /4 width=3 by drops_atom, isid_eq_repl_back/
76 | #I #L1 #L2 #V #f1 #_ #IH #f2 #H elim (eq_inv_nx … H) -H
77 /3 width=3 by drops_drop/
78 | #I #L1 #L2 #V1 #v2 #f1 #_ #HV #IH #f2 #H elim (eq_inv_px … H) -H
79 /3 width=3 by drops_skip, lifts_eq_repl_back/
83 lemma drops_eq_repl_fwd: ∀L1,L2,c. eq_repl_fwd … (λf. ⬇*[c, f] L1 ≡ L2).
84 #L1 #L2 #c @eq_repl_sym /2 width=3 by drops_eq_repl_back/ (**) (* full auto fails *)
87 (* Basic_2A1: includes: drop_refl *)
88 lemma drops_refl: ∀c,L,f. 𝐈⦃f⦄ → ⬇*[c, f] L ≡ L.
89 #c #L elim L -L /2 width=1 by drops_atom/
90 #L #I #V #IHL #f #Hf elim (isid_inv_gen … Hf) -Hf
91 /3 width=1 by drops_skip, lifts_refl/
94 (* Basic_2A1: includes: drop_split *)
95 lemma drops_split_trans: ∀L1,L2,f,c. ⬇*[c, f] L1 ≡ L2 → ∀f1,f2. f1 ⊚ f2 ≡ f → 𝐔⦃f1⦄ →
96 ∃∃L. ⬇*[c, f1] L1 ≡ L & ⬇*[c, f2] L ≡ L2.
97 #L1 #L2 #f #c #H elim H -L1 -L2 -f
98 [ #f #Hc #f1 #f2 #Hf #Hf1 @(ex2_intro … (⋆)) @drops_atom
100 #H elim (after_inv_isid3 … Hf H) -f //
101 | #I #L1 #L2 #V #f #HL12 #IHL12 #f1 #f2 #Hf #Hf1 elim (after_inv_xxn … Hf) -Hf [1,3: * |*: // ]
102 [ #g1 #g2 #Hf #H1 #H2 destruct
103 lapply (isuni_inv_push … Hf1 ??) -Hf1 [1,2: // ] #Hg1
105 /4 width=5 by drops_drop, drops_skip, lifts_refl, isuni_isid, ex2_intro/
106 | #g1 #Hf #H destruct elim (IHL12 … Hf) -f
107 /3 width=5 by ex2_intro, drops_drop, isuni_inv_next/
109 | #I #L1 #L2 #V1 #V2 #f #_ #HV21 #IHL12 #f1 #f2 #Hf #Hf1 elim (after_inv_xxp … Hf) -Hf [2,3: // ]
110 #g1 #g2 #Hf #H1 #H2 destruct elim (lifts_split_trans … HV21 … Hf) -HV21
111 elim (IHL12 … Hf) -f /3 width=5 by ex2_intro, drops_skip, isuni_fwd_push/
115 (* Basic_2A1: includes: drop_FT *)
116 lemma drops_TF: ∀L1,L2,f. ⬇*[Ⓣ, f] L1 ≡ L2 → ⬇*[Ⓕ, f] L1 ≡ L2.
117 #L1 #L2 #f #H elim H -L1 -L2 -f
118 /3 width=1 by drops_atom, drops_drop, drops_skip/
121 (* Basic_2A1: includes: drop_gen *)
122 lemma drops_gen: ∀L1,L2,c,f. ⬇*[Ⓣ, f] L1 ≡ L2 → ⬇*[c, f] L1 ≡ L2.
123 #L1 #L2 * /2 width=1 by drops_TF/
126 (* Basic_2A1: includes: drop_T *)
127 lemma drops_F: ∀L1,L2,c,f. ⬇*[c, f] L1 ≡ L2 → ⬇*[Ⓕ, f] L1 ≡ L2.
128 #L1 #L2 * /2 width=1 by drops_TF/
131 (* Basic forward lemmas *****************************************************)
133 (* Basic_1: includes: drop_gen_refl *)
134 (* Basic_2A1: includes: drop_inv_O2 *)
135 lemma drops_fwd_isid: ∀L1,L2,c,f. ⬇*[c, f] L1 ≡ L2 → 𝐈⦃f⦄ → L1 = L2.
136 #L1 #L2 #c #f #H elim H -L1 -L2 -f //
137 [ #I #L1 #L2 #V #f #_ #_ #H elim (isid_inv_next … H) //
138 | /5 width=5 by isid_inv_push, lifts_fwd_isid, eq_f3, sym_eq/
142 fact drops_fwd_drop2_aux: ∀X,Y,c,f2. ⬇*[c, f2] X ≡ Y → ∀I,K,V. Y = K.ⓑ{I}V →
143 ∃∃f1,f. 𝐈⦃f1⦄ & f2 ⊚ ⫯f1 ≡ f & ⬇*[c, f] X ≡ K.
144 #X #Y #c #f2 #H elim H -X -Y -f2
145 [ #f2 #Ht2 #J #K #W #H destruct
146 | #I #L1 #L2 #V #f2 #_ #IHL #J #K #W #H elim (IHL … H) -IHL
147 /3 width=7 by after_next, ex3_2_intro, drops_drop/
148 | #I #L1 #L2 #V1 #V2 #f2 #HL #_ #_ #J #K #W #H destruct
149 lapply (isid_after_dx 𝐈𝐝 … f2) /3 width=9 by after_push, ex3_2_intro, drops_drop/
153 lemma drops_fwd_drop2: ∀I,X,K,V,c,f2. ⬇*[c, f2] X ≡ K.ⓑ{I}V →
154 ∃∃f1,f. 𝐈⦃f1⦄ & f2 ⊚ ⫯f1 ≡ f & ⬇*[c, f] X ≡ K.
155 /2 width=5 by drops_fwd_drop2_aux/ qed-.
157 lemma drops_after_fwd_drop2: ∀I,X,K,V,c,f2. ⬇*[c, f2] X ≡ K.ⓑ{I}V →
158 ∀f1,f. 𝐈⦃f1⦄ → f2 ⊚ ⫯f1 ≡ f → ⬇*[c, f] X ≡ K.
159 #I #X #K #V #c #f2 #H #f1 #f #Hf1 #Hf elim (drops_fwd_drop2 … H) -H
160 #g1 #g #Hg1 #Hg #HK lapply (after_mono_eq … Hg … Hf ??) -Hg -Hf
161 /3 width=5 by drops_eq_repl_back, isid_inv_eq_repl, eq_next/
164 (* Basic_1: was: drop_S *)
165 (* Basic_2A1: was: drop_fwd_drop2 *)
166 lemma drops_isuni_fwd_drop2: ∀I,X,K,V,c,f. 𝐔⦃f⦄ → ⬇*[c, f] X ≡ K.ⓑ{I}V → ⬇*[c, ⫯f] X ≡ K.
167 /3 width=7 by drops_after_fwd_drop2, after_isid_isuni/ qed-.
169 (* Forward lemmas with test for finite colength *****************************)
171 lemma drops_fwd_isfin: ∀L1,L2,f. ⬇*[Ⓣ, f] L1 ≡ L2 → 𝐅⦃f⦄.
172 #L1 #L2 #f #H elim H -L1 -L2 -f
173 /3 width=1 by isfin_next, isfin_push, isfin_isid/
176 (* Basic inversion lemmas ***************************************************)
178 fact drops_inv_atom1_aux: ∀X,Y,c,f. ⬇*[c, f] X ≡ Y → X = ⋆ →
179 Y = ⋆ ∧ (c = Ⓣ → 𝐈⦃f⦄).
180 #X #Y #c #f * -X -Y -f
181 [ /3 width=1 by conj/
182 | #I #L1 #L2 #V #f #_ #H destruct
183 | #I #L1 #L2 #V1 #V2 #f #_ #_ #H destruct
187 (* Basic_1: includes: drop_gen_sort *)
188 (* Basic_2A1: includes: drop_inv_atom1 *)
189 lemma drops_inv_atom1: ∀Y,c,f. ⬇*[c, f] ⋆ ≡ Y → Y = ⋆ ∧ (c = Ⓣ → 𝐈⦃f⦄).
190 /2 width=3 by drops_inv_atom1_aux/ qed-.
192 fact drops_inv_drop1_aux: ∀X,Y,c,f. ⬇*[c, f] X ≡ Y → ∀I,K,V,g. X = K.ⓑ{I}V → f = ⫯g →
194 #X #Y #c #f * -X -Y -f
195 [ #f #Ht #J #K #W #g #H destruct
196 | #I #L1 #L2 #V #f #HL #J #K #W #g #H1 #H2 <(injective_next … H2) -g destruct //
197 | #I #L1 #L2 #V1 #V2 #f #_ #_ #J #K #W #g #_ #H2 elim (discr_push_next … H2)
201 (* Basic_1: includes: drop_gen_drop *)
202 (* Basic_2A1: includes: drop_inv_drop1_lt drop_inv_drop1 *)
203 lemma drops_inv_drop1: ∀I,K,Y,V,c,f. ⬇*[c, ⫯f] K.ⓑ{I}V ≡ Y → ⬇*[c, f] K ≡ Y.
204 /2 width=7 by drops_inv_drop1_aux/ qed-.
207 fact drops_inv_skip1_aux: ∀X,Y,c,f. ⬇*[c, f] X ≡ Y → ∀I,K1,V1,g. X = K1.ⓑ{I}V1 → f = ↑g →
208 ∃∃K2,V2. ⬇*[c, g] K1 ≡ K2 & ⬆*[g] V2 ≡ V1 & Y = K2.ⓑ{I}V2.
209 #X #Y #c #f * -X -Y -f
210 [ #f #Ht #J #K1 #W1 #g #H destruct
211 | #I #L1 #L2 #V #f #_ #J #K1 #W1 #g #_ #H2 elim (discr_next_push … H2)
212 | #I #L1 #L2 #V1 #V2 #f #HL #HV #J #K1 #W1 #g #H1 #H2 <(injective_push … H2) -g destruct
213 /2 width=5 by ex3_2_intro/
217 (* Basic_1: includes: drop_gen_skip_l *)
218 (* Basic_2A1: includes: drop_inv_skip1 *)
219 lemma drops_inv_skip1: ∀I,K1,V1,Y,c,f. ⬇*[c, ↑f] K1.ⓑ{I}V1 ≡ Y →
220 ∃∃K2,V2. ⬇*[c, f] K1 ≡ K2 & ⬆*[f] V2 ≡ V1 & Y = K2.ⓑ{I}V2.
221 /2 width=5 by drops_inv_skip1_aux/ qed-.
223 fact drops_inv_skip2_aux: ∀X,Y,c,f. ⬇*[c, f] X ≡ Y → ∀I,K2,V2,g. Y = K2.ⓑ{I}V2 → f = ↑g →
224 ∃∃K1,V1. ⬇*[c, g] K1 ≡ K2 & ⬆*[g] V2 ≡ V1 & X = K1.ⓑ{I}V1.
225 #X #Y #c #f * -X -Y -f
226 [ #f #Ht #J #K2 #W2 #g #H destruct
227 | #I #L1 #L2 #V #f #_ #J #K2 #W2 #g #_ #H2 elim (discr_next_push … H2)
228 | #I #L1 #L2 #V1 #V2 #f #HL #HV #J #K2 #W2 #g #H1 #H2 <(injective_push … H2) -g destruct
229 /2 width=5 by ex3_2_intro/
233 (* Basic_1: includes: drop_gen_skip_r *)
234 (* Basic_2A1: includes: drop_inv_skip2 *)
235 lemma drops_inv_skip2: ∀I,X,K2,V2,c,f. ⬇*[c, ↑f] X ≡ K2.ⓑ{I}V2 →
236 ∃∃K1,V1. ⬇*[c, f] K1 ≡ K2 & ⬆*[f] V2 ≡ V1 & X = K1.ⓑ{I}V1.
237 /2 width=5 by drops_inv_skip2_aux/ qed-.
239 (* Inversion lemmas with test for uniformity ********************************)
241 (* Basic_2A1: was: drop_inv_O1_pair1 *)
242 lemma drops_inv_pair1_isuni: ∀I,K,L2,V,c,f. 𝐔⦃f⦄ → ⬇*[c, f] K.ⓑ{I}V ≡ L2 →
243 (𝐈⦃f⦄ ∧ L2 = K.ⓑ{I}V) ∨
244 ∃∃g. ⬇*[c, g] K ≡ L2 & f = ⫯g.
245 #I #K #L2 #V #c #f #Hf #H elim (isuni_split … Hf) -Hf * #g #Hg #H0 destruct
246 [ lapply (drops_inv_skip1 … H) -H * #Y #X #HY #HX #H destruct
247 <(drops_fwd_isid … HY Hg) -Y >(lifts_fwd_isid … HX Hg) -X
248 /4 width=3 by isid_push, or_introl, conj/
249 | lapply (drops_inv_drop1 … H) -H /3 width=3 by ex2_intro, or_intror/
253 (* Basic_2A1: was: drop_inv_O1_pair2 *)
254 lemma drops_inv_pair2_isuni: ∀I,K,V,c,f,L1. 𝐔⦃f⦄ → ⬇*[c, f] L1 ≡ K.ⓑ{I}V →
255 (𝐈⦃f⦄ ∧ L1 = K.ⓑ{I}V) ∨
256 ∃∃I1,K1,V1,g. ⬇*[c, g] K1 ≡ K.ⓑ{I}V & L1 = K1.ⓑ{I1}V1 & f = ⫯g.
258 [ #Hf #H elim (drops_inv_atom1 … H) -H #H destruct
259 | #L1 #I1 #V1 #Hf #H elim (drops_inv_pair1_isuni … Hf H) -Hf -H *
260 [ #Hf #H destruct /3 width=1 by or_introl, conj/
261 | /3 width=7 by ex3_4_intro, or_intror/
266 lemma drops_inv_pair2_isuni_next: ∀I,K,V,c,f,L1. 𝐔⦃f⦄ → ⬇*[c, ⫯f] L1 ≡ K.ⓑ{I}V →
267 ∃∃I1,K1,V1. ⬇*[c, f] K1 ≡ K.ⓑ{I}V & L1 = K1.ⓑ{I1}V1.
268 #I #K #V #c #f #L1 #Hf #H elim (drops_inv_pair2_isuni … H) -H /2 width=3 by isuni_next/ -Hf *
269 [ #H elim (isid_inv_next … H) -H //
270 | /2 width=5 by ex2_3_intro/
274 (* Basic_2A1: removed theorems 12:
275 drops_inv_nil drops_inv_cons d1_liftable_liftables
276 drop_refl_atom_O2 drop_inv_pair1
277 drop_inv_Y1 drop_Y1 drop_O_Y drop_fwd_Y2
278 drop_fwd_length_minus2 drop_fwd_length_minus4
280 (* Basic_1: removed theorems 53:
281 drop1_gen_pnil drop1_gen_pcons drop1_getl_trans
282 drop_ctail drop_skip_flat
283 cimp_flat_sx cimp_flat_dx cimp_bind cimp_getl_conf
284 drop_clear drop_clear_O drop_clear_S
285 clear_gen_sort clear_gen_bind clear_gen_flat clear_gen_flat_r
286 clear_gen_all clear_clear clear_mono clear_trans clear_ctail clear_cle
287 getl_ctail_clen getl_gen_tail clear_getl_trans getl_clear_trans
288 getl_clear_bind getl_clear_conf getl_dec getl_drop getl_drop_conf_lt
289 getl_drop_conf_ge getl_conf_ge_drop getl_drop_conf_rev
290 drop_getl_trans_lt drop_getl_trans_le drop_getl_trans_ge
291 getl_drop_trans getl_flt getl_gen_all getl_gen_sort getl_gen_O
292 getl_gen_S getl_gen_2 getl_gen_flat getl_gen_bind getl_conf_le
293 getl_trans getl_refl getl_head getl_flat getl_ctail getl_mono