Size bounds on machine configurations along a run
DefinitionMIPRE_Foundations_Cost_MachineBoundThis bundle defines the bounds that every configuration of the evaluation machine satisfies along the simulation of a derivation, and the resulting bound on the size of its encoding.
MIPRE.Cost.Machine.FrameBound is a predicate on frames: a frame carrying an environment (, , ) must hold a program of size at most and an environment of length at most all of whose values have size at most ; a frame must have .
MIPRE.Cost.Machine.CfgBound is the corresponding bound on a configuration , a structure with six clauses:
- a returned value has size at most ;
- a program under evaluation has size at most ;
- the environment has length at most ;
- every value in the environment has size at most ;
- the stack has length at most ;
- every frame of the stack satisfies .
MIPRE.Cost.Machine.cfgSizeBound is the explicit bound
on the size of the data encoding of any configuration satisfying .
No lemma is proved inside this bundle.
Formalization Note. Along the machine run simulating a derivation the bounds hold with any number at least and at least the sizes of the initial values (every value produced is the result of a sub-derivation of cost at most , hence of size at most ), the initial environment length plus , the size of the initial program (every program under evaluation is one of its subterms), and the initial stack length plus (the stack gains at most frames). The uploaded theorems eval_steps_bound and size_toData_le establish this; the consequence, that every configuration handled by the self-interpreter on a halting run has size polynomial in , is what bounds the cost of the universal machine.
/- Copyright (c) 2026 Thomas Vidick. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Thomas Vidick -/ /- Generated for Prove2Me from vidick/MIPRE-formalization@70cbf1c, MIPRE/Foundations/Cost/MachineBound.lean (definition bundle: declarations the uploaded statements rest on); produced mechanically by prove2me/tools/gen.py, never edited by hand. -/ 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 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_Machine import Definitions.Def_MIPRE_Foundations_Cost_Codable import Definitions.Def_MIPRE_Foundations_Cost_MachineData /-! # Size bounds along machine runs Along the run of the evaluation machine that simulates a derivation `Eval env p r t`, every configuration stays bounded (`CfgBound`): values have size at most `V` (where `t ≤ V` and the initial values are at most `V`, since every value produced is the result of a sub-derivation of cost at most `t`), environments have length at most `L + 2 t`, programs are subterms of the initial ones, and the stack gains at most `t` frames (`eval_steps_bound`). Consequently the data encoding of every configuration along the run has size polynomial in the sizes of the program, the input and the cost (`size_toData_le`). This is what bounds the cost of the self-interpreter. -/ namespace MIPRE.Cost namespace Machine /-! ## Bounds on configurations -/ /-- Bounds on a frame: values of size at most `V`, an environment of length at most `L`, a program of size at most `P`. -/ def FrameBound (V L P : ℕ) : Frame → Prop | .cons1 t env => esize t ≤ P ∧ env.length ≤ L ∧ ∀ v ∈ env, v.size ≤ V | .cons2 a => a.size ≤ V | .let1 b env => esize b ≤ P ∧ env.length ≤ L ∧ ∀ v ∈ env, v.size ≤ V | .loop1 b env => esize b ≤ P ∧ env.length ≤ L ∧ ∀ v ∈ env, v.size ≤ V /-- Bounds on a configuration: values of size at most `V`, environments of length at most `L`, programs of size at most `P`, a stack of length at most `K`. -/ structure CfgBound (V L P K : ℕ) (c : Cfg) : Prop where ctrl_val : ∀ v, c.ctrl = .ret v → v.size ≤ V ctrl_prog : ∀ p, c.ctrl = .ev p → esize p ≤ P env_len : c.env.length ≤ L env_val : ∀ v ∈ c.env, v.size ≤ V kont_len : c.kont.length ≤ K frames : ∀ f ∈ c.kont, FrameBound V L P f /-! ## Program subterms -/ /-! ## Chaining bounds along runs -/ /-! ## Size of the encoded configurations -/ /-- Size of the encoding of a configuration satisfying `CfgBound V L P K`. -/ def cfgSizeBound (V L P K : ℕ) : ℕ := V + P + L * V + L + K * (V + P + L * V + L + 10) + K + 8 /-! ## Runs from the empty stack are bounded forever -/ /-! ## The number of steps of a run -/ /-! ## Cost sums -/ end Machine end MIPRE.Cost