]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/relocation/drops.ma
- commit of the "s_computation" component ...
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / relocation / drops.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 "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".
20
21 (* GENERIC SLICING FOR LOCAL ENVIRONMENTS ***********************************)
22
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
26 *)
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)
33 .
34
35 interpretation "uniform slicing (local environment)"
36    'RDropStar i L1 L2 = (drops true (uni i) L1 L2).
37
38 interpretation "general slicing (local environment)"
39    'RDropStar c f L1 L2 = (drops c f L1 L2).
40
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.
44
45 definition d_liftable2: predicate (lenv → relation term) ≝
46                         λR. ∀K,T1,T2. R K T1 T2 → ∀L,c,f. ⬇*[c, f] L ≡ K →
47                         ∀U1. ⬆*[f] T1 ≡ U1 → 
48                         ∃∃U2. ⬆*[f] T2 ≡ U2 & R L U1 U2.
49
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 →
52                              ∀T1. ⬆*[f] T1 ≡ U1 →
53                              ∃∃T2. ⬆*[f] T2 ≡ U2 & R K T1 T2.
54
55 definition dropable_sn: predicate (rtmap → relation lenv) ≝
56                         λR. ∀L1,K1,c,f. ⬇*[c, f] L1 ≡ K1 → ∀L2,f2. R f2 L1 L2 →
57                         ∀f1. f ⊚ f1 ≡ f2 →
58                         ∃∃K2. R f1 K1 K2 & ⬇*[c, f] L2 ≡ K2.
59
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⦄ →
63                         ∀f1. f ⊚ f1 ≡ f2 → 
64                         ∃∃K1. ⬇*[c, f] L1 ≡ K1 & R f1 K1 K2.
65
66 definition dedropable_sn: predicate (rtmap → relation lenv) ≝
67                           λR. ∀L1,K1,c,f. ⬇*[c, f] L1 ≡ K1 → ∀K2,f1. R f1 K1 K2 →
68                           ∀f2. f ⊚ f1 ≡ f2 →
69                           ∃∃L2. R f2 L1 L2 & ⬇*[c, f] L2 ≡ K2 & L1 ≡[f] L2.
70
71 (* Basic properties *********************************************************)
72
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/
80 ]
81 qed-.
82
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 *)
85 qed-.
86
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/
92 qed.
93
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
99   #H lapply (Hc H) -c
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
104     elim (IHL12 … Hf) -f
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/
108   ]
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/
112 ]
113 qed-.
114
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/
119 qed.
120
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/
124 qed-.
125
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/
129 qed-.
130
131 (* Basic forward lemmas *****************************************************)
132
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/
139 ]
140 qed-.
141
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/
150 ]
151 qed-.
152
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-.
156
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/
162 qed-.
163
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-.
168
169 (* Forward lemmas with test for finite colength *****************************)
170
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/
174 qed-.
175
176 (* Basic inversion lemmas ***************************************************)
177
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
184 ]
185 qed-.
186
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-.
191
192 fact drops_inv_drop1_aux: ∀X,Y,c,f. ⬇*[c, f] X ≡ Y → ∀I,K,V,g. X = K.ⓑ{I}V → f = ⫯g →
193                           ⬇*[c, g] K ≡ Y.
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)
198 ]
199 qed-.
200
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-.
205
206
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/
214 ]
215 qed-.
216
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-.
222
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/
230 ]
231 qed-.
232
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-.
238
239 (* Inversion lemmas with test for uniformity ********************************)
240
241 lemma drops_inv_isuni: ∀L1,L2,f. ⬇*[Ⓣ, f] L1 ≡ L2 → 𝐔⦃f⦄ →
242                        (𝐈⦃f⦄ ∧ L2 = L1) ∨
243                        ∃∃I,K,V,g. ⬇*[Ⓣ, g] K ≡ L2 & L1 = K.ⓑ{I}V & f = ⫯g.
244 #L1 #L2 #f * -L1 -L2 -f
245 [ /4 width=1 by or_introl, conj/
246 | /4 width=7 by ex3_4_intro, or_intror/
247 | /7 width=6 by drops_fwd_isid, lifts_fwd_isid, isuni_inv_push, isid_push, or_introl, conj, eq_f3, sym_eq/
248 ]
249 qed-.
250
251 (* Basic_2A1: was: drop_inv_O1_pair1 *)
252 lemma drops_inv_pair1_isuni: ∀I,K,L2,V,c,f. 𝐔⦃f⦄ → ⬇*[c, f] K.ⓑ{I}V ≡ L2 →
253                              (𝐈⦃f⦄ ∧ L2 = K.ⓑ{I}V) ∨
254                              ∃∃g. ⬇*[c, g] K ≡ L2 & f = ⫯g.
255 #I #K #L2 #V #c #f #Hf #H elim (isuni_split … Hf) -Hf * #g #Hg #H0 destruct
256 [ lapply (drops_inv_skip1 … H) -H * #Y #X #HY #HX #H destruct
257   <(drops_fwd_isid … HY Hg) -Y >(lifts_fwd_isid … HX Hg) -X
258   /4 width=3 by isid_push, or_introl, conj/
259 | lapply (drops_inv_drop1 … H) -H /3 width=3 by ex2_intro, or_intror/
260 ]
261 qed-.
262
263 (* Basic_2A1: was: drop_inv_O1_pair2 *)
264 lemma drops_inv_pair2_isuni: ∀I,K,V,c,f,L1. 𝐔⦃f⦄ → ⬇*[c, f] L1 ≡ K.ⓑ{I}V →
265                              (𝐈⦃f⦄ ∧ L1 = K.ⓑ{I}V) ∨
266                              ∃∃I1,K1,V1,g. ⬇*[c, g] K1 ≡ K.ⓑ{I}V & L1 = K1.ⓑ{I1}V1 & f = ⫯g.
267 #I #K #V #c #f *
268 [ #Hf #H elim (drops_inv_atom1 … H) -H #H destruct
269 | #L1 #I1 #V1 #Hf #H elim (drops_inv_pair1_isuni … Hf H) -Hf -H *
270   [ #Hf #H destruct /3 width=1 by or_introl, conj/
271   | /3 width=7 by ex3_4_intro, or_intror/
272   ]
273 ]
274 qed-.
275
276 lemma drops_inv_pair2_isuni_next: ∀I,K,V,c,f,L1. 𝐔⦃f⦄ → ⬇*[c, ⫯f] L1 ≡ K.ⓑ{I}V →
277                                   ∃∃I1,K1,V1. ⬇*[c, f] K1 ≡ K.ⓑ{I}V & L1 = K1.ⓑ{I1}V1.
278 #I #K #V #c #f #L1 #Hf #H elim (drops_inv_pair2_isuni … H) -H /2 width=3 by isuni_next/ -Hf *
279 [ #H elim (isid_inv_next … H) -H //
280 | /2 width=5 by ex2_3_intro/
281 ]
282 qed-. 
283
284 (* Inversion lemmas with uniform relocations ********************************)
285
286 lemma drops_inv_succ: ∀L1,L2,l. ⬇*[⫯l] L1 ≡ L2 →
287                       ∃∃I,K,V. ⬇*[l] K ≡ L2 & L1 = K.ⓑ{I}V.
288 #L1 #L2 #l #H elim (drops_inv_isuni … H) -H // *
289 [ #H elim (isid_inv_next … H) -H //
290 | /2 width=5 by ex2_3_intro/
291 ]
292 qed-. 
293
294 (* Basic_2A1: removed theorems 12:
295               drops_inv_nil drops_inv_cons d1_liftable_liftables
296               drop_refl_atom_O2 drop_inv_pair1
297               drop_inv_Y1 drop_Y1 drop_O_Y drop_fwd_Y2
298               drop_fwd_length_minus2 drop_fwd_length_minus4
299 *)
300 (* Basic_1: removed theorems 53:
301             drop1_gen_pnil drop1_gen_pcons drop1_getl_trans
302             drop_ctail drop_skip_flat
303             cimp_flat_sx cimp_flat_dx cimp_bind cimp_getl_conf
304             drop_clear drop_clear_O drop_clear_S
305             clear_gen_sort clear_gen_bind clear_gen_flat clear_gen_flat_r
306             clear_gen_all clear_clear clear_mono clear_trans clear_ctail clear_cle
307             getl_ctail_clen getl_gen_tail clear_getl_trans getl_clear_trans
308             getl_clear_bind getl_clear_conf getl_dec getl_drop getl_drop_conf_lt
309             getl_drop_conf_ge getl_conf_ge_drop getl_drop_conf_rev
310             drop_getl_trans_lt drop_getl_trans_le drop_getl_trans_ge
311             getl_drop_trans getl_flt getl_gen_all getl_gen_sort getl_gen_O
312             getl_gen_S getl_gen_2 getl_gen_flat getl_gen_bind getl_conf_le
313             getl_trans getl_refl getl_head getl_flat getl_ctail getl_mono
314 *)