Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

`clockRun` returns the timeout value nil\mathsf{nil}nil when the program does not halt within the cost budget

Proved
MIPRE.Cost.Machine.clockRun_of_not

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

computabilitymipre-formalizationself-interpreteruniversal-machine

Let ccc be a program of the ambient cost model and vvv an input, and let c0=⟨ev c,[v],[ ]⟩c_0 = \langle\mathsf{ev}\,c, [v], [\,]\ranglec0​=⟨evc,[v],[]⟩ be the initial configuration of the evaluation machine for ccc on vvv. Let clockRun(c0,k,Θ,b,n)\mathtt{clockRun}(c_0, k, \Theta, b, n)clockRun(c0​,k,Θ,b,n) be the specification of the clocked interpreter loop started on the nnn-th configuration of the run with bbb further iterations, cost budget kkk and size guard Θ\ThetaΘ: it is the flagged value of the current configuration if that is final, and otherwise either nil\mathsf{nil}nil (when b=0b = 0b=0, when the cumulative cost costSum(c0,n+1)\mathsf{costSum}(c_0, n+1)costSum(c0​,n+1) would exceed kkk, or when the next configuration exceeds the guard) or the value at the next configuration with one fewer iteration.

Suppose that ccc does not halt on vvv within cost kkk: there are no rrr and t≤kt \le kt≤k with Eval  [v]  c  r  t\mathsf{Eval}\;[v]\;c\;r\;tEval[v]crt. Then for all b,n∈Nb, n \in \mathbb{N}b,n∈N with costSum(c0,n)≤k\mathsf{costSum}(c_0, n) \le kcostSum(c0​,n)≤k,

clockRun(c0,k,Θ,b,n)=nil.\mathtt{clockRun}(c_0, k, \Theta, b, n) = \mathsf{nil} .clockRun(c0​,k,Θ,b,n)=nil.

This is the timeout half of the identification of the clocked loop's value with the budgeted result clockedResult (clockRun_eq; the other half is clockRun_of_final), used by the clocked universal machine of blueprint lem:universal-tm.

Formalization Note: The hypothesis is stated with Prog.Runs c v r t, that is, a derivation in the one-element environment [v][v][v], and the cost kkk is the cost of the big-step semantics, not a number of machine steps. The guard Θ\ThetaΘ plays no role in the conclusion. The condition costSum(c0,n)≤k\mathsf{costSum}(c_0, n) \le kcostSum(c0​,n)≤k is what the recursion of clockRun maintains; at n=0n = 0n=0 it is trivial.

Preamble
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.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

open MIPRE
open MIPRE.Cost
open MIPRE.Cost.Machine
open Polynomial
open MIPRE.Cost.Prog
Formal statement
theorem MIPRE.Cost.Machine.clockRun_of_not (c : Prog) (v : Data) (k Θ : ℕ)
    (hno : ¬ ∃ r t, t ≤ k ∧ c.Runs v r t) :
    ∀ b n, costSum ⟨.ev c, [v], []⟩ n ≤ k → clockRun ⟨.ev c, [v], []⟩ k Θ b n = .nil := by sorry
Source
https://github.com/vidick/MIPRE-formalization/blob/70cbf1c52e3d5e1dff1162fdf952c9a9f4bd99ed/MIPRE/Foundations/Cost/Universal.lean#L1138-L1157; internal lemma of the formalization of blueprint lem:universal-tm, https://vidick.github.io/MIPRE-formalization/blueprint/

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