This file proves that `VauE.Steps` (zero or more steps of the vau-e rules of `Vau/Env/Reduction.lean`,
open Term
| app t => isValueB t
simp only [isValueB, Bool.and_eq_true, isValueB_iff a, isValueB_iff b]
exact Iff.intro (fun h => IsValue.pair h.1 h.2)
simp only [isValueB, isValueB_iff t]
| pair _ b => isListB b
simp only [isListB, isListB_iff b]
| dat (n : Nat) : Par (dat n) (dat n)
| sym (s : Nat) : Par (sym s) (sym s)
| ign : Par ign ign
| nil : Par nil nil
| envNil : Par (env []) (env [])
| oper {a a' b b' c c' d d' : Term} :
| comb {a a' b b' c c' : Term} :
Par (env bs) (env bs') -> Env.lookup s bs' = some u -> Par (eval (sym s) (env bs)) u
Par (eval (pair a b) (env bs)) (comb (eval a' (env bs')) b' (env bs'))
Par (eval (app t) (env bs)) (app (eval t' (env bs')))
ematch (pair v1' v2') (pair v3' (env e2')) = some m ->
Par (env bs) (env bs') ->
Par (env bs) (env bs') ->
Par (env e1) (env e1') ->
buildListStar vs' = some r -> Par (comb (prim .listStar) vs (env bs)) r
namespace Par
| .env bs => reflEnv bs
| .app t => .app (refl t)
| .capsule k v => .capsule k (refl v)
Par (VauE.evalList e ts) (VauE.evalList e' ts') := by
(hl : Env.lookup s bs = some u) : exists u', Env.lookup s bs' = some u' /\ Par u u' := by
| nil => simp [Env.lookup] at hl
simp only [Env.lookup] at hl
simp only [Env.lookup]
simp only [ematch] at hm
| _ => simp [ematch] at hm
| .dat _, _, _, _, hm, _ => by simp [ematch] at hm
| .prim _, _, _, _, hm, _ => by simp [ematch] at hm
| .env _, _, _, _, hm, _ => by simp [ematch] at hm
| .oper _ _ _ _, _, _, _, hm, _ => by simp [ematch] at hm
| .app _, _, _, _, hm, _ => by simp [ematch] at hm
| .eval _ _, _, _, _, hm, _ => by simp [ematch] at hm
| .comb _ _ _, _, _, _, hm, _ => by simp [ematch] at hm
| .capsule _ _, _, _, _, hm, _ => by simp [ematch] at hm
simp only [ematch] at hm; cases hm
cases t <;> simp [ematch] at hm
simp only [ematch] at hm; cases hm
simp only [ematch] at hm
exact (ematch_some h1 hc).elim fun m1' h1' => (ematch_some h2 hd).elim fun m2' h2' =>
Exists.intro (Env.join m1' m2')
| _ => simp [ematch] at hm
| .dat _, _, _, _, hm, _ => by simp [ematch] at hm
| .prim _, _, _, _, hm, _ => by simp [ematch] at hm
| .env _, _, _, _, hm, _ => by simp [ematch] at hm
| .oper _ _ _ _, _, _, _, hm, _ => by simp [ematch] at hm
| .app _, _, _, _, hm, _ => by simp [ematch] at hm
| .eval _ _, _, _, _, hm, _ => by simp [ematch] at hm
| .comb _ _ _, _, _, _, hm, _ => by simp [ematch] at hm
| .capsule _ _, _, _, _, hm, _ => by simp [ematch] at hm
exists r', buildListStar x' = some r' /\ Par r r'
simp only [buildListStar] at hb; cases hb
simp only [buildListStar, Option.map_eq_some_iff] at hb
(buildListStar_some hr0.1 (.pair hc hd)).elim fun r1 hr1 => by
. simp only [buildListStar, hr1.1, Option.map_some]
| _ => simp [buildListStar] at hb
| .dat _, _, _, hb, _ => by simp [buildListStar] at hb
| .prim _, _, _, hb, _ => by simp [buildListStar] at hb
| .sym _, _, _, hb, _ => by simp [buildListStar] at hb
| .ign, _, _, hb, _ => by simp [buildListStar] at hb
| .nil, _, _, hb, _ => by simp [buildListStar] at hb
| .env _, _, _, hb, _ => by simp [buildListStar] at hb
| .oper _ _ _ _, _, _, hb, _ => by simp [buildListStar] at hb
| .app _, _, _, hb, _ => by simp [buildListStar] at hb
| .eval _ _, _, _, hb, _ => by simp [buildListStar] at hb
| .comb _ _ _, _, _, hb, _ => by simp [buildListStar] at hb
| .capsule _ _, _, _, hb, _ => by simp [buildListStar] at hb
isCapsuleOf k x' = isCapsuleOf k x := by
simp only [capsCheck, Option.map_eq_some_iff] at hc
simp only [capsCheck, capsCheck_some hr hb0.1 h2, Option.map_some, isCapsuleOf_eq hx h1]
| .dat _, _, _, _, hc, _ => by simp [capsCheck] at hc
| .prim _, _, _, _, hc, _ => by simp [capsCheck] at hc
| .sym _, _, _, _, hc, _ => by simp [capsCheck] at hc
| .ign, _, _, _, hc, _ => by simp [capsCheck] at hc
| .env _, _, _, _, hc, _ => by simp [capsCheck] at hc
| .oper _ _ _ _, _, _, _, hc, _ => by simp [capsCheck] at hc
| .app _, _, _, _, hc, _ => by simp [capsCheck] at hc
| .eval _ _, _, _, _, hc, _ => by simp [capsCheck] at hc
| .comb _ _ _, _, _, _, hc, _ => by simp [capsCheck] at hc
| .capsule _ _, _, _, _, hc, _ => by simp [capsCheck] at hc
end Par
match Env.lookup s (envOf e') with
match ematch (pair w1 w2) (pair x' e') with
| some m => eval body' (env (Env.join m sb'))
if isValueB v then
if isValueB v then
if isValueB v then
if isValueB x then
match buildListStar x' with
if isValueB v then
if isValueB x then
match capsCheck k x' with
| env _, oper v1 v2 _ (env _) => cdBeta v1 v2 x f' x' e'
if isListB x then
| app u => comb u (evalList e' x') e'
| env _, prim p => cdDelta p x f' x' e'
| env bs => env (cdL bs)
| app t => app (cd t)
| capsule k v => capsule k (cd v)
cdEval t e t' e' = eval t' e' := by
cdComb f x e f' x' e' = comb f' x' e' := by
theorem cdEval_self {t t' e' : Term} {bs : Env} (hs : SelfEval t) : cdEval t (env bs) t' e' = t' := by¶ node
theorem Par.eval_case {a a' b b' : Term} (ha : Par a a') (hb : Par b b') (iha : Par a' (cd a))¶ node
exact (Par.env_inv hb).elim fun bs' hbs => by
subst hbs
rw [cd_env] at ihb
rw [cd_env]
next => simp only [cd]; exact .eval (.sym s) ihb
simp only [cd] at iha
simp only [cd] at iha
| dat n => exact .evalSelf bs' (ha.selfEval (.dat n)) iha
| prim q => exact .evalSelf bs' (ha.selfEval (.prim q)) iha
| env cs => exact .evalSelf bs' (ha.selfEval (.env cs)) iha
| ign => exact .evalSelf bs' (ha.selfEval .ign) iha
| nil => exact .evalSelf bs' (ha.selfEval .nil) iha
| oper p q r w => exact .evalSelf bs' (ha.selfEval (.oper p q r w)) iha
| capsule k v => exact .evalSelf bs' (ha.selfEval (.capsule k v)) iha
| _ => rw [cdEval_nonenv (by intro bs h; cases h)]; exact .eval iha ihb
exact (Par.env_inv he).elim fun bs1 hbs1 => by
subst hbs1
rw [cd_env] at ihe fb
rw [cd_env]
exact (Par.env_inv h4).elim fun sb1 hsb1 => by
subst hsb1
simp only [cd] at ihf fb
rw [<- cd_env] at ihf fb
rw [<- cd_env]
rw [cd_env] at i4
simp only [Bool.and_eq_true, isValueB_iff] at hv
rw [cd_env]
exact .beta (h1.isValue hv.1.1) (h2.isValue hv.1.2) (hx.isValue hv.2)
next => rw [<- cd_env]; exact fb
simp only [cd] at ihf fb
next hl => exact .combApp (hx.isList ((isListB_iff x).1 hl)) hu' ihx ihe
simp only [cd] at fb
simp only [cdDelta]
simp only [Bool.and_eq_true, isValueB_iff] at hv
simp only [cd] at ihx
simp only [cd]
simp only [cdDelta]
rw [isValueB_iff] at hv
simp only [cd] at ihx
simp only [cd]
simp only [cdDelta]
rw [isValueB_iff] at hv
simp only [cd] at ihx
simp only [cd]
simp only [cdDelta]
rw [isValueB_iff] at hv
exact (Par.env_inv hen).elim fun eb1 heb1 => by
subst heb1
simp only [cd] at ihx
rw [<- cd_env] at ihx
simp only [cd]
rw [cd_env] at j2
simp only [cdDelta]
rw [isValueB_iff] at hv
next r hr => exact .deltaListStar bs1 (hx.isValue hv) ihx hr
simp only [cdDelta]
rw [isValueB_iff] at hv
simp only [cd] at ihx
simp only [cd]
simp only [cdDelta]
rw [isValueB_iff] at hv
next b hb => exact .deltaIsEncap k bs1 (hx.isValue hv) ihx hb
simp only [cdDelta]
subst hk
simp only [cd] at ihx
simp only [cd]
| _ => rw [cdComb_nonenv (by intro bs h; cases h)]; exact fb
| envNil => rw [cd_env]; exact .envNil
rw [cd_env] at ihr
rw [cd_env]
| oper _ _ _ _ iha ihb ihc ihd => simp only [cd]; exact .oper iha ihb ihc ihd
| pair _ _ iha ihb => simp only [cd]; exact .pair iha ihb
| app _ ih => simp only [cd]; exact .app ih
| eval ha hb iha ihb => simp only [cd]; exact Par.eval_case ha hb iha ihb
| comb hf hx he ihf ihx ihe => simp only [cd]; exact Par.comb_case hf hx he ihf ihx ihe
| evalSelf bs hs _ ih => simp only [cd]; rw [cdEval_self hs]; exact ih
rw [cd_env] at ihb
simp only [cd]
rw [<- cd_env]
exact (Par.lookup_some ihb (u := _) hl).elim fun u' hu' => by
rw [cd_env] at ihe
simp only [cd]
rw [<- cd_env]
rw [cd_env] at ihe
simp only [cd]
rw [<- cd_env]
rw [cd_env] at ihe1 ihe2
have hpat := Par.pattern hm (Par.pair ih1 ih2)
simp only [Term.pair.injEq] at hpat
exact (Par.ematch_some hm (Par.pair ih3 ihe2)).elim fun m2 hm2 => by
simp only [cd]
simp only [cd_env, cdComb, cdBeta, (isValueB_iff v1).2 hv1, (isValueB_iff v2).2 hv2,
(isValueB_iff v3).2 hv3, Bool.and_self, if_true, hpat.1, hpat.2, hm2.1]
exact .eval ihb (Par.join hm2.2 ihe1)
rw [cd_env] at ihe
simp only [cd]
rw [<- cd_env]
simp only [cd_env, cdComb, (isListB_iff ts).2 hl, if_true]
exact .comb iht (Par.evalList ihe ihts (hts.isList hl)) ihe
rw [cd_env] at ihe
simp only [cd]
rw [<- cd_env]
simp only [cd_env, cdComb, cdDelta, (isValueB_iff v1).2 hv1, (isValueB_iff v2).2 hv2,
(isValueB_iff v3).2 hv3, Bool.and_self, if_true]
simp only [cd]
rw [<- cd_env]
simp only [cd_env, cdComb, cdDelta, (isValueB_iff v).2 hv, if_true]
simp only [cd]
rw [<- cd_env]
simp only [cd_env, cdComb, cdDelta, (isValueB_iff v).2 hv, if_true]
rw [cd_env] at ihe
simp only [cd]
simp only [cd_env, cdComb, cdDelta, (isValueB_iff v).2 hv, if_true]
exact (Par.buildListStar_some hr ih).elim fun r' hr' => by
simp only [cd]
rw [<- cd_env]
simp only [cd_env, cdComb, cdDelta, (isValueB_iff vs).2 hv, if_true, hr'.1]
| capsule k _ ih => simp only [cd]; exact .capsule k ih
simp only [cd]
rw [<- cd_env]
simp only [cd_env, cdComb, cdDelta, (isValueB_iff v).2 hv, if_true]
have hc' := Par.capsCheck_some (hvs.isValue hv) hc ih
simp only [cd]
rw [<- cd_env]
simp only [cd_env, cdComb, cdDelta, (isValueB_iff vs).2 hv, if_true, hc']
simp only [cd]
rw [<- cd_env]
namespace Steps
| top h => cases h
exists l, b = env l /\ Steps (env (x :: r)) (env (x :: l)) := by
| refl => exact Exists.intro r (And.intro rfl (.refl _))
subst e1
exact (step_env_inv hs).elim fun l' hl' => by
subst hl'
theorem envCons {s : Nat} {t t' : Term} {r r' : Env} (ht : Steps t t') (hr : Steps (env r) (env r')) :¶ node
Steps (env ((s, t) :: r)) (env ((s, t') :: r')) := by
refine Star.trans (Star.map (fun y => Term.env ((s, y) :: r)) (fun h => Step.envHere s r h) ht) ?_
exact (envTail (s, t') hr).elim fun l hl => by
theorem oper {a a' b b' c c' d d' : Term} (ha : Steps a a') (hb : Steps b b') (hc : Steps c c')¶ node
Star.trans (Star.map (fun y => Term.oper y b c d) (fun h => Step.oper1 b c d h) ha)
(Star.trans (Star.map (fun y => Term.oper a' y c d) (fun h => Step.oper2 a' c d h) hb)
(Star.trans (Star.map (fun y => Term.oper a' b' y d) (fun h => Step.oper3 a' b' d h) hc)
Star.trans (Star.map (fun y => Term.eval y b) (fun h => Step.evalL b h) ha)
Star.trans (Steps.comb c ha hb)
theorem capsule {k : Nat} {v v' : Term} (h : Steps v v') : Steps (Term.capsule k v) (Term.capsule k v') :=¶ node
end Steps
| evalSelf e hs => exact .evalSelf e hs (Par.refl _)
| evalSym hl => exact .evalSym (Par.reflEnv _) hl
| evalPair a b e => exact .evalPair (Par.refl a) (Par.refl b) (Par.reflEnv e)
| evalApp t e => exact .evalApp (Par.refl t) (Par.reflEnv e)
(Par.reflEnv _) (Par.reflEnv _) hm
| combApp t e hl => exact .combApp hl (Par.refl t) (Par.refl _) (Par.reflEnv e)
exact .deltaVau hv1 hv2 hv3 (Par.refl _) (Par.refl _) (Par.refl _) (Par.reflEnv e)
| deltaWrap e hv => exact .deltaWrap e hv (Par.refl _)
| deltaUnwrap e hv => exact .deltaUnwrap e hv (Par.refl _)
| deltaEval e1 e hv => exact .deltaEval e hv (Par.refl _) (Par.reflEnv e1)
| deltaListStar e hv hr => exact .deltaListStar e hv (Par.refl _) hr
| deltaEncap k e hv => exact .deltaEncap k e hv (Par.refl _)
| deltaIsEncap k e hv hc => exact .deltaIsEncap k e hv (Par.refl _) hc
| deltaDecap k e => exact .deltaDecap k e (Par.refl _)
| top h => exact Par.of_top h
| envHere s r _ ih => exact .envCons s ih (Par.reflEnv r)
| envThere b _ ih => cases b with | mk s t => exact .envCons s (Par.refl t) ih
| pairL b _ ih => exact .pair ih (Par.refl b)
| pairR a _ ih => exact .pair (Par.refl a) ih
| evalL b _ ih => exact .eval ih (Par.refl b)
| evalR a _ ih => exact .eval (Par.refl a) ih
| envCons s _ _ iht ihr => exact Steps.envCons iht ihr
| oper _ _ _ _ iha ihb ihc ihd => exact Steps.oper iha ihb ihc ihd
| pair _ _ iha ihb => exact Steps.pair iha ihb
| app _ ih => exact Steps.app ih
| eval _ _ iha ihb => exact Steps.eval iha ihb
| comb _ _ _ iha ihb ihc => exact Steps.comb3 iha ihb ihc
| evalSelf bs hs _ ih => exact Vau.Star.head (Step.top (.evalSelf bs hs)) ih
| evalSym _ hl ihb => exact (Steps.eval (Steps.refl _) ihb).trans (Steps.top (.evalSym hl))
exact (Steps.eval (Steps.pair iha ihb) ihe).trans (Steps.top (.evalPair _ _ _))
exact (Steps.eval (Steps.app iht) ihe).trans (Steps.top (.evalApp _ _))
exact (Steps.comb3 (Steps.oper ih1 ih2 ihb ihe1) ih3 ihe2).trans
(Steps.top (.beta (h1.isValue hv1) (h2.isValue hv2) (h3.isValue hv3) hm))
exact (Steps.comb3 (Steps.app iht) ihts ihe).trans (Steps.top (.combApp _ _ (hts.isList hl)))
exact (Steps.comb3 (Steps.refl _) (Steps.pair ih1 (Steps.pair ih2 (Steps.pair ih3 (Steps.refl _))))
ihe).trans (Steps.top (.deltaVau _ (h1.isValue hv1) (h2.isValue hv2) (h3.isValue hv3)))
exact (Steps.comb3 (Steps.refl _) (Steps.pair ih (Steps.refl _)) (Steps.refl _)).trans
exact (Steps.comb3 (Steps.refl _) (Steps.pair (Steps.app ih) (Steps.refl _)) (Steps.refl _)).trans
exact (Steps.comb3 (Steps.refl _) (Steps.pair ih (Steps.pair ihe (Steps.refl _))) (Steps.refl _)).trans
exact (Steps.comb3 (Steps.refl _) ih (Steps.refl _)).trans
| capsule k _ ih => exact Steps.capsule ih
exact (Steps.comb3 (Steps.refl _) (Steps.pair ih (Steps.refl _)) (Steps.refl _)).trans
exact (Steps.comb3 (Steps.refl _) ih (Steps.refl _)).trans
exact (Steps.comb3 (Steps.refl _) (Steps.pair (Steps.capsule ih) (Steps.refl _)) (Steps.refl _)).trans
(Steps.top (.deltaDecap k bs))
Iff.intro (Vau.Star.mono (fun h => Vau.Star.single (Par.of_step h))) (Vau.Star.mono Par.toSteps)
(Par.diamond hbc hu.1).elim fun w hw =>
theorem Par.star_confluent {t s1 s2 : Term} (h1 : Vau.Star Par t s1) (h2 : Vau.Star Par t s2) :¶ node
(Par.strip hu.2 hbc).elim fun w hw =>
(Par.star_confluent (steps_iff_par_star.1 h1) (steps_iff_par_star.1 h2)).elim fun u hu =>
Exists.intro u (And.intro (steps_iff_par_star.2 hu.1) (steps_iff_par_star.2 hu.2))
| rel h => exact Exists.intro _ (And.intro (Vau.Star.single h) (.refl _))
(confluence h1.2 h2.1).elim fun w hw =>
| tail _ hs ih => subst ih; exact absurd hs (hn _)
(hn2 : Normal n2) : n1 = n2 :=
(confluence h1 h2).elim fun u hu => by
rw [Steps.normal_eq hn1 hu.1, Steps.normal_eq hn2 hu.2]