Documentation

MIPRE.Foundations.Cost.MachineBound

Size bounds along machine runs #

Along the run of the evaluation machine that simulates a derivation Eval env p r t, every configuration stays bounded (CfgBound): values have size at most V (where t ≤ V and the initial values are at most V, since every value produced is the result of a sub-derivation of cost at most t), environments have length at most L + 2 t, programs are subterms of the initial ones, and the stack gains at most t frames (eval_steps_bound). Consequently the data encoding of every configuration along the run has size polynomial in the sizes of the program, the input and the cost (size_toData_le). This is what bounds the cost of the self-interpreter.

Bounds on configurations #

Bounds on a frame: values of size at most V, an environment of length at most L, a program of size at most P.

Equations
Instances For
    structure MIPRE.Cost.Machine.CfgBound (V L P K : ) (c : Cfg) :

    Bounds on a configuration: values of size at most V, environments of length at most L, programs of size at most P, a stack of length at most K.

    Instances For
      theorem MIPRE.Cost.Machine.FrameBound.mono {V L P V' L' P' : } (hV : V V') (hL : L L') (hP : P P') {f : Frame} (h : FrameBound V L P f) :
      FrameBound V' L' P' f
      theorem MIPRE.Cost.Machine.CfgBound.mono {V L P K V' L' P' K' : } (hV : V V') (hL : L L') (hP : P P') (hK : K K') {c : Cfg} (h : CfgBound V L P K c) :
      CfgBound V' L' P' K' c

      Program subterms #

      Chaining bounds along runs #

      theorem MIPRE.Cost.Machine.bound_chain {B : CfgProp} {c₁ c₂ : Cfg} {m₁ m₂ : } (h₁ : step^[m₁] c₁ = c₂) (hb₁ : nm₁, B (step^[n] c₁)) (hb₂ : nm₂, B (step^[n] c₂)) (n : ) :
      n m₁ + m₂B (step^[n] c₁)
      theorem MIPRE.Cost.Machine.bound_one {B : CfgProp} {c : Cfg} (h₀ : B c) (h₁ : B (step c)) (n : ) :
      n 1B (step^[n] c)
      theorem MIPRE.Cost.Machine.eval_steps_bound {env : Env} {p : Prog} {r : Data} {t : } (h : Eval env p r t) (k : List Frame) (V L P K : ) :
      CfgBound V L P K { ctrl := Ctrl.ev p, env := env, kont := k }t V∃ (N : ) (env' : Env), Steps { ctrl := Ctrl.ev p, env := env, kont := k } N { ctrl := Ctrl.ret r, env := env', kont := k } t nN, CfgBound V (L + 2 * t) P (K + t) (step^[n] { ctrl := Ctrl.ev p, env := env, kont := k })

      Every configuration along the machine run of a derivation is bounded.

      Size of the encoded configurations #

      theorem MIPRE.Cost.Machine.sumSize_le_of_forall {V : } (l : List Data) :
      (∀ vl, v.size V)Data.sumSize l l.length * V
      theorem MIPRE.Cost.Machine.size_list_le_of_forall {V L : } (l : List Data) (hl : l.length L) (h : vl, v.size V) :
      (Data.list l).size L * V + L + 1
      theorem MIPRE.Cost.Machine.frame_size_le {V L P : } {f : Frame} (h : FrameBound V L P f) :
      f.toData.size V + P + L * V + L + 10

      Size of the encoding of a configuration satisfying CfgBound V L P K.

      Equations
      Instances For
        theorem MIPRE.Cost.Machine.size_toData_le {V L P K : } {c : Cfg} (h : CfgBound V L P K c) :

        Runs from the empty stack are bounded forever #

        theorem MIPRE.Cost.Machine.step_final (r : Data) (e : Env) (n : ) :
        step^[n] { ctrl := Ctrl.ret r, env := e, kont := [] } = { ctrl := Ctrl.ret r, env := e, kont := [] }
        theorem MIPRE.Cost.Machine.eval_steps_bound_forever {env : Env} {p : Prog} {r : Data} {t : } (h : Eval env p r t) (V L P K : ) (hb : CfgBound V L P K { ctrl := Ctrl.ev p, env := env, kont := [] }) (ht : t V) :
        ∃ (N : ) (env' : Env), Steps { ctrl := Ctrl.ev p, env := env, kont := [] } N { ctrl := Ctrl.ret r, env := env', kont := [] } t ∀ (n : ), CfgBound V (L + 2 * t) P (K + t) (step^[n] { ctrl := Ctrl.ev p, env := env, kont := [] })

        Along the run of a derivation from the empty stack, every configuration — also after the final one, which is fixed — is bounded.

        The number of steps of a run #

        theorem MIPRE.Cost.Machine.eval_steps_count {env : Env} {p : Prog} {r : Data} {t : } (h : Eval env p r t) (k : List Frame) :
        ∃ (N : ) (env' : Env), Steps { ctrl := Ctrl.ev p, env := env, kont := k } N { ctrl := Ctrl.ret r, env := env', kont := k } t N 3 * t

        The machine run of a derivation of cost t has at most 3 t steps (the free steps — entering a loop, and returning to a cons/let frame — are each matched with a paid one).

        Cost sums #

        theorem MIPRE.Cost.Machine.costSum_le_of_le (c : Cfg) {m n : } (h : m n) :
        theorem MIPRE.Cost.Machine.stepCost_final (r : Data) (e : Env) :
        stepCost { ctrl := Ctrl.ret r, env := e, kont := [] } = 0
        theorem MIPRE.Cost.Machine.costSum_final (r : Data) (e : Env) (n : ) :
        costSum { ctrl := Ctrl.ret r, env := e, kont := [] } n = 0