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/relocation/cny_lift.ma".
16 include "basic_2/substitution/fqup.ma".
17 include "basic_2/substitution/cpys_lift.ma".
18 include "basic_2/substitution/cpye.ma".
20 (* EVALUATION FOR CONTEXT-SENSITIVE EXTENDED SUBSTITUTION ON TERMS **********)
22 (* Advanced properties ******************************************************)
24 lemma cpye_subst: ∀I,G,L,K,V1,V2,W2,i,d,e. d ≤ yinj i → i < d + e →
25 ⇩[i] L ≡ K.ⓑ{I}V1 → ⦃G, K⦄ ⊢ V1 ▶*[O, ⫰(d+e-i)] 𝐍⦃V2⦄ →
26 ⇧[O, i+1] V2 ≡ W2 → ⦃G, L⦄ ⊢ #i ▶*[d, e] 𝐍⦃W2⦄.
27 #I #G #L #K #V1 #V2 #W2 #i #d #e #Hdi #Hide #HLK *
28 /4 width=13 by cpys_subst, cny_lift_subst, ldrop_fwd_drop2, conj/
31 lemma cpye_total: ∀G,L,T1,d,e. ∃T2. ⦃G, L⦄ ⊢ T1 ▶*[d, e] 𝐍⦃T2⦄.
32 #G #L #T1 @(fqup_wf_ind_eq … G L T1) -G -L -T1
33 #Z #Y #X #IH #G #L * *
34 [ #k #HG #HL #HT #d #e destruct -IH /2 width=2 by ex_intro/
35 | #i #HG #HL #HT #d #e destruct
36 elim (ylt_split i d) /3 width=2 by cpye_skip, ex_intro/
37 elim (ylt_split i (d+e)) /3 width=2 by cpye_top, ex_intro/
38 elim (lt_or_ge i (|L|)) /3 width=2 by cpye_free, ex_intro/
39 #Hi #Hide #Hdi elim (ldrop_O1_lt L i) // -Hi
40 #I #K #V1 #HLK elim (IH G K V1 … 0 (⫰(d+e-i))) -IH /2 width=2 by fqup_lref/
41 #V2 elim (lift_total V2 0 (i+1)) /3 width=8 by ex_intro, cpye_subst/
42 | #p #HG #HL #HT #d #e destruct -IH /2 width=2 by ex_intro/
43 | #a #I #V1 #T1 #HG #HL #HT #d #e destruct
44 elim (IH G L V1 … d e) // elim (IH G (L.ⓑ{I}V1) T1 … (⫯d) e) //
45 /3 width=2 by cpye_bind, ex_intro/
46 | #I #V1 #T1 #HG #HL #HT #d #e destruct
47 elim (IH G L V1 … d e) // elim (IH G L T1 … d e) //
48 /3 width=2 by cpye_flat, ex_intro/
52 (* Advanced inversion lemmas ************************************************)
54 lemma cpye_inv_lref1: ∀G,L,T2,d,e,i. ⦃G, L⦄ ⊢ #i ▶*[d, e] 𝐍⦃T2⦄ →
56 | d + e ≤ yinj i ∧ T2 = #i
57 | yinj i < d ∧ T2 = #i
58 | ∃∃I,K,V1,V2. d ≤ yinj i & yinj i < d + e &
60 ⦃G, K⦄ ⊢ V1 ▶*[yinj 0, ⫰(d+e-yinj i)] 𝐍⦃V2⦄ &
62 #G #L #T2 #i #d #e * #H1 #H2 elim (cpys_inv_lref1 … H1) -H1
63 [ #H destruct elim (cny_inv_lref … H2) -H2
64 /3 width=1 by or4_intro0, or4_intro1, or4_intro2, conj/
65 | * #I #K #V1 #V2 #Hdi #Hide #HLK #HV12 #HVT2
66 @or4_intro3 @(ex5_4_intro … HLK … HVT2) (**) (* explicit constructor *)
67 /4 width=13 by cny_inv_lift_subst, ldrop_fwd_drop2, conj/
71 lemma cpye_inv_lref1_free: ∀G,L,T2,d,e,i. ⦃G, L⦄ ⊢ #i ▶*[d, e] 𝐍⦃T2⦄ →
72 (∨∨ |L| ≤ i | d + e ≤ yinj i | yinj i < d) → T2 = #i.
73 #G #L #T2 #d #e #i #H * elim (cpye_inv_lref1 … H) -H * //
74 #I #K #V1 #V2 #Hdi #Hide #HLK #_ #_ #H
75 [ elim (lt_refl_false i) -d
76 @(lt_to_le_to_lt … H) -H /2 width=5 by ldrop_fwd_length_lt2/ (**) (* full auto slow: 19s *)
78 elim (ylt_yle_false … H) //
81 lemma cpye_inv_lref1_lget: ∀G,L,T2,d,e,i. ⦃G, L⦄ ⊢ #i ▶*[d, e] 𝐍⦃T2⦄ →
82 ∀I,K,V1. ⇩[i] L ≡ K.ⓑ{I}V1 →
83 ∨∨ d + e ≤ yinj i ∧ T2 = #i
84 | yinj i < d ∧ T2 = #i
85 | ∃∃V2. d ≤ yinj i & yinj i < d + e &
86 ⦃G, K⦄ ⊢ V1 ▶*[yinj 0, ⫰(d+e-yinj i)] 𝐍⦃V2⦄ &
88 #G #L #T2 #d #e #i #H #I #K #V1 #HLK elim (cpye_inv_lref1 … H) -H *
89 [ #H elim (lt_refl_false i) -T2 -d
90 @(lt_to_le_to_lt … H) -H /2 width=5 by ldrop_fwd_length_lt2/
91 | /3 width=1 by or3_intro0, conj/
92 | /3 width=1 by or3_intro1, conj/
93 | #Z #Y #X1 #X2 #Hdi #Hide #HLY #HX12 #HXT2
94 lapply (ldrop_mono … HLY … HLK) -HLY -HLK #H destruct
95 /3 width=3 by or3_intro2, ex4_intro/
99 lemma cpye_inv_lref1_subst_ex: ∀G,L,T2,d,e,i. ⦃G, L⦄ ⊢ #i ▶*[d, e] 𝐍⦃T2⦄ →
100 ∀I,K,V1. d ≤ yinj i → yinj i < d + e →
102 ∃∃V2. ⦃G, K⦄ ⊢ V1 ▶*[yinj 0, ⫰(d+e-yinj i)] 𝐍⦃V2⦄ &
104 #G #L #T2 #d #e #i #H #I #K #V1 #Hdi #Hide #HLK
105 elim (cpye_inv_lref1_lget … H … HLK) -H * /2 width=3 by ex2_intro/
106 #H elim (ylt_yle_false … H) //
109 lemma cpye_inv_lref1_subst: ∀G,L,T2,d,e,i. ⦃G, L⦄ ⊢ #i ▶*[d, e] 𝐍⦃T2⦄ →
110 ∀I,K,V1,V2. d ≤ yinj i → yinj i < d + e →
111 ⇩[i] L ≡ K.ⓑ{I}V1 → ⇧[O, i+1] V2 ≡ T2 →
112 ⦃G, K⦄ ⊢ V1 ▶*[yinj 0, ⫰(d+e-yinj i)] 𝐍⦃V2⦄.
113 #G #L #T2 #d #e #i #H #I #K #V1 #V2 #Hdi #Hide #HLK #HVT2
114 elim (cpye_inv_lref1_subst_ex … H … HLK) -H -HLK //
115 #X2 #H0 #HXT2 lapply (lift_inj … HXT2 … HVT2) -HXT2 -HVT2 #H destruct //
118 (* Inversion lemmas on relocation *******************************************)
120 lemma cpye_inv_lift1_le: ∀G,L,U1,U2,dt,et. ⦃G, L⦄ ⊢ U1 ▶*[dt, et] 𝐍⦃U2⦄ →
121 ∀K,s,d,e. ⇩[s, d, e] L ≡ K → ∀T1. ⇧[d, e] T1 ≡ U1 →
123 ∃∃T2. ⦃G, K⦄ ⊢ T1 ▶*[dt, et] 𝐍⦃T2⦄ & ⇧[d, e] T2 ≡ U2.
124 #G #L #U1 #U2 #dt #et * #HU12 #HU2 #K #s #d #e #HLK #T1 #HTU1 #Hdetd
125 elim (cpys_inv_lift1_le … HU12 … HLK … HTU1) -U1 // #T2 #HT12 #HTU2
126 lapply (cny_inv_lift_le … HU2 … HLK … HTU2 ?) -L
127 /3 width=3 by ex2_intro, conj/
130 lemma cpye_inv_lift1_be: ∀G,L,U1,U2,dt,et. ⦃G, L⦄ ⊢ U1 ▶*[dt, et] 𝐍⦃U2⦄ →
131 ∀K,s,d,e. ⇩[s, d, e] L ≡ K → ∀T1. ⇧[d, e] T1 ≡ U1 →
132 dt ≤ d → yinj d + e ≤ dt + et →
133 ∃∃T2. ⦃G, K⦄ ⊢ T1 ▶*[dt, et - e] 𝐍⦃T2⦄ & ⇧[d, e] T2 ≡ U2.
134 #G #L #U1 #U2 #dt #et * #HU12 #HU2 #K #s #d #e #HLK #T1 #HTU1 #Hdtd #Hdedet
135 elim (cpys_inv_lift1_be … HU12 … HLK … HTU1) -U1 // #T2 #HT12 #HTU2
136 lapply (cny_inv_lift_be … HU2 … HLK … HTU2 ? ?) -L
137 /3 width=3 by ex2_intro, conj/
140 lemma cpye_inv_lift1_ge: ∀G,L,U1,U2,dt,et. ⦃G, L⦄ ⊢ U1 ▶*[dt, et] 𝐍⦃U2⦄ →
141 ∀K,s,d,e. ⇩[s, d, e] L ≡ K → ∀T1. ⇧[d, e] T1 ≡ U1 →
143 ∃∃T2. ⦃G, K⦄ ⊢ T1 ▶*[dt - e, et] 𝐍⦃T2⦄ & ⇧[d, e] T2 ≡ U2.
144 #G #L #U1 #U2 #dt #et * #HU12 #HU2 #K #s #d #e #HLK #T1 #HTU1 #Hdedt
145 elim (cpys_inv_lift1_ge … HU12 … HLK … HTU1) -U1 // #T2 #HT12 #HTU2
146 lapply (cny_inv_lift_ge … HU2 … HLK … HTU2 ?) -L
147 /3 width=3 by ex2_intro, conj/
150 lemma cpye_inv_lift1_ge_up: ∀G,L,U1,U2,dt,et. ⦃G, L⦄ ⊢ U1 ▶*[dt, et] 𝐍⦃U2⦄ →
151 ∀K,s,d,e. ⇩[s, d, e] L ≡ K → ∀T1. ⇧[d, e] T1 ≡ U1 →
152 d ≤ dt → dt ≤ yinj d + e → yinj d + e ≤ dt + et →
153 ∃∃T2. ⦃G, K⦄ ⊢ T1 ▶*[d, dt + et - (yinj d + e)] 𝐍⦃T2⦄ &
155 #G #L #U1 #U2 #dt #et * #HU12 #HU2 #K #s #d #e #HLK #T1 #HTU1 #Hddt #Hdtde #Hdedet
156 elim (cpys_inv_lift1_ge_up … HU12 … HLK … HTU1) -U1 // #T2 #HT12 #HTU2
157 lapply (cny_inv_lift_ge_up … HU2 … HLK … HTU2 ? ? ?) -L
158 /3 width=3 by ex2_intro, conj/
161 lemma cpye_inv_lift1_subst: ∀G,L,W1,W2,d,e. ⦃G, L⦄ ⊢ W1 ▶*[d, e] 𝐍⦃W2⦄ →
162 ∀K,V1,i. ⇩[i+1] L ≡ K → ⇧[O, i+1] V1 ≡ W1 →
163 d ≤ yinj i → i < d + e →
164 ∃∃V2. ⦃G, K⦄ ⊢ V1 ▶*[O, ⫰(d+e-i)] 𝐍⦃V2⦄ & ⇧[O, i+1] V2 ≡ W2.
165 #G #L #W1 #W2 #d #e * #HW12 #HW2 #K #V1 #i #HLK #HVW1 #Hdi #Hide
166 elim (cpys_inv_lift1_subst … HW12 … HLK … HVW1) -W1 // #V2 #HV12 #HVW2
167 lapply (cny_inv_lift_subst … HLK HW2 HVW2) -L
168 /3 width=3 by ex2_intro, conj/