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 "lambda/subterms/booleanized.ma".
16 include "lambda/paths/labeled_sequential_reduction.ma".
17 include "lambda/paths/standard_order.ma".
19 (* PATH-LABELED STANDARD REDUCTION ON SUBTERMS (SINGLE STEP) ****************)
21 (* Note: this is standard reduction on marked redexes,
22 left residuals are unmarked in the reductum
24 inductive pl_st: path → relation subterms ≝
25 | pl_st_beta : ∀V,T. pl_st (◊) ({⊤}@V.{⊤}𝛌.T) ([↙V]T)
26 | pl_st_abst : ∀b,p,T1,T2. pl_st p T1 T2 → pl_st (rc::p) ({b}𝛌.T1) ({⊥}𝛌.T2)
27 | pl_st_appl_sn: ∀b,p,V1,V2,T. pl_st p V1 V2 → pl_st (sn::p) ({b}@V1.T) ({⊥}@V2.{⊥}⇕T)
28 | pl_st_appl_dx: ∀b,p,V,T1,T2. pl_st p T1 T2 → pl_st (dx::p) ({b}@V.T1) ({b}@V.T2)
31 interpretation "path-labeled standard reduction"
32 'Std F p G = (pl_st p F G).
34 notation "hvbox( F break Ⓡ ↦ [ term 46 p ] break term 46 G )"
35 non associative with precedence 45
36 for @{ 'Std $F $p $G }.
38 lemma pl_st_fwd_pl_sred: ∀p,F1,F2. F1 Ⓡ↦[p] F2 → ⇓F1 ↦[p] ⇓F2.
39 #p #F1 #F2 #H elim H -p -F1 -F2 normalize /2 width=1/
42 lemma pl_st_inv_vref: ∀p,F,G. F Ⓡ↦[p] G → ∀b,i. {b}#i = F → ⊥.
43 #p #F #G #HFG #b #i #H
44 lapply (pl_st_fwd_pl_sred … HFG) -HFG #HFG
45 lapply (eq_f … carrier … H) -H normalize #H
46 /2 width=6 by pl_sred_inv_vref/
49 lemma pl_st_inv_abst: ∀p,F,G. F Ⓡ↦[p] G → ∀c,U1. {c}𝛌.U1 = F →
50 ∃∃q,U2. U1 Ⓡ↦[q] U2 & rc::q = p & {⊥}𝛌.U2 = G.
52 [ #V #T #c #U1 #H destruct
53 | #b #p #T1 #T2 #HT12 #c #U1 #H destruct /2 width=5/
54 | #b #p #V1 #V2 #T #_ #c #U1 #H destruct
55 | #b #p #V #T1 #T2 #_ #c #U1 #H destruct
59 lemma pl_st_inv_appl: ∀p,F,G. F Ⓡ↦[p] G → ∀c,W,U. {c}@W.U = F →
60 ∨∨ (∃∃U0. ⊤ = c & ◊ = p & {⊤}𝛌.U0 = U & [↙W] U0 = G)
61 | (∃∃q,W0. sn::q = p & W Ⓡ↦[q] W0 & {⊥}@W0.{⊥}⇕U = G)
62 | (∃∃q,U0. dx::q = p & U Ⓡ↦[q] U0 & {c}@W.U0 = G).
64 [ #V #T #c #W #U #H destruct /3 width=3/
65 | #b #p #T1 #T2 #_ #c #W #U #H destruct
66 | #b #p #V1 #V2 #T #HV12 #c #W #U #H destruct /3 width=5/
67 | #b #p #V #T1 #T2 #HT12 #c #W #U #H destruct /3 width=5/
71 lemma pl_st_fwd_abst: ∀p,F,G. F Ⓡ↦[p] G → ∀c,U2. {c}𝛌.U2 = G →
72 ◊ = p ∨ ∃q. rc::q = p.
76 | #b #p #V1 #V2 #T #_ #c #U2 #H destruct
77 | #b #p #V #T1 #T2 #_ #c #U2 #H destruct
81 lemma pl_st_inv_nil: ∀p,F,G. F Ⓡ↦[p] G → ◊ = p →
82 ∃∃V,T. {⊤}@V.{⊤} 𝛌.T = F & [↙V] T = G.
84 [ #V #T #_ destruct /2 width=4/
85 | #b #p #T1 #T2 #_ #H destruct
86 | #b #p #V1 #V2 #T #_ #H destruct
87 | #b #p #V #T1 #T2 #_ #H destruct
91 lemma pl_st_inv_rc: ∀p,F,G. F Ⓡ↦[p] G → ∀q. rc::q = p →
92 ∃∃b,T1,T2. T1 Ⓡ↦[q] T2 & {b}𝛌.T1 = F & {⊥}𝛌.T2 = G.
94 [ #V #T #q #H destruct
95 | #b #p #T1 #T2 #HT12 #q #H destruct /2 width=6/
96 | #b #p #V1 #V2 #T #_ #q #H destruct
97 | #b #p #V #T1 #T2 #_ #q #H destruct
101 lemma pl_st_inv_sn: ∀p,F,G. F Ⓡ↦[p] G → ∀q. sn::q = p →
102 ∃∃b,V1,V2,T. V1 Ⓡ↦[q] V2 & {b}@V1.T = F & {⊥}@V2.{⊥}⇕T = G.
104 [ #V #T #q #H destruct
105 | #b #p #T1 #T2 #_ #q #H destruct
106 | #b #p #V1 #V2 #T #HV12 #q #H destruct /2 width=7/
107 | #b #p #V #T1 #T2 #_ #q #H destruct
111 lemma pl_st_inv_dx: ∀p,F,G. F Ⓡ↦[p] G → ∀q. dx::q = p →
112 ∃∃b,V,T1,T2. T1 Ⓡ↦[q] T2 & {b}@V.T1 = F & {b}@V.T2 = G.
114 [ #V #T #q #H destruct
115 | #b #p #T1 #T2 #_ #q #H destruct
116 | #b #p #V1 #V2 #T #_ #q #H destruct
117 | #b #p #V #T1 #T2 #HT12 #q #H destruct /2 width=7/
121 lemma pl_st_inv_pl_sred: ∀p. in_whd p → ∀M1,F2. {⊤}⇑M1 Ⓡ↦[p] F2 →
122 ∃∃M2. M1 ↦[p] M2 & {⊤}⇑M2 = F2.
123 #p @(in_whd_ind … p) -p
125 elim (pl_st_inv_nil … H …) -H // #V #T #HM1 #H
126 elim (boolean_inv_appl … (sym_eq … HM1)) -HM1 #B #N #_ #HB #HN #HM1
127 elim (boolean_inv_abst … HN) -HN #A #_ #HA #HN destruct /2 width=3/
128 | #p #_ #IHp #M1 #F2 #H
129 elim (pl_st_inv_dx … H …) -H [3: // |2:skip ] #b #V #T1 #T2 #HT12 #HM1 #H (**) (* simplify line *)
130 elim (boolean_inv_appl … (sym_eq … HM1)) -HM1 #B #A #Hb #HB #HA #HM1 destruct
131 elim (IHp … HT12) -IHp -HT12 #C #HAC #H destruct
132 @(ex2_intro … (@B.C)) // /2 width=1/ (**) (* auto needs some help here *)
136 lemma pl_st_lift: ∀p. sliftable (pl_st p).
137 #p #h #F1 #F2 #H elim H -p -F1 -F2 /2 width=1/
138 [ #V #T #d normalize <sdsubst_slift_le //
139 | #b #p #V1 #V2 #T #_ #IHV12 #d
140 whd in ⊢ (??%%); <booleanized_lift /2 width=1/ (**) (* auto needs some help here *)
144 lemma pl_st_inv_lift: ∀p. sdeliftable_sn (pl_st p).
145 #p #h #G1 #G2 #H elim H -p -G1 -G2
147 elim (slift_inv_appl … H) -H #V #F #H0 #HF #H destruct
148 elim (slift_inv_abst … HF) -HF #T #H0 #H destruct /3 width=3/
149 | #b #p #U1 #U2 #_ #IHU12 #d #F1 #H
150 elim (slift_inv_abst … H) -H #T1 #HTU1 #H
151 elim (IHU12 … HTU1) -U1 #T2 #HT12 #HTU2 destruct
152 @(ex2_intro … ({⊥}𝛌.T2)) // /2 width=1/
153 | #b #p #W1 #W2 #U1 #_ #IHW12 #d #F1 #H
154 elim (slift_inv_appl … H) -H #V1 #T #HVW1 #H1 #H2
155 elim (IHW12 … HVW1) -W1 #V2 #HV12 #HVW2 destruct
156 @(ex2_intro … ({⊥}@V2.{⊥}⇕T)) [ /2 width=1/ ]
157 whd in ⊢ (??%%); // (**) (* auto needs some help here *)
158 | #b #p #W1 #U1 #U2 #_ #IHU12 #d #F1 #H
159 elim (slift_inv_appl … H) -H #V #T1 #H1 #HTU1 #H2
160 elim (IHU12 … HTU1) -U1 #T2 #HT12 #HTU2 destruct
161 @(ex2_intro … ({b}@V.T2)) // /2 width=1/
165 lemma pl_st_dsubst: ∀p. sdsubstable_f_dx … (booleanized ⊥) (pl_st p).
166 #p #W1 #F1 #F2 #H elim H -p -F1 -F2 /2 width=1/
167 [ #W2 #T #d normalize >sdsubst_sdsubst_ge //
168 | #b #p #V1 #V2 #T #_ #IHV12 #d
169 whd in ⊢ (??%%); <(booleanized_booleanized ⊥) in ⊢ (???(???%)); <booleanized_dsubst /2 width=1/ (**) (* auto needs some help here *)
173 lemma pl_st_inv_empty: ∀p,F1,F2. F1 Ⓡ↦[p] F2 → ∀M1. {⊥}⇑M1 = F1 → ⊥.
174 #p #F1 #F2 #H elim H -p -F1 -F2
176 elim (boolean_inv_appl … H) -H #B #A #H destruct
177 | #b #p #T1 #T2 #_ #IHT12 #M1 #H
178 elim (boolean_inv_abst … H) -H /2 width=2/
179 | #b #p #V1 #V2 #T #_ #IHV12 #M1 #H
180 elim (boolean_inv_appl … H) -H /2 width=2/
181 | #b #p #V #T1 #T2 #_ #IHT12 #M1 #H
182 elim (boolean_inv_appl … H) -H /2 width=2/
186 theorem pl_st_mono: ∀p. singlevalued … (pl_st p).
187 #p #F #G1 #H elim H -p -F -G1
188 [ #V #T #G2 #H elim (pl_st_inv_nil … H …) -H //
189 #W #U #H #HG2 destruct //
190 | #b #p #T1 #T2 #_ #IHT12 #G2 #H elim (pl_st_inv_rc … H …) -H [3: // |2: skip ] (**) (* simplify line *)
191 #c #U1 #U2 #HU12 #H #HG2 destruct /3 width=1/
192 | #b #p #V1 #V2 #T #_ #IHV12 #G2 #H elim (pl_st_inv_sn … H …) -H [3: // |2: skip ] (**) (* simplify line *)
193 #c #W1 #W2 #U #HW12 #H #HG2 destruct /3 width=1/
194 | #b #p #V #T1 #T2 #_ #IHT12 #G2 #H elim (pl_st_inv_dx … H …) -H [3: // |2: skip ] (**) (* simplify line *)
195 #c #W #U1 #U2 #HU12 #H #HG2 destruct /3 width=1/
199 theorem pl_st_fwd_sle: ∀p1,F1,F. F1 Ⓡ↦[p1] F →
200 ∀p2,F2. F Ⓡ↦[p2] F2 → p1 ≤ p2.
201 #p1 #F1 #F #H elim H -p1 -F1 -F //
202 [ #b #p #T1 #T #_ #IHT1 #p2 #F2 #H elim (pl_st_inv_abst … H …) -H [3: // |2,4: skip ] (**) (* simplify line *)
203 #q #T2 #HT2 #H1 #H2 destruct /3 width=2/
204 | #b #p #V1 #V #T #_ #IHV1 #p2 #F2 #H elim (pl_st_inv_appl … H …) -H [7: // |2,3,4: skip ] * (**) (* simplify line *)
206 | #q #V2 #H1 #HV2 #H2 destruct /3 width=2/
207 | #q #U #_ #H elim (pl_st_inv_empty … H …) [ // | skip ] (**) (* simplify line *)
209 | #b #p #V #T1 #T #HT1 #IHT1 #p2 #F2 #H elim (pl_st_inv_appl … H …) -H [7: // |2,3,4: skip ] * (**) (* simplify line *)
210 [ #U #_ #H1 #H2 #_ -b -V -F2 -IHT1
211 elim (pl_st_fwd_abst … HT1 … H2) // -H1 * #q #H
212 elim (pl_st_inv_rc … HT1 … H) -HT1 -H #b #U1 #U2 #_ #_ #H -b -q -T1 -U1 destruct
213 | #q #V2 #H1 #_ #_ -b -F2 -T1 -T -V -V2 destruct //
214 | #q #T2 #H1 #HT2 #H2 -b -F2 -T1 -V /3 width=2/