Documentation

MIPRE.Foundations.Cost.MachineData

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 03 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

      The initial configuration for the program p (as data) on the input x.

      Equations
      Instances For
        theorem MIPRE.Cost.Machine.initData_eq (p : Prog) (x : Data) :
        initData p.toData x = { ctrl := Ctrl.ev p, env := [x], kont := [] }.toData

        Final configurations, as data: a returned value with an empty stack.

        Equations
        Instances For

          The value of a final configuration.

          Equations
          Instances For
            theorem MIPRE.Cost.Machine.isFinalD_toData (c : Cfg) :
            IsFinalD c.toData ∃ (r : Data) (e : Env), c = { ctrl := Ctrl.ret r, env := e, kont := [] }
            theorem MIPRE.Cost.Machine.resultD_toData (r : Data) (e : Env) :
            resultD { ctrl := Ctrl.ret r, env := e, kont := [] }.toData = r

            The step function on data #

            def MIPRE.Cost.Machine.stepEv (p env kont : 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.
                Instances For

                  The step on data agrees with the machine.