Documentation

LeanCert.Engine.Optimization.BoundVerify

Adaptive Bound Verification via Branch-and-Bound #

This file provides adaptive bound verification functions that use the branch-and-bound global optimization algorithm to verify bounds on expressions. Unlike single-shot interval evaluation, these functions automatically subdivide the domain until the bound can be verified or the iteration limit is reached.

Main definitions #

Main theorems #

Usage #

These functions are intended to be used as fallbacks when single-shot interval evaluation fails due to over-approximation. They provide better precision at the cost of increased computation.

-- Single-shot fails on tight bounds, but adaptive succeeds
example : verifyUpperBound1 (Expr.sin (Expr.var 0)) ⟨0, 11/10, by norm_num⟩ (85/100) = true := by
  native_decide

Configuration for bound verification #

Configuration for adaptive bound verification

  • maxIterations :

    Maximum number of subdivisions

  • tolerance :

    Stop when box width is below this threshold

  • taylorDepth :

    Taylor depth for interval evaluation

  • useMonotonicity : Bool

    Use monotonicity-based pruning (symbolic pre-pass for gradient signs)

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

        Convert BoundVerifyConfig to GlobalOptConfig

        Equations
        Instances For

          Witness/Epsilon-argmax structures #

          A witness point for an optimization result

          • coords : List

            The coordinates of the witness point

          • The function value at this point (interval containing true value)

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

              Result of bound verification with witness information

              • verified : Bool

                Whether the bound was verified

              • computedBound :

                The computed bound (lo for min, hi for max)

              • witness : WitnessPoint

                Approximate argmin/argmax (midpoint of best box)

              • epsilon :

                Width of the best box (epsilon for ε-approximate argmin/argmax)

              • iterations :

                Number of iterations used

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

                  Extract witness point from a box (midpoint of each interval)

                  Equations
                  Instances For

                    Compute maximum width of a box (the ε in ε-approximate)

                    Equations
                    Instances For

                      Evaluate expression at a rational point (using singleton intervals)

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

                        Computable bound verification functions #

                        Verify f(x) ≤ bound for all x in box using adaptive subdivision. Returns true if the maximum of f over the box is ≤ bound.

                        Equations
                        Instances For

                          Verify f(x) ≥ bound for all x in box using adaptive subdivision. Returns true if the minimum of f over the box is ≥ bound.

                          Equations
                          Instances For

                            Verify f(x) < bound for all x in box using adaptive subdivision. Returns true if the maximum of f over the box is < bound.

                            Equations
                            Instances For

                              Verify f(x) > bound for all x in box using adaptive subdivision. Returns true if the minimum of f over the box is > bound.

                              Equations
                              Instances For

                                Epsilon-argmax/argmin functions with witness information #

                                Find the maximum of f over a box, returning result with witness information. The witness is an ε-approximate argmax: a point where f(witness) is within ε of the true maximum, where ε = bestBox.maxWidth.

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

                                  Find the minimum of f over a box, returning result with witness information. The witness is an ε-approximate argmin: a point where f(witness) is within ε of the true minimum, where ε = bestBox.maxWidth.

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

                                    Verify f(x) ≤ bound with witness information. Returns the verification result along with an ε-approximate argmax.

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

                                      Verify f(x) ≥ bound with witness information. Returns the verification result along with an ε-approximate argmin.

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

                                        Single-variable convenience functions #

                                        Convert a single interval to a 1D box

                                        Equations
                                        Instances For

                                          Correctness theorems (noncomputable proofs) #

                                          Helper: convert single-variable environment to box membership

                                          theorem LeanCert.Engine.Optimization.intervalToBox_zero (I : Core.IntervalRat) (x : ) (i : ) :
                                          i List.length (intervalToBox I)(fun (x_1 : ) => x) i = x

                                          Helper: if i ≥ 1, then (fun _ => x) i = 0 is vacuously satisfiable for our purposes

                                          theorem LeanCert.Engine.Optimization.verifyUpperBound_correct (e : Core.Expr) (hsupp : ExprSupported e) (B : Box) (bound : ) (cfg : BoundVerifyConfig) (hverify : (globalMaximize e B cfg.toGlobalOptConfig).bound.hi bound) (ρ : ) :
                                          Box.envMem ρ B(∀ iList.length B, ρ i = 0)Core.Expr.eval ρ e bound

                                          If verifyUpperBound succeeds, the upper bound holds for all points in the box. Note: This uses the noncomputable globalMaximize for the proof, but the computable globalMaximizeCore is used for execution.

                                          theorem LeanCert.Engine.Optimization.verifyLowerBound_correct (e : Core.Expr) (hsupp : ExprSupported e) (B : Box) (bound : ) (cfg : BoundVerifyConfig) (hverify : (globalMinimize e B cfg.toGlobalOptConfig).bound.lo bound) (ρ : ) :
                                          Box.envMem ρ B(∀ iList.length B, ρ i = 0)bound Core.Expr.eval ρ e

                                          If verifyLowerBound succeeds, the lower bound holds for all points in the box.

                                          Expression uses only var 0 #

                                          Predicate: expression only uses variable index 0

                                          Equations
                                          Instances For
                                            theorem LeanCert.Engine.Optimization.Expr.eval_usesOnlyVar0 (e : Core.Expr) (he : e.usesOnlyVar0 = true) (ρ ρ' : ) (h0 : ρ 0 = ρ' 0) :

                                            If an expression uses only var 0, evaluation depends only on ρ 0

                                            Tactic-facing lemmas for adaptive bound verification #

                                            theorem LeanCert.Engine.Optimization.adaptive_upper_bound (e : Core.Expr) (hsupp : ExprSupported e) (he : e.usesOnlyVar0 = true) (I : Core.IntervalRat) (c : ) (cfg : BoundVerifyConfig) (hverify : (globalMaximize e [I] cfg.toGlobalOptConfig).bound.hi c) (x : ) :
                                            x ICore.Expr.eval (fun (x_1 : ) => x) e c

                                            Tactic-facing lemma: if adaptive verification succeeds, upper bound holds. This is the key lemma that tactics use to close goals. Requires that the expression uses only var 0.

                                            theorem LeanCert.Engine.Optimization.adaptive_lower_bound (e : Core.Expr) (hsupp : ExprSupported e) (he : e.usesOnlyVar0 = true) (I : Core.IntervalRat) (c : ) (cfg : BoundVerifyConfig) (hverify : (globalMinimize e [I] cfg.toGlobalOptConfig).bound.lo c) (x : ) :
                                            x Ic Core.Expr.eval (fun (x_1 : ) => x) e

                                            Tactic-facing lemma: if adaptive verification succeeds, lower bound holds. Requires that the expression uses only var 0.

                                            theorem LeanCert.Engine.Optimization.adaptive_upper_bound_strict (e : Core.Expr) (hsupp : ExprSupported e) (he : e.usesOnlyVar0 = true) (I : Core.IntervalRat) (c : ) (cfg : BoundVerifyConfig) (hverify : (globalMaximize e [I] cfg.toGlobalOptConfig).bound.hi < c) (x : ) :
                                            x ICore.Expr.eval (fun (x_1 : ) => x) e < c

                                            Strict upper bound version

                                            theorem LeanCert.Engine.Optimization.adaptive_lower_bound_strict (e : Core.Expr) (hsupp : ExprSupported e) (he : e.usesOnlyVar0 = true) (I : Core.IntervalRat) (c : ) (cfg : BoundVerifyConfig) (hverify : (globalMinimize e [I] cfg.toGlobalOptConfig).bound.lo > c) (x : ) :
                                            x Ic < Core.Expr.eval (fun (x_1 : ) => x) e

                                            Strict lower bound version

                                            Theorem versions for Set.Icc (for tactic compatibility) #

                                            theorem LeanCert.Engine.Optimization.adaptive_upper_bound_Icc (e : Core.Expr) (hsupp : ExprSupported e) (he : e.usesOnlyVar0 = true) (lo hi : ) (hle : lo hi) (c : ) (cfg : BoundVerifyConfig) (hverify : (globalMaximize e [{ lo := lo, hi := hi, le := hle }] cfg.toGlobalOptConfig).bound.hi c) (x : ) :
                                            x Set.Icc lo hiCore.Expr.eval (fun (x_1 : ) => x) e c

                                            Adaptive upper bound for Set.Icc membership

                                            theorem LeanCert.Engine.Optimization.adaptive_lower_bound_Icc (e : Core.Expr) (hsupp : ExprSupported e) (he : e.usesOnlyVar0 = true) (lo hi : ) (hle : lo hi) (c : ) (cfg : BoundVerifyConfig) (hverify : (globalMinimize e [{ lo := lo, hi := hi, le := hle }] cfg.toGlobalOptConfig).bound.lo c) (x : ) :
                                            x Set.Icc lo hic Core.Expr.eval (fun (x_1 : ) => x) e

                                            Adaptive lower bound for Set.Icc membership

                                            theorem LeanCert.Engine.Optimization.adaptive_upper_bound_Icc_strict (e : Core.Expr) (hsupp : ExprSupported e) (he : e.usesOnlyVar0 = true) (lo hi : ) (hle : lo hi) (c : ) (cfg : BoundVerifyConfig) (hverify : (globalMaximize e [{ lo := lo, hi := hi, le := hle }] cfg.toGlobalOptConfig).bound.hi < c) (x : ) :
                                            x Set.Icc lo hiCore.Expr.eval (fun (x_1 : ) => x) e < c

                                            Strict upper bound for Set.Icc

                                            theorem LeanCert.Engine.Optimization.adaptive_lower_bound_Icc_strict (e : Core.Expr) (hsupp : ExprSupported e) (he : e.usesOnlyVar0 = true) (lo hi : ) (hle : lo hi) (c : ) (cfg : BoundVerifyConfig) (hverify : (globalMinimize e [{ lo := lo, hi := hi, le := hle }] cfg.toGlobalOptConfig).bound.lo > c) (x : ) :
                                            x Set.Icc lo hic < Core.Expr.eval (fun (x_1 : ) => x) e

                                            Strict lower bound for Set.Icc