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