Gradient Interval Computation for Optimization #
This file provides functions to compute interval bounds on the gradient ∇f(B) of an expression over a box B. This is used for monotonicity-based pruning in branch-and-bound global optimization.
Main definitions #
gradientInterval- Compute interval bounds on all partial derivatives over a boxgradientSignature- Determine the sign of each partial derivativecanPruneToLo/canPruneToHi- Check if a coordinate can be pruned by monotonicity
Design #
The gradient is computed by running forward-mode AD (from AD.lean) for each coordinate direction. The result is a list of intervals, one per variable.
Monotonicity pruning: If ∂f/∂xᵢ > 0 on the entire box B, then f is minimized when xᵢ = B[i].lo. We can shrink the box in that dimension to a point.
Gradient computation #
Compute the gradient interval: bounds on each partial derivative over a box. Returns a list of intervals, where the i-th interval contains ∂f/∂xᵢ for all x ∈ B.
Equations
- LeanCert.Engine.Optimization.gradientInterval e B = List.ofFn fun (i : Fin (List.length B)) => LeanCert.Engine.derivInterval e B.toEnv ↑i
Instances For
Compute gradient for n variables (explicit dimension)
Equations
- LeanCert.Engine.Optimization.gradientIntervalN e B n = List.map (fun (i : ℕ) => LeanCert.Engine.derivInterval e B.toEnv i) (List.range n)
Instances For
Computable versions #
Create dual environment for differentiating with respect to variable idx (computable).
Active variable gets der = 1, passive variables get der = 0.
Equations
- LeanCert.Engine.Optimization.mkDualEnvCore ρ idx i = if i = idx then LeanCert.Engine.DualInterval.varActive (ρ i) else LeanCert.Engine.DualInterval.varPassive (ρ i)
Instances For
Evaluate with derivative with respect to variable idx (computable version)
Equations
Instances For
Computable derivative interval for multi-variable expressions. Computes the interval containing ∂f/∂xᵢ over the box.
Equations
- LeanCert.Engine.Optimization.derivIntervalCoreN e ρ idx cfg = (LeanCert.Engine.Optimization.evalWithDerivCore e ρ idx cfg).der
Instances For
Computable version of gradient interval for Core expressions.
This can be used with native_decide for verified optimization.
Equations
- LeanCert.Engine.Optimization.gradientIntervalCore e B cfg = List.map (fun (i : ℕ) => LeanCert.Engine.Optimization.derivIntervalCoreN e B.toEnv i cfg) (List.range (List.length B))
Instances For
Sign classification #
Classification of an interval's sign
- positive : IntervalSign
- negative : IntervalSign
- nonpositive : IntervalSign
- nonnegative : IntervalSign
- indefinite : IntervalSign
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Classify the sign of an interval
Equations
- One or more equations did not get rendered due to their size.
Instances For
The gradient signature: sign of each partial derivative (noncomputable wrapper)
Equations
Instances For
Monotonicity predicates #
Check if interval is strictly positive
Equations
Instances For
Check if interval is strictly negative
Equations
Instances For
Check if interval is nonnegative
Equations
Instances For
Check if interval is nonpositive
Equations
Instances For
Pruning queries #
Can we prune coordinate i to its low endpoint for minimization? True if ∂f/∂xᵢ > 0 on B (f is increasing in xᵢ, so min is at lo).
Equations
Instances For
Can we prune coordinate i to its high endpoint for minimization? True if ∂f/∂xᵢ < 0 on B (f is decreasing in xᵢ, so min is at hi).
Equations
Instances For
Prune a box for minimization by fixing monotonic coordinates. Returns a (potentially smaller) box and a list of fixed coordinates.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Correctness theorems #
The computed gradient interval contains the true partial derivatives. This follows from evalDual_der_correct_idx in AD.lean.
If we prune a coordinate to lo because ∂f/∂xᵢ > 0, the minimum is preserved. Informal: if f is increasing in xᵢ on B, then min{f(x) : x ∈ B} = min{f(x) : xᵢ = B[i].lo}. NOTE: Requires ρ j = 0 for j ≥ B.length (standard assumption for box membership).
If we prune a coordinate to hi because ∂f/∂xᵢ < 0, the minimum is preserved. NOTE: Requires ρ j = 0 for j ≥ B.length (standard assumption for box membership).
Pruned box membership and correctness #
Helper: membership in the pruned box implies membership in the original box. The pruned box only shrinks coordinates, never expands them.
The pruned box has the same length as the original box
Main correctness theorem for pruneBoxForMin:
After pruning, for any point ρ in the original box B, there exists a point ρ' in the pruned box B' such that f(ρ') ≤ f(ρ).
This means the minimum over B can be found by searching only in B'.
The proof constructs ρ' by moving each coordinate to its endpoint when the gradient has a definite sign. For each coordinate:
- If ∂f/∂xᵢ > 0 on B, move xᵢ to B[i].lo (f is increasing, min at left)
- If ∂f/∂xᵢ < 0 on B, move xᵢ to B[i].hi (f is decreasing, min at right)
- Otherwise, keep xᵢ = ρ[i]
The proof then shows f(ρ') ≤ f(ρ) by induction on coordinates, using
the monotonicity lemmas increasing_min_at_left_idx and decreasing_min_at_right_idx.