Documentation

MIPRE.Foundations.Cost.BoundedEval

Running a program under a cost budget, computably #

Machine.evalData runs a program to completion and is only partial recursive; and Cost.evalWithin, which reads off the result of a run within a budget, is noncomputable — it picks a witness out of an existential with Classical.choice. Neither can be used to compute anything, and the tabulation of a verifier's game (blueprint rem:compression-abstract, item 3) has to compute: it runs the decider on every answer tuple under the decider's own time bound and fills in an acceptance table.

Machine.runForD p x k is the computable version: iterate the machine's step function 3 k times from the initial configuration and read off the result if the configuration reached is final. Three facts make it right:

runForD_eq_some and runs_of_runForD are the two directions of its correctness, and runForD_isSome_iff the decision procedure they add up to: for a program that halts within the budget on the input, whether it returns a given value is decidable, which is what boundedness buys the tabulation.

Finality of a configuration as a Bool, so that the budgeted run is a plain branch.

Equations
Instances For

    Running p on x under a cost budget k: iterate the step function 3 k times and read off the result if the configuration reached is final. Total and computable.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      theorem MIPRE.Cost.Machine.runForD_eq_some {p : Prog} {x r : Data} {t k : ℕ} (h : p.Runs x r t) (hk : t ≤ k) :
      runForD (encode p) x k = some r

      Completeness. A run of cost at most the budget is found.

      theorem MIPRE.Cost.Machine.runs_of_runForD {p : Prog} {x r : Data} {k : ℕ} (h : runForD (encode p) x k = some r) :
      ∃ (t : ℕ), p.Runs x r t

      Soundness. Whatever is found is a genuine run.

      theorem MIPRE.Cost.Machine.runForD_eq_some_iff {p : Prog} {x r : Data} {k : ℕ} (hb : HaltsWithin p x k) :
      runForD (encode p) x k = some r ↔ ∃ (t : ℕ), p.Runs x r t

      The decision procedure. For a program that halts within the budget, whether it returns a given value is decidable.

      Computability #

      theorem MIPRE.Cost.Machine.primrec_runForD :
      Primrec fun (q : (Data × Data) × ℕ) => runForD q.1.1 q.1.2 q.2