Lean2Js.StepAgree
The small-step machine answers what eval answers #
The small-step machine answers what eval answers.
eval spends fuel on the depth of what it evaluates and the machine spends a step on every transition, so
the two bounds do not line up: a long array costs the machine a step per element and eval nothing. The
claim is therefore that the machine, given enough steps, reaches the answer eval gives. The proof follows
eval's recursion on fuel and carries the continuation the machine holds when it enters an expression.
Lean2Js.StepAgree.steps
sourceEquations
- Lean2Js.StepAgree.steps p 0 x✝ = x✝
- Lean2Js.StepAgree.steps p n.succ x✝ = Lean2Js.StepAgree.steps p n (Lean2Js.step p x✝)
Instances For
Used by
Lean2Js.StepAgree.steps_add
sourceUsed by
Lean2Js.StepAgree.steps_done
sourceUsed by
Lean2Js.StepAgree.Reaches
sourceEquations
- Lean2Js.StepAgree.Reaches p s t = ∃ (n : Nat), Lean2Js.StepAgree.steps p n s = t
Instances For
Used by
Lean2Js.StepAgree.Reaches.refl
sourceUsed by
Lean2Js.StepAgree.Reaches.trans
sourceUsed by
Lean2Js.StepAgree.Reaches.head
sourceUsed by
Lean2Js.StepAgree.outcome
sourceWhere the machine stands once eval's answer is in: a value has been handed to the continuation, and an
error has stopped the machine whatever the continuation was.
Equations
Instances For
Used by
Lean2Js.StepAgree.outcome_nil
sourceUsed by
Lean2Js.StepAgree.finishOrFail
sourceUsed by
Lean2Js.StepAgree.Sim
sourceEquations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.StepAgree.sub
sourceEnters a subterm under one more frame and resumes from what it returned.
Used by
Lean2Js.StepAgree.args
sourceUsed by
Lean2Js.StepAgree.mapItems
sourceUsed by
Lean2Js.StepAgree.sortDone_reaches
sourceUsed by
Lean2Js.StepAgree.sortItems
sourceUsed by
Lean2Js.StepAgree.filterItems
sourceUsed by
Lean2Js.StepAgree.findItems
sourceUsed by
Lean2Js.StepAgree.quantItems
sourceUsed by
Lean2Js.StepAgree.reduceItems
sourceUsed by
The walk a fold takes #
A fold recurses on the value rather than on the expression, so the machine's walk over a node needs an
induction of its own: one strong induction on a bound for the value's size, carrying the node walk, the
field walk and the element walk at once because they call each other. Each carries the continuation the
way mapItems carries it along a list — the state the field walk hands its answer to is the field walk
itself with nothing left to walk.
Lean2Js.StepAgree.foldWalk
sourceUsed by
Lean2Js.StepAgree.step_bin
sourceUsed by
Lean2Js.StepAgree.tacticResume
sourceCloses a goal once the machine has applied a frame that computes its answer outright: the frame and
eval branch on the same values, so after unfolding both sides the branches pair off.
Equations
- Lean2Js.StepAgree.tacticResume = Lean.ParserDescr.node `Lean2Js.StepAgree.tacticResume 1024 (Lean.ParserDescr.nonReservedSymbol "resume" false)
Instances For
Used by
Lean2Js.StepAgree.sim
sourceUsed by
Lean2Js.StepAgree.steps_of_run
sourceUsed by
Lean2Js.StepAgree.run_of_steps
sourceUsed by
Lean2Js.StepAgree.stepCall_eventually
sourceWhenever eval gives an answer, the machine gives the same one once it is allowed enough steps.
Used by
Lean2Js.StepAgree.stepCall_refines
sourceThe machine is deterministic, so an answer it gives within any bound is the one it settles on.
Used by
Lean2Js.StepAgree.stepCall_agrees
sourceFor a program lean2js agrees to emit, the machine answers exactly as eval does, given enough
steps, every call whose arguments the entry check can read.