]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/static/frees_drops.ma
renaming in basic_2
[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
19 (* CONTEXT-SENSITIVE FREE VARIABLES *****************************************)
20
21 (* Advanced properties ******************************************************)
22
23 lemma frees_atom_drops: ∀b,L,i. ⬇*[b, 𝐔❴i❵] L ≘ ⋆ →
24                         ∀f. 𝐈⦃f⦄ → L ⊢ 𝐅*⦃#i⦄ ≘ ⫯*[i]↑f.
25 #b #L elim L -L /2 width=1 by frees_atom/
26 #L #I #IH *
27 [ #H lapply (drops_fwd_isid … H ?) -H // #H destruct
28 | /4 width=3 by frees_lref, drops_inv_drop1/
29 ]
30 qed.
31
32 lemma frees_pair_drops: ∀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_pair/
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_unit_drops: ∀f.  𝐈⦃f⦄ → ∀I,K,i,L. ⬇*[i] L ≘ K.ⓤ{I} →
41                        L ⊢ 𝐅*⦃#i⦄ ≘ ⫯*[i] ↑f.
42 #f #Hf #I #K #i elim i -i
43 [ #L #H lapply (drops_fwd_isid … H ?) -H /2 width=1 by frees_unit/
44 | #i #IH #Y #H elim (drops_inv_succ … H) -H
45   #J #L #HLK #H destruct /3 width=1 by frees_lref/
46 ]
47 qed.
48 (*
49 lemma frees_sort_pushs: ∀f,K,s. K ⊢ 𝐅*⦃⋆s⦄ ≘ f →
50                         ∀i,L. ⬇*[i] L ≘ K → L ⊢ 𝐅*⦃⋆s⦄ ≘ ⫯*[i] f.
51 #f #K #s #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 /3 width=1 by frees_sort/
54 ]
55 qed.
56 *)
57 lemma frees_lref_pushs: ∀f,K,j. K ⊢ 𝐅*⦃#j⦄ ≘ f →
58                         ∀i,L. ⬇*[i] L ≘ K → L ⊢ 𝐅*⦃#(i+j)⦄ ≘ ⫯*[i] f.
59 #f #K #j #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
62   #I #Y #HYK #H destruct /3 width=1 by frees_lref/
63 ]
64 qed.
65 (*
66 lemma frees_gref_pushs: ∀f,K,l. K ⊢ 𝐅*⦃§l⦄ ≘ f →
67                         ∀i,L. ⬇*[i] L ≘ K → L ⊢ 𝐅*⦃§l⦄ ≘ ⫯*[i] f.
68 #f #K #l #Hf #i elim i -i
69 [ #L #H lapply (drops_fwd_isid … H ?) -H //
70 | #i #IH #L #H elim (drops_inv_succ … H) -H /3 width=1 by frees_gref/
71 ]
72 qed.
73 *)
74 (* Advanced inversion lemmas ************************************************)
75
76 lemma frees_inv_lref_drops: ∀L,i,f. L ⊢ 𝐅*⦃#i⦄ ≘ f →
77                             ∨∨ ∃∃g. ⬇*[Ⓕ, 𝐔❴i❵] L ≘ ⋆ & 𝐈⦃g⦄ & f = ⫯*[i] ↑g
78                              | ∃∃g,I,K,V. K ⊢ 𝐅*⦃V⦄ ≘ g &
79                                           ⬇*[i] L ≘ K.ⓑ{I}V & f = ⫯*[i] ↑g
80                              | ∃∃g,I,K. ⬇*[i] L ≘ K.ⓤ{I} & 𝐈⦃g⦄ & f = ⫯*[i] ↑g.
81 #L elim L -L
82 [ #i #g | #L #I #IH * [ #g cases I -I [ #I | #I #V ] -IH | #i #g ] ] #H
83 [ elim (frees_inv_atom … H) -H #f #Hf #H destruct
84   /3 width=3 by or3_intro0, ex3_intro/
85 | elim (frees_inv_unit … H) -H #f #Hf #H destruct
86   /4 width=3 by drops_refl, or3_intro2, ex3_3_intro/
87 | elim (frees_inv_pair … H) -H #f #Hf #H destruct
88   /4 width=7 by drops_refl, or3_intro1, ex3_4_intro/
89 | elim (frees_inv_lref … H) -H #f #Hf #H destruct
90   elim (IH … Hf) -IH -Hf *
91   [ /4 width=3 by drops_drop, or3_intro0, ex3_intro/
92   | /4 width=7 by drops_drop, or3_intro1, ex3_4_intro/
93   | /4 width=3 by drops_drop, or3_intro2, ex3_3_intro/
94   ]
95 ]
96 qed-.
97
98 (* Properties with generic slicing for local environments *******************)
99
100 lemma frees_lifts: ∀b,f1,K,T. K ⊢ 𝐅*⦃T⦄ ≘ f1 →
101                    ∀f,L. ⬇*[b, f] L ≘ K → ∀U. ⬆*[f] T ≘ U →
102                    ∀f2. f ~⊚ f1 ≘ f2 → L ⊢ 𝐅*⦃U⦄ ≘ f2.
103 #b #f1 #K #T #H lapply (frees_fwd_isfin … H) elim H -f1 -K -T
104 [ #f1 #K #s #Hf1 #_ #f #L #HLK #U #H2 #f2 #H3
105   lapply (coafter_isid_inv_dx … H3 … Hf1) -f1 #Hf2
106   >(lifts_inv_sort1 … H2) -U /2 width=1 by frees_sort/
107 | #f1 #i #Hf1 #_ #f #L #H1 #U #H2 #f2 #H3
108   elim (lifts_inv_lref1 … H2) -H2 #j #Hij #H destruct
109   elim (coafter_fwd_xnx_pushs … Hij H3) -H3 #g2 #Hg2 #H2 destruct
110   lapply (coafter_isid_inv_dx … Hg2 … Hf1) -f1 #Hf2
111   elim (drops_inv_atom2 … H1) -H1 #n #g #H1 #Hf
112   elim (after_at_fwd … Hij … Hf) -f #x #_ #Hj -g -i
113   lapply (at_inv_uni … Hj) -Hj #H destruct
114   /3 width=8 by frees_atom_drops, drops_trans/
115 | #f1 #I #K #V #_ #IH #Hf1 #f #L #H1 #U #H2 #f2 #H3
116   lapply (isfin_inv_next … Hf1 ??) -Hf1 [3: |*: // ] #Hf1
117   lapply (lifts_inv_lref1 … H2) -H2 * #j #Hf #H destruct
118   elim (drops_split_trans_bind2 … H1) -H1 [ |*: // ] #Z #Y #HLY #HYK #H
119   elim (liftsb_inv_pair_sn … H) -H #W #HVW #H destruct
120   elim (coafter_fwd_xnx_pushs … Hf H3) -H3 #g2 #H3 #H2 destruct
121   lapply (IH … HYK … HVW … H3) -IH -H3 -HYK -HVW //
122   /2 width=5 by frees_pair_drops/
123 | #f1 #I #K #Hf1 #_ #f #L #H1 #U #H2 #f2 #H3
124   lapply (lifts_inv_lref1 … H2) -H2 * #j #Hf #H destruct
125   elim (coafter_fwd_xnx_pushs … Hf H3) -H3 #g2 #H3 #H2 destruct
126   lapply (coafter_isid_inv_dx … H3 … Hf1) -f1 #Hg2
127   elim (drops_split_trans_bind2 … H1 … Hf) -H1 -Hf #Z #Y #HLY #_ #H
128   lapply (liftsb_inv_unit_sn … H) -H #H destruct
129   /2 width=3 by frees_unit_drops/
130 | #f1 #I #K #i #_ #IH #Hf1 #f #L #H1 #U #H2 #f2 #H3
131   lapply (isfin_inv_push … Hf1 ??) -Hf1 [3: |*: // ] #Hf1
132   lapply (lifts_inv_lref1 … H2) -H2 * #x #Hf #H destruct
133   elim (at_inv_nxx … Hf) -Hf [ |*: // ] #j #Hf #H destruct
134   elim (drops_split_trans_bind2 … H1) -H1 [ |*: // ] #Z #Y #HLY #HYK #_
135   elim (coafter_fwd_xpx_pushs … 0 … H3) [ |*: // ] #g2 #H3 #H2 destruct
136   lapply (drops_isuni_fwd_drop2 … HLY) -HLY // #HLY
137   lapply (IH … HYK … H3) -IH -H3 -HYK [4: |*: /2 width=2 by lifts_lref/ ]
138   >plus_S1 /2 width=3 by frees_lref_pushs/ (**) (* full auto fails *)
139 | #f1 #K #l #Hf1 #_ #f #L #HLK #U #H2 #f2 #H3
140   lapply (coafter_isid_inv_dx … H3 … Hf1) -f1 #Hf2
141   >(lifts_inv_gref1 … H2) -U /2 width=1 by frees_gref/
142 | #f1V #f1T #f1 #p #I #K #V #T #_ #_ #H1f1 #IHV #IHT #H2f1 #f #L #H1 #Y #H2 #f2 #H3
143   elim (sor_inv_isfin3 … H1f1) // #Hf1V #H
144   lapply (isfin_inv_tl … H) -H
145   elim (lifts_inv_bind1 … H2) -H2 #W #U #HVW #HTU #H destruct
146   elim (coafter_sor … H3 … H1f1) /2 width=5 by coafter_isfin2_fwd/ -H3 -H1f1 #f2V #f2T #Hf2V #H
147   elim (coafter_inv_tl1 … H) -H
148   /5 width=5 by frees_bind, drops_skip, ext2_pair/
149 | #f1V #f1T #f1 #I #K #V #T #_ #_ #H1f1 #IHV #IHT #H2f1 #f #L #H1 #Y #H2 #f2 #H3
150   elim (sor_inv_isfin3 … H1f1) //
151   elim (lifts_inv_flat1 … H2) -H2 #W #U #HVW #HTU #H destruct
152   elim (coafter_sor … H3 … H1f1)
153   /3 width=5 by coafter_isfin2_fwd, frees_flat/
154 ]
155 qed-.
156
157 lemma frees_lifts_SO: ∀b,L,K. ⬇*[b, 𝐔❴1❵] L ≘ K → ∀T,U. ⬆*[1] T ≘ U →
158                       ∀f. K ⊢ 𝐅*⦃T⦄ ≘ f → L ⊢ 𝐅*⦃U⦄ ≘ ⫯f.
159 #b #L #K #HLK #T #U #HTU #f #Hf
160 @(frees_lifts b … Hf … HTU) //  (**) (* auto fails *)
161 qed.
162
163 (* Forward lemmas with generic slicing for local environments ***************)
164
165 lemma frees_fwd_coafter: ∀b,f2,L,U. L ⊢ 𝐅*⦃U⦄ ≘ f2 →
166                          ∀f,K. ⬇*[b, f] L ≘ K → ∀T. ⬆*[f] T ≘ U →
167                          ∀f1. K ⊢ 𝐅*⦃T⦄ ≘ f1 → f ~⊚ f1 ≘ f2.
168 /4 width=11 by frees_lifts, frees_mono, coafter_eq_repl_back0/ qed-.
169
170 (* Inversion lemmas with generic slicing for local environments *************)
171
172 lemma frees_inv_lifts_ex: ∀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 #Hf2 #f #K #HLK #T elim (frees_total K T)
176 /3 width=9 by frees_fwd_coafter, ex2_intro/
177 qed-.
178
179 lemma frees_inv_lifts_SO: ∀b,f,L,U. L ⊢ 𝐅*⦃U⦄ ≘ f →
180                           ∀K. ⬇*[b, 𝐔❴1❵] L ≘ K → ∀T. ⬆*[1] T ≘ U →
181                           K ⊢ 𝐅*⦃T⦄ ≘ ⫱f.
182 #b #f #L #U #H #K #HLK #T #HTU elim(frees_inv_lifts_ex … H … HLK … HTU) -b -L -U
183 #f1 #Hf #Hf1 elim (coafter_inv_nxx … Hf) -Hf
184 /3 width=5 by frees_eq_repl_back, coafter_isid_inv_sn/
185 qed-.
186
187 lemma frees_inv_lifts: ∀b,f2,L,U. L ⊢ 𝐅*⦃U⦄ ≘ f2 →
188                        ∀f,K. ⬇*[b, f] L ≘ K → ∀T. ⬆*[f] T ≘ U →
189                        ∀f1. f ~⊚ f1 ≘ f2 → K ⊢ 𝐅*⦃T⦄ ≘ f1.
190 #b #f2 #L #U #H #f #K #HLK #T #HTU #f1 #Hf2 elim (frees_inv_lifts_ex … H … HLK … HTU) -b -L -U
191 /3 width=7 by frees_eq_repl_back, coafter_inj/
192 qed-.
193
194 (* Note: this is used by rex_conf and might be modified *)
195 lemma frees_inv_drops_next: ∀f1,L1,T1. L1 ⊢ 𝐅*⦃T1⦄ ≘ f1 →
196                             ∀I2,L2,V2,n. ⬇*[n] L1 ≘ L2.ⓑ{I2}V2 →
197                             ∀g1. ↑g1 = ⫱*[n] f1 →
198                             ∃∃g2. L2 ⊢ 𝐅*⦃V2⦄ ≘ g2 & g2 ⊆ g1.
199 #f1 #L1 #T1 #H elim H -f1 -L1 -T1
200 [ #f1 #L1 #s #Hf1 #I2 #L2 #V2 #n #_ #g1 #H1 -I2 -L1 -s
201   lapply (isid_tls n … Hf1) -Hf1 <H1 -f1 #Hf1
202   elim (isid_inv_next … Hf1) -Hf1 //
203 | #f1 #i #_ #I2 #L2 #V2 #n #H
204   elim (drops_inv_atom1 … H) -H #H destruct
205 | #f1 #I1 #L1 #V1 #Hf1 #IH #I2 #L2 #V2 *
206   [ -IH #HL12 lapply (drops_fwd_isid … HL12 ?) -HL12 //
207     #H destruct #g1 #Hgf1 >(injective_next … Hgf1) -g1
208     /2 width=3 by ex2_intro/
209   | -Hf1 #n #HL12 lapply (drops_inv_drop1 … HL12) -HL12
210     #HL12 #g1 <tls_xn <tl_next_rew #Hgf1 elim (IH … HL12 … Hgf1) -IH -HL12 -Hgf1
211     /2 width=3 by ex2_intro/
212   ]
213 | #f1 #I1 #L1 #Hf1 #I2 #L2 #V2 *
214   [ #HL12 lapply (drops_fwd_isid … HL12 ?) -HL12 // #H destruct
215   | #n #_ #g1 #Hgf1 elim (isid_inv_next … Hgf1) -Hgf1 <tls_xn /2 width=1 by isid_tls/
216   ]
217 | #f1 #I1 #L1 #i #_ #IH #I2 #L2 #V2 *
218   [ -IH #_ #g1 #Hgf1 elim (discr_next_push … Hgf1)
219   | #n #HL12 lapply (drops_inv_drop1 … HL12) -HL12
220     #HL12 #g1 <tls_xn #Hgf1 elim (IH … HL12 … Hgf1) -IH -HL12 -Hgf1
221     /2 width=3 by ex2_intro/
222   ]
223 | #f1 #L1 #l #Hf1 #I2 #L2 #V2 #n #_ #g1 #H1 -I2 -L1 -l
224   lapply (isid_tls n … Hf1) -Hf1 <H1 -f1 #Hf1
225   elim (isid_inv_next … Hf1) -Hf1 //
226 | #fV1 #fT1 #f1 #p #I1 #L1 #V1 #T1 #_ #_ #Hf1 #IHV1 #IHT1 #I2 #L2 #V2 #n #HL12 #g1 #Hgf1
227   lapply (sor_tls … Hf1 n) -Hf1 <Hgf1 -Hgf1 #Hf1
228   elim (sor_xxn_tl … Hf1) [1,2: * |*: // ] -Hf1
229   #gV1 #gT1 #Hg1
230   [ -IHT1 #H1 #_ elim (IHV1 … HL12 … H1) -IHV1 -HL12 -H1
231     /3 width=6 by sor_inv_sle_sn_trans, ex2_intro/
232   | -IHV1 #_ >tls_xn #H2 elim (IHT1 … H2) -IHT1 -H2
233     /3 width=6 by drops_drop, sor_inv_sle_dx_trans, ex2_intro/
234   ]
235 | #fV1 #fT1 #f1 #I1 #L1 #V1 #T1 #_ #_ #Hf1 #IHV1 #IHT1 #I2 #L2 #V2 #n #HL12 #g1 #Hgf1
236   lapply (sor_tls … Hf1 n) -Hf1 <Hgf1 -Hgf1 #Hf1
237   elim (sor_xxn_tl … Hf1) [1,2: * |*: // ] -Hf1
238   #gV1 #gT1 #Hg1
239   [ -IHT1 #H1 #_ elim (IHV1 … HL12 … H1) -IHV1 -HL12 -H1
240     /3 width=6 by sor_inv_sle_sn_trans, ex2_intro/
241   | -IHV1 #_ #H2 elim (IHT1 … HL12 … H2) -IHT1 -HL12 -H2
242     /3 width=6 by sor_inv_sle_dx_trans, ex2_intro/
243   ]
244 ]
245 qed-.