The halting problem of Mathlib's partial recursive codes compiles into the ambient model, computably on descriptions
ProvedMIPRE.Cost.exists_compileMathlib's Nat.Partrec.Code is a Gödel numbering of the partial recursive functions: every code has a partial function , and says that halts on the input ; Computable is Mathlib's notion of computability between types carrying a Primcodable structure. In the ambient cost model, programs (Prog) are encoded as data by their tree serialization , data form a Primcodable type (through a Cantor-pairing bijection with ), and (Halts) says that the program run on the input halts, with some result at some cost. The s-m-n map (hardcode p d) runs on the pair of the literal and its input, and denotes the unary numeral of (the list of copies of ).
Statement. There is a map such that
- the description map is computable, and
- for every code ,
This is the seam at which the development meets Mathlib's halting problem (blueprint lem:halting-form). The compression lemmas produce reductions from the halting problem of the cost model; composing with gives reductions from the halting problem of Nat.Partrec.Code, which is what recursive_compression_halting, compressibility_criterion_halting and ultimately the headline undecidability statement consume. Computability of the composite follows from clause 1 together with the Mathlib-computability of polynomial-time functions on computably encoded inputs (PolyTimeFun.computable_comp).
Formalization Note: The compiler carries no time bound — it is a computability-only bridge, which is why this step is available for the computable form of the main theorem but not for a polynomial-time one. Computability is stated for the description as data, since Prog deliberately has no Primcodable instance. The empty input is the datum (the encoding of the empty bit string), and the witness is : the s-m-n hardcoding of the Gödel number of (Encodable.encode pc), as a unary numeral, into the translation of a ToPartrec code for the universal partial function .
import Mathlib.Algebra.Polynomial.Eval.Defs import Mathlib.Computability.PartrecCode import Mathlib.Computability.Primrec.List import Mathlib.Computability.TuringMachine.Config 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 import Definitions.Def_MIPRE_Foundations_Cost_Kleene import Definitions.Def_MIPRE_Foundations_Cost_FromPartrec open MIPRE open MIPRE.Cost open Turing.ToPartrec (Code)
theorem MIPRE.Cost.exists_compile :
∃ compile : Nat.Partrec.Code → Prog,
Computable (fun pc => (encode (compile pc) : Data)) ∧
∀ pc : Nat.Partrec.Code, Halts (compile pc) .nil ↔ (pc.eval 0).Dom := by sorry