Evaluation as a partial recursive function on data agrees with the big-step semantics
ProvedMIPRE.Cost.Machine.mem_evalData_iffThe evaluation machine of the ambient cost model has configurations (a control or , an environment and a stack of frames), a total step function fixing the final configurations , and it implements the big-step semantics: writing for "the program on input halts with result at cost ", one has for some iff for some (halts_iff). To connect with Mathlib's computability, configurations are encoded as data (Cfg.toData): a control is or , a configuration is with the environment and the stack as -chains, and frames carry unary tags. On data, is defined by first-order tree operations alone and agrees with the machine, (stepData_toData); tests finality on data, reads the returned value, and is the encoding of the initial configuration for an encoded program . Evaluation on data is the partial function
the PFun.fix of one iteration of the evaluation loop (evalStep); it is partial recursive (partrec_evalData) because the step on data is primitive recursive.
Statement. For every program and data ,
Together with partrec_evalData, this is the bridge from the ambient model to Mathlib's computability: a polynomial-time function of the model, precomposed with a computable encoding of its input, has a computable encoded output (PolyTimeFun.computable_encode_comp, computable_comp), which is how the reductions of the halting form of the compression lemmas (blueprint lem:halting-form: recursive_compression_halting, compressibility_criterion_halting) are shown Computable.
Formalization Note: Membership is Mathlib's Part membership (the value is defined and equals ); the program enters as its serialization c.toData, and no Primcodable instance for Prog is involved — everything is at the level of Data, which is denumerable through Cantor pairing. No cost information survives the transport: the right-hand side is halting with an unspecified cost.
import Mathlib.Algebra.Polynomial.Eval.Defs import Mathlib.Computability.Partrec 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_Machine import Definitions.Def_MIPRE_Foundations_Cost_Codable import Definitions.Def_MIPRE_Foundations_Cost_MachineData import Definitions.Def_MIPRE_Foundations_Cost_Partrec open MIPRE open MIPRE.Cost open MIPRE.Cost.Machine open Primrec
theorem MIPRE.Cost.Machine.mem_evalData_iff (c : Prog) (x r : Data) :
r ∈ evalData c.toData x ↔ ∃ t, c.Runs x r t := by sorry