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