]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/relocation/lifts.ma
some renaming and reordering of variables
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / relocation / lifts.ma
1
2 (**************************************************************************)
3 (*       ___                                                              *)
4 (*      ||M||                                                             *)
5 (*      ||A||       A project by Andrea Asperti                           *)
6 (*      ||T||                                                             *)
7 (*      ||I||       Developers:                                           *)
8 (*      ||T||         The HELM team.                                      *)
9 (*      ||A||         http://helm.cs.unibo.it                             *)
10 (*      \   /                                                             *)
11 (*       \ /        This file is distributed under the terms of the       *)
12 (*        v         GNU General Public License Version 2                  *)
13 (*                                                                        *)
14 (**************************************************************************)
15
16 include "ground_2/relocation/nstream_after.ma".
17 include "basic_2/notation/relations/rliftstar_3.ma".
18 include "basic_2/grammar/term.ma".
19
20 (* GENERIC RELOCATION FOR TERMS *********************************************)
21
22 (* Basic_1: includes:
23             lift_sort lift_lref_lt lift_lref_ge lift_bind lift_flat
24             lifts_nil lifts_cons
25 *)
26 inductive lifts: rtmap → relation term ≝
27 | lifts_sort: ∀f,s. lifts f (⋆s) (⋆s)
28 | lifts_lref: ∀f,i1,i2. @⦃i1, f⦄ ≡ i2 → lifts f (#i1) (#i2)
29 | lifts_gref: ∀f,l. lifts f (§l) (§l)
30 | lifts_bind: ∀f,p,I,V1,V2,T1,T2.
31               lifts f V1 V2 → lifts (↑f) T1 T2 →
32               lifts f (ⓑ{p,I}V1.T1) (ⓑ{p,I}V2.T2)
33 | lifts_flat: ∀f,I,V1,V2,T1,T2.
34               lifts f V1 V2 → lifts f T1 T2 →
35               lifts f (ⓕ{I}V1.T1) (ⓕ{I}V2.T2)
36 .
37
38 interpretation "uniform relocation (term)"
39    'RLiftStar i T1 T2 = (lifts (uni i) T1 T2).
40
41 interpretation "generic relocation (term)"
42    'RLiftStar f T1 T2 = (lifts f T1 T2).
43
44
45 (* Basic inversion lemmas ***************************************************)
46
47 fact lifts_inv_sort1_aux: ∀f,X,Y. ⬆*[f] X ≡ Y → ∀s. X = ⋆s → Y = ⋆s.
48 #f #X #Y * -f -X -Y //
49 [ #f #i1 #i2 #_ #x #H destruct
50 | #f #p #I #V1 #V2 #T1 #T2 #_ #_ #x #H destruct
51 | #f #I #V1 #V2 #T1 #T2 #_ #_ #x #H destruct
52 ]
53 qed-.
54
55 (* Basic_1: was: lift1_sort *)
56 (* Basic_2A1: includes: lift_inv_sort1 *)
57 lemma lifts_inv_sort1: ∀f,Y,s. ⬆*[f] ⋆s ≡ Y → Y = ⋆s.
58 /2 width=4 by lifts_inv_sort1_aux/ qed-.
59
60 fact lifts_inv_lref1_aux: ∀f,X,Y. ⬆*[f] X ≡ Y → ∀i1. X = #i1 →
61                           ∃∃i2. @⦃i1, f⦄ ≡ i2 & Y = #i2.
62 #f #X #Y * -f -X -Y
63 [ #f #s #x #H destruct
64 | #f #i1 #i2 #Hi12 #x #H destruct /2 width=3 by ex2_intro/
65 | #f #l #x #H destruct
66 | #f #p #I #V1 #V2 #T1 #T2 #_ #_ #x #H destruct
67 | #f #I #V1 #V2 #T1 #T2 #_ #_ #x #H destruct
68 ]
69 qed-.
70
71 (* Basic_1: was: lift1_lref *)
72 (* Basic_2A1: includes: lift_inv_lref1 lift_inv_lref1_lt lift_inv_lref1_ge *)
73 lemma lifts_inv_lref1: ∀f,Y,i1. ⬆*[f] #i1 ≡ Y →
74                        ∃∃i2. @⦃i1, f⦄ ≡ i2 & Y = #i2.
75 /2 width=3 by lifts_inv_lref1_aux/ qed-.
76
77 fact lifts_inv_gref1_aux: ∀f,X,Y. ⬆*[f] X ≡ Y → ∀l. X = §l → Y = §l.
78 #f #X #Y * -f -X -Y //
79 [ #f #i1 #i2 #_ #x #H destruct
80 | #f #p #I #V1 #V2 #T1 #T2 #_ #_ #x #H destruct
81 | #f #I #V1 #V2 #T1 #T2 #_ #_ #x #H destruct
82 ]
83 qed-.
84
85 (* Basic_2A1: includes: lift_inv_gref1 *)
86 lemma lifts_inv_gref1: ∀f,Y,l. ⬆*[f] §l ≡ Y → Y = §l.
87 /2 width=4 by lifts_inv_gref1_aux/ qed-.
88
89 fact lifts_inv_bind1_aux: ∀f,X,Y. ⬆*[f] X ≡ Y →
90                           ∀p,I,V1,T1. X = ⓑ{p,I}V1.T1 →
91                           ∃∃V2,T2. ⬆*[f] V1 ≡ V2 & ⬆*[↑f] T1 ≡ T2 &
92                                    Y = ⓑ{p,I}V2.T2.
93 #f #X #Y * -f -X -Y
94 [ #f #s #q #J #W1 #U1 #H destruct
95 | #f #i1 #i2 #_ #q #J #W1 #U1 #H destruct
96 | #f #l #b #J #W1 #U1 #H destruct
97 | #f #p #I #V1 #V2 #T1 #T2 #HV12 #HT12 #q #J #W1 #U1 #H destruct /2 width=5 by ex3_2_intro/
98 | #f #I #V1 #V2 #T1 #T2 #_ #_ #q #J #W1 #U1 #H destruct
99 ]
100 qed-.
101
102 (* Basic_1: was: lift1_bind *)
103 (* Basic_2A1: includes: lift_inv_bind1 *)
104 lemma lifts_inv_bind1: ∀f,p,I,V1,T1,Y. ⬆*[f] ⓑ{p,I}V1.T1 ≡ Y →
105                        ∃∃V2,T2. ⬆*[f] V1 ≡ V2 & ⬆*[↑f] T1 ≡ T2 &
106                                 Y = ⓑ{p,I}V2.T2.
107 /2 width=3 by lifts_inv_bind1_aux/ qed-.
108
109 fact lifts_inv_flat1_aux: ∀f:rtmap. ∀X,Y. ⬆*[f] X ≡ Y →
110                           ∀I,V1,T1. X = ⓕ{I}V1.T1 →
111                           ∃∃V2,T2. ⬆*[f] V1 ≡ V2 & ⬆*[f] T1 ≡ T2 &
112                                    Y = ⓕ{I}V2.T2.
113 #f #X #Y * -f -X -Y
114 [ #f #s #J #W1 #U1 #H destruct
115 | #f #i1 #i2 #_ #J #W1 #U1 #H destruct
116 | #f #l #J #W1 #U1 #H destruct
117 | #f #p #I #V1 #V2 #T1 #T2 #_ #_ #J #W1 #U1 #H destruct
118 | #f #I #V1 #V2 #T1 #T2 #HV12 #HT12 #J #W1 #U1 #H destruct /2 width=5 by ex3_2_intro/
119 ]
120 qed-.
121
122 (* Basic_1: was: lift1_flat *)
123 (* Basic_2A1: includes: lift_inv_flat1 *)
124 lemma lifts_inv_flat1: ∀f:rtmap. ∀I,V1,T1,Y. ⬆*[f] ⓕ{I}V1.T1 ≡ Y →
125                        ∃∃V2,T2. ⬆*[f] V1 ≡ V2 & ⬆*[f] T1 ≡ T2 &
126                                 Y = ⓕ{I}V2.T2.
127 /2 width=3 by lifts_inv_flat1_aux/ qed-.
128
129 fact lifts_inv_sort2_aux: ∀f,X,Y. ⬆*[f] X ≡ Y → ∀s. Y = ⋆s → X = ⋆s.
130 #f #X #Y * -f -X -Y //
131 [ #f #i1 #i2 #_ #x #H destruct
132 | #f #p #I #V1 #V2 #T1 #T2 #_ #_ #x #H destruct
133 | #f #I #V1 #V2 #T1 #T2 #_ #_ #x #H destruct
134 ]
135 qed-.
136
137 (* Basic_1: includes: lift_gen_sort *)
138 (* Basic_2A1: includes: lift_inv_sort2 *)
139 lemma lifts_inv_sort2: ∀f,X,s. ⬆*[f] X ≡ ⋆s → X = ⋆s.
140 /2 width=4 by lifts_inv_sort2_aux/ qed-.
141
142 fact lifts_inv_lref2_aux: ∀f,X,Y. ⬆*[f] X ≡ Y → ∀i2. Y = #i2 →
143                           ∃∃i1. @⦃i1, f⦄ ≡ i2 & X = #i1.
144 #f #X #Y * -f -X -Y
145 [ #f #s #x #H destruct
146 | #f #i1 #i2 #Hi12 #x #H destruct /2 width=3 by ex2_intro/
147 | #f #l #x #H destruct
148 | #f #p #I #V1 #V2 #T1 #T2 #_ #_ #x #H destruct
149 | #f #I #V1 #V2 #T1 #T2 #_ #_ #x #H destruct
150 ]
151 qed-.
152
153 (* Basic_1: includes: lift_gen_lref lift_gen_lref_lt lift_gen_lref_false lift_gen_lref_ge *)
154 (* Basic_2A1: includes: lift_inv_lref2 lift_inv_lref2_lt lift_inv_lref2_be lift_inv_lref2_ge lift_inv_lref2_plus *)
155 lemma lifts_inv_lref2: ∀f,X,i2. ⬆*[f] X ≡ #i2 →
156                        ∃∃i1. @⦃i1, f⦄ ≡ i2 & X = #i1.
157 /2 width=3 by lifts_inv_lref2_aux/ qed-.
158
159 fact lifts_inv_gref2_aux: ∀f,X,Y. ⬆*[f] X ≡ Y → ∀l. Y = §l → X = §l.
160 #f #X #Y * -f -X -Y //
161 [ #f #i1 #i2 #_ #x #H destruct
162 | #f #p #I #V1 #V2 #T1 #T2 #_ #_ #x #H destruct
163 | #f #I #V1 #V2 #T1 #T2 #_ #_ #x #H destruct
164 ]
165 qed-.
166
167 (* Basic_2A1: includes: lift_inv_gref1 *)
168 lemma lifts_inv_gref2: ∀f,X,l. ⬆*[f] X ≡ §l → X = §l.
169 /2 width=4 by lifts_inv_gref2_aux/ qed-.
170
171 fact lifts_inv_bind2_aux: ∀f,X,Y. ⬆*[f] X ≡ Y →
172                           ∀p,I,V2,T2. Y = ⓑ{p,I}V2.T2 →
173                           ∃∃V1,T1. ⬆*[f] V1 ≡ V2 & ⬆*[↑f] T1 ≡ T2 &
174                                    X = ⓑ{p,I}V1.T1.
175 #f #X #Y * -f -X -Y
176 [ #f #s #q #J #W2 #U2 #H destruct
177 | #f #i1 #i2 #_ #q #J #W2 #U2 #H destruct
178 | #f #l #q #J #W2 #U2 #H destruct
179 | #f #p #I #V1 #V2 #T1 #T2 #HV12 #HT12 #q #J #W2 #U2 #H destruct /2 width=5 by ex3_2_intro/
180 | #f #I #V1 #V2 #T1 #T2 #_ #_ #q #J #W2 #U2 #H destruct
181 ]
182 qed-.
183
184 (* Basic_1: includes: lift_gen_bind *)
185 (* Basic_2A1: includes: lift_inv_bind2 *)
186 lemma lifts_inv_bind2: ∀f,p,I,V2,T2,X. ⬆*[f] X ≡ ⓑ{p,I}V2.T2 →
187                        ∃∃V1,T1. ⬆*[f] V1 ≡ V2 & ⬆*[↑f] T1 ≡ T2 &
188                                 X = ⓑ{p,I}V1.T1.
189 /2 width=3 by lifts_inv_bind2_aux/ qed-.
190
191 fact lifts_inv_flat2_aux: ∀f:rtmap. ∀X,Y. ⬆*[f] X ≡ Y →
192                           ∀I,V2,T2. Y = ⓕ{I}V2.T2 →
193                           ∃∃V1,T1. ⬆*[f] V1 ≡ V2 & ⬆*[f] T1 ≡ T2 &
194                                    X = ⓕ{I}V1.T1.
195 #f #X #Y * -f -X -Y
196 [ #f #s #J #W2 #U2 #H destruct
197 | #f #i1 #i2 #_ #J #W2 #U2 #H destruct
198 | #f #l #J #W2 #U2 #H destruct
199 | #f #p #I #V1 #V2 #T1 #T2 #_ #_ #J #W2 #U2 #H destruct
200 | #f #I #V1 #V2 #T1 #T2 #HV12 #HT12 #J #W2 #U2 #H destruct /2 width=5 by ex3_2_intro/
201 ]
202 qed-.
203
204 (* Basic_1: includes: lift_gen_flat *)
205 (* Basic_2A1: includes: lift_inv_flat2 *)
206 lemma lifts_inv_flat2: ∀f:rtmap. ∀I,V2,T2,X. ⬆*[f] X ≡ ⓕ{I}V2.T2 →
207                        ∃∃V1,T1. ⬆*[f] V1 ≡ V2 & ⬆*[f] T1 ≡ T2 &
208                                 X = ⓕ{I}V1.T1.
209 /2 width=3 by lifts_inv_flat2_aux/ qed-.
210
211 (* Basic_2A1: includes: lift_inv_pair_xy_x *)
212 lemma lifts_inv_pair_xy_x: ∀f,I,V,T. ⬆*[f] ②{I}V.T ≡ V → ⊥.
213 #f #J #V elim V -V
214 [ * #i #U #H
215   [ lapply (lifts_inv_sort2 … H) -H #H destruct
216   | elim (lifts_inv_lref2 … H) -H
217     #x #_ #H destruct
218   | lapply (lifts_inv_gref2 … H) -H #H destruct
219   ]
220 | * [ #p ] #I #V2 #T2 #IHV2 #_ #U #H
221   [ elim (lifts_inv_bind2 … H) -H #V1 #T1 #HV12 #_ #H destruct /2 width=3 by/
222   | elim (lifts_inv_flat2 … H) -H #V1 #T1 #HV12 #_ #H destruct /2 width=3 by/
223   ]
224 ]
225 qed-.
226
227 (* Basic_1: includes: thead_x_lift_y_y *)
228 (* Basic_2A1: includes: lift_inv_pair_xy_y *)
229 lemma lifts_inv_pair_xy_y: ∀I,T,V,f. ⬆*[f] ②{I}V.T ≡ T → ⊥.
230 #J #T elim T -T
231 [ * #i #W #f #H
232   [ lapply (lifts_inv_sort2 … H) -H #H destruct
233   | elim (lifts_inv_lref2 … H) -H
234     #x #_ #H destruct
235   | lapply (lifts_inv_gref2 … H) -H #H destruct
236   ]
237 | * [ #p ] #I #V2 #T2 #_ #IHT2 #W #f #H
238   [ elim (lifts_inv_bind2 … H) -H #V1 #T1 #_ #HT12 #H destruct /2 width=4 by/
239   | elim (lifts_inv_flat2 … H) -H #V1 #T1 #_ #HT12 #H destruct /2 width=4 by/
240   ]
241 ]
242 qed-.
243
244 (* Basic forward lemmas *****************************************************)
245
246 (* Basic_2A1: includes: lift_inv_O2 *)
247 lemma lifts_fwd_isid: ∀f,T1,T2. ⬆*[f] T1 ≡ T2 → 𝐈⦃f⦄ → T1 = T2.
248 #f #T1 #T2 #H elim H -f -T1 -T2
249 /4 width=3 by isid_inv_at_mono, isid_push, eq_f2, eq_f/
250 qed-.
251
252 (* Basic_2A1: includes: lift_fwd_pair1 *)
253 lemma lifts_fwd_pair1: ∀f:rtmap. ∀I,V1,T1,Y. ⬆*[f] ②{I}V1.T1 ≡ Y →
254                        ∃∃V2,T2. ⬆*[f] V1 ≡ V2 & Y = ②{I}V2.T2.
255 #f * [ #p ] #I #V1 #T1 #Y #H
256 [ elim (lifts_inv_bind1 … H) -H /2 width=4 by ex2_2_intro/
257 | elim (lifts_inv_flat1 … H) -H /2 width=4 by ex2_2_intro/
258 ]
259 qed-.
260
261 (* Basic_2A1: includes: lift_fwd_pair2 *)
262 lemma lifts_fwd_pair2: ∀f:rtmap. ∀I,V2,T2,X. ⬆*[f] X ≡ ②{I}V2.T2 →
263                        ∃∃V1,T1. ⬆*[f] V1 ≡ V2 & X = ②{I}V1.T1.
264 #f * [ #p ] #I #V2 #T2 #X #H
265 [ elim (lifts_inv_bind2 … H) -H /2 width=4 by ex2_2_intro/
266 | elim (lifts_inv_flat2 … H) -H /2 width=4 by ex2_2_intro/
267 ]
268 qed-.
269
270 (* Basic properties *********************************************************)
271
272 lemma lifts_eq_repl_back: ∀T1,T2. eq_repl_back … (λf. ⬆*[f] T1 ≡ T2).
273 #T1 #T2 #f1 #H elim H -T1 -T2 -f1
274 /4 width=5 by lifts_flat, lifts_bind, lifts_lref, at_eq_repl_back, eq_push/
275 qed-.
276
277 lemma lifts_eq_repl_fwd: ∀T1,T2. eq_repl_fwd … (λf. ⬆*[f] T1 ≡ T2).
278 #T1 #T2 @eq_repl_sym /2 width=3 by lifts_eq_repl_back/ (**) (* full auto fails *)
279 qed-.
280
281 (* Basic_1: includes: lift_r *)
282 (* Basic_2A1: includes: lift_refl *)
283 lemma lifts_refl: ∀T,f. 𝐈⦃f⦄ → ⬆*[f] T ≡ T.
284 #T elim T -T *
285 /4 width=3 by lifts_flat, lifts_bind, lifts_lref, isid_inv_at, isid_push/
286 qed.
287
288 (* Basic_2A1: includes: lift_total *)
289 lemma lifts_total: ∀T1,f. ∃T2. ⬆*[f] T1 ≡ T2.
290 #T1 elim T1 -T1 *
291 /3 width=2 by lifts_lref, lifts_sort, lifts_gref, ex_intro/
292 [ #p ] #I #V1 #T1 #IHV1 #IHT1 #f
293 elim (IHV1 f) -IHV1 #V2 #HV12
294 [ elim (IHT1 (↑f)) -IHT1 /3 width=2 by lifts_bind, ex_intro/
295 | elim (IHT1 f) -IHT1 /3 width=2 by lifts_flat, ex_intro/
296 ]
297 qed-.
298
299 lemma lift_lref_uni: ∀l,i. ⬆*[l] #i ≡ #(l+i).
300 #l elim l -l /2 width=1 by lifts_lref/
301 qed.
302
303 (* Basic_1: includes: lift_free (right to left) *)
304 (* Basic_2A1: includes: lift_split *)
305 lemma lifts_split_trans: ∀f,T1,T2. ⬆*[f] T1 ≡ T2 →
306                          ∀f1,f2. f2 ⊚ f1 ≡ f →
307                          ∃∃T. ⬆*[f1] T1 ≡ T & ⬆*[f2] T ≡ T2.
308 #f #T1 #T2 #H elim H -f -T1 -T2
309 [ /3 width=3 by lifts_sort, ex2_intro/
310 | #f #i1 #i2 #Hi #f1 #f2 #Ht elim (after_at_fwd … Hi … Ht) -Hi -Ht
311   /3 width=3 by lifts_lref, ex2_intro/
312 | /3 width=3 by lifts_gref, ex2_intro/
313 | #f #p #I #V1 #V2 #T1 #T2 #_ #_ #IHV #IHT #f1 #f2 #Ht
314   elim (IHV … Ht) elim (IHT (↑f1) (↑f2)) -IHV -IHT
315   /3 width=5 by lifts_bind, after_O2, ex2_intro/
316 | #f #I #V1 #V2 #T1 #T2 #_ #_ #IHV #IHT #f1 #f2 #Ht
317   elim (IHV … Ht) elim (IHT … Ht) -IHV -IHT -Ht
318   /3 width=5 by lifts_flat, ex2_intro/
319 ]
320 qed-.
321
322 (* Note: apparently, this was missing in Basic_2A1 *)
323 lemma lifts_split_div: ∀f1,T1,T2. ⬆*[f1] T1 ≡ T2 →
324                        ∀f2,f. f2 ⊚ f1 ≡ f →
325                        ∃∃T. ⬆*[f2] T2 ≡ T & ⬆*[f] T1 ≡ T.
326 #f1 #T1 #T2 #H elim H -f1 -T1 -T2
327 [ /3 width=3 by lifts_sort, ex2_intro/
328 | #f1 #i1 #i2 #Hi #f2 #f #Ht elim (after_at1_fwd … Hi … Ht) -Hi -Ht
329   /3 width=3 by lifts_lref, ex2_intro/
330 | /3 width=3 by lifts_gref, ex2_intro/
331 | #f1 #p #I #V1 #V2 #T1 #T2 #_ #_ #IHV #IHT #f2 #f #Ht
332   elim (IHV … Ht) elim (IHT (↑f2) (↑f)) -IHV -IHT
333   /3 width=5 by lifts_bind, after_O2, ex2_intro/
334 | #f1 #I #V1 #V2 #T1 #T2 #_ #_ #IHV #IHT #f2 #f #Ht
335   elim (IHV … Ht) elim (IHT … Ht) -IHV -IHT -Ht
336   /3 width=5 by lifts_flat, ex2_intro/
337 ]
338 qed-.
339
340 (* Basic_1: includes: dnf_dec2 dnf_dec *)
341 (* Basic_2A1: includes: is_lift_dec *)
342 lemma is_lifts_dec: ∀T2,f. Decidable (∃T1. ⬆*[f] T1 ≡ T2).
343 #T1 elim T1 -T1
344 [ * [1,3: /3 width=2 by lifts_sort, lifts_gref, ex_intro, or_introl/ ]
345   #i2 #f elim (is_at_dec f i2) //
346   [ * /4 width=3 by lifts_lref, ex_intro, or_introl/
347   | #H @or_intror *
348     #X #HX elim (lifts_inv_lref2 … HX) -HX
349     /3 width=2 by ex_intro/
350   ]
351 | * [ #p ] #I #V2 #T2 #IHV2 #IHT2 #f
352   [ elim (IHV2 f) -IHV2
353     [ * #V1 #HV12 elim (IHT2 (↑f)) -IHT2
354       [ * #T1 #HT12 @or_introl /3 width=2 by lifts_bind, ex_intro/
355       | -V1 #HT2 @or_intror * #X #H
356         elim (lifts_inv_bind2 … H) -H /3 width=2 by ex_intro/
357       ]
358     | -IHT2 #HV2 @or_intror * #X #H
359       elim (lifts_inv_bind2 … H) -H /3 width=2 by ex_intro/
360     ]
361   | elim (IHV2 f) -IHV2
362     [ * #V1 #HV12 elim (IHT2 f) -IHT2
363       [ * #T1 #HT12 /4 width=2 by lifts_flat, ex_intro, or_introl/
364       | -V1 #HT2 @or_intror * #X #H
365         elim (lifts_inv_flat2 … H) -H /3 width=2 by ex_intro/
366       ]
367     | -IHT2 #HV2 @or_intror * #X #H
368       elim (lifts_inv_flat2 … H) -H /3 width=2 by ex_intro/
369     ]
370   ]
371 ]
372 qed-.
373
374 (* Basic_2A1: removed theorems 14:
375               lifts_inv_nil lifts_inv_cons
376               lift_inv_Y1 lift_inv_Y2 lift_inv_lref_Y1 lift_inv_lref_Y2 lift_lref_Y lift_Y1
377               lift_lref_lt_eq lift_lref_ge_eq lift_lref_plus lift_lref_pred
378               lift_lref_ge_minus lift_lref_ge_minus_eq
379 *)
380 (* Basic_1: removed theorems 8:
381             lift_lref_gt            
382             lift_head lift_gen_head 
383             lift_weight_map lift_weight lift_weight_add lift_weight_add_O
384             lift_tlt_dx
385 *)