]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/relocation/drops.ma
- minor corrections
[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_4.ma".
17 include "basic_2/relocation/lreq.ma".
18 include "basic_2/relocation/lifts.ma".
19
20 (* GENERIC SLICING FOR LOCAL ENVIRONMENTS ***********************************)
21
22 (* Basic_1: includes: drop_skip_bind drop1_skip_bind *)
23 (* Basic_2A1: includes: drop_atom drop_pair drop_drop drop_skip
24                         drop_refl_atom_O2 drop_drop_lt drop_skip_lt
25 *)
26 inductive drops (c:bool): rtmap → relation lenv ≝
27 | drops_atom: ∀f. (c = Ⓣ → 𝐈⦃f⦄) → drops c (f) (⋆) (⋆)
28 | drops_drop: ∀I,L1,L2,V,f. drops c f L1 L2 → drops c (⫯f) (L1.ⓑ{I}V) L2
29 | drops_skip: ∀I,L1,L2,V1,V2,f.
30               drops c f L1 L2 → ⬆*[f] V2 ≡ V1 →
31               drops c (↑f) (L1.ⓑ{I}V1) (L2.ⓑ{I}V2)
32 .
33
34 interpretation "general slicing (local environment)"
35    'RDropStar c f L1 L2 = (drops c f L1 L2).
36
37 definition d_liftable1: relation2 lenv term → predicate bool ≝
38                         λR,c. ∀L,K,f. ⬇*[c, f] L ≡ K →
39                         ∀T,U. ⬆*[f] T ≡ U → R K T → R L U.
40
41 definition d_liftable2: predicate (lenv → relation term) ≝
42                         λR. ∀K,T1,T2. R K T1 T2 → ∀L,c,f. ⬇*[c, f] L ≡ K →
43                         ∀U1. ⬆*[f] T1 ≡ U1 → 
44                         ∃∃U2. ⬆*[f] T2 ≡ U2 & R L U1 U2.
45
46 definition d_deliftable2_sn: predicate (lenv → relation term) ≝
47                              λR. ∀L,U1,U2. R L U1 U2 → ∀K,c,f. ⬇*[c, f] L ≡ K →
48                              ∀T1. ⬆*[f] T1 ≡ U1 →
49                              ∃∃T2. ⬆*[f] T2 ≡ U2 & R K T1 T2.
50
51 definition dropable_sn: predicate (rtmap → relation lenv) ≝
52                         λR. ∀L1,K1,c,f. ⬇*[c, f] L1 ≡ K1 → ∀L2,f2. R f2 L1 L2 →
53                         ∀f1. f ⊚ f1 ≡ f2 →
54                         ∃∃K2. R f1 K1 K2 & ⬇*[c, f] L2 ≡ K2.
55
56 definition dropable_dx: predicate (rtmap → relation lenv) ≝
57                         λR. ∀L1,L2,f2. R f2 L1 L2 →
58                         ∀K2,c,f. ⬇*[c, f] L2 ≡ K2 →  𝐔⦃f⦄ →
59                         ∀f1. f ⊚ f1 ≡ f2 → 
60                         ∃∃K1. ⬇*[c, f] L1 ≡ K1 & R f1 K1 K2.
61
62 definition dedropable_sn: predicate (rtmap → relation lenv) ≝
63                           λR. ∀L1,K1,c,f. ⬇*[c, f] L1 ≡ K1 → ∀K2,f1. R f1 K1 K2 →
64                           ∀f2. f ⊚ f1 ≡ f2 →
65                           ∃∃L2. R f2 L1 L2 & ⬇*[c, f] L2 ≡ K2 & L1 ≡[f] L2.
66
67 (* Basic inversion lemmas ***************************************************)
68
69 fact drops_inv_atom1_aux: ∀X,Y,c,f. ⬇*[c, f] X ≡ Y → X = ⋆ →
70                           Y = ⋆ ∧ (c = Ⓣ → 𝐈⦃f⦄).
71 #X #Y #c #f * -X -Y -f
72 [ /3 width=1 by conj/
73 | #I #L1 #L2 #V #f #_ #H destruct
74 | #I #L1 #L2 #V1 #V2 #f #_ #_ #H destruct
75 ]
76 qed-.
77
78 (* Basic_1: includes: drop_gen_sort *)
79 (* Basic_2A1: includes: drop_inv_atom1 *)
80 lemma drops_inv_atom1: ∀Y,c,f. ⬇*[c, f] ⋆ ≡ Y → Y = ⋆ ∧ (c = Ⓣ → 𝐈⦃f⦄).
81 /2 width=3 by drops_inv_atom1_aux/ qed-.
82
83 fact drops_inv_drop1_aux: ∀X,Y,c,f. ⬇*[c, f] X ≡ Y → ∀I,K,V,g. X = K.ⓑ{I}V → f = ⫯g →
84                           ⬇*[c, g] K ≡ Y.
85 #X #Y #c #f * -X -Y -f
86 [ #f #Ht #J #K #W #g #H destruct
87 | #I #L1 #L2 #V #f #HL #J #K #W #g #H1 #H2 <(injective_next … H2) -g destruct //
88 | #I #L1 #L2 #V1 #V2 #f #_ #_ #J #K #W #g #_ #H2 elim (discr_push_next … H2)
89 ]
90 qed-.
91
92 (* Basic_1: includes: drop_gen_drop *)
93 (* Basic_2A1: includes: drop_inv_drop1_lt drop_inv_drop1 *)
94 lemma drops_inv_drop1: ∀I,K,Y,V,c,f. ⬇*[c, ⫯f] K.ⓑ{I}V ≡ Y → ⬇*[c, f] K ≡ Y.
95 /2 width=7 by drops_inv_drop1_aux/ qed-.
96
97
98 fact drops_inv_skip1_aux: ∀X,Y,c,f. ⬇*[c, f] X ≡ Y → ∀I,K1,V1,g. X = K1.ⓑ{I}V1 → f = ↑g →
99                           ∃∃K2,V2. ⬇*[c, g] K1 ≡ K2 & ⬆*[g] V2 ≡ V1 & Y = K2.ⓑ{I}V2.
100 #X #Y #c #f * -X -Y -f
101 [ #f #Ht #J #K1 #W1 #g #H destruct
102 | #I #L1 #L2 #V #f #_ #J #K1 #W1 #g #_ #H2 elim (discr_next_push … H2)
103 | #I #L1 #L2 #V1 #V2 #f #HL #HV #J #K1 #W1 #g #H1 #H2 <(injective_push … H2) -g destruct
104   /2 width=5 by ex3_2_intro/
105 ]
106 qed-.
107
108 (* Basic_1: includes: drop_gen_skip_l *)
109 (* Basic_2A1: includes: drop_inv_skip1 *)
110 lemma drops_inv_skip1: ∀I,K1,V1,Y,c,f. ⬇*[c, ↑f] K1.ⓑ{I}V1 ≡ Y →
111                        ∃∃K2,V2. ⬇*[c, f] K1 ≡ K2 & ⬆*[f] V2 ≡ V1 & Y = K2.ⓑ{I}V2.
112 /2 width=5 by drops_inv_skip1_aux/ qed-.
113
114 fact drops_inv_skip2_aux: ∀X,Y,c,f. ⬇*[c, f] X ≡ Y → ∀I,K2,V2,g. Y = K2.ⓑ{I}V2 → f = ↑g →
115                           ∃∃K1,V1. ⬇*[c, g] K1 ≡ K2 & ⬆*[g] V2 ≡ V1 & X = K1.ⓑ{I}V1.
116 #X #Y #c #f * -X -Y -f
117 [ #f #Ht #J #K2 #W2 #g #H destruct
118 | #I #L1 #L2 #V #f #_ #J #K2 #W2 #g #_ #H2 elim (discr_next_push … H2)
119 | #I #L1 #L2 #V1 #V2 #f #HL #HV #J #K2 #W2 #g #H1 #H2 <(injective_push … H2) -g destruct
120   /2 width=5 by ex3_2_intro/
121 ]
122 qed-.
123
124 (* Basic_1: includes: drop_gen_skip_r *)
125 (* Basic_2A1: includes: drop_inv_skip2 *)
126 lemma drops_inv_skip2: ∀I,X,K2,V2,c,f. ⬇*[c, ↑f] X ≡ K2.ⓑ{I}V2 →
127                        ∃∃K1,V1. ⬇*[c, f] K1 ≡ K2 & ⬆*[f] V2 ≡ V1 & X = K1.ⓑ{I}V1.
128 /2 width=5 by drops_inv_skip2_aux/ qed-.
129
130 (* Basic properties *********************************************************)
131
132 lemma drops_eq_repl_back: ∀L1,L2,c. eq_repl_back … (λf. ⬇*[c, f] L1 ≡ L2).
133 #L1 #L2 #c #f1 #H elim H -L1 -L2 -f1
134 [ /4 width=3 by drops_atom, isid_eq_repl_back/
135 | #I #L1 #L2 #V #f1 #_ #IH #f2 #H elim (eq_inv_nx … H) -H
136   /3 width=3 by drops_drop/
137 | #I #L1 #L2 #V1 #v2 #f1 #_ #HV #IH #f2 #H elim (eq_inv_px … H) -H
138   /3 width=3 by drops_skip, lifts_eq_repl_back/
139 ]
140 qed-.
141
142 lemma drops_eq_repl_fwd: ∀L1,L2,c. eq_repl_fwd … (λf. ⬇*[c, f] L1 ≡ L2).
143 #L1 #L2 #c @eq_repl_sym /2 width=3 by drops_eq_repl_back/ (**) (* full auto fails *)
144 qed-.
145
146 (* Basic_2A1: includes: drop_refl *)
147 lemma drops_refl: ∀c,L,f. 𝐈⦃f⦄ → ⬇*[c, f] L ≡ L.
148 #c #L elim L -L /2 width=1 by drops_atom/
149 #L #I #V #IHL #f #Hf elim (isid_inv_gen … Hf) -Hf
150 /3 width=1 by drops_skip, lifts_refl/
151 qed.
152
153 (* Basic_2A1: includes: drop_FT *)
154 lemma drops_TF: ∀L1,L2,f. ⬇*[Ⓣ, f] L1 ≡ L2 → ⬇*[Ⓕ, f] L1 ≡ L2.
155 #L1 #L2 #f #H elim H -L1 -L2 -f
156 /3 width=1 by drops_atom, drops_drop, drops_skip/
157 qed.
158
159 (* Basic_2A1: includes: drop_gen *)
160 lemma drops_gen: ∀L1,L2,c,f. ⬇*[Ⓣ, f] L1 ≡ L2 → ⬇*[c, f] L1 ≡ L2.
161 #L1 #L2 * /2 width=1 by drops_TF/
162 qed-.
163
164 (* Basic_2A1: includes: drop_T *)
165 lemma drops_F: ∀L1,L2,c,f. ⬇*[c, f] L1 ≡ L2 → ⬇*[Ⓕ, f] L1 ≡ L2.
166 #L1 #L2 * /2 width=1 by drops_TF/
167 qed-.
168
169 (* Basic forward lemmas *****************************************************)
170
171 (* Basic_1: includes: drop_gen_refl *)
172 (* Basic_2A1: includes: drop_inv_O2 *)
173 lemma drops_fwd_isid: ∀L1,L2,c,f. ⬇*[c, f] L1 ≡ L2 → 𝐈⦃f⦄ → L1 = L2.
174 #L1 #L2 #c #f #H elim H -L1 -L2 -f //
175 [ #I #L1 #L2 #V #f #_ #_ #H elim (isid_inv_next … H) //
176 | /5 width=5 by isid_inv_push, lifts_fwd_isid, eq_f3, sym_eq/
177 ]
178 qed-.
179
180 fact drops_fwd_drop2_aux: ∀X,Y,c,f2. ⬇*[c, f2] X ≡ Y → ∀I,K,V. Y = K.ⓑ{I}V →
181                           ∃∃f1,f. 𝐈⦃f1⦄ & f2 ⊚ ⫯f1 ≡ f & ⬇*[c, f] X ≡ K.
182 #X #Y #c #f2 #H elim H -X -Y -f2
183 [ #f2 #Ht2 #J #K #W #H destruct
184 | #I #L1 #L2 #V #f2 #_ #IHL #J #K #W #H elim (IHL … H) -IHL
185   /3 width=7 by after_next, ex3_2_intro, drops_drop/
186 | #I #L1 #L2 #V1 #V2 #f2 #HL #_ #_ #J #K #W #H destruct
187   lapply (isid_after_dx 𝐈𝐝 … f2) /3 width=9 by after_push, ex3_2_intro, drops_drop/
188 ]
189 qed-.
190
191 lemma drops_fwd_drop2: ∀I,X,K,V,c,f2. ⬇*[c, f2] X ≡ K.ⓑ{I}V →
192                        ∃∃f1,f. 𝐈⦃f1⦄ & f2 ⊚ ⫯f1 ≡ f & ⬇*[c, f] X ≡ K.
193 /2 width=5 by drops_fwd_drop2_aux/ qed-.
194
195 lemma drops_after_fwd_drop2: ∀I,X,K,V,c,f2. ⬇*[c, f2] X ≡ K.ⓑ{I}V →
196                              ∀f1,f. 𝐈⦃f1⦄ → f2 ⊚ ⫯f1 ≡ f → ⬇*[c, f] X ≡ K.
197 #I #X #K #V #c #f2 #H #f1 #f #Hf1 #Hf elim (drops_fwd_drop2 … H) -H
198 #g1 #g #Hg1 #Hg #HK lapply (after_mono_eq … Hg … Hf ??) -Hg -Hf
199 /3 width=5 by drops_eq_repl_back, isid_inv_eq_repl, eq_next/
200 qed-.
201
202 (* Basic_1: was: drop_S *)
203 (* Basic_2A1: was: drop_fwd_drop2 *)
204 lemma drops_isuni_fwd_drop2: ∀I,X,K,V,c,f. 𝐔⦃f⦄ → ⬇*[c, f] X ≡ K.ⓑ{I}V → ⬇*[c, ⫯f] X ≡ K.
205 /3 width=7 by drops_after_fwd_drop2, after_isid_isuni/ qed-.
206
207 (* forward lemmas with test for finite colength *****************************)
208
209 lemma drops_fwd_isfin: ∀L1,L2,f. ⬇*[Ⓣ, f] L1 ≡ L2 → 𝐅⦃f⦄.
210 #L1 #L2 #f #H elim H -L1 -L2 -f
211 /3 width=1 by isfin_next, isfin_push, isfin_isid/
212 qed-.
213
214 (* Basic_2A1: removed theorems 14:
215               drops_inv_nil drops_inv_cons d1_liftable_liftables
216               drop_refl_atom_O2
217               drop_inv_O1_pair1 drop_inv_pair1 drop_inv_O1_pair2
218               drop_inv_Y1 drop_Y1 drop_O_Y drop_fwd_Y2
219               drop_fwd_length_minus2 drop_fwd_length_minus4
220 *)
221 (* Basic_1: removed theorems 53:
222             drop1_gen_pnil drop1_gen_pcons drop1_getl_trans
223             drop_ctail drop_skip_flat
224             cimp_flat_sx cimp_flat_dx cimp_bind cimp_getl_conf
225             drop_clear drop_clear_O drop_clear_S
226             clear_gen_sort clear_gen_bind clear_gen_flat clear_gen_flat_r
227             clear_gen_all clear_clear clear_mono clear_trans clear_ctail clear_cle
228             getl_ctail_clen getl_gen_tail clear_getl_trans getl_clear_trans
229             getl_clear_bind getl_clear_conf getl_dec getl_drop getl_drop_conf_lt
230             getl_drop_conf_ge getl_conf_ge_drop getl_drop_conf_rev
231             drop_getl_trans_lt drop_getl_trans_le drop_getl_trans_ge
232             getl_drop_trans getl_flt getl_gen_all getl_gen_sort getl_gen_O
233             getl_gen_S getl_gen_2 getl_gen_flat getl_gen_bind getl_conf_le
234             getl_trans getl_refl getl_head getl_flat getl_ctail getl_mono
235 *)