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