Encoded size of a bounded machine configuration is at most
ProvedMIPRE.Cost.Machine.size_toData_leConfigurations of the evaluation machine of the ambient cost model (MIPRE.Cost.Machine; see eval_steps_bound for the machine) are encoded as data (Cfg.toData) so that the self-interpreter can operate on them. Data are binary trees built from and , with the number of nodes (); a list of data is encoded as the -chain of its elements ending in (, Data.list), a program by its syntax tree, of size , and the unary numeral (Data.ofNat j) has size . The encoding of a configuration is
where the control is encoded as and as , and a frame as with the tag for , , , respectively, and payload , resp. , resp. .
Recall that means: a returned value of has size at most , a program under evaluation has encoded size at most , the environment has length at most with values of size at most , the stack has at most frames, and each frame's program, environment and value obey the same bounds , (with values at most ) and . Define
Theorem. If , then
Together with eval_steps_bound, which bounds every configuration along the run simulating a derivation of cost by , this makes every encoded configuration of such a run polynomially bounded in the size of the program, the size of the input and the cost. The proof of the efficient universal machine (blueprint lem:universal-tm, in MIPRE.Foundations.Cost.Universal) takes with for a program run on at cost , so that and , and uses (sigmaFun), a cubic polynomial in , as the bound on the input of every call to the step program in the self-interpreter and in the size guard of the clocked universal machine.
Formalization Note The bound is a closed-form polynomial obtained by adding up the components of the encoding: the control contributes at most (the sum of the two cases and , rather than their maximum); the environment chain at most , since a -chain of at most values of size at most has size at most (size_list_le_of_forall); each frame at most (frame_size_le, where accounts for the largest tag , of size , and three nodes); the stack chain therefore at most ; plus the two outer nodes. It holds for every bounded configuration, not only for those arising along runs.
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 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_Machine import Definitions.Def_MIPRE_Foundations_Cost_Codable import Definitions.Def_MIPRE_Foundations_Cost_MachineData import Definitions.Def_MIPRE_Foundations_Cost_MachineBound open MIPRE open MIPRE.Cost open MIPRE.Cost.Machine
theorem MIPRE.Cost.Machine.size_toData_le {V L P K : ℕ} {c : Cfg} (h : CfgBound V L P K c) :
(Cfg.toData c).size ≤ cfgSizeBound V L P K := by sorry