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