The clocked universal program returns the budgeted result `clockedResult c v k` in time polynomial in
ProvedMIPRE.Cost.Machine.univTProg_runsFix the ambient cost model: programs act on values (binary trees), (in Lean c.Runs v r t) says that on input halts with result at cost , every program is encoded as a value (encode c, the tree encoding Prog.toData) of size , and natural numbers used as budgets are passed in unary, being the list of copies of . The budgeted result of on under the cost budget is
which is well defined because the semantics is deterministic.
univTProg is a fixed closed program, the clocked self-interpreter: on the input it computes and a size guard in unary, builds the initial configuration of the evaluation machine for on , and runs the clocked interpreter loop with cost budget , step budget and guard . The theorem states its correctness and its time bound.
For every program , every value and every there is a cost
such that univTProg, run on the single input , halts with result at cost . The function is an explicit polynomial (univTPoly): with , and ,
where , , , are the (quadratic) cost bounds of the unary size, addition, tripling and replication programs and is the polynomial cost bound of one iteration of the clocked loop.
This theorem is the run field of the clocked universal machine selfClockedUniversal, and so proves exists_clocked_universal, half of blueprint lem:universal-tm ([MNY, Lemma 2.1]). The clocked machine is the primitive with which the deciders of the compression pipeline simulate other deciders under a budget, and with which the recursive compression argument runs a description "for steps".
Formalization Note: The budget counts cost units of the big-step semantics (not machine steps), is supplied in unary (so the input has size ), and the bound is polynomial in itself. The result is total: the program halts on every input, also when the simulated run does not halt, which is what the step budget and the size guard are for; the guard never fires on a run that halts within the budget, whose configurations have size at most . The constants in the bound are those produced by the proof.
import Mathlib.Algebra.Polynomial.Eval.Defs import Mathlib.Computability.Primrec.List import Mathlib.Data.List.Basic import Mathlib.Data.Nat.Bits import Mathlib.Data.Nat.Notation import Mathlib.Data.Nat.Size import Mathlib.Logic.Denumerable import Mathlib.Logic.Function.Iterate import Mathlib.Tactic.Linarith import Mathlib.Tactic.Ring import Definitions.Def_MIPRE_Foundations_Cost_Basic import Definitions.Def_MIPRE_Foundations_Cost_Encoding import Definitions.Def_MIPRE_Foundations_Cost_PolyTime import Definitions.Def_MIPRE_Foundations_Cost_Closure import Definitions.Def_MIPRE_Foundations_Cost_Loops import Definitions.Def_MIPRE_Foundations_Cost_Unary import Definitions.Def_MIPRE_Foundations_Cost_Toolkit import Definitions.Def_MIPRE_Foundations_Cost_Machine import Definitions.Def_MIPRE_Foundations_Cost_Codable import Definitions.Def_MIPRE_Foundations_Cost_MachineData import Definitions.Def_MIPRE_Foundations_Cost_Interpreter import Definitions.Def_MIPRE_Foundations_Cost_MachineBound import Definitions.Def_MIPRE_Foundations_Cost_Universal open MIPRE open MIPRE.Cost open MIPRE.Cost.Machine open Polynomial open MIPRE.Cost.Prog
theorem MIPRE.Cost.Machine.univTProg_runs (c : Prog) (v : Data) (k : ℕ) :
∃ t ≤ univTBoundFun (k + esize c + v.size),
univTProg.Runs (.cons (.ofNat k) (.cons (encode c) v)) (clockedResult c v k) t := by sorry