Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

The hardcoded search program halts once the start-level string is produced and the semidecider accepts it

Proved
MIPRE.Cost.Prog.searchProg_runs

by thomasvidick · Oct 12, 2026 · Mathlib 0df444a (Lean v4.33.1)

computabilitymipre-formalizationrecursive-compressionuniversal-machine

We work in the ambient cost model (programs Prog on binary-tree data, timed semantics, Prog.Runs p x r t: the program ppp on the input xxx halts with rrr at cost ttt). A universal machine UUU (UniversalMachine) is a closed program U.univU.\mathrm{univ}U.univ with a polynomial overhead such that every run of a program ccc on vvv with result rrr yields a run of U.univU.\mathrm{univ}U.univ on the pair (encode(c),v)(\mathrm{encode}(c), v)(encode(c),v) with the same result, and conversely U.univU.\mathrm{univ}U.univ halts on (encode(c),v)(\mathrm{encode}(c), v)(encode(c),v) only if ccc halts on vvv, with the same result.

The compressibility criterion (Lin's criterion, blueprint lem:compressible-criterion-nested) adds a search branch to the self-referential decider of the recursive compression argument: at each level the decider tests, under a budget, whether a semidecision procedure SSS accepts the string at the start level mmm of the recursion. The program tested is the search program with its data hardcoded. For a universal program univ\mathrm{univ}univ and a program SSS, searchProg(univ,S)\mathrm{searchProg}(\mathrm{univ}, S)searchProg(univ,S) expects the pair of d=encode(((c′,(e,(m,m))),m))d = \mathrm{encode}(((c', (e, (m, m))), m))d=encode(((c′,(e,(m,m))),m)) and an (ignored) input: it runs univ\mathrm{univ}univ on the first component of ddd, i.e. simulates c′c'c′ on the encoded triple (e,(m,m))(e, (m, m))(e,(m,m)) to obtain a value xxx (the string at the start level), and then runs SSS on the pair cons(x,encode(m))\texttt{cons}(x, \mathrm{encode}(m))cons(x,encode(m)). The s-m-n map hardcode(p,d)=let_ (cons (const d) (var 0)) p\mathrm{hardcode}(p, d) = \texttt{let\_}\,(\texttt{cons}\,(\texttt{const}\,d)\,(\texttt{var}\,0))\ phardcode(p,d)=let_(cons(constd)(var0)) p fixes ddd, so that hardcode(searchProg(univ,S),d)\mathrm{hardcode}(\mathrm{searchProg}(\mathrm{univ}, S), d)hardcode(searchProg(univ,S),d) is a program to be run on the empty input nil.

Let UUU be a universal machine, SSS a closed program (well-scoped in one variable), c′,ec', ec′,e programs, m∈Nm \in \mathbb{N}m∈N, and x,rx, rx,r data. Suppose that c′c'c′ on encode((e,(m,m)))\mathrm{encode}((e, (m, m)))encode((e,(m,m))) halts with xxx (at some cost txt_xtx​) and that SSS on cons(x,encode(m))\texttt{cons}(x, \mathrm{encode}(m))cons(x,encode(m)) halts with rrr (at some cost tst_sts​). Then

∃T,hardcode(searchProg(U.univ,S), encode(((c′,(e,(m,m))),m))) on the input ‘nil‘ halts with r at cost T.\exists T,\qquad \mathrm{hardcode}\bigl(\mathrm{searchProg}(U.\mathrm{univ}, S),\ \mathrm{encode}(((c', (e, (m,m))), m))\bigr)\ \text{on the input `nil` halts with } r \text{ at cost } T.∃T,hardcode(searchProg(U.univ,S), encode(((c′,(e,(m,m))),m))) on the input ‘nil‘ halts with r at cost T.

This is the forward direction of the correctness of the search branch; with its converse searchProg_halts_of it shows that the search branch of the decider fires exactly when SSS halts on the string at the start level, which is what the proof of compressibility_criterion_nested uses (the search eventually fires if the start string lies outside the class recognized by SSS).

Formalization Note. The statement is MIPRE.Cost.Prog.searchProg_runs; the triple (e,(m,m))(e, (m, m))(e,(m,m)) carries the start level mmm twice because the decider's input is (c′,(e,(m,n)))(c', (e, (m, n)))(c′,(e,(m,n))) with mmm the start level and nnn the current level, and the search is about the string at n=mn = mn=m. The semidecider SSS receives the pair cons(x,encode(m))\texttt{cons}(x, \mathrm{encode}(m))cons(x,encode(m)), in the per-level form of the criterion where SSS halts on (x,n)(x, n)(x,n) iff x∉B1(n)x \notin B_1(n)x∈/B1​(n). No cost bound is claimed (only the existence of a halting run), since the decider tests halting within a budget that is then taken large enough.

Preamble
import Mathlib.Algebra.Polynomial.Eval.Defs
import Mathlib.Algebra.Polynomial.Eval.Degree
import Mathlib.Computability.Halting
import Mathlib.Computability.Partrec
import Mathlib.Computability.PartrecCode
import Mathlib.Computability.Primrec.List
import Mathlib.Computability.TuringMachine.Config
import Mathlib.Data.ENat.Lattice
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_Numeric
import Definitions.Def_MIPRE_Foundations_Cost_BitQuery
import Definitions.Def_MIPRE_Foundations_Cost_Toolkit
import Definitions.Def_MIPRE_Foundations_Cost_Succinct
import Definitions.Def_MIPRE_Foundations_Cost_Clocked
import Definitions.Def_MIPRE_Foundations_Cost_Threshold
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_Partrec
import Definitions.Def_MIPRE_Foundations_Cost_FromPartrec
import Definitions.Def_MIPRE_Foundations_Compression

open MIPRE
open MIPRE.Cost
open MIPRE.Cost.Prog
open Polynomial
Formal statement
theorem MIPRE.Cost.Prog.searchProg_runs (U : UniversalMachine) {S : Prog} (hS : S.WellScoped 1)
    {c' e : Prog} {m : ℕ} {x r : Data} {tx ts : ℕ}
    (hx : c'.Runs (encode (e, (m, m))) x tx) (hSr : S.Runs (.cons x (encode m)) r ts) :
    ∃ T, (hardcode (searchProg U.univ S) (encode ((c', (e, (m, m))), m))).Runs .nil r T := by sorry
Source
https://github.com/vidick/MIPRE-formalization/blob/70cbf1c52e3d5e1dff1162fdf952c9a9f4bd99ed/MIPRE/Foundations/Compression.lean#L348-L370; internal lemma of the formalization of blueprint lem:compressible-criterion-nested (the search branch of Lin's compressibility criterion, lem:compressible-criterion)

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me