Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Determinism of the timed big-step semantics: a run has a unique result and a unique cost

Proved
MIPRE.Cost.Eval.deterministic

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

computabilitycost-modelmip-remipre-formalization

Let Data\mathsf{Data}Data be the type of binary trees (the values of the ambient cost model, built from nil\mathsf{nil}nil and cons\mathsf{cons}cons), let Prog\mathsf{Prog}Prog be the type of programs of the ambient first-order language with de Bruijn variables, and let an environment ρ\rhoρ be a list of values (variable iii reads the iii-th entry, and nil\mathsf{nil}nil beyond the end of the list). The timed big-step semantics is the inductively defined relation Eval  ρ  p  r  t\mathsf{Eval}\;\rho\;p\;r\;tEvalρprt, read "in environment ρ\rhoρ the program ppp halts with result rrr at cost t∈Nt \in \mathbb{N}t∈N". It charges one unit per evaluation rule, except that reading a variable costs 1+size1 + \mathrm{size}1+size of the value read and a literal const d\mathsf{const}\,dconstd costs size(d)\mathrm{size}(d)size(d).

Let ρ\rhoρ be an environment, ppp a program, r,r′r, r'r,r′ values and t,t′t, t't,t′ natural numbers. If both Eval  ρ  p  r  t\mathsf{Eval}\;\rho\;p\;r\;tEvalρprt and Eval  ρ  p  r′  t′\mathsf{Eval}\;\rho\;p\;r'\;t'Evalρpr′t′ hold, then

r=r′andt=t′.r = r' \quad\text{and}\quad t = t'.r=r′andt=t′.

In words: the semantics is a partial function of the environment and the program, in both its result and its cost. This is the lemma that lets a run of a program be "read back": whenever a derivation is inverted (a run of the self-interpreter, of the s-m-n program, of a clocked simulation), the sub-run that one has constructed by hand must coincide with the one in the hypothesis. It also makes the budgeted result evalWithin (and hence clockedResult) well defined.

Formalization Note: The statement is about the relation MIPRE.Cost.Eval of Cost/Basic.lean; Env is List Data, lookup is Env.get (total, returning nil\mathsf{nil}nil out of range), and there is no well-scopedness hypothesis on ppp. Determinism includes the cost, so the cost ttt of a halting run is a function of (ρ,p)(\rho, p)(ρ,p); Prog.Runs p v r t is the special case ρ=[v]\rho = [v]ρ=[v].

Preamble
import Mathlib.Data.List.Basic
import Mathlib.Data.Nat.Notation
import Definitions.Def_MIPRE_Foundations_Cost_Basic

open MIPRE
open MIPRE.Cost
open MIPRE.Cost.Eval
Formal statement
theorem MIPRE.Cost.Eval.deterministic {env : Env} {p : Prog} {r r' : Data} {t t' : ℕ}
    (h : Eval env p r t) (h' : Eval env p r' t') : r = r' ∧ t = t' := by sorry
Source
https://github.com/vidick/MIPRE-formalization/blob/70cbf1c52e3d5e1dff1162fdf952c9a9f4bd99ed/MIPRE/Foundations/Cost/Basic.lean#L274-L323; 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