The self-interpreter, I: the step function as a program #
Programs of the ambient model implementing the step function of the evaluation machine on
data (Machine.stepData, Cost/MachineData.lean): stepEvProg for "evaluate" controls,
stepRetProg for "return" controls, and stepProg combining them. Each is proved to
compute stepData on encoded configurations, at a cost quadratic in the size of the
configuration (the only non-constant work is the walk getListProg along the environment,
which copies the remaining environment at each of its steps).
Conventions: every sub-program is closed and receives its input, a tuple built with
cons, at variable 0; tuples are taken apart with elim (free), and the pieces are read
back with var (paid by size). Tag dispatch on a unary numeral is a chain of elims; the
case programs are called through callVar on a packaged tuple whose index grows by two
per level of the chain.
Discharge a linear inequality between costs and sizes, after expanding the sizes of constructors and of encoded configurations.
Equations
- MIPRE.Cost.Machine.tacticSize_omega = Lean.ParserDescr.node `MIPRE.Cost.Machine.tacticSize_omega 1024 (Lean.ParserDescr.nonReservedSymbol "size_omega" false)
Instances For
Projections at an arbitrary index #
left of the value of variable i.
Equations
Instances For
right of the value of variable i.
Equations
Instances For
The environment walk #
Body of getListProg: on the state cons env idx, stop with left env if idx is
exhausted, else continue with cons (right env) idx'.
Equations
- One or more equations did not get rendered due to their size.
Instances For
getListProg on cons env idx computes getList env (unaryToNat idx).
Instances For
The "evaluate" cases #
Cases of stepEvProg; input cons body (cons env kont). After the two elims the
environment is [env, kont, body, cons env kont, input].
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Tag dispatch #
dispatch cs i idx: case analysis on the unary numeral at variable i, calling the
k-th program of cs on the tuple at variable idx + 2 k (each level of the chain binds
two more variables).
Equations
- MIPRE.Cost.Machine.dispatch [] x✝¹ x✝ = MIPRE.Cost.Prog.nil
- MIPRE.Cost.Machine.dispatch [c] x✝¹ x✝ = MIPRE.Cost.Prog.callVar x✝ c
- MIPRE.Cost.Machine.dispatch (c :: c' :: cs) x✝¹ x✝ = MIPRE.Cost.Prog.elim x✝¹ (MIPRE.Cost.Prog.callVar x✝ c) (MIPRE.Cost.Machine.dispatch (c' :: cs) 1 (x✝ + 2))
Instances For
The "evaluate" step #
The case programs of stepEvProg, indexed by the tag of the program.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The step on "evaluate p"; input cons (toData p) (cons env kont).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The environment in which the dispatch of stepEvProg runs, for a program with tag k
and body body.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The prefix of stepEvProg up to the dispatch.
Bound of one "evaluate" step in terms of S = esize p + env.size + kont.size.
Instances For
The "return" cases #
Cases of stepRetProg; input cons v (cons env (cons fb k)) with fb the payload of
the top frame. After the three elims the environment is
[fb, k, env, cons fb k, v, cons env (cons fb k), input].
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
The "return" step #
The step on "return v"; input cons v (cons env kont).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The environment in which the dispatch of stepRetProg runs, for a top frame with tag
ftag and payload fb.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Bound of one "return" step in terms of S = v.size + env.size + kont.size.
Equations
- MIPRE.Cost.Machine.stepRetBound S = 8 * S + 120
Instances For
The step #
The step function as a program: on the encoding of a configuration, the encoding of the next configuration.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Bound of one step of the interpreter in terms of the size of the configuration.