Determinism of the timed big-step semantics: a run has a unique result and a unique cost
ProvedMIPRE.Cost.Eval.deterministicLet be the type of binary trees (the values of the ambient cost model, built from and ), let be the type of programs of the ambient first-order language with de Bruijn variables, and let an environment be a list of values (variable reads the -th entry, and beyond the end of the list). The timed big-step semantics is the inductively defined relation , read "in environment the program halts with result at cost ". It charges one unit per evaluation rule, except that reading a variable costs of the value read and a literal costs .
Let be an environment, a program, values and natural numbers. If both and hold, then
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 out of range), and there is no well-scopedness hypothesis on . Determinism includes the cost, so the cost of a halting run is a function of ; Prog.Runs p v r t is the special case .
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
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