The evaluation machine on data #
Configurations of the evaluation machine (Cost/Machine.lean) encoded as Data
(Machine.Cfg.toData), and the step function transported to Data (Machine.stepData),
defined by the first-order operations left, right, cons, unaryToNat, getList
only — so that it is primitive recursive (Cost/Partrec.lean) and implementable by a
program of the ambient model (the self-interpreter). The correspondence is
stepData_toData : stepData c.toData = (step c).toData.
Encoding: a control is cons nil (toData p) ("evaluate p") or cons (cons nil nil) v
("return v"); a configuration is cons ctrl (cons env kont) with the environment and the
stack as cons-chains; a frame is cons (ofNat tag) payload with tags 0–3 for
cons1 t env (payload cons t env), cons2 a (payload a), let1 b env, loop1 b env.
Encoding #
The control "evaluate the program p" (as data).
Equations
Instances For
The control "return the value v".
Equations
Instances For
Controls as data.
Equations
Instances For
Frames as data.
Equations
- (MIPRE.Cost.Machine.Frame.cons1 t env).toData = (MIPRE.Cost.Data.ofNat 0).cons (t.toData.cons (MIPRE.Cost.Data.list env))
- (MIPRE.Cost.Machine.Frame.cons2 a).toData = (MIPRE.Cost.Data.ofNat 1).cons a
- (MIPRE.Cost.Machine.Frame.let1 b env).toData = (MIPRE.Cost.Data.ofNat 2).cons (b.toData.cons (MIPRE.Cost.Data.list env))
- (MIPRE.Cost.Machine.Frame.loop1 b env).toData = (MIPRE.Cost.Data.ofNat 3).cons (b.toData.cons (MIPRE.Cost.Data.list env))
Instances For
Configurations as data.
Equations
Instances For
The initial configuration for the program p (as data) on the input x.
Equations
Instances For
Final configurations, as data: a returned value with an empty stack.
Equations
Instances For
The value of a final configuration.
Equations
Instances For
The step function on data #
The step on "evaluate p" with environment env and stack kont.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The step on "return v" with environment env and stack kont.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The step function on data.
Equations
- One or more equations did not get rendered due to their size.