Documentation

LeanCert.Validity.Bounds

Certificate-Driven Verification (umbrella) #

The bound checkers and Golden Theorems formerly defined in this file live in the LeanCert.Validity.Bounds.* modules:

This file re-exports all of them (via the imports above) and additionally defines the global-optimization and root-finding certificate layers.

Certificate-driven verification: an external agent (e.g. Python) proposes a Certificate (expression, domain, claim, proof parameters such as Taylor depth); Lean re-checks the boolean certificate — typically via native_decide — and a Golden Theorem lifts the boolean result to a semantic proof. The golden theorems themselves are axiom-free (see Tests/AxiomAudit.lean).

Usage #

example : ∀ x ∈ I01, Expr.eval (fun _ => x) exprExp ≤ 3 :=
  verify_upper_bound exprExp exprExp_core I01 3 { taylorDepth := 15 } (by native_decide)

Global Optimization Certificates #

These checkers and theorems extend the certificate pattern to multivariate global optimization over n-dimensional boxes.

Boolean Checkers for Global Optimization #

Check if c is a lower bound for e over box B. Returns true iff globalMinimizeCore(e, B, cfg).bound.lo ≥ c.

Equations
  • One or more equations did not get rendered due to their size.
Instances For

    Check if c is an upper bound for e over box B. Returns true iff globalMaximizeCore(e, B, cfg).bound.hi ≤ c. (i.e., the upper bound on max(e) is ≤ c, which proves ∀ρ, e(ρ) ≤ c)

    Note: bound.hi = -globalMinimizeCore(-e).bound.lo, and by correctness globalMinimizeCore(-e).bound.lo ≤ -e(ρ) for all ρ, so e(ρ) ≤ bound.hi.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      Golden Theorems for Global Optimization #

      Golden Theorem for Global Lower Bounds

      If checkGlobalLowerBound e B c cfg = true, then ∀ ρ ∈ B, c ≤ Expr.eval ρ e.

      This converts the boolean certificate into a semantic proof about all points in the box.

      Note: This uses ADSupported (no log) which guarantees domain validity automatically. For expressions with log, use the Core version with explicit domain validity proofs.

      Golden Theorem for Global Upper Bounds

      If checkGlobalUpperBound e B c cfg = true, then ∀ ρ ∈ B, Expr.eval ρ e ≤ c.

      The maximization problem is reduced to minimization of -e.

      Note: This uses ADSupported (no log) which guarantees domain validity automatically. For expressions with log, use the Core version with explicit domain validity proofs.

      theorem LeanCert.Validity.GlobalOpt.verify_global_bounds (e : Core.Expr) (hsupp : Core.ADSupported e) (B : Engine.Optimization.Box) (lo hi : ℚ) (cfg : Engine.Optimization.GlobalOptConfig) (h_cert : checkGlobalBounds e B lo hi cfg = true) (ρ : ℕ → ℝ) :
      Engine.Optimization.Box.envMem ρ B → (∀ i ≥ List.length B, ρ i = 0) → ↑lo ≤ Core.Expr.eval ρ e ∧ Core.Expr.eval ρ e ≤ ↑hi

      Two-sided global bound verification

      Root Finding Certificates #

      These checkers and theorems provide certificate-driven verification for root existence and uniqueness.

      Configuration for root finding certificates #

      Configuration for root-finding checks

      • maxDepth : ℕ

        Maximum bisection depth

      • taylorDepth : ℕ

        Taylor depth for interval evaluation

      Instances For
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          Configuration for Newton uniqueness checks

          • iterations : ℕ

            Number of Newton iterations

          • tmDegree : ℕ

            Taylor model degree

          Instances For
            Equations
            • One or more equations did not get rendered due to their size.
            Instances For

              Boolean Checkers for Root Finding #

              Check if expression has a sign change on interval (indicating a root). Uses interval arithmetic to check if f(lo) and f(hi) have opposite signs.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

                Check if interval definitely has no root (function has constant sign). Returns true if the function's interval evaluation doesn't contain 0.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For

                  Computable Newton Step for Unique Root Verification #

                  Computable Newton step using LeanCert.Internal.Rational.evalTotalCore1 and derivIntervalCore.

                  This is the computable equivalent of newtonStepSimple. It performs one interval Newton iteration: N(I) = c - f(c)/f'(I) where c = midpoint(I).

                  Returns none if the derivative interval contains 0 (can't safely divide). Returns some (I ∩ N) otherwise.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    theorem LeanCert.Validity.RootFinding.newtonStepCore_extract (e : Core.Expr) (I N : Core.IntervalRat) (cfg : Engine.EvalConfig) (hCore : newtonStepCore e I cfg = some N) :
                    have c := I.midpoint; have fc := Internal.Rational.evalTotalCore1 e (Core.IntervalRat.singleton c) cfg; have dI := Engine.derivIntervalCore e I cfg; ∃ (hdI_nonzero : ¬dI.containsZero), have dNonzero := { toIntervalRat := dI, nonzero := hdI_nonzero }; have Q := fc.mul (Core.IntervalRat.invNonzero dNonzero); N.lo = max I.lo (c - Q.hi) ∧ N.hi = min I.hi (c - Q.lo)

                    Extract structure from newtonStepCore.

                    Computable check if Newton iteration contracts. Returns true if newtonStepCore produces N with I.lo < N.lo and N.hi < I.hi.

                    This can be used with native_decide for unique root verification.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For

                      Check if Newton iteration contracts, indicating unique root existence. Returns true if the Newton step from I gives N ⊂ interior(I).

                      Note: This is noncomputable because newtonStepSimple uses derivInterval which uses evalInterval (noncomputable). For native_decide, we would need a fully computable version using LeanCert.Internal.Rational.evalTotalCore.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For

                        Golden Theorems for Root Finding #

                        theorem LeanCert.Validity.RootFinding.verify_no_root (e : Core.Expr) (hsupp : Core.ExprSupportedCore e) (I : Core.IntervalRat) (cfg : Engine.EvalConfig) (h_cert : checkNoRoot e I cfg = true) (x : ℝ) :
                        x ∈ I → Core.Expr.eval (fun (x_1 : ℕ) => x) e ≠ 0

                        Golden Theorem for No Root

                        If checkNoRoot e I cfg = true, then ∀ x ∈ I, Expr.eval (fun _ => x) e ≠ 0.

                        theorem LeanCert.Validity.RootFinding.verify_unique_root_newton (e : Core.Expr) (hsupp : Core.ADSupported e) (hvar0 : Engine.UsesOnlyVar0 e) (I : Core.IntervalRat) (cfg : NewtonConfig) (hCont : ContinuousOn (fun (x : ℝ) => Core.Expr.eval (fun (x_1 : ℕ) => x) e) (Set.Icc ↑I.lo ↑I.hi)) (h_cert : checkNewtonContracts e I cfg = true) :
                        ∃! x : ℝ, x ∈ I ∧ Core.Expr.eval (fun (x_1 : ℕ) => x) e = 0

                        Golden Theorem for Newton Contraction (Unique Root Existence)

                        If checkNewtonContracts e I cfg = true, then there exists a unique root in I.

                        This theorem requires additional hypotheses that the external checker must verify:

                        • The expression is supported
                        • The expression uses only variable 0
                        • The function is continuous on I

                        Core MVT Lemmas for Newton Contraction Contradiction #

                        These lemmas prove that if Newton contraction holds but f has constant sign at both endpoints, we get a contradiction via MVT bounds.

                        Key insight: If f doesn't change sign on I (both endpoints positive or both negative), then by monotonicity (from nonzero derivative), f has constant sign throughout I. But Newton contraction requires specific quotient bounds that MVT proves are violated.

                        MVT lower bound using derivIntervalCore: if f'(ξ) ∈ [dI.lo, dI.hi] for all ξ ∈ I, then f(y) - f(x) ≥ dI.lo * (y - x) for x ≤ y in I.

                        MVT upper bound using derivIntervalCore: if f'(ξ) ∈ [dI.lo, dI.hi] for all ξ ∈ I, then f(y) - f(x) ≤ dI.hi * (y - x) for x ≤ y in I.

                        theorem LeanCert.Validity.RootFinding.verify_unique_root_core (e : Core.Expr) (hsupp : Core.ADSupported e) (hvar0 : Engine.UsesOnlyVar0 e) (I : Core.IntervalRat) (evalCfg : Engine.EvalConfig) (newtonCfg : NewtonConfig) (hCont : ContinuousOn (fun (x : ℝ) => Core.Expr.eval (fun (x_1 : ℕ) => x) e) (Set.Icc ↑I.lo ↑I.hi)) (_h_cert_core : checkNewtonContractsCore e I evalCfg = true) (h_cert_newton : checkNewtonContracts e I newtonCfg = true) :
                        ∃! x : ℝ, x ∈ I ∧ Core.Expr.eval (fun (x_1 : ℕ) => x) e = 0

                        Golden Theorem for Computable Newton Contraction (Unique Root Existence)

                        This version assumes both:

                        1. Core contraction check (computable, used by search/external tools)
                        2. Non-core contraction check (used for the formal proof, via verify_unique_root_newton).

                        The formal proof only relies on the non-core checker; the core checker can be used by the external agent for optimization but is not needed logically. This avoids the need to prove complex MVT-based contradiction lemmas for the Core interval functions.

                        Note: The h_cert_core hypothesis is not used in the proof but is kept in the signature so the certificate format can include it for external tooling purposes.

                        Fully Computable Unique Root Verification #

                        The following theorems provide a fully computable path to proving unique root existence using only checkNewtonContractsCore. This allows native_decide to work without requiring noncomputable functions like Real.exp or Real.log.

                        theorem LeanCert.Validity.RootFinding.newton_preserves_root_core (e : Core.Expr) (hsupp : Core.ADSupported e) (hvar0 : Engine.UsesOnlyVar0 e) (I N : Core.IntervalRat) (cfg : Engine.EvalConfig) (hStep : newtonStepCore e I cfg = some N) (x : ℝ) (hx : x ∈ I) (hroot : Core.Expr.eval (fun (x_1 : ℕ) => x) e = 0) :
                        x ∈ N

                        Newton step preserves roots when using Core evaluation functions. If x is a root in I and newtonStepCore produces N, then x ∈ N.

                        theorem LeanCert.Validity.RootFinding.newton_step_core_at_most_one_root (e : Core.Expr) (hsupp : Core.ADSupported e) (_hvar0 : Engine.UsesOnlyVar0 e) (I : Core.IntervalRat) (cfg : Engine.EvalConfig) (hStep : ∃ (N : Core.IntervalRat), newtonStepCore e I cfg = some N) (hCont : ContinuousOn (fun (x : ℝ) => Core.Expr.eval (fun (x_1 : ℕ) => x) e) (Set.Icc ↑I.lo ↑I.hi)) (x y : ℝ) (hx : x ∈ I) (hy : y ∈ I) (hx_root : Core.Expr.eval (fun (x_1 : ℕ) => x) e = 0) (hy_root : Core.Expr.eval (fun (x : ℕ) => y) e = 0) :
                        x = y

                        If Newton step succeeds, there's at most one root in I (via Rolle's theorem). This uses the fact that if dI doesn't contain zero, the derivative is nonzero everywhere on I, so f is strictly monotonic.

                        theorem LeanCert.Validity.RootFinding.mvt_fc_lower_bound_pos_increasing_core (e : Core.Expr) (hsupp : Core.ADSupported e) (I : Core.IntervalRat) (cfg : Engine.EvalConfig) (_hI_nonsingleton : I.lo < I.hi) (_hdI_lo_pos : 0 < (Engine.derivIntervalCore e I cfg).lo) (hCont : ContinuousOn (Engine.evalFunc1 e) (Set.Icc ↑I.lo ↑I.hi)) (hf_Ilo_pos : 0 < Engine.evalFunc1 e ↑I.lo) :
                        have c := I.midpoint; have hw := (I.hi - I.lo) / 2; have dI := Engine.derivIntervalCore e I cfg; Engine.evalFunc1 e ↑c > ↑dI.lo * ↑hw

                        MVT bound using Core functions: If f' ≥ dI.lo > 0 (increasing) and f(I.lo) > 0, then f(c) > dI.lo * hw where c = midpoint and hw = half-width.

                        theorem LeanCert.Validity.RootFinding.mvt_fc_upper_bound_pos_increasing_core (e : Core.Expr) (hsupp : Core.ADSupported e) (I : Core.IntervalRat) (cfg : Engine.EvalConfig) (_hI_nonsingleton : I.lo < I.hi) (_hdI_lo_pos : 0 < (Engine.derivIntervalCore e I cfg).lo) (hCont : ContinuousOn (Engine.evalFunc1 e) (Set.Icc ↑I.lo ↑I.hi)) (hf_Ihi_neg : Engine.evalFunc1 e ↑I.hi < 0) :
                        have c := I.midpoint; have hw := (I.hi - I.lo) / 2; have dI := Engine.derivIntervalCore e I cfg; Engine.evalFunc1 e ↑c < -(↑dI.lo * ↑hw)

                        MVT bound using Core functions: If f' ≥ dI.lo > 0 (increasing) and f(I.hi) < 0, then f(c) < -dI.lo * hw where c = midpoint and hw = half-width.

                        theorem LeanCert.Validity.RootFinding.mvt_fc_upper_bound_neg_decreasing_core (e : Core.Expr) (hsupp : Core.ADSupported e) (I : Core.IntervalRat) (cfg : Engine.EvalConfig) (_hI_nonsingleton : I.lo < I.hi) (_hdI_hi_neg : (Engine.derivIntervalCore e I cfg).hi < 0) (hCont : ContinuousOn (Engine.evalFunc1 e) (Set.Icc ↑I.lo ↑I.hi)) (hf_Ilo_neg : Engine.evalFunc1 e ↑I.lo < 0) :
                        have c := I.midpoint; have hw := (I.hi - I.lo) / 2; have dI := Engine.derivIntervalCore e I cfg; Engine.evalFunc1 e ↑c < ↑dI.hi * ↑hw

                        MVT bound using Core functions: If f' ≤ dI.hi < 0 (decreasing) and f(I.lo) < 0, then f(c) < 0 and more specifically, fc.lo / dI.hi ≥ hw.

                        theorem LeanCert.Validity.RootFinding.mvt_fc_lower_bound_neg_decreasing_core (e : Core.Expr) (hsupp : Core.ADSupported e) (I : Core.IntervalRat) (cfg : Engine.EvalConfig) (_hI_nonsingleton : I.lo < I.hi) (_hdI_hi_neg : (Engine.derivIntervalCore e I cfg).hi < 0) (hCont : ContinuousOn (Engine.evalFunc1 e) (Set.Icc ↑I.lo ↑I.hi)) (hf_Ihi_pos : 0 < Engine.evalFunc1 e ↑I.hi) :
                        have c := I.midpoint; have hw := (I.hi - I.lo) / 2; have dI := Engine.derivIntervalCore e I cfg; Engine.evalFunc1 e ↑c > -(↑dI.hi * ↑hw)

                        MVT bound using Core functions: If f' ≤ dI.hi < 0 (decreasing) and f(I.hi) > 0, then f(c) > 0 and more specifically, fc.hi / dI.hi ≤ -hw.

                        theorem LeanCert.Validity.RootFinding.verify_unique_root_computable (e : Core.Expr) (hsupp : Core.ADSupported e) (hvar0 : Engine.UsesOnlyVar0 e) (I : Core.IntervalRat) (cfg : Engine.EvalConfig) (hCont : ContinuousOn (fun (x : ℝ) => Core.Expr.eval (fun (x_1 : ℕ) => x) e) (Set.Icc ↑I.lo ↑I.hi)) (h_cert : checkNewtonContractsCore e I cfg = true) :
                        ∃! x : ℝ, x ∈ I ∧ Core.Expr.eval (fun (x_1 : ℕ) => x) e = 0

                        Golden Theorem for Computable Unique Root (Fully Computable)

                        If checkNewtonContractsCore e I cfg = true, then there exists a unique root in I.

                        This theorem uses ONLY computable functions (no Real.exp, Real.log, etc.), making it suitable for native_decide verification.

                        Sign Change Root Existence #

                        theorem LeanCert.Validity.RootFinding.verify_sign_change (e : Core.Expr) (hsupp : Core.ExprSupportedCore e) (I : Core.IntervalRat) (cfg : Engine.EvalConfig) (hCont : ContinuousOn (fun (x : ℝ) => Core.Expr.eval (fun (x_1 : ℕ) => x) e) (Set.Icc ↑I.lo ↑I.hi)) (h_cert : checkSignChange e I cfg = true) :
                        ∃ x ∈ I, Core.Expr.eval (fun (x_1 : ℕ) => x) e = 0

                        Golden Theorem for Sign Change Root Existence

                        If checkSignChange e I cfg = true, then there exists a root in I.

                        This uses the Intermediate Value Theorem: if f(lo) and f(hi) have opposite signs, and f is continuous on I, then f has a root in I.

                        Bisection-Based Root Existence #

                        Check if bisection finds a root (returns hasRoot for some sub-interval). This runs the bisection algorithm and checks if any interval has hasRoot status.

                        Note: This is noncomputable because bisectRoot uses LeanCert.Internal.Rational.evalUnchecked1.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          theorem LeanCert.Validity.RootFinding.verify_has_root (e : Core.Expr) (hsupp : Core.ADSupported e) (I : Core.IntervalRat) (cfg : RootConfig) (hCont : ContinuousOn (fun (x : ℝ) => Core.Expr.eval (fun (x_1 : ℕ) => x) e) (Set.Icc ↑I.lo ↑I.hi)) (h_cert : checkHasRoot e I cfg = true) :
                          ∃ x ∈ I, Core.Expr.eval (fun (x_1 : ℕ) => x) e = 0

                          Golden Theorem for Bisection Root Existence

                          If checkHasRoot e I cfg = true, then there exists a root in I.

                          This uses bisectRoot_hasRoot_correct which proves that if bisection returns hasRoot for a sub-interval J ⊆ I, then there exists a root in J (hence in I).