]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/static/frees_drops.ma
previous lemma proved ...
[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_fqup.ma".
18 include "basic_2/static/frees_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 lemma frees_sort_pushs: ∀f,K,s. K ⊢ 𝐅*⦃⋆s⦄ ≡ f →
42                         ∀i,L. ⬇*[i] L ≡ K → L ⊢ 𝐅*⦃⋆s⦄ ≡ ↑*[i] f.
43 #f #K #s #Hf #i elim i -i
44 [ #L #H lapply (drops_fwd_isid … H ?) -H //
45 | #i #IH #L #H elim (drops_inv_succ … H) -H /3 width=1 by frees_sort/
46 ]
47 qed.
48
49 lemma frees_lref_pushs: ∀f,K,j. K ⊢ 𝐅*⦃#j⦄ ≡ f →
50                         ∀i,L. ⬇*[i] L ≡ K → L ⊢ 𝐅*⦃#(i+j)⦄ ≡ ↑*[i] f.
51 #f #K #j #Hf #i elim i -i
52 [ #L #H lapply (drops_fwd_isid … H ?) -H //
53 | #i #IH #L #H elim (drops_inv_succ … H) -H
54   #I #Y #V #HYK #H destruct /3 width=1 by frees_lref/
55 ]
56 qed.
57
58 lemma frees_gref_pushs: ∀f,K,l. K ⊢ 𝐅*⦃§l⦄ ≡ f →
59                         ∀i,L. ⬇*[i] L ≡ K → L ⊢ 𝐅*⦃§l⦄ ≡ ↑*[i] f.
60 #f #K #l #Hf #i elim i -i
61 [ #L #H lapply (drops_fwd_isid … H ?) -H //
62 | #i #IH #L #H elim (drops_inv_succ … H) -H /3 width=1 by frees_gref/
63 ]
64 qed.
65
66 (* Advanced inversion lemmas ************************************************)
67
68 lemma frees_inv_lref_drops: ∀i,f,L. L ⊢ 𝐅*⦃#i⦄ ≡ f →
69                             (⬇*[Ⓕ, 𝐔❴i❵] L ≡ ⋆ ∧ 𝐈⦃f⦄) ∨
70                             ∃∃g,I,K,V. K ⊢ 𝐅*⦃V⦄ ≡ g &
71                                        ⬇*[i] L ≡ K.ⓑ{I}V & f = ↑*[i] ⫯g.
72 #i elim i -i
73 [ #f #L #H elim (frees_inv_zero … H) -H *
74   /4 width=7 by ex3_4_intro, or_introl, or_intror, conj, drops_refl/
75 | #i #IH #f #L #H elim (frees_inv_lref … H) -H * /3 width=1 by or_introl, conj/
76   #g #I #K #V #Hg #H1 #H2 destruct
77   elim (IH … Hg) -IH -Hg *
78   [ /4 width=3 by or_introl, conj, isid_push, drops_drop/
79   | /4 width=7 by drops_drop, ex3_4_intro, or_intror/
80   ]
81 ]
82 qed-.
83
84 (* Properties with generic slicing for local environments *******************)
85
86 lemma frees_lifts: ∀b,f1,K,T. K ⊢ 𝐅*⦃T⦄ ≡ f1 →
87                    ∀f,L. ⬇*[b, f] L ≡ K → ∀U. ⬆*[f] T ≡ U →
88                    ∀f2. f ~⊚ f1 ≡ f2 → L ⊢ 𝐅*⦃U⦄ ≡ f2.
89 #b #f1 #K #T #H lapply (frees_fwd_isfin … H) elim H -f1 -K -T
90 [ #f1 #I #Hf1 #_ #f #L #H1 #U #H2 #f2 #H3
91   lapply (coafter_isid_inv_dx … H3 … Hf1) -f1 #Hf2
92   elim (lifts_inv_atom1 … H2) -H2 *
93   /2 width=1 by frees_sort_gen, frees_gref_gen/
94   #i #j #Hij #H #H0 destruct
95   elim (drops_inv_atom2 … H1) -H1 #n #g #H1 #Hf
96   elim (after_at_fwd … Hij … Hf) -f #x #_ #Hj -g -i
97   lapply (at_inv_uni … Hj) -Hj #H destruct
98   /3 width=8 by frees_lref_atom, drops_trans/
99 | #f1 #I #K #V #s #_ #IH #Hf1 #f #L #H1 #U #H2 #f2 #H3
100   lapply (isfin_fwd_push … Hf1 ??) -Hf1 [3: |*: // ] #Hf1
101   lapply (lifts_inv_sort1 … H2) -H2 #H destruct
102   elim (drops_split_trans_pair2 … H1) -H1 [ |*: // ] #Y #W #HLY #HYK #_
103   elim (coafter_fwd_xpx_pushs … H3) [ |*: // ] #g2 #H2 destruct
104   lapply (coafter_tls_succ … H3 ??) -H3 [3: |*: // ] #H3
105   lapply (IH … HYK … H3) -IH -H3 -HYK [1,3: // | skip ]
106   /3 width=5 by drops_isuni_fwd_drop2, frees_sort_pushs/
107 | #f1 #I #K #V #_ #IH #Hf1 #f #L #H1 #U #H2 #f2 #H3
108   lapply (isfin_inv_next … Hf1 ??) -Hf1 [3: |*: // ] #Hf1
109   lapply (lifts_inv_lref1 … H2) -H2 * #j #Hf #H destruct
110   elim (drops_split_trans_pair2 … H1) -H1 [ |*: // ] #Y #W #HLY #HYK #HVW
111   elim (coafter_fwd_xnx_pushs … H3) [ |*: // ] #g2 #H2 destruct
112   lapply (coafter_tls_succ … H3 ??) -H3 [3: |*: // ]
113   <tls_S in ⊢ (???%→?); <tls_pushs <tl_next_rew <tl_next_rew #H3
114   lapply (IH … HYK … HVW … H3) -IH -H3 -HYK -HVW //
115   /2 width=5 by frees_lref_pair/
116 | #f1 #I #K #V #i #_ #IH #Hf1 #f #L #H1 #U #H2 #f2 #H3
117   lapply (isfin_fwd_push … Hf1 ??) -Hf1 [3: |*: // ] #Hf1
118   lapply (lifts_inv_lref1 … H2) -H2 * #x #Hf #H destruct
119   elim (at_inv_nxx … Hf) -Hf [ |*: // ] #j #Hf #H destruct
120   elim (drops_split_trans_pair2 … H1) -H1 [ |*: // ] #Y #W #HLY #HYK #_
121   elim (coafter_fwd_xpx_pushs … H3) [ |*: // ] #g2 #H2 destruct
122   lapply (coafter_tls_succ … H3 ??) -H3 [3: |*: // ] <tls_pushs #H3
123   lapply (drops_isuni_fwd_drop2 … HLY) -HLY // #HLY
124   lapply (IH … HYK … H3) -IH -H3 -HYK [4: |*: /2 width=2 by lifts_lref/ ]
125   >plus_S1 /2 width=3 by frees_lref_pushs/ (**) (* full auto fails *)
126 | #f1 #I #K #V #l #_ #IH #Hf1 #f #L #H1 #U #H2 #f2 #H3
127   lapply (isfin_fwd_push … Hf1 ??) -Hf1 [3: |*: // ] #Hf1
128   lapply (lifts_inv_gref1 … H2) -H2 #H destruct
129   elim (drops_split_trans_pair2 … H1) -H1 [ |*: // ] #Y #W #HLY #HYK #_
130   elim (coafter_fwd_xpx_pushs … H3) [ |*: // ] #g2 #H2 destruct
131   lapply (coafter_tls_succ … H3 ??) -H3 [3: |*: // ] #H3
132   lapply (IH … HYK … H3) -IH -H3 -HYK [1,3: // | skip ]
133   /3 width=5 by drops_isuni_fwd_drop2, frees_gref_pushs/
134 | #f1V #f1T #f1 #p #I #K #V #T #_ #_ #H1f1 #IHV #IHT #H2f1 #f #L #H1 #Y #H2 #f2 #H3
135   elim (sor_inv_isfin3 … H1f1) // #Hf1V #H
136   lapply (isfin_inv_tl … H) -H
137   elim (lifts_inv_bind1 … H2) -H2 #W #U #HVW #HTU #H destruct
138   elim (coafter_sor … H3 … H1f1) /2 width=5 by coafter_isfin2_fwd/ -H3 -H1f1 #f2V #f2T #Hf2V #H
139   elim (coafter_inv_tl1 … H) -H /4 width=5 by frees_bind, drops_skip/
140 | #f1V #f1T #f1 #I #K #V #T #_ #_ #H1f1 #IHV #IHT #H2f1 #f #L #H1 #Y #H2 #f2 #H3
141   elim (sor_inv_isfin3 … H1f1) //
142   elim (lifts_inv_flat1 … H2) -H2 #W #U #HVW #HTU #H destruct
143   elim (coafter_sor … H3 … H1f1)
144   /3 width=5 by coafter_isfin2_fwd, frees_flat/
145 ]
146 qed-.
147
148 (* Forward lemmas with generic slicing for local environments ***************)
149
150 lemma frees_fwd_coafter: ∀b,f2,L,U. L ⊢ 𝐅*⦃U⦄ ≡ f2 →
151                          ∀f,K. ⬇*[b, f] L ≡ K → ∀T. ⬆*[f] T ≡ U →
152                          ∀f1. K ⊢ 𝐅*⦃T⦄ ≡ f1 → f ~⊚ f1 ≡ f2.
153 /4 width=11 by frees_lifts, frees_mono, coafter_eq_repl_back0/ qed-.
154
155 (* Inversion lemmas with generic slicing for local environments *************)
156
157 lemma frees_inv_lifts_ex: ∀b,f2,L,U. L ⊢ 𝐅*⦃U⦄ ≡ f2 →
158                           ∀f,K. ⬇*[b, f] L ≡ K → ∀T. ⬆*[f] T ≡ U →
159                           ∃∃f1. f ~⊚ f1 ≡ f2 & K ⊢ 𝐅*⦃T⦄ ≡ f1.
160 #b #f2 #L #U #Hf2 #f #K #HLK #T elim (frees_total K T)
161 /3 width=9 by frees_fwd_coafter, ex2_intro/
162 qed-.
163
164 lemma frees_inv_lifts_SO: ∀b,f,L,U. L ⊢ 𝐅*⦃U⦄ ≡ f →
165                           ∀K. ⬇*[b, 𝐔❴1❵] L ≡ K → ∀T. ⬆*[1] T ≡ U →
166                           K ⊢ 𝐅*⦃T⦄ ≡ ⫱f.
167 #b #f #L #U #H #K #HLK #T #HTU elim(frees_inv_lifts_ex … H … HLK … HTU) -b -L -U
168 #f1 #Hf #Hf1 elim (coafter_inv_nxx … Hf) -Hf
169 /3 width=5 by frees_eq_repl_back, coafter_isid_inv_sn/
170 qed-.
171
172 lemma frees_inv_lifts: ∀b,f2,L,U. L ⊢ 𝐅*⦃U⦄ ≡ f2 →
173                        ∀f,K. ⬇*[b, f] L ≡ K → ∀T. ⬆*[f] T ≡ U →
174                        ∀f1. f ~⊚ f1 ≡ f2 → K ⊢ 𝐅*⦃T⦄ ≡ f1.
175 #b #f2 #L #U #H #f #K #HLK #T #HTU #f1 #Hf2 elim (frees_inv_lifts_ex … H … HLK … HTU) -b -L -U
176 /3 width=7 by frees_eq_repl_back, coafter_inj/
177 qed-.
178
179 lemma frees_inv_drops: ∀f2,L,U. L ⊢ 𝐅*⦃U⦄ ≡ f2 →
180                        ∀f,K. ⬇*[Ⓣ, f] L ≡ K → ∀f1. f ~⊚ f1 ≡ f2 →
181                        ∃∃T. K ⊢ 𝐅*⦃T⦄ ≡ f1 & ⬆*[f] T ≡ U.
182 #f2 #L #U #H lapply (frees_fwd_isfin … H) elim H -f2 -L -U
183 [ #f2 #I #Hf2 #_ #f #K #H1 #f1 #H2
184   lapply (coafter_fwd_isid2 … H2 ??) -H2 // -Hf2 #Hf1
185   elim (drops_inv_atom1 … H1) -H1 #H #Hf destruct
186   /4 width=3 by frees_atom, lifts_refl, ex2_intro/
187 | #f2 #I #L #W #s #_ #IH #Hf2 #f #Y #H1 #f1 #H2
188   lapply (isfin_fwd_push … Hf2 ??) -Hf2 [3: |*: // ] #Hf2
189   elim (coafter_inv_xxp … H2) -H2 [1,3: * |*: // ]
190   [ #g #g1 #Hf2 #H #H0 destruct
191     elim (drops_inv_skip1 … H1) -H1 #K #V #HLK #_ #H destruct
192   | #g #Hf2 #H destruct
193     lapply (drops_inv_drop1 … H1) -H1 #HLK
194   ]
195   elim (IH … HLK … Hf2) -L // -f2 #X #Hg1 #HX
196   lapply (lifts_inv_sort2 … HX) -HX #H destruct
197   /3 width=3 by frees_sort, lifts_sort, ex2_intro/
198 | #f2 #I #L #W #_ #IH #Hf2 #f #Y #H1 #f1 #H2
199   lapply (isfin_inv_next … Hf2 ??) -Hf2 [3: |*: // ] #Hf2
200   elim (coafter_inv_xxn … H2) -H2 [ |*: // ] #g #g1 #Hf2 #H0 #H destruct
201   elim (drops_inv_skip1 … H1) -H1 #K #V #HLK #HVW #H destruct
202   elim (IH … HLK … Hf2) -L // -f2 #X #Hg1 #HX
203   lapply (lifts_inj … HX … HVW) -W #H destruct
204   /3 width=3 by frees_zero, lifts_lref, ex2_intro/
205 | #f2 #I #L #W #j #_ #IH #Hf2 #f #Y #H1 #f1 #H2
206   lapply (isfin_fwd_push … Hf2 ??) -Hf2 [3: |*: // ] #Hf2
207   elim (coafter_inv_xxp … H2) -H2 [1,3: * |*: // ]
208   [ #g #g1 #Hf2 #H #H0 destruct
209     elim (drops_inv_skip1 … H1) -H1 #K #V #HLK #_ #H destruct
210   | #g #Hf2 #H destruct
211     lapply (drops_inv_drop1 … H1) -H1 #HLK
212   ]
213   elim (IH … HLK … Hf2) -L // -f2 #X #Hg1 #HX
214   elim (lifts_inv_lref2 … HX) -HX #i #Hij #H destruct
215   /4 width=7 by frees_lref, lifts_lref, at_S1, at_next, ex2_intro/
216 | #f2 #I #L #W #l #_ #IH #Hf2 #f #Y #H1 #f1 #H2
217   lapply (isfin_fwd_push … Hf2 ??) -Hf2 [3: |*: // ] #Hf2
218   elim (coafter_inv_xxp … H2) -H2 [1,3: * |*: // ]
219   [ #g #g1 #Hf2 #H #H0 destruct
220     elim (drops_inv_skip1 … H1) -H1 #K #V #HLK #_ #H destruct
221   | #g #Hf2 #H destruct
222     lapply (drops_inv_drop1 … H1) -H1 #HLK
223   ]
224   elim (IH … HLK … Hf2) -L // -f2 #X #Hg1 #HX
225   lapply (lifts_inv_gref2 … HX) -HX #H destruct
226   /3 width=3 by frees_gref, lifts_gref, ex2_intro/
227 | #f2W #f2U #f2 #p #I #L #W #U #_ #_ #H1f2 #IHW #IHU #H2f2 #f #K #H1 #f1 #H2
228   elim (sor_inv_isfin3 … H1f2) // #H1f2W #H
229   lapply (isfin_inv_tl … H) -H #H1f2U
230   elim (coafter_inv_sor … H2 … H1f2) -H2 -H1f2 // #f1W #f1U #H2f2W #H #Hf1
231   elim (coafter_inv_tl0 … H) -H #g1 #H2f2U #H destruct
232   elim (IHW … H1 … H2f2W) -IHW -H2f2W // -H1f2W #V #Hf1W #HVW
233   elim (IHU … H2f2U) -IHU -H2f2U
234   /3 width=5 by frees_bind, drops_skip, lifts_bind, ex2_intro/
235 | #f2W #f2U #f2 #I #L #W #U #_ #_ #H1f2 #IHW #IHU #H2f2 #f #K #H1 #f1 #H2
236   elim (sor_inv_isfin3 … H1f2) // #H1f2W #H1f2U
237   elim (coafter_inv_sor … H2 … H1f2) -H2 -H1f2 // #f1W #f1U #H2f2W #H2f2U #Hf1
238   elim (IHW … H1 … H2f2W) -IHW -H2f2W // -H1f2W
239   elim (IHU … H1 … H2f2U) -L -H2f2U
240   /3 width=5 by frees_flat, lifts_flat, ex2_intro/
241 ]
242 qed-.