Global Optimization via Branch-and-Bound #
This file implements a branch-and-bound algorithm for rigorous global optimization of expressions over n-dimensional boxes.
Main definitions #
GlobalBound- Result of global optimization (lower bound and optional upper bound)globalMinimize- Branch-and-bound minimization over a boxglobalMaximize- Branch-and-bound maximization over a box
Algorithm #
The branch-and-bound algorithm works by:
- Evaluating the expression over the current box using interval arithmetic
- Using the interval lower bound to prune boxes that can't contain the minimum
- Splitting the widest dimension when bounds aren't tight enough
- Optionally pruning using monotonicity (gradient sign information)
Correctness #
The algorithm maintains the invariant that the returned lower bound is ≤ f(x) for all x in the original box. When the interval upper bound equals the lower bound (or is close enough), we have found the global minimum.
Configuration #
Equations
- One or more equations did not get rendered due to their size.
Instances For
Result types #
Equations
- One or more equations did not get rendered due to their size.
Instances For
Result of optimization with certificate data
- bound : GlobalBound
The computed bound
Priority queue of remaining boxes (for resumption)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Priority queue operations #
Core algorithm #
Evaluate expression on a box and get interval bounds
Equations
Instances For
One step of branch-and-bound for minimization with explicit bestLB tracking.
When cfg.useMonotonicity is true, applies gradient-based pruning before evaluation.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Run branch-and-bound for a fixed number of iterations with explicit bestLB tracking
Equations
- One or more equations did not get rendered due to their size.
Instances For
Global minimization over a box
Equations
- One or more equations did not get rendered due to their size.
Instances For
Global maximization over a box (minimize -e)
Equations
- One or more equations did not get rendered due to their size.
Instances For
Computable versions for execution #
Evaluate expression on a box (computable version for ExprSupportedCore)
Equations
- LeanCert.Engine.Optimization.evalOnBoxCore e B cfg = LeanCert.Engine.evalIntervalCore e B.toEnv { taylorDepth := cfg.taylorDepth }
Instances For
Evaluate expression on a box (computable version with division support). This is used by the Python bridge for applications where division is common. Note: No formal correctness proof yet; returns sound but possibly wide bounds.
Equations
- LeanCert.Engine.Optimization.evalOnBoxCoreDiv e B cfg = LeanCert.Engine.evalIntervalCoreWithDiv e B.toEnv { taylorDepth := cfg.taylorDepth }
Instances For
One step of branch-and-bound (computable version) with explicit bestLB tracking.
When cfg.useMonotonicity is true, applies gradient-based pruning before evaluation.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Run branch-and-bound (computable version) with explicit bestLB tracking
Equations
- One or more equations did not get rendered due to their size.
Instances For
Global minimization (computable version)
Equations
- One or more equations did not get rendered due to their size.
Instances For
Global maximization (computable version)
Equations
- One or more equations did not get rendered due to their size.
Instances For
Division-supporting versions for Python bridge #
These variants use evalIntervalCoreWithDiv which handles division (inv) properly. They have the same structure as the standard versions but support expressions with division.
One step of branch-and-bound with division support
Equations
- One or more equations did not get rendered due to their size.
Instances For
Run branch-and-bound loop with division support
Equations
- One or more equations did not get rendered due to their size.
Instances For
Global minimization with division support
Equations
- One or more equations did not get rendered due to their size.
Instances For
Global maximization with division support
Equations
- One or more equations did not get rendered due to their size.
Instances For
Correctness theorems #
The lower bound from interval evaluation is correct.
The upper bound from interval evaluation is correct (∃ point achieving it).
Helper: construct a midpoint environment for a box
Equations
- B.midpointEnv i = if h : i < List.length B then ↑B[i].midpoint else 0
Instances For
The midpoint environment is in the box
The midpoint environment is zero outside the box
Helper lemma: split preserves box length
Helper lemma: splitWidest preserves box length
New simplified correctness architecture with explicit bestLB tracking #
The key idea: track both bestLB (global lower bound) and bestUB (global upper bound) explicitly. This makes the invariants much simpler:
- (Global LB) For all ρ in the original box, bestLB ≤ f(ρ)
- (Global UB witness) There exists ρ* in bestBox such that f(ρ*) ≤ bestUB
- (Queue boxes are sub-boxes) Every B' in queue is a sub-box of the original box
Helper: bestUB only decreases during minimizeStep
Helper: bestLB only decreases during minimizeStep
Helper: new queue entries either come from original tail or have lb ≤ newBestUB
Helper: bestBox' is either bestBox or a subset of hd.2 (the pruned box B_curr). When monotonicity pruning is enabled, bestBox' may be the pruned version of hd.2.
Helper: queue entries in result are either from tl or splits of B_curr (the possibly pruned hd.2)
Helper: bestUB' is achievable if bestUB is achievable
Helper: if ρ is in a split of B, then ρ is in B
Helper: splits preserve length
Key correctness theorem: minimizeStep preserves lower bound invariant #
Pruning returns a sub-box: any point in the pruned box is also in the original.
This is a direct consequence of pruneBoxForMin_subset from Gradient.lean.
minimizeStep preserves the lower bound invariant. If bestLB ≤ f(ρ) for all ρ in origB before the step, then bestLB' ≤ f(ρ) for all ρ after.
The main loop correctness theorem with explicit bestLB tracking
The key correctness theorem: globalMinimize returns a lower bound that is ≤ the minimum of f over any point in the original box.
There exists a point achieving (approximately) the upper bound.
Correctness theorems for Core (computable) versions #
The lower bound from core interval evaluation is correct.
The upper bound from core interval evaluation is correct.
minimizeStepCore preserves the lower bound invariant.
This version uses ExprSupportedCore with an explicit domain validity hypothesis for all boxes of the same length as origB. This is necessary because the branch-and-bound algorithm operates on sub-boxes that maintain the same length.
The main loop correctness theorem for Core version
The key correctness theorem for Core version: globalMinimizeCore returns a lower bound that is ≤ the minimum of f over any point in the original box.
This theorem requires a domain validity hypothesis for ExprSupportedCore expressions. For ExprSupported expressions, use globalMinimizeCore_lo_correct_supported which derives domain validity automatically.
There exists a point achieving (approximately) the upper bound for Core version.
The lower bound is ≤ the upper bound. This follows from the existence of a witness: there's some ρ with f(ρ) ≤ hi, and lo ≤ f(ρ) for all ρ in B, so lo ≤ f(witness) ≤ hi.
Maximization correctness theorems #
The upper bound from globalMaximizeCore is correct: f(ρ) ≤ hi for all ρ in B.
There exists a point achieving approximately the lower bound for maximization.
The lower bound is ≤ the upper bound for maximization.
Dyadic backend versions for high-performance optimization #
These variants use Dyadic arithmetic (n * 2^e) instead of rationals, preventing denominator explosion for deep expressions. 10-100x faster for complex expressions like neural networks.
Configuration for Dyadic global optimization
- maxIterations : ℕ
Maximum number of subdivisions
- tolerance : ℚ
Stop when box width is below this threshold
- useMonotonicity : Bool
Use monotonicity pruning (requires gradient computation)
- taylorDepth : ℕ
Taylor depth for interval evaluation
- precision : ℤ
Dyadic precision (minimum exponent for outward rounding)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Evaluate expression on a box using Dyadic arithmetic
Equations
- One or more equations did not get rendered due to their size.
Instances For
One step of branch-and-bound using Dyadic arithmetic
Equations
- One or more equations did not get rendered due to their size.
Instances For
Run branch-and-bound loop using Dyadic arithmetic
Equations
- One or more equations did not get rendered due to their size.
Instances For
Helper: bestLB only decreases during minimizeStepDyadic.
Helper: minimizeLoopDyadic preserves the initial lower bound.
Global minimization using Dyadic arithmetic
Equations
- One or more equations did not get rendered due to their size.
Instances For
Global maximization using Dyadic arithmetic
Equations
- One or more equations did not get rendered due to their size.
Instances For
Affine backend versions for tight bounds #
These variants use Affine Arithmetic to track correlations between variables, solving the "dependency problem" in interval arithmetic. For example:
- Interval: x - x on [-1, 1] gives [-2, 2]
- Affine: x - x on [-1, 1] gives [0, 0] (exact!)
Configuration for Affine global optimization
- maxIterations : ℕ
Maximum number of subdivisions
- tolerance : ℚ
Stop when box width is below this threshold
- useMonotonicity : Bool
Use monotonicity pruning (requires gradient computation)
- taylorDepth : ℕ
Taylor depth for interval evaluation
- maxNoiseSymbols : ℕ
Max noise symbols before consolidation (0 = no limit)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Evaluate expression on a box using Affine arithmetic
Equations
- One or more equations did not get rendered due to their size.
Instances For
One step of branch-and-bound using Affine arithmetic
Equations
- One or more equations did not get rendered due to their size.
Instances For
Run branch-and-bound loop using Affine arithmetic
Equations
- One or more equations did not get rendered due to their size.
Instances For
Helper: bestLB only decreases during minimizeStepAffine.
Helper: minimizeLoopAffine preserves the initial lower bound.
Global minimization using Affine arithmetic
Equations
- One or more equations did not get rendered due to their size.
Instances For
Global maximization using Affine arithmetic
Equations
- One or more equations did not get rendered due to their size.
Instances For
Correctness theorems for Dyadic optimization #
The lower bound from Dyadic interval evaluation is correct.
The proof uses evalIntervalDyadic_correct and IntervalDyadic.toIntervalRat_correct
to show that the true value is contained in the resulting rational interval.
Note: Requires domain validity for expressions with log.
The key correctness theorem for Dyadic minimization: globalMinimizeDyadic returns a lower bound that is ≤ the minimum of f over any point in the original box.
Note: Requires domain validity for expressions with log.
The upper bound from globalMaximizeDyadic is correct: f(ρ) ≤ hi for all ρ in B.
Note: Requires domain validity for expressions with log.
Correctness theorems for Affine optimization #
The lower bound from Affine interval evaluation is correct. Note: Requires ExprSupportedCore, valid noise assignment, and domain validity for log.
The key correctness theorem for Affine minimization.
Note: Requires domain validity for expressions with log.
The upper bound from globalMaximizeAffine is correct.
Note: Requires domain validity for expressions with log.