Samplinglib
Lean gate not recorded for this source state main · 9bb7a7394ab0

QuadraticRegularizationOracle: mathematical reading route

Read the statements and derivations in source order. Every result has its own optional Lean statement and proof. Source assumptions, library reuse and unproved boundaries are kept explicit.

  1. A deterministic interpreter that counts oracle queries
  2. Simulate the regularized first-order oracle with no extra queries
Samplinglib mathematical lesson

A deterministic interpreter that counts oracle queries

AutoSamplingTheory.TechnicalLemmas.Analysis.QuadraticRegularizationOracle.run · def · Teaching coverage

Read this first

Mathematical 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.

\[R_n(s)\in(S\times\mathrm{Option}(X))\times\mathbb N.\]
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

Exact module and namespace context

Proof roadmap

  1. 1Inspect 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.

  2. 2Consume 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.

Full assumptions and notation

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.

\[R_0(s)=\begin{cases}((s,\mathrm{some}(x)),0)&\mathrm{next}(s)=\mathrm{halt}(x),\\((s,\mathrm{none}),0)&\mathrm{next}(s)=\mathrm{query}(q).\end{cases}\]
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.

\[a=O(q),\quad s^\prime=\mathrm{update}(s,q,a),\quad R_{n+1}(s)=(p,c+1)\ \text{if }R_n(s^\prime)=(p,c).\]
Corresponding Lean step

Structural recursion on natural query fuel; let-bound answer and tail.

Lean verification

The exact proof begins folded immediately after the mathematical argument; the statement is folded beside the claim above.

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.

Download module (.lean)
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

Exact module and namespace context

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.
Sources, dependencies, and reuse

Source and reuse

Samplinglib parents called

    Mathlib API called (external library)

    • Nat.rec

    Mathematical sources

    Samplinglib prose is not a quotation or a source-equivalence certificate. Definitions and aliases are explained as constructions, not counted as new mathematical proofs.

    Samplinglib mathematical lesson

    Simulate the regularized first-order oracle with no extra queries

    AutoSamplingTheory.TechnicalLemmas.Analysis.QuadraticRegularizationOracle.simulate_regularized · theorem · Teaching coverage

    Read this first

    Mathematical statement

    E is a complete real inner-product space. The objective f:E→R is everywhere differentiable and convex, with genuine beta-Lipschitz gradient; beta,delta are nonnegative (including zero), and u:E is arbitrary. S and X are arbitrary state and output types. Fix next:S→X⊕E and update:S→E→(R×E)→S. Quantify every query allowance n:N and initial state s:S. Set W(x)=f(x)+delta||x-u||²/2, O_f(x)=(f(x),gradient f(x)), and O_W(x)=(W(x),gradient W(x)). Correct a reply a using the known x,u,delta before applying the same update. The corrected original run equals the true regularized run in final state, halt/exhaustion outcome and actual count; that count is at most n.

    \[\begin{gathered}O_f(x)=(f(x),\nabla f(x)),\qquad W(x)=f(x)+\frac\delta2\|x-u\|^2,\\T_x(v,g)=(v+\frac\delta2\|x-u\|^2,g+\delta(x-u)),\\R_n^{\mathrm{update}\circ T,O_f}(s)=R_n^{\mathrm{update},O_W}(s),\qquad c_n\le n.\end{gathered}\]
    Lean statement · simulate_regularized

    Full execution equality and actual query counter bounded by fuel.

    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.

    theorem simulate_regularized
        {E S X : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [CompleteSpace E]
        (next : S → Sum X E) (update : S → E → (ℝ × E) → S)
        {f : E → ℝ} (hd : Differentiable ℝ f) (hc : ConvexOn ℝ univ f)
        {β δ : ℝ≥0} (hL : LipschitzWith β (gradient f)) (u : E) (fuel : ℕ) (s : S) :
        let W := fun x => f x + (δ : ℝ)/2*‖x-u‖^2
        let corrected := fun s x (a : ℝ × E) =>
          update s x (a.1 + (δ : ℝ)/2*‖x-u‖^2, a.2 + (δ : ℝ) • (x-u))
        let base := run next corrected (fun x => (f x, gradient f x)) fuel s
        let target := run next update (fun x => (W x, gradient W x)) fuel s
        base = target ∧ base.2 ≤ fuel

    Exact module and namespace context

    Proof roadmap

    1. 1Identify the actual regularized reply

      The compiled first-order regularization theorem computes the genuine gradient of W. Its value is W by definition. Therefore adding the known quadratic value and gradient correction to one O_f reply produces exactly O_W(x). Convexity and gradient Lipschitzness are inherited source-class premises of the reused parent; no Hessian or second derivative is needed.

    2. 2Follow the same adaptive control path

      Induct on query allowance, for every state. Both runs inspect the same next(s). A halt or zero-fuel exhaustion returns the same result without querying. In the positive-fuel query branch, corrected and true replies update to exactly the same state. Apply the induction hypothesis there; this handles reply-dependent future queries and stopping.

    3. 3Preserve and bound the interaction counter

      In the only querying branch both interpreters make one interaction and add one to the equal recursive counters. The inductive bound c≤n gives c+1≤n+1. Halt/exhaustion branches have zero cost. No externally supplied cost label or objective minimizer enters the execution.

    Full assumptions and notation

    All objects and hypotheses

    • E is a complete real inner-product space. The objective f:E→R is everywhere differentiable and convex, with genuine beta-Lipschitz gradient; beta,delta are nonnegative (including zero), and u:E is arbitrary.
    • S and X are arbitrary state and output types. Fix next:S→X⊕E and update:S→E→(R×E)→S. Quantify every query allowance n:N and initial state s:S.
    • Set W(x)=f(x)+delta||x-u||²/2, O_f(x)=(f(x),gradient f(x)), and O_W(x)=(W(x),gradient W(x)). Correct a reply a using the known x,u,delta before applying the same update.

    Mathematical proof

    1. Identify the actual regularized reply

    The compiled first-order regularization theorem computes the genuine gradient of W. Its value is W by definition. Therefore adding the known quadratic value and gradient correction to one O_f reply produces exactly O_W(x). Convexity and gradient Lipschitzness are inherited source-class premises of the reused parent; no Hessian or second derivative is needed.

    \[T_x(v,g)=\left(v+\frac\delta2\|x-u\|^2,\ g+\delta(x-u)\right),\qquad T_x(O_f(x))=O_W(x).\]
    Corresponding Lean step

    AutoSamplingTheory.TechnicalLemmas.Analysis.QuadraticRegularizationFirstOrder.curvature_gradient_and_smoothness (third conjunct).

    2. Follow the same adaptive control path

    Induct on query allowance, for every state. Both runs inspect the same next(s). A halt or zero-fuel exhaustion returns the same result without querying. In the positive-fuel query branch, corrected and true replies update to exactly the same state. Apply the induction hypothesis there; this handles reply-dependent future queries and stopping.

    \[R^{\mathrm{update}\circ T,O_f}_n(s)=R^{\mathrm{update},O_W}_n(s).\]
    Corresponding Lean step

    Natural induction generalizing s; cases on next s; rewrite actual gradient identity; congrArg on recursive pair.

    3. Preserve and bound the interaction counter

    In the only querying branch both interpreters make one interaction and add one to the equal recursive counters. The inductive bound c≤n gives c+1≤n+1. Halt/exhaustion branches have zero cost. No externally supplied cost label or objective minimizer enters the execution.

    \[c_{\rm base}=c_{\rm target}\le n.\]
    Corresponding Lean step

    Nat.succ_le_succ; run query branch.

    Lean verification

    The exact proof begins folded immediately after the mathematical argument; the statement is folded beside the claim above.

    Lean proof · simulate_regularized

    The compiled first-order regularization theorem computes the genuine gradient of W. Its value is W by definition. Therefore adding the known quadratic value and gradient correction to one O_f reply produces exactly O_W(x). Convexity and gradient Lipschitzness are inherited source-class premises of the reused parent; no Hessian or second derivative is needed. Induct on query allowance, for every state. Both runs inspect the same next(s). A halt or zero-fuel exhaustion returns the same result without querying. In the positive-fuel query branch, corrected and true replies update to exactly the same state. Apply the induction hypothesis there; this handles reply-dependent future queries and stopping. In the only querying branch both interpreters make one interaction and add one to the equal recursive counters. The inductive bound c≤n gives c+1≤n+1. Halt/exhaustion branches have zero cost. No externally supplied cost label or objective minimizer enters the execution.

    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.

    Download module (.lean)
    theorem simulate_regularized
        {E S X : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [CompleteSpace E]
        (next : S → Sum X E) (update : S → E → (ℝ × E) → S)
        {f : E → ℝ} (hd : Differentiable ℝ f) (hc : ConvexOn ℝ univ f)
        {β δ : ℝ≥0} (hL : LipschitzWith β (gradient f)) (u : E) (fuel : ℕ) (s : S) :
        let W := fun x => f x + (δ : ℝ)/2*‖x-u‖^2
        let corrected := fun s x (a : ℝ × E) =>
          update s x (a.1 + (δ : ℝ)/2*‖x-u‖^2, a.2 + (δ : ℝ) • (x-u))
        let base := run next corrected (fun x => (f x, gradient f x)) fuel s
        let target := run next update (fun x => (W x, gradient W x)) fuel s
        base = target ∧ base.2 ≤ fuel := by
      dsimp only
      have hg := (QuadraticRegularizationFirstOrder.curvature_gradient_and_smoothness
        hd hc hL (δ := δ) u).2.2.1
      induction fuel generalizing s with
      | zero => cases h : next s <;> simp [run, h]
      | succ n ih =>
        cases h : next s with
        | inl x => simp [run, h]
        | inr x =>
          have step (upd : S → E → (ℝ × E) → S) (O : E → ℝ × E) :
              run next upd O (n+1) s =
                let tail := run next upd O n (upd s x (O x))
                (tail.1, tail.2+1) := by rw [run, h]
          simp only [step, hg]
          obtain ⟨he, hn⟩ := ih (update s x
            (f x + (δ : ℝ)/2*‖x-u‖^2, gradient f x + (δ : ℝ) • (x-u)))
          refine ⟨?_, Nat.succ_le_succ hn⟩
          simpa only [hg] using congrArg (fun r => (r.1, r.2+1)) he
    end AutoSamplingTheory.TechnicalLemmas.Analysis.QuadraticRegularizationOracle

    Exact module and namespace context

    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.
    Sources, dependencies, and reuse

    Source and reuse

    Samplinglib parents called

    Mathlib API called (external library)

    • Nat.succ_le_succ
    • congrArg

    Mathematical sources

    Samplinglib prose is not a quotation or a source-equivalence certificate. Definitions and aliases are explained as constructions, not counted as new mathematical proofs.