1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "ground/relocation/nstream_coafter.ma".
16 include "static_2/relocation/drops_drops.ma".
17 include "static_2/static/frees_fqup.ma".
19 (* CONTEXT-SENSITIVE FREE VARIABLES *****************************************)
21 (* Advanced properties ******************************************************)
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/
28 [ #H lapply (drops_fwd_isid … H ?) -H // #H destruct
29 | /4 width=3 by frees_lref, drops_inv_drop1/
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/
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/
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/
62 (* Advanced inversion lemmas ************************************************)
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.
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/
86 (* Properties with generic slicing for local environments *******************)
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 (pr_coafter_isi_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 (pr_coafter_isi_inv_dx … Hg2 … Hf1) -f1 #Hf2
100 elim (drops_inv_atom2 … H1) -H1 #n #g #H1 #Hf
101 elim (pr_after_pat_des … Hij … Hf) -f #x #_ #Hj -g -i
102 lapply (pr_pat_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 (pr_isf_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 (pr_coafter_isi_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 (pr_isf_inv_push … Hf1 ??) -Hf1 [3: |*: // ] #Hf1
121 lapply (lifts_inv_lref1 … H2) -H2 * #x #Hf #H destruct
122 elim (pr_pat_inv_succ_sn … 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 >nplus_succ_sn /2 width=3 by frees_lref_pushs/ (**) (* full auto fails *)
128 | #f1 #K #l #Hf1 #_ #f #L #HLK #U #H2 #f2 #H3
129 lapply (pr_coafter_isi_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 (pr_sor_inv_isf … H1f1) // #Hf1V #H
133 lapply (pr_isf_inv_tl … H) -H
134 elim (lifts_inv_bind1 … H2) -H2 #W #U #HVW #HTU #H destruct
135 elim (pr_sor_coafter_dx_tans … H3 … H1f1) /2 width=5 by pr_coafter_des_ist_isf/ -H3 -H1f1 #f2V #f2T #Hf2V #H
136 elim (pr_coafter_inv_tl_dx … 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 (pr_sor_inv_isf … H1f1) //
140 elim (lifts_inv_flat1 … H2) -H2 #W #U #HVW #HTU #H destruct
141 elim (pr_sor_coafter_dx_tans … H3 … H1f1)
142 /3 width=5 by pr_coafter_des_ist_isf, frees_flat/
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 *)
153 (* Forward lemmas with generic slicing for local environments ***************)
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, pr_coafter_eq_repl_back/ qed-.
161 (* Inversion lemmas with generic slicing for local environments *************)
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/
171 lemma frees_inv_lifts_SO:
172 ∀b,f,L,U. L ⊢ 𝐅+❨U❩ ≘ f →
173 ∀K. ⇩*[b,𝐔❨1❩] L ≘ K → ∀T. ⇧[1] T ≘ U →
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 (pr_coafter_inv_next_sn … Hf) -Hf
177 /3 width=5 by frees_eq_repl_back, pr_coafter_isi_inv_sn/
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, pr_coafter_inj/
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 (pr_isi_tls j … Hf1) -Hf1 <H1 -f1 #Hf1
197 elim (pr_isi_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 >(eq_inv_pr_next_bi … Hgf1) -g1
203 /2 width=3 by ex2_intro/
204 | -Hf1 #j #HL12 lapply (drops_inv_drop1 … HL12) -HL12
205 #HL12 #g1 <pr_tls_swap <pr_tl_next #Hgf1 elim (IH … HL12 … Hgf1) -IH -HL12 -Hgf1
206 /2 width=3 by ex2_intro/
208 | #f1 #I1 #L1 #Hf1 #I2 #L2 #V2 *
209 [ #HL12 lapply (drops_fwd_isid … HL12 ?) -HL12 // #H destruct
210 | #j #_ #g1 #Hgf1 elim (pr_isi_inv_next … Hgf1) -Hgf1 <pr_tls_swap /2 width=1 by pr_isi_tls/
212 | #f1 #I1 #L1 #i #_ #IH #I2 #L2 #V2 *
213 [ -IH #_ #g1 #Hgf1 elim (eq_inv_pr_next_push … Hgf1)
214 | #j #HL12 lapply (drops_inv_drop1 … HL12) -HL12
215 #HL12 #g1 <pr_tls_swap #Hgf1 elim (IH … HL12 … Hgf1) -IH -HL12 -Hgf1
216 /2 width=3 by ex2_intro/
218 | #f1 #L1 #l #Hf1 #I2 #L2 #V2 #j #_ #g1 #H1 -I2 -L1 -l
219 lapply (pr_isi_tls j … Hf1) -Hf1 <H1 -f1 #Hf1
220 elim (pr_isi_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 (pr_sor_tls … Hf1 j) -Hf1 <Hgf1 -Hgf1 #Hf1
223 elim (pr_sor_next_tl … Hf1) [1,2: * |*: // ] -Hf1
225 [ -IHT1 #H1 #_ elim (IHV1 … HL12 … H1) -IHV1 -HL12 -H1
226 /3 width=6 by pr_sor_inv_sle_sn_trans, ex2_intro/
227 | -IHV1 #_ >pr_tls_swap #H2 elim (IHT1 … H2) -IHT1 -H2
228 /3 width=6 by drops_drop, pr_sor_inv_sle_dx_trans, ex2_intro/
230 | #fV1 #fT1 #f1 #I1 #L1 #V1 #T1 #_ #_ #Hf1 #IHV1 #IHT1 #I2 #L2 #V2 #j #HL12 #g1 #Hgf1
231 lapply (pr_sor_tls … Hf1 j) -Hf1 <Hgf1 -Hgf1 #Hf1
232 elim (pr_sor_next_tl … Hf1) [1,2: * |*: // ] -Hf1
234 [ -IHT1 #H1 #_ elim (IHV1 … HL12 … H1) -IHV1 -HL12 -H1
235 /3 width=6 by pr_sor_inv_sle_sn_trans, ex2_intro/
236 | -IHV1 #_ #H2 elim (IHT1 … HL12 … H2) -IHT1 -HL12 -H2
237 /3 width=6 by pr_sor_inv_sle_dx_trans, ex2_intro/