`parseProg` reads a serialization back: on the encoded bit string it computes `parse x` in quadratic time
ProvedMIPRE.Cost.Prog.parseProg_runsAmbient cost model: data are binary trees (Data, with the number of nodes), is the size-faithful encoding (a bit string of length encodes as a -chain of bits, of size between and ), and (p.Runs v r t) means that the program on the single input halts with result at cost . Description strings are postorder serializations of data (Data.toBitsPost), read back by the stack machine of Data.stackRun: a pushes , a pops two entries and pushes their pair; the total reader = Data.parse x is the top of the stack after running the machine over from the empty stack, if that stack is empty. parseProg is the program of the ambient model that pairs its input with the empty stack and runs the loop parseBody (parseLoop_runs).
For every bit string :
Since , the cost is quadratic in . parseProg is the program with which the compressor's decider reads the description it is handed (Halting/Compressor.lean); together with serProg, which writes a serialization, it moves between a datum and its description string inside the model.
Formalization Note. The theorem is MIPRE.Cost.Prog.parseProg_runs (x : BitStr), with conclusion ∃ t ≤ (x.length + 2) * ((encode x : Data).size + 2 * x.length + 25), parseProg.Runs (encode x) (parse x) t. parseProg is .let_ (.cons (.var 0) .nil) (.loop parseBody) and parse x = (stackRun x []).headD nil; Prog.Runs p v r t is Eval [v] p r t. The bound is an explicit polynomial in and , not an asymptotic statement, and no hypothesis on is needed: the reader is total, since the stack machine ignores a 1 on a stack with fewer than two entries.
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.Tactic.Linarith import Mathlib.Tactic.Ring import Definitions.Def_MIPRE_Foundations_Cost_Basic import Definitions.Def_MIPRE_Foundations_Cost_Basic_B import Definitions.Def_MIPRE_Foundations_Cost_Encoding import Definitions.Def_MIPRE_Foundations_Cost_Encoding_B 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_Loops_B import Definitions.Def_MIPRE_Foundations_Cost_Codable import Definitions.Def_MIPRE_Foundations_Cost_Codable_B import Definitions.Def_MIPRE_Foundations_Cost_Unary import Definitions.Def_MIPRE_Foundations_Halting_Descriptions import Definitions.Def_MIPRE_Foundations_Cost_Numeric import Definitions.Def_MIPRE_Foundations_Cost_Numeric_B import Definitions.Def_MIPRE_Foundations_Halting_Lists import Definitions.Def_MIPRE_Foundations_Halting_Serial open MIPRE open MIPRE.Cost open MIPRE.Cost.Prog open MIPRE.Cost.Data
theorem MIPRE.Cost.Prog.parseProg_runs (x : BitStr) :
∃ t ≤ (x.length + 2) * ((encode x : Data).size + 2 * x.length + 25),
parseProg.Runs (encode x) (parse x) t := by sorry