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 "basic_2/rt_computation/cpms_drops.ma".
16 include "basic_2/rt_conversion/cpce.ma".
18 (* CONTEXT-SENSITIVE PARALLEL ETA-CONVERSION FOR TERMS **********************)
20 (* Advanced properties ******************************************************)
22 lemma cpce_zero_drops (h) (G):
23 ∀i,L. (∀n,p,K,W,V,U. ⇩*[i] L ≘ K.ⓛW → ⦃G,K⦄ ⊢ W ➡*[n,h] ⓛ{p}V.U → ⊥) →
26 [ * [ #_ // ] #L #I #Hi
27 /4 width=8 by cpce_zero, drops_refl/
28 | #i #IH * [ -IH #_ // ] #L #I #Hi
29 /5 width=8 by cpce_lref, drops_drop/
33 lemma cpce_eta_drops (h) (n) (G) (K):
34 ∀p,W,V1,U. ⦃G,K⦄ ⊢ W ➡*[n,h] ⓛ{p}V1.U →
35 ∀V2. ⦃G,K⦄ ⊢ V1 ⬌η[h] V2 →
36 ∀i,L. ⇩*[i] L ≘ K.ⓛW →
37 ∀W2. ⇧*[↑i] V2 ≘ W2 → ⦃G,L⦄ ⊢ #i ⬌η[h] +ⓛW2.ⓐ#0.#↑i.
38 #h #n #G #K #p #W #V1 #U #HWU #V2 #HV12 #i elim i -i
40 >(drops_fwd_isid … HLK) -L [| // ] /2 width=8 by cpce_eta/
41 | #i #IH #L #HLK #W2 #HVW2
42 elim (drops_inv_succ … HLK) -HLK #I #Y #HYK #H destruct
43 elim (lifts_split_trans … HVW2 (𝐔❴↑i❵) (𝐔❴1❵)) [| // ] #X2 #HVX2 #HXW2
44 /5 width=7 by cpce_lref, lifts_push_lref, lifts_bind, lifts_flat/
48 lemma cpce_lref_drops (h) (G) (K) (i):
49 ∀T. ⦃G,K⦄ ⊢ #i ⬌η[h] T → ∀j,L. ⇩*[j] L ≘ K →
50 ∀U. ⇧*[j] T ≘ U → ⦃G,L⦄ ⊢ #(j+i) ⬌η[h] U.
51 #h #G #K #i #T #Hi #j elim j -j
53 lapply (drops_fwd_isid … HLK ?) -HLK [ // ] #H destruct
54 lapply (lifts_fwd_isid … HTU ?) -HTU [ // ] #H destruct //
55 | #j #IH #Y #HYK #X #HTX -Hi
56 elim (drops_inv_succ … HYK) -HYK #I #L #HLK #H destruct
57 elim (lifts_split_trans … HTX (𝐔❴j❵) (𝐔❴1❵)) [| // ] #U #HTU #HUX
58 /3 width=3 by cpce_lref/
62 (* Advanced inversion lemmas ************************************************)
64 lemma cpce_inv_lref_sn_drops_bind (h) (G) (i) (L):
65 ∀X2. ⦃G,L⦄ ⊢ #i ⬌η[h] X2 →
66 ∀I,K. ⇩*[i] L ≘ K.ⓘ{I} →
67 ∨∨ ∧∧ ∀n,p,W,V,U. I = BPair Abst W → ⦃G,K⦄ ⊢ W ➡*[n,h] ⓛ{p}V.U → ⊥ & #i = X2
68 | ∃∃n,p,W,V1,V2,W2,U. ⦃G,K⦄ ⊢ W ➡*[n,h] ⓛ{p}V1.U & ⦃G,K⦄ ⊢ V1 ⬌η[h] V2
69 & ⇧*[↑i] V2 ≘ W2 & I = BPair Abst W & +ⓛW2.ⓐ#0.#(↑i) = X2.
71 [ #L #X2 #HX2 #I #K #HLK
72 lapply (drops_fwd_isid … HLK ?) -HLK [ // ] #H destruct
73 /2 width=1 by cpce_inv_zero_sn/
74 | #i #IH #L0 #X0 #HX0 #J #K #H0
75 elim (drops_inv_succ … H0) -H0 #I #L #HLK #H destruct
76 elim (cpce_inv_lref_sn … HX0) -HX0 #X2 #HX2 #HX20
77 elim (IH … HX2 … HLK) -IH -I -L *
79 lapply (lifts_inv_lref1_uni … HX20) -HX20 #H destruct
80 /4 width=7 by or_introl, conj/
81 | #n #p #W #V1 #V2 #W2 #U #HWU #HV12 #HVW2 #H1 #H2 destruct
82 elim (lifts_inv_bind1 … HX20) -HX20 #X2 #X #HWX2 #HX #H destruct
83 elim (lifts_inv_flat1 … HX) -HX #X0 #X1 #H0 #H1 #H destruct
84 lapply (lifts_inv_push_zero_sn … H0) -H0 #H destruct
85 elim (lifts_inv_push_succ_sn … H1) -H1 #j #Hj #H destruct
86 lapply (lifts_inv_lref1_uni … Hj) -Hj #H destruct
87 /4 width=12 by lifts_trans_uni, ex5_7_intro, or_intror/
92 lemma cpce_inv_zero_sn_drops (h) (G) (i) (L):
93 ∀X2. ⦃G,L⦄ ⊢ #i ⬌η[h] X2 →
94 ∀I,K. ⇩*[i] L ≘ K.ⓘ{I} →
95 (∀n,p,W,V,U. I = BPair Abst W → ⦃G,K⦄ ⊢ W ➡*[n,h] ⓛ{p}V.U → ⊥) →
97 #h #G #i #L #X2 #HX2 #I #K #HLK #HI
98 elim (cpce_inv_lref_sn_drops_bind … HX2 … HLK) -L *
100 | #n #p #W #V1 #V2 #W2 #U #HWU #_ #_ #H destruct
101 elim (HI … HWU) -n -p -K -X2 -V1 -V2 -W2 -U -i //
105 (* Properties with uniform slicing for local environments *******************)
107 lemma cpce_lifts_sn (h) (G):
108 d_liftable2_sn … lifts (cpce h G).
109 #h #G #K #T1 #T2 #H elim H -G -K -T1 -T2
110 [ #G #K #s #b #f #L #HLK #X #HX
111 lapply (lifts_inv_sort1 … HX) -HX #H destruct
112 /2 width=3 by cpce_sort, lifts_sort, ex2_intro/
113 | #G #i #b #f #L #HLK #X #HX
114 elim (lifts_inv_lref1 … HX) -HX #j #Hf #H destruct
116 [ /2 width=1 by lifts_lref/
117 | @cpce_zero_drops #n #p #Y #W #V #U #HY #_
118 elim (drops_inv_atom2 … HLK) -HLK #j1 #g #HLK #Hg
119 elim (after_at_fwd … Hf … Hg) -f #j2 #_ #Hj -g -i
120 lapply (at_inv_uni … Hj) -Hj #H destruct
121 lapply (drops_conf … HLK … HY ??) -L [3:|*: // ] #H
122 elim (drops_inv_atom1 … H) -H #H #_ destruct
124 | #G #K #I #HI #b #f #L #HLK #X #HX
125 elim (lifts_inv_lref1 … HX) -HX #j #Hf #H destruct
127 [ /2 width=1 by lifts_lref/
128 | elim (drops_split_trans_bind2 … HLK … Hf) -HLK -Hf #J #Y1 #HY1 #HK #HIJ
129 @cpce_zero_drops #n #p #Y2 #W #V #U #HY2 #HWU
130 lapply (drops_mono … HY2 … HY1) -L #H destruct
131 elim (liftsb_inv_pair_dx … HIJ) -HIJ #X #HXW #H destruct
132 elim (cpms_inv_lifts_sn … HWU … HK … HXW) -b -Y1 -W #X0 #H #HXU
133 elim (lifts_inv_bind2 … H) -H #V0 #U0 #_ #_ #H destruct -f -j -V -U
136 | #n #p #G #K #W #V1 #V2 #W2 #U #HWU #_ #HVW2 #IH #b #f #L #HLK #X #HX
137 elim (lifts_inv_lref1 … HX) -HX #j #Hf #H destruct
138 elim (drops_split_trans_bind2 … HLK … Hf) -HLK #J #Y #HY #HK #HIJ
139 elim (liftsb_inv_pair_sn … HIJ) -HIJ #W0 #HW0 #H destruct
140 elim (cpms_lifts_sn … HWU … HK … HW0) -HWU -HW0 #X #H #HWU0
141 elim (lifts_inv_bind1 … H) -H #V0 #U0 #HV10 #HU0 #H destruct
142 elim (IH … HK … HV10) -IH -HK -HV10 #VX #HV2X #HV0X
143 elim (lifts_total W2 f) #WX2 #HWX2
144 lapply (lifts_trans … HVW2 … HWX2 ??) [3:|*: // ] -HVW2 #HVX2
145 @(ex2_intro … (+ⓛWX2.ⓐ#O.#(↑j)))
146 [ /5 width=1 by lifts_lref, lifts_bind, lifts_flat, at_S1/
147 | /4 width=18 by cpce_eta_drops, lifts_conf, after_uni_succ_dx/
149 | #I #G #K #T #U #i #_ #HTU #IH #b #f #L #HLK #X #HX
150 elim (lifts_inv_lref1 … HX) -HX #x #Hf #H destruct
151 elim (at_inv_nxx … Hf) -Hf [|*: // ] #j #Hf #H destruct
152 elim (drops_split_trans_bind2 … HLK) -HLK [|*: // ] #Z #Y #HLY #HYK #_ -I
153 lapply (drops_isuni_fwd_drop2 … HLY) -HLY [ // ] #HLY
154 elim (IH … HYK) -IH -HYK [|*: /2 width=2 by lifts_lref/ ] -i #T0 #HT0 #Hj
155 elim (lifts_total U f) #U0 #HU0
156 lapply (lifts_trans … HTU … HU0 ??) [3:|*: // ] -HTU #HTU0
157 lapply (lifts_conf … HT0 … HTU0 ??) -T
158 [3:|*: /2 width=3 by after_uni_succ_dx/ ] #HTU0 >plus_S1
159 /3 width=7 by cpce_lref_drops, ex2_intro/
160 | #G #K #l #b #f #L #HLK #X #HX
161 lapply (lifts_inv_gref1 … HX) -HX #H destruct
162 /2 width=3 by cpce_gref, lifts_gref, ex2_intro/
163 | #p #I #G #K #V1 #V2 #T1 #T2 #_ #_ #IHV #IHT #b #f #L #HLK #X #HX
164 elim (lifts_inv_bind1 … HX) -HX #W1 #U1 #HVW1 #HTU1 #H destruct
165 elim (IHV … HLK … HVW1) -IHV #W2 #HVW2 #HW12
166 elim (IHT … HTU1) -IHT -HTU1 [|*: /3 width=3 by drops_skip, ext2_pair/ ] -HVW1 #U2 #HTU2 #HU12
167 /3 width=5 by cpce_bind, lifts_bind, ex2_intro/
168 | #I #G #K #V1 #V2 #T1 #T2 #_ #_ #IHV #IHT #b #f #L #HLK #X #HX
169 elim (lifts_inv_flat1 … HX) -HX #W1 #U1 #HVW1 #HTU1 #H destruct
170 elim (IHV … HLK … HVW1) -IHV -HVW1 #W2 #HVW2 #HW12
171 elim (IHT … HLK … HTU1) -IHT -HTU1 -HLK #U2 #HTU2 #HU12
172 /3 width=5 by cpce_flat, lifts_flat, ex2_intro/
176 lemma cpce_lifts_bi (h) (G):
177 d_liftable2_bi … lifts (cpce h G).
178 /3 width=12 by cpce_lifts_sn, d_liftable2_sn_bi, lifts_mono/ qed-.
180 (* Inversion lemmas with uniform slicing for local environments *************)
182 lemma cpce_inv_lifts_sn (h) (G):
183 d_deliftable2_sn … lifts (cpce h G).
184 #h #G #K #T1 #T2 #H elim H -G -K -T1 -T2
185 [ #G #K #s #b #f #L #HLK #X #HX
186 lapply (lifts_inv_sort2 … HX) -HX #H destruct
187 /2 width=3 by cpce_sort, lifts_sort, ex2_intro/
188 | #G #i #b #f #L #HLK #X #HX
189 elim (lifts_inv_lref2 … HX) -HX #j #Hf #H destruct
191 [ /2 width=1 by lifts_lref/
192 | @cpce_zero_drops #n #p #Y #W #V #U #HY #_ -n -p -G -V -U -i
193 elim (drops_inv_atom1 … HLK) -HLK #H #_ destruct -b -f
194 elim (drops_inv_atom1 … HY) -HY #H #_ destruct
196 | #G #K #I #HI #b #f #L #HLK #X #HX
197 elim (lifts_inv_lref2 … HX) -HX #j #Hf #H destruct
199 [ /2 width=1 by lifts_lref/
200 | elim (at_inv_xxp … Hf) -Hf [| // ] #g #H1 #H2 destruct
201 elim (drops_inv_skip1 … HLK) -HLK #J #Y #HKY #HIJ #H destruct
202 @cpce_zero #n #p #W #V #U #H #HWU destruct
203 elim (liftsb_inv_pair_sn … HIJ) -HIJ #X #HXW #H destruct
204 elim (cpms_lifts_sn … HWU … HKY … HXW) -b -Y -W #X0 #H #HXU
205 elim (lifts_inv_bind1 … H) -H #V0 #U0 #_ #_ #H destruct -V -U
208 | #n #p #G #K #W #V1 #V2 #W2 #U #HWU #_ #HVW2 #IH #b #f #L #HLK #X #HX
209 elim (lifts_inv_lref2 … HX) -HX #j #Hf #H destruct
210 elim (at_inv_xxp … Hf) -Hf [| // ] #g #H1 #H2 destruct
211 elim (drops_inv_skip1 … HLK) -HLK #J #Y #HKY #HIJ #H destruct
212 elim (liftsb_inv_pair_dx … HIJ) -HIJ #W0 #HW0 #H destruct
213 elim (cpms_inv_lifts_sn … HWU … HKY … HW0) -HWU -HW0 #X #H #HWU0
214 elim (lifts_inv_bind2 … H) -H #V0 #U0 #HV10 #HU0 #H destruct
215 elim (IH … HKY … HV10) -IH -HKY -HV10 #VX #HV2X #HV0X
216 lapply (lifts_trans … HV2X … HVW2 (↑g) ?)
217 [ /3 width=5 by after_isid_sn, after_next/ ] -V2 #H
218 elim (lifts_split_trans … H 𝐔❴1❵ (⫯g) ?)
219 [| /3 width=7 by after_isid_dx, after_push/ ] #VX2 #HVX2 #HVW2
220 /5 width=10 by cpce_eta, lifts_flat, lifts_bind, lifts_lref, ex2_intro/
221 | #I #G #K #T #U #i #_ #HTU #IH #b #f #L #HLK #X #HX
222 elim (lifts_inv_lref2 … HX) -HX #x #Hf #H destruct
223 (**) (* this part should be a lemma *)
224 elim (at_inv_xxn … Hf) -Hf [2,4: // ] *
225 [ #g #j #Hij #H1 #H2 destruct
226 elim (drops_inv_skip1 … HLK) -HLK #J #Y #HLK #_ #H destruct -I
227 | #g #Hij #H destruct
228 lapply (drops_inv_drop1 … HLK) -HLK #HLK
231 elim (IH … HLK) -IH -HLK [1,4:|*: /2 width=2 by lifts_lref/ ] -i #T0 #HT0 #Hj
232 lapply (lifts_trans … HT0 … HTU (↑g) ?)
233 [1,3: /3 width=5 by after_isid_sn, after_next/ ] -T #H
234 elim (lifts_split_trans … H 𝐔❴1❵ (⫯g) ?)
235 [2,4: /3 width=7 by after_isid_dx, after_push/ ] #U0 #HTU0 #HU0
236 /3 width=5 by cpce_lref, ex2_intro/
237 | #G #K #l #b #f #L #HLK #X #HX
238 lapply (lifts_inv_gref2 … HX) -HX #H destruct
239 /2 width=3 by cpce_gref, lifts_gref, ex2_intro/
240 | #p #I #G #K #V1 #V2 #T1 #T2 #_ #_ #IHV #IHT #b #f #L #HLK #X #HX
241 elim (lifts_inv_bind2 … HX) -HX #W1 #U1 #HVW1 #HTU1 #H destruct
242 elim (IHV … HLK … HVW1) -IHV #W2 #HVW2 #HW12
243 elim (IHT … HTU1) -IHT -HTU1 [|*: /3 width=3 by drops_skip, ext2_pair/ ] -HVW1 #U2 #HTU2 #HU12
244 /3 width=5 by cpce_bind, lifts_bind, ex2_intro/
245 | #I #G #K #V1 #V2 #T1 #T2 #_ #_ #IHV #IHT #b #f #L #HLK #X #HX
246 elim (lifts_inv_flat2 … HX) -HX #W1 #U1 #HVW1 #HTU1 #H destruct
247 elim (IHV … HLK … HVW1) -IHV -HVW1 #W2 #HVW2 #HW12
248 elim (IHT … HLK … HTU1) -IHT -HTU1 -HLK #U2 #HTU2 #HU12
249 /3 width=5 by cpce_flat, lifts_flat, ex2_intro/
253 lemma cpce_inv_lifts_bi (h) (G):
254 d_deliftable2_bi … lifts (cpce h G).
255 /3 width=12 by cpce_inv_lifts_sn, d_deliftable2_sn_bi, lifts_inj/ qed-.