The canonicity walk accepts exactly the encodings of bit strings that are empty or end in a one
ProvedMIPRE.Cost.Data.canonWalk_iffIn the ambient cost model, data are binary trees (Data, built from nil and cons), a bit is encoded as and , and a bit string as the -chain of its encoded bits ending in , written . The function walks a datum while recording whether the string read so far is empty or ends in a one: ; ; ; and for any other head .
For every datum and Boolean ,
This is the specification of the walk performed by the program normBinProg, with which the wrapper decider of the halting reduction normalizes the parameter of a description (a canonical binary numeral is a bit string that is empty or ends in a one). Its instance at is canonWalk_eq_isCanonBin.
Formalization Note. The statement is MIPRE.Cost.Data.canonWalk_iff. BitStr is List Bool, encode l is Data.ofList Data.ofBool l, and the last-bit condition is l.getLast? = some true; the empty and nonempty cases are stated as two separate implications, (l = [] → b = true) and (l ≠ [] → l.getLast? = some true). For a datum that is not the encoding of any bit string, the right side is false because no l satisfies d = encode l. There are no hypotheses.
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.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 open MIPRE open MIPRE.Cost open MIPRE.Cost.Data
theorem MIPRE.Cost.Data.canonWalk_iff (d : Data) (b : Bool) :
canonWalk d b = true ↔
∃ l : BitStr, d = encode l ∧ (l = [] → b = true) ∧ (l ≠ [] → l.getLast? = some true) := by sorry