* `lambda_expr`: evaluating `($lambda p b)` in `e1` gives `<applicative <operative p #ignore b e1>>`
open Term
vau : Env.lookup sVau e = some (prim .vau)
wrap : Env.lookup sWrap e = some wrapA
eval : Env.lookup sEval e = some evalA
listStar : Env.lookup sListStar e = some listStarA
abbrev srcListStar : Term := pair (sym sListStar) (list4 (sym sVau) (sym sPtree) ign (sym sBody))¶ plain English
abbrev lambdaSrc : Term := list4 (sym sVau) (pair (sym sPtree) (sym sBody)) (sym sStatic) lambdaBody¶ node
abbrev lambdaOp (e0 : Env) : Term := oper (pair (sym sPtree) (sym sBody)) (sym sStatic) lambdaBody (env e0)¶ plain English
simp [disjoint]
Vau.Star.head (Step.top h) h2
Steps.comb e (Steps.top h) (Steps.refl x)
refine Steps.head (.evalPair _ _ _) ?_
refine Steps.trans (Steps.combOp _ _ (.evalSym h0)) ?_
refine Steps.top (.deltaVau _ ?_ ?_ ?_) <;> repeat (first | constructor)
(sPtree, p) :: (sBody, list1 b) :: (sStatic, env e1) :: e0
Env.lookup s (lambdaLocal p b e1 e0) = Env.lookup s e0 := by
simp only [Env.lookup, h5, h6, h7, if_false]
(hb : IsValue b) :
Steps (eval srcListStar (env (lambdaLocal p b e1 e0))) (builtVau p b) := by
have hls : Env.lookup sListStar (lambdaLocal p b e1 e0) = some listStarA := by
rw [lookup_local_ground (by decide)]; exact h0.listStar
have hv : Env.lookup sVau (lambdaLocal p b e1 e0) = some (prim .vau) := by
rw [lookup_local_ground (by decide)]; exact h0.vau
refine Steps.head (.evalPair _ _ _) ?_
refine Steps.trans (Steps.combOp _ _ (.evalSym hls)) ?_
refine Steps.head (.combApp _ _ (by repeat constructor)) ?_
refine Steps.trans (Steps.comb _ (Steps.refl _)
(Steps.pair (Steps.top (.evalSym hv))
(Steps.pair (Steps.top (.evalSym (t := p) rfl))
(Steps.pair (Steps.top (.evalSelf _ .ign))
(Steps.pair (Steps.top (.evalSym (t := list1 b) rfl))
(Steps.refl _)))))) ?_
refine Steps.top (.deltaListStar _ ?_ rfl)
(hb : IsValue b) :
Steps (eval srcEval (env (lambdaLocal p b e1 e0))) (oper p ign b (env e1)) := by
have he : Env.lookup sEval (lambdaLocal p b e1 e0) = some evalA := by
rw [lookup_local_ground (by decide)]; exact h0.eval
refine Steps.head (.evalPair _ _ _) ?_
refine Steps.trans (Steps.combOp _ _ (.evalSym he)) ?_
refine Steps.head (.combApp _ _ (by repeat constructor)) ?_
refine Steps.trans (Steps.comb _ (Steps.refl _)
(Steps.pair (eval_srcListStar h0 hp hb)
(Steps.pair (Steps.top (.evalSym (t := env e1) rfl))
(Steps.refl _)))) ?_
refine Steps.head (.deltaEval _ _ (by repeat (first | assumption | constructor))) ?_
refine Steps.head (.evalPair _ _ _) ?_
refine Steps.trans (Steps.combOp _ _ (.evalSelf _ (.prim _))) ?_
exact Steps.top (.deltaVau _ hp .ign hb)
(h1 : Env.lookup sLambda e1 = some (lambdaOp e0)) (hp : IsValue p) (hb : IsValue b) :
refine Steps.head (.evalPair _ _ _) ?_
refine Steps.trans (Steps.combOp _ _ (.evalSym h1)) ?_
= some [(sPtree, p), (sBody, list1 b), (sStatic, env e1)] := rfl
refine Steps.head (.beta (by repeat constructor) (.sym _) (by repeat (first | assumption | constructor)) hm) ?_
have hw : Env.lookup sWrap (lambdaLocal p b e1 e0) = some wrapA := by
rw [lookup_local_ground (by decide)]; exact h0.wrap
refine Steps.head (.evalPair _ _ _) ?_
refine Steps.trans (Steps.combOp _ _ (.evalSym hw)) ?_
refine Steps.head (.combApp _ _ (by repeat constructor)) ?_
refine Steps.trans (Steps.comb _ (Steps.refl _) (Steps.pair (eval_srcEval h0 hp hb) (Steps.refl _))) ?_
exact Steps.top (.deltaWrap _ (.oper _ _ _ _))
theorem lambda_call {p b args vs : Term} {e1 e2 m : Env} (hp : IsValue p) (hargs : IsList args)¶ node
refine Steps.head (.combApp _ _ hargs) ?_
refine Steps.trans (Steps.comb _ (Steps.refl _) hev) ?_
simp only [ematch, syms, disjoint_nil, if_true, hm]
have := Top.beta (body := b) (e1 := e1) hp .ign hvs hmatch
rw [Env.join_emp] at this
exact Steps.top this
(h1 : Env.lookup sLambda e = some (lambdaOp e0)) (hp : IsValue p) (hb : IsValue b)
(hm : ematch p vs = some m) :
refine Steps.head (.evalPair _ _ _) ?_
refine Steps.trans (Steps.comb _ (lambda_expr h0 h1 hp hb) (Steps.refl _)) ?_
exact lambda_call hp hargs hev hvs hm
some other environment `e2`. Calling `(f . args)` from `e2` evaluates the arguments in `e2`, but runs
theorem lambda_static_scope {p b args vs : Term} {e0 e1 e2 m : Env} {f : Nat} (h0 : Ground e0)¶ node
(h1 : Env.lookup sLambda e1 = some (lambdaOp e0)) (hp : IsValue p) (hb : IsValue b)
(hf : Env.lookup f e2 = some (app (oper p ign b (env e1))))
(hm : ematch p vs = some m) :
refine And.intro (lambda_expr h0 h1 hp hb) ?_
refine Steps.head (.evalPair _ _ _) ?_
refine Steps.trans (Steps.combOp _ _ (.evalSym hf)) ?_
exact lambda_call hp hargs hev hvs hm
(hv : Env.lookup sVau e = some (prim .vau)) (hp : IsValue p) (hb : IsValue b) :
refine Steps.head (.evalPair _ _ _) ?_
refine Steps.trans (Steps.combOp _ _ (.evalSym hw)) ?_
refine Steps.head (.combApp _ _ (by repeat constructor)) ?_
refine Steps.head (.evalPair _ _ _) ?_
refine Steps.trans (Steps.combOp _ _ (.evalSym hv)) ?_
exact Steps.top (.deltaVau _ hp .ign hb)
refine Steps.trans (Steps.comb _ (Steps.refl _) (Steps.pair hin (Steps.refl _))) ?_
exact Steps.top (.deltaWrap _ (.oper _ _ _ _))
(h1 : Env.lookup sLambda e = some (lambdaOp e0)) (hw : Env.lookup sWrap e = some wrapA)
(hv : Env.lookup sVau e = some (prim .vau)) (hp : IsValue p) (hb : IsValue b) :
Vau.EqvGen.trans (lambda_expr h0 h1 hp hb).toEqvGen
(Vau.EqvGen.symm (wrap_vau_expr hw hv hp hb).toEqvGen)
theorem vau_call {p b v : Term} {d : Nat} {e1 e2 m : Env} (hp : IsValue p) (hv : IsValue v)¶ plain English
Steps (comb (oper p (sym d) b (env e1)) v (env e2))
exact Steps.top (.beta hp (.sym d) hv hmatch)
Env.lookup s (Env.join (Env.join m [(d, env e2)]) e1)
= if s = d then some (env e2) else Env.lookup s e1 := by
simp only [Env.lookup_join, hms, Env.lookup, Option.none_or]
(hu : Env.lookup sUnwrap e = some unwrapA) (hc : Steps (eval c (env e)) v) (hv : IsValue v) :
refine Steps.head (.evalPair _ _ _) ?_
refine Steps.trans (Steps.combOp _ _ (.evalSym hu)) ?_
refine Steps.head (.combApp _ _ (by repeat constructor)) ?_
refine Steps.head (.evalPair _ _ _) ?_
refine Steps.trans (Steps.combOp _ _ (.evalSym hw)) ?_
refine Steps.head (.combApp _ _ (by repeat constructor)) ?_
refine Steps.trans (Steps.comb _ (Steps.refl _) (Steps.pair hc (Steps.refl _))) ?_
exact Steps.top (.deltaWrap _ hv)
refine Steps.trans (Steps.comb _ (Steps.refl _) (Steps.pair hin (Steps.refl _))) ?_
exact Steps.top (.deltaUnwrap _ hv)
lambda_def rfl
refine Steps.trans (derived_lambda (vs := list1 (dat 7)) (m := [(9, dat 7)])
ground_groundEnv rfl (by repeat constructor) (.sym 9) (by repeat constructor)
(Steps.pair (Steps.top (.evalSelf _ (.dat 7))) (Steps.refl _)) (by repeat constructor) rfl) ?_
exact Steps.top (.evalSym rfl)