A deterministic interpreter that counts oracle queries
AutoSamplingTheory.TechnicalLemmas.Analysis.QuadraticRegularizationOracle.run · def · Teaching coverage
Statement
S,Q,A,X are arbitrary types of state, query, reply and output. A fixed deterministic policy next:S→X⊕Q either halts (left) or asks a query (right). An update:S→Q→A→S and oracle:Q→A are given. Fuel n is a natural query allowance and s is any initial state. There are no analytic assumptions. The following recursion defines its final state, optional successful output and actual interaction counter.
All objects and hypotheses
- S,Q,A,X are arbitrary types of state, query, reply and output. A fixed deterministic policy next:S→X⊕Q either halts (left) or asks a query (right).
- An update:S→Q→A→S and oracle:Q→A are given. Fuel n is a natural query allowance and s is any initial state. There are no analytic assumptions.
Construction and meaning
1. Inspect control before spending query fuel
If next(s) halts with x, return the current state, some x, and zero queries, even when n=0. If it asks q with n=0, return state s, none, and zero queries.
Corresponding Lean step
Outer match on next s; zero-fuel branch.
2. Consume exactly one oracle interaction
For a query q with positive fuel, obtain the single answer a=O(q), update to s′, and recurse with one fewer query. Preserve the final state and halt/exhaustion outcome; increment only the returned counter.
Corresponding Lean step
Structural recursion on natural query fuel; let-bound answer and tail.
Lean statement · run
Generic fuel-bounded state/output/query-count recursion.
Braces mark parameters Lean can infer; square brackets request structures such as a measurable space or probability measure. Named hypotheses are mathematical premises, not facts established by this declaration. Section parameters are described in the mathematical hypotheses above; the module link retains their exact source context.
def run {S Q A X : Type*} (next : S → Sum X Q) (update : S → Q → A → S)
(oracle : Q → A) : ℕ → S → (S × Option X) × ℕ
| fuel, s => match next s with
| .inl x => ((s, some x), 0)
| .inr q => match fuel with
| 0 => ((s, none), 0)
| n+1 =>
let answer := oracle q
let tail := run next update oracle n (update s q answer)
(tail.1, tail.2+1)
set_option backward.isDefEq.respectTransparency false in
/-- Correct each original value/gradient reply using known quadratic data.
For every adaptive program and fuel, this preserves the actual regularized
execution, including its state, halt/exhaustion outcome and query count. -/Lean construction · run
If next(s) halts with x, return the current state, some x, and zero queries, even when n=0. If it asks q with n=0, return state s, none, and zero queries. For a query q with positive fuel, obtain the single answer a=O(q), update to s′, and recurse with one fewer query. Preserve the final state and halt/exhaustion outcome; increment only the returned counter.
Braces mark parameters Lean can infer; square brackets request structures such as a measurable space or probability measure. Named hypotheses are mathematical premises, not facts established by this declaration. Section parameters are described in the mathematical hypotheses above; the module link retains their exact source context.
def run {S Q A X : Type*} (next : S → Sum X Q) (update : S → Q → A → S)
(oracle : Q → A) : ℕ → S → (S × Option X) × ℕ
| fuel, s => match next s with
| .inl x => ((s, some x), 0)
| .inr q => match fuel with
| 0 => ((s, none), 0)
| n+1 =>
let answer := oracle q
let tail := run next update oracle n (update s q answer)
(tail.1, tail.2+1)
set_option backward.isDefEq.respectTransparency false in
/-- Correct each original value/gradient reply using known quadratic data.
For every adaptive program and fuel, this preserves the actual regularized
execution, including its state, halt/exhaustion outcome and query count. -/Scope and omitted-condition boundaries
- The interpreter counts exact oracle interactions; local arithmetic and control inspection are free. It is a mathematical semantics on exact replies, not executable real arithmetic, finite precision or machine runtime.
- This is a finite deterministic simulation component. Equality holds for every fixed program and initial state, including adaptive queries and early stopping. It does not prove that a program chosen using f is information-restricted. Class-uniform work must quantify a single program/initialization before f and prove its halting accuracy and budget over the whole class.
- Halting after the last allowed reply is detected with no extra query. A halted output is some x; none means fuel exhaustion and carries no successful-output claim. No randomized/unbounded-machine equivalence, minimizer existence or full Lemma4.2 complexity reduction is asserted.
Source and reuse
ASTIS parents called
Mathlib API called (external library)
- Nat.rec
Mathematical sources
- Chewi Section1.1 oracle interactions — Exact first-order replies and cost model; class-uniformity remains an additional obligation.
- Chewi Lemma4.2 quadratic reduction — Explicit realization of its regularized oracle using one original reply.
ASTIS prose is not a quotation or a source-equivalence certificate. Definitions and aliases are explained as constructions, not counted as new mathematical proofs.