Conditional correctness of the bit-query program: from a run of on to answers about its output
ProvedMIPRE.Cost.Prog.bitQueryProg_runsWe work in the ambient cost model: data are binary trees with the number of nodes, programs (Prog) form a first-order language with de Bruijn variables, and (Eval ρ p r t) means that evaluated in the environment halts with result at cost ; a program runs on the input to at cost (Prog.Runs) when . Every type with a size-aware encoding (SizedEncoding) has an encoding map and the size (esize). Programs are encoded by their syntax trees; pairs by , so that ; bit strings as lists of bits; and natural numbers in binary, so that where is the bit length of (Nat.size).
A universal machine (UniversalMachine) consists of a closed program (U.univ) and a polynomial (U.bound) such that, for every program and data : if runs on to at cost , then runs on to at some cost at most ; and if runs on to , then runs on to .
The bit-query program (bitQueryProg u) takes as input the encoding of — two programs and , a parameter of some encodable type , and a query — runs on , that is, simulates on the input , and feeds the resulting string and the query to the bit-indexing program bitAtProg. The answer expected to a bit-query about is (bitQueryAnswer y m)
with the -th bit of and the unary numeral , the out-of-range marker.
Theorem. Let be a universal machine with program and polynomial , let be programs, , , , and suppose that runs on to at cost :
Put and let be the polynomial (bitQueryBound U)
Then there is a cost with
The string is given only implicitly, as the output of on ; the theorem says that answers any bit-query about it at a cost polynomial in the sizes of the data and in the running time of , times . It is the engine of isSuccinctDesc_hardcode: hardcoding into turns it into a succinct description of in the sense of blueprint def:succinct, which is how the proofs of the recursive compression lemma (lem:recursive-compression) and of the compressibility criterion describe the string computed at the next recursion level.
Formalization Note The parameter type is any type with a SizedEncoding (in the compression lemmas it is or a pair of naturals), and enters the bound only through . The factor comes from the bit walk: it takes at most iterations, each of cost at most (bitAtIter_le), and both and are at most , because a run of cost produces a result of size at most (Eval.size_le); this gives the term . The term is the universal machine's overhead, its argument being . The term absorbs the copies of the arguments and of the intermediate values and the constant-cost rules, after using and . Only the forward direction is stated: a run of yields a run of ; nothing is claimed about when does not halt.
import Mathlib.Algebra.Polynomial.Eval.Defs import Mathlib.Data.List.Basic import Mathlib.Data.Nat.Bits import Mathlib.Data.Nat.Notation import Mathlib.Data.Nat.Size 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 open MIPRE open MIPRE.Cost open MIPRE.Cost.Prog open Polynomial
theorem MIPRE.Cost.Prog.bitQueryProg_runs (U : UniversalMachine) {α : Type*} [SizedEncoding α]
(c' e : Prog) (n : α) (y : BitStr) (m : ℕ) {t : ℕ}
(hrun : c'.Runs (encode (e, n)) (encode y) t) :
∃ T ≤ (bitQueryBound U).eval (esize c' + esize e + esize n + t) * (Nat.size m + 1) ^ 2,
(bitQueryProg U.univ).Runs (encode (((c', e), n), m)) (bitQueryAnswer y m) T := by sorry