]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/static/frees_drops.ma
work in progress on frees_drops
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / static / frees_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_pushs.ma".
16 include "ground_2/relocation/rtmap_coafter.ma".
17 include "basic_2/relocation/drops_drops.ma".
18 include "basic_2/static/frees.ma".
19
20 (* CONTEXT-SENSITIVE FREE VARIABLES *****************************************)
21
22 (* Advanced properties ******************************************************)
23
24 lemma frees_lref_atom: ∀b,L,i. ⬇*[b, 𝐔❴i❵] L ≡ ⋆ →
25                        ∀f. 𝐈⦃f⦄ → L ⊢ 𝐅*⦃#i⦄ ≡ f.
26 #b #L elim L -L /2 width=1 by frees_atom/
27 #L #I #V #IH *
28 [ #H lapply (drops_fwd_isid … H ?) -H // #H destruct
29 | /5 width=3 by frees_eq_repl_back, frees_lref, drops_inv_drop1, eq_push_inv_isid/
30 ]
31 qed.
32
33 lemma frees_lref_pair: ∀f,K,V. K ⊢ 𝐅*⦃V⦄ ≡ f → 
34                        ∀i,I,L. ⬇*[i] L ≡ K.ⓑ{I}V → L ⊢ 𝐅*⦃#i⦄ ≡ ↑*[i] ⫯f.
35 #f #K #V #Hf #i elim i -i
36 [ #I #L #H lapply (drops_fwd_isid … H ?) -H /2 width=1 by frees_zero/
37 | #i #IH #I #L #H elim (drops_inv_succ … H) -H /3 width=2 by frees_lref/
38 ]
39 qed.
40
41 (* Advanced inversion lemmas ************************************************)
42
43 lemma frees_inv_lref_drops: ∀i,f,L. L ⊢ 𝐅*⦃#i⦄ ≡ f →
44                             (⬇*[Ⓕ, 𝐔❴i❵] L ≡ ⋆ ∧ 𝐈⦃f⦄) ∨
45                             ∃∃g,I,K,V. K ⊢ 𝐅*⦃V⦄ ≡ g &
46                                        ⬇*[i] L ≡ K.ⓑ{I}V & f = ↑*[i] ⫯g.
47 #i elim i -i
48 [ #f #L #H elim (frees_inv_zero … H) -H *
49   /4 width=7 by ex3_4_intro, or_introl, or_intror, conj, drops_refl/
50 | #i #IH #f #L #H elim (frees_inv_lref … H) -H * /3 width=1 by or_introl, conj/
51   #g #I #K #V #Hg #H1 #H2 destruct
52   elim (IH … Hg) -IH -Hg *
53   [ /4 width=3 by or_introl, conj, isid_push, drops_drop/
54   | /4 width=7 by drops_drop, ex3_4_intro, or_intror/
55   ]
56 ]
57 qed-.
58
59 (* Properties with generic slicing for local environments *******************)
60
61 axiom coafter_inv_xpx: ∀g2,f1,g. g2 ~⊚ ↑f1 ≡ g → ∀n. @⦃0, g2⦄ ≡ n →
62                        ∃∃f2,f. f2 ~⊚ f1 ≡ f & ⫱*[n]g2 = ↑f2 & ⫱*[n]g = ↑f.
63 (*
64 #g2 #g1 #g #Hg #n #Hg2
65 lapply (coafter_tls … Hg2 … Hg) -Hg #Hg
66 lapply (at_pxx_tls … Hg2) -Hg2 #H
67 elim (at_inv_pxp … H) -H [ |*: // ] #f2 #H2
68 elim (coafter_inv_pxx … Hg … H2) -Hg * #f1 #f #Hf #H1 #H0 destruct   
69 <tls_rew_S <tls_rew_S <H2 <H0 -g2 -g -n //
70 qed.
71 *)
72
73 lemma coafter_tls_succ: ∀g2,g1,g. g2 ~⊚ g1 ≡ g →
74                         ∀n. @⦃0, g2⦄ ≡ n → ⫱*[⫯n]g2 ~⊚ ⫱g1 ≡ ⫱*[⫯n]g.
75 #g2 #g1 #g #Hg #n #Hg2
76 lapply (coafter_tls … Hg2 … Hg) -Hg #Hg
77 lapply (at_pxx_tls … Hg2) -Hg2 #H
78 elim (at_inv_pxp … H) -H [ |*: // ] #f2 #H2
79 elim (coafter_inv_pxx … Hg … H2) -Hg * #f1 #f #Hf #H1 #H0 destruct   
80 <tls_rew_S <tls_rew_S <H2 <H0 -g2 -g -n //
81 qed.
82
83 lemma frees_lifts: ∀b,f1,K,T. K ⊢ 𝐅*⦃T⦄ ≡ f1 →
84                    ∀f,L. ⬇*[b, f] L ≡ K → ∀U. ⬆*[f] T ≡ U →
85                    ∀f2. f ~⊚ f1 ≡ f2 → L ⊢ 𝐅*⦃U⦄ ≡ f2.
86 #b #f1 #K #T #H lapply (frees_fwd_isfin … H) elim H -f1 -K -T
87 [ #f1 #I #Hf1 #_ #f #L #H1 #U #H2 #f2 #H3
88   lapply (coafter_isid_inv_dx … H3 … Hf1) -f1 #Hf2
89   elim (lifts_inv_atom1 … H2) -H2 *
90   /2 width=1 by frees_sort_gen, frees_gref_gen/
91   #i #j #Hij #H #H0 destruct
92   elim (drops_inv_atom2 … H1) -H1 #n #g #H1 #Hf
93   elim (after_at_fwd … Hij … Hf) -f #x #_ #Hj -g -i
94   lapply (at_inv_uni … Hj) -Hj #H destruct
95   /3 width=8 by frees_lref_atom, drops_trans/
96 | #f1 #I #K #V #s #_ #IH #Hf1 #f #L #H1 #U #H2 #f2 #H3
97   lapply (isfin_fwd_push … Hf1 ??) -Hf1 [3: |*: // ] #Hf1
98   lapply (lifts_inv_sort1 … H2) -H2 #H destruct
99   lapply (at_total 0 f) #H
100   elim (drops_split_trans … H1) -H1
101   [5: @(after_uni_dx … H) /2 width=1 by after_isid_dx/ |2,3: skip
102   |4: // ] #X #HLX #HXK
103   lapply (drops_inv_tls_at … H … HXK) -HXK #HXK
104   elim (drops_inv_skip2 … HXK) -HXK
105   #Y #W #HYK #HVW #H0 destruct
106 (*  
107     
108   elim (coafter_inv_xpx … H3 ??) -H3 [ |*: // ] #g2 #g #Hg #H2 #H0 
109   lapply (IH … Hg) -IH -Hg
110   [1,5: // | skip
111   | 
112   |6: #H 
113 *)
114
115   lapply (coafter_tls_succ … H3 ??) -H3 [3: |*: // ] #H3
116   lapply (IH … HYK … H3) -IH -H3 -HYK
117   [1,3: // | skip ]
118   #H lapply (frees_sort … H)
119    
120    ]
121
122   
123   elim (coafter_inv_xxp … H3) -H3 [1,3: * |*: // ]
124   [ #g #g1 #Hf2 #H #H0 destruct
125     elim (drops_inv_skip1 … H1) -H1 #K #V #HLK #_ #H destruct
126   | #g #Hf2 #H destruct
127     lapply (drops_inv_drop1 … H1) -H1
128   ] /3 width=4 by frees_sort/
129
130 |
131 |
132 |
133 | #f1V #f1T #f1 #p #I #K #V #T #_ #_ #H1f1 #IHV #IHT #H2f1 #f #L #H1 #Y #H2 #f2 #H3
134   elim (sor_inv_isfin3 … H1f1) // #Hf1V #H
135   lapply (isfin_inv_tl … H) -H
136   elim (lifts_inv_bind1 … H2) -H2 #W #U #HVW #HTU #H destruct
137   elim (coafter_sor … H3 … H1f1) /2 width=5 by coafter_isfin2_fwd/ -H3 -H1f1 #f2V #f2T #Hf2V #H
138   elim (coafter_inv_tl1 … H) -H /4 width=5 by frees_bind, drops_skip/
139 | #f1V #f1T #f1 #I #K #V #T #_ #_ #H1f1 #IHV #IHT #H2f1 #f #L #H1 #Y #H2 #f2 #H3
140   elim (sor_inv_isfin3 … H1f1) //
141   elim (lifts_inv_flat1 … H2) -H2 #W #U #HVW #HTU #H destruct
142   elim (coafter_sor … H3 … H1f1)
143   /3 width=5 by coafter_isfin2_fwd, frees_flat/
144 ]
145
146 (* Inversion lemmas with generic slicing for local environments *************)
147
148 lemma frees_inv_lifts: ∀b,f2,L,U. L ⊢ 𝐅*⦃U⦄ ≡ f2 →
149                        ∀f,K. ⬇*[b, f] L ≡ K → ∀T. ⬆*[f] T ≡ U →
150                        ∀f1. f ~⊚ f1 ≡ f2 → K ⊢ 𝐅*⦃T⦄ ≡ f1.
151 #b #f2 #L #U #H lapply (frees_fwd_isfin … H) elim H -f2 -L -U
152 [ #f2 #I #Hf2 #_ #f #K #H1 #T #H2 #f1 #H3
153   lapply (coafter_fwd_isid2 … H3 … Hf2) -H3 // -Hf2 #Hf1
154   elim (drops_inv_atom1 … H1) -H1 #H #_ destruct
155   elim (lifts_inv_atom2 … H2) -H2 * /2 width=3 by frees_atom/
156 | #f2 #I #L #W #s #_ #IH #Hf2 #f #Y #H1 #T #H2 #f1 #H3
157   lapply (isfin_fwd_push … Hf2 ??) -Hf2 [3: |*: // ] #Hf2
158   lapply (lifts_inv_sort2 … H2) -H2 #H destruct
159   elim (coafter_inv_xxp … H3) -H3 [1,3: * |*: // ]
160   [ #g #g1 #Hf2 #H #H0 destruct
161     elim (drops_inv_skip1 … H1) -H1 #K #V #HLK #_ #H destruct
162   | #g #Hf2 #H destruct
163     lapply (drops_inv_drop1 … H1) -H1
164   ] /3 width=4 by frees_sort/
165 | #f2 #I #L #W #_ #IH #Hf2 #f #Y #H1 #T #H2 #f1 #H3
166   lapply (isfin_inv_next … Hf2 ??) -Hf2 [3: |*: // ] #Hf2
167   elim (lifts_inv_lref2 … H2) -H2 #i #H2 #H destruct
168   lapply (at_inv_xxp … H2 ?) -H2 // * #g #H #H0 destruct
169   elim (drops_inv_skip1 … H1) -H1 #K #V #HLK #HVW #H destruct
170   elim (coafter_inv_pxn … H3) -H3 [ |*: // ] #g1 #Hf2 #H destruct
171   /3 width=4 by frees_zero/
172 | #f2 #I #L #W #j #_ #IH #Hf2 #f #Y #H1 #T #H2 #f1 #H3
173   lapply (isfin_fwd_push … Hf2 ??) -Hf2 [3: |*: // ] #Hf2
174   elim (lifts_inv_lref2 … H2) -H2 #x #H2 #H destruct
175   elim (coafter_inv_xxp … H3) -H3 [1,3: * |*: // ]
176   [ #g #g1 #Hf2 #H #H0 destruct
177     elim (drops_inv_skip1 … H1) -H1 #K #V #HLK #HVW #H destruct
178     elim (at_inv_xpn … H2) -H2 [ |*: // ] #j #Hg #H destruct
179   | #g #Hf2 #H destruct
180     lapply (drops_inv_drop1 … H1) -H1
181     lapply (at_inv_xnn … H2 ????) -H2 [5: |*: // ]
182   ] /4 width=4 by lifts_lref, frees_lref/
183 | #f2 #I #L #W #l #_ #IH #Hf2 #f #Y #H1 #T #H2 #f1 #H3
184   lapply (isfin_fwd_push … Hf2 ??) -Hf2 [3: |*: // ] #Hf2
185   lapply (lifts_inv_gref2 … H2) -H2 #H destruct
186   elim (coafter_inv_xxp … H3) -H3 [1,3: * |*: // ]
187   [ #g #g1 #Hf2 #H #H0 destruct
188     elim (drops_inv_skip1 … H1) -H1 #K #V #HLK #_ #H destruct
189   | #g #Hf2 #H destruct
190     lapply (drops_inv_drop1 … H1) -H1
191   ] /3 width=4 by frees_gref/
192 | #f2W #f2U #f2 #p #I #L #W #U #_ #_ #H1f2 #IHW #IHU #H2f2 #f #K #H1 #X #H2 #f1 #H3
193   elim (sor_inv_isfin3 … H1f2) // #H1f2W #H
194   lapply (isfin_inv_tl … H) -H
195   elim (lifts_inv_bind2 … H2) -H2 #V #T #HVW #HTU #H destruct
196   elim (coafter_inv_sor … H3 … H1f2) -H3 -H1f2 // #f1W #f1U #H2f2W #H
197   elim (coafter_inv_tl0 … H) -H /4 width=5 by frees_bind, drops_skip/
198 | #f2W #f2U #f2 #I #L #W #U #_ #_ #H1f2 #IHW #IHU #H2f2 #f #K #H1 #X #H2 #f1 #H3
199   elim (sor_inv_isfin3 … H1f2) //
200   elim (lifts_inv_flat2 … H2) -H2 #V #T #HVW #HTU #H destruct
201   elim (coafter_inv_sor … H3 … H1f2) -H3 -H1f2 /3 width=5 by frees_flat/
202 ]
203 qed-.
204
205 lemma frees_inv_drops: ∀f2,L,U. L ⊢ 𝐅*⦃U⦄ ≡ f2 →
206                        ∀f,K. ⬇*[Ⓣ, f] L ≡ K → ∀f1. f ~⊚ f1 ≡ f2 →
207                        ∃∃T. K ⊢ 𝐅*⦃T⦄ ≡ f1 & ⬆*[f] T ≡ U.
208 #f2 #L #U #H lapply (frees_fwd_isfin … H) elim H -f2 -L -U
209 [ #f2 #I #Hf2 #_ #f #K #H1 #f1 #H2
210   lapply (coafter_fwd_isid2 … H2 ??) -H2 // -Hf2 #Hf1
211   elim (drops_inv_atom1 … H1) -H1 #H #Hf destruct
212   /4 width=3 by frees_atom, lifts_refl, ex2_intro/
213 | #f2 #I #L #W #s #_ #IH #Hf2 #f #Y #H1 #f1 #H2
214   lapply (isfin_fwd_push … Hf2 ??) -Hf2 [3: |*: // ] #Hf2
215   elim (coafter_inv_xxp … H2) -H2 [1,3: * |*: // ]
216   [ #g #g1 #Hf2 #H #H0 destruct
217     elim (drops_inv_skip1 … H1) -H1 #K #V #HLK #_ #H destruct
218   | #g #Hf2 #H destruct
219     lapply (drops_inv_drop1 … H1) -H1 #HLK
220   ]
221   elim (IH … HLK … Hf2) -L // -f2 #X #Hg1 #HX
222   lapply (lifts_inv_sort2 … HX) -HX #H destruct
223   /3 width=3 by frees_sort, lifts_sort, ex2_intro/
224 | #f2 #I #L #W #_ #IH #Hf2 #f #Y #H1 #f1 #H2
225   lapply (isfin_inv_next … Hf2 ??) -Hf2 [3: |*: // ] #Hf2
226   elim (coafter_inv_xxn … H2) -H2 [ |*: // ] #g #g1 #Hf2 #H0 #H destruct
227   elim (drops_inv_skip1 … H1) -H1 #K #V #HLK #HVW #H destruct
228   elim (IH … HLK … Hf2) -L // -f2 #X #Hg1 #HX
229   lapply (lifts_inj … HX … HVW) -W #H destruct
230   /3 width=3 by frees_zero, lifts_lref, ex2_intro/
231 | #f2 #I #L #W #j #_ #IH #Hf2 #f #Y #H1 #f1 #H2
232   lapply (isfin_fwd_push … Hf2 ??) -Hf2 [3: |*: // ] #Hf2
233   elim (coafter_inv_xxp … H2) -H2 [1,3: * |*: // ]
234   [ #g #g1 #Hf2 #H #H0 destruct
235     elim (drops_inv_skip1 … H1) -H1 #K #V #HLK #_ #H destruct
236   | #g #Hf2 #H destruct
237     lapply (drops_inv_drop1 … H1) -H1 #HLK
238   ]
239   elim (IH … HLK … Hf2) -L // -f2 #X #Hg1 #HX
240   elim (lifts_inv_lref2 … HX) -HX #i #Hij #H destruct
241   /4 width=7 by frees_lref, lifts_lref, at_S1, at_next, ex2_intro/
242 | #f2 #I #L #W #l #_ #IH #Hf2 #f #Y #H1 #f1 #H2
243   lapply (isfin_fwd_push … Hf2 ??) -Hf2 [3: |*: // ] #Hf2
244   elim (coafter_inv_xxp … H2) -H2 [1,3: * |*: // ]
245   [ #g #g1 #Hf2 #H #H0 destruct
246     elim (drops_inv_skip1 … H1) -H1 #K #V #HLK #_ #H destruct
247   | #g #Hf2 #H destruct
248     lapply (drops_inv_drop1 … H1) -H1 #HLK
249   ]
250   elim (IH … HLK … Hf2) -L // -f2 #X #Hg1 #HX
251   lapply (lifts_inv_gref2 … HX) -HX #H destruct
252   /3 width=3 by frees_gref, lifts_gref, ex2_intro/
253 | #f2W #f2U #f2 #p #I #L #W #U #_ #_ #H1f2 #IHW #IHU #H2f2 #f #K #H1 #f1 #H2
254   elim (sor_inv_isfin3 … H1f2) // #H1f2W #H
255   lapply (isfin_inv_tl … H) -H #H1f2U
256   elim (coafter_inv_sor … H2 … H1f2) -H2 -H1f2 // #f1W #f1U #H2f2W #H #Hf1
257   elim (coafter_inv_tl0 … H) -H #g1 #H2f2U #H destruct
258   elim (IHW … H1 … H2f2W) -IHW -H2f2W // -H1f2W #V #Hf1W #HVW
259   elim (IHU … H2f2U) -IHU -H2f2U
260   /3 width=5 by frees_bind, drops_skip, lifts_bind, ex2_intro/
261 | #f2W #f2U #f2 #I #L #W #U #_ #_ #H1f2 #IHW #IHU #H2f2 #f #K #H1 #f1 #H2
262   elim (sor_inv_isfin3 … H1f2) // #H1f2W #H1f2U
263   elim (coafter_inv_sor … H2 … H1f2) -H2 -H1f2 // #f1W #f1U #H2f2W #H2f2U #Hf1
264   elim (IHW … H1 … H2f2W) -IHW -H2f2W // -H1f2W
265   elim (IHU … H1 … H2f2U) -L -H2f2U
266   /3 width=5 by frees_flat, lifts_flat, ex2_intro/
267 ]
268 qed-.