Convex analysis and optimization in Lean 4
A Lean 4 library of convex and nonsmooth analysis, monotone operator theory and optimization on top of the current Mathlib. Lean checks every proof. The library covers subdifferentials and conjugate functions, proximal and monotone operators, duality and KKT conditions, the convergence of first-order and operator splitting methods, Clarke's generalized gradient, fixed point theorems from Brouwer to Kakutani–Fan–Glicksberg, and tools of global optimization and rigorous numerics: interval Newton methods and branch and bound, interval and ball arithmetic, and computer-assisted existence proofs with the radii polynomial theorem, whose numerical bounds Lean checks as well. The plan follows Bauschke–Combettes, Convex Analysis and Monotone Operator Theory in Hilbert Spaces (2nd ed., 2017).
Website: overview (this page), API documentation (doc-gen4) and declaration map (every declaration with what it uses and what uses it).
Papers:
- H. Schilly, Claude (Opus 5.5), Convex analysis and optimization in Lean 4, technical report on this library,
aiXiv:2611.03751; source in
paper/, PDF also on the website. - H. Schilly, Claude (Opus 5.5), Nesterov's lower bound for Lipschitz minimization on the cube: two gaps, the exact
constant, and a Lean proof, aiXiv:2611.03750; source in
notes/lipschitz-complexity/.
Contents
Everything below is proved without sorry; ROADMAP.md has the plan and what is still open. On the
website each file links to its API documentation.
Convex functions and subdifferentials
| File | Content |
|---|---|
ConvexAnalysis/Basic.lean |
f : E → EReal: effective domain, proper functions, epigraph, convexity via the epigraph and its agreement with Mathlib's ConvexOn ℝ s f, multiples c f and sums, lower semicontinuity iff closed epigraph, the indicator function ι_C |
ConvexAnalysis/Subgradient.lean |
subgradients in a real inner product space, Fermat's rule, ∂f x convex and closed, ∂f monotone, scaling ∂(c f) = c ∂f, normal cone N_C = ∂ι_C |
ConvexAnalysis/Continuity.lean |
a convex f : E → EReal with f x > ⊥ that is bounded above near x is continuous at x; a convex function that is ⊥ somewhere is ⊥ on the interior of its domain; in finite dimension, continuity on the interior of the domain |
ConvexAnalysis/SubgradientExistence.lean |
for f : H → EReal with f ≤ M on a ball of radius δ around x: every subgradient has norm at most (M - f x) / δ, and ∂f x is nonempty if f is convex with f x > ⊥ (complete H), hence at points of dom f where f is continuous, and in finite dimension at interior points of the domain; the max formula: the largest ⟪d, v⟫, v ∈ ∂f x, is attained and is the directional derivative |
ConvexAnalysis/SumRule.lean |
the sandwich theorem, from which all sum and chain rules follow; for convex f : H → EReal, g : K → EReal and a bounded linear map A between Hilbert spaces, ∂(f + g ∘ A) x = ∂f x + A† (∂g (A x)) if g is continuous at a point A x₀ ∈ dom g with x₀ ∈ dom f; the chain rule (f = 0) and the Moreau–Rockafellar sum rule (A = id) are special cases. For surjective A the chain rule holds for every f, with no qualification, and so for affine maps y ↦ A y + b and isometries. In detail: the sum rule ∂(f + g) x = ∂f x + ∂g x for convex f, g : H → EReal (complete H), if f is continuous at a point of dom f ∩ dom g, and in finite dimension if a point of dom g is interior to dom f; as corollaries ∂(f + ι_C) = ∂f + N_C and the optimality condition: x ∈ C minimizes a proper convex f on a convex C iff 0 ∈ ∂f x + N_C x, if f is continuous at a point of dom f ∩ C |
ConvexAnalysis/FiniteSum.lean |
the sum rule ∂(∑ fᵢ) x = ∑ ∂fᵢ x for finitely many convex fᵢ : H → EReal, if all but one are continuous at a common point of the domains; in finite dimension if that point is interior to all but one domain; the form ∂(g + ∑ fᵢ) = ∂g + ∑ ∂fᵢ used for KKT |
ConvexAnalysis/MaxRule.lean |
the max rule: for finitely many convex fᵢ : H → EReal upper semicontinuous at x (complete H), ∂(max fᵢ) x is the convex hull of the subdifferentials of the active fᵢ (no closure needed: they are weakly compact); the convex hull of finitely many compact convex sets is compact in any real topological vector space |
ConvexAnalysis/EpsSubdifferential.lean |
the ε-subdifferential ∂_ε f x: closed, convex, characterized by f x + f* u ≤ ⟪x, u⟫ + ε, nonempty on dom f for ε > 0 if f is convex and lsc; the Brøndsted–Rockafellar theorem (via Ekeland), so dom ∂f is dense in dom f and the range of ∂f is dense in dom f* |
ConvexAnalysis/Gradient.lean |
∂f x = {∇f x} for a convex f : H → ℝ differentiable at x; at a point of differentiability every subgradient is the gradient |
ConvexAnalysis/SmoothConvex.lean |
differentiable convex f : H → ℝ on a convex set: the gradient inequality and its converse, monotone gradients characterize convexity, IsMinOn f C x ↔ -∇f x ∈ N_C x; the same for strongly convex f |
ConvexAnalysis/SubdifferentialCalculus.lean |
locality of ∂, N_C x = {0} at interior points, ∂(f + ι_C) x = ∂f x at interior points of C for convex f (no continuity), the max rule for two functions |
Conjugation, duality and optimality conditions
| File | Content |
|---|---|
ConvexAnalysis/Conjugate.lean |
the Fenchel conjugate f* u = ⨆ x, ⟪x, u⟫ - f x: Fenchel–Young, f* convex and lower semicontinuous, f** ≤ f, subgradients as the equality case of Fenchel–Young, properness of f*, weak Fenchel–Rockafellar duality, support functions, conjugates of f + c, f + ⟪a, ·⟫, f (· + a), c f; ι_C* = σ_C, (½‖·‖²)* = ½‖·‖², ‖·‖* = ι_B |
ConvexAnalysis/InfimalConvolution.lean |
the infimal convolution f □ g: domain, convexity, ι_C □ ι_D = ι_{C+D}, (f □ g)* = f* + g*, (f + g)* ≤ f* □ g* |
ConvexAnalysis/FenchelMoreau.lean |
the Fenchel–Moreau theorem f** = f for proper lower semicontinuous convex f : H → EReal (complete H), and f** = f iff f is convex, lsc, and proper or ≡ ±∞; affine minorants; ∂f* = (∂f)⁻¹; closed convex sets through their support functions |
ConvexAnalysis/FenchelRockafellar.lean |
strong Fenchel–Rockafellar duality inf_x f x + g (A x) = max_w -f* (A† w) - g* (-w) for convex f, g with g bounded above near A x₀, x₀ ∈ dom f; no primal minimizer needed; primal–dual optimality conditions; Fenchel duality |
ConvexAnalysis/ConjugateCalculus.lean |
conjugates of f (-·), f (c • ·) and epi-multiples; support functions sublinear, σ_{C+D} = σ_C + σ_D; (f + g ∘ A)* u = min_w f* (u - A† w) + g* w with attainment, with Attouch–Brézis (f + g)* = f* □ g* and (g ∘ A)* u = min {g* w : A† w = u} as special cases, from Fenchel–Rockafellar duality |
ConvexAnalysis/KKT.lean |
the convex program min f₀ s.t. gᵢ ≤ 0, A x = b (f₀, gᵢ : H → ℝ, A : H → K): Lagrange multipliers under Slater's condition (no topology needed), strong duality exists_dual_eq_primal with dual attainment and no lower bound on the primal, the sensitivity theorem -μ ∈ ∂v 0, KKT conditions with an abstract convex constraint set, KKT sufficient in general, weak duality |
ConvexAnalysis/PolyhedralDuality.lean |
Lagrangian strong duality and KKT without continuity: under Slater's condition, and under the refined Slater condition (convex inequality constraints strictly feasible, affine inequalities only feasible), also with A x = b, multipliers exist without a primal minimizer, with no continuity of f₀, gᵢ and no completeness (for linear functionals on any real vector space); zero duality gap, saddle points, KKT at a minimizer; the nonhomogeneous Farkas lemma; the KKT conditions for A x = b necessary under Slater without continuity (with subgradients, with gradients, and in the matrix form of Boyd–Vandenberghe on ℝⁿ); the normal cone of a polyhedron |
ConvexAnalysis/LinearProgramming.lean |
Carathéodory's theorem for cones (exists_linearIndepOn_of_mem_finiteCone), finitely generated cones are closed (in any Hausdorff real TVS), Farkas' lemma for cones and matrices, and the linear programming duality theorem for min c ⬝ᵥ x s.t. A x = b, x ≥ 0 with all feasibility cases, attainment on both sides, complementary slackness, and the inequality form |
Proximal and monotone operators
| File | Content |
|---|---|
ConvexAnalysis/Prox.lean |
the proximal operator of a proper lsc convex f : H → EReal (complete H): existence and uniqueness, p = prox f x ↔ x - p ∈ ∂f p, the three-point inequality, firm nonexpansiveness, prox f is 1-Lipschitz, fixed points are minimizers, prox of ι_C is the nearest point (Mathlib's orthogonal projection for subspaces), prox (γ f), the Moreau decomposition prox f x + prox f* x = x |
ConvexAnalysis/MoreauEnvelope.lean |
the Moreau envelope e_γ f x = ⨅ y, f y + ‖y - x‖² / (2γ): convex for every convex f, same minimizers as f for every f bounded below and lsc at the point; for proper lsc convex f (complete H): attained at prox_{γf} x, C¹ with gradient (x - prox_{γf} x) / γ, which is γ⁻¹-Lipschitz; (e_γ f)* = f* + γ ‖·‖² / 2 and Moreau's identity e₁ f + e₁ f* = ‖·‖² / 2 |
ConvexAnalysis/ProxCalculus.lean |
scaled Moreau decomposition prox_{γf} + γ prox_{γ⁻¹f*} ∘ γ⁻¹ = id and identity e_γ f + e_{γ⁻¹} f* ∘ γ⁻¹ = ‖·‖²/(2γ); prox of translates, tilts, constants, linear isometries, rescaled and reflected arguments and of γ f* as equalities; e_γ f x → f x as γ ↓ 0 |
ConvexAnalysis/MonotoneOperator.lean |
monotone and maximal monotone operators H → Set H, closed convex values and closed graph of maximal monotone operators, the resolvent is firmly nonexpansive, J_{γ∂f} = prox (γ f), the easy direction of Minty's theorem, and Rockafellar's theorem: ∂f is maximal monotone for proper lsc convex f (complete H) |
ConvexAnalysis/Minty.lean |
Minty's theorem: a monotone T : H → Set H is maximal monotone iff id + T is surjective (complete H), via the Fitzpatrick function; the resolvent J_T of a maximal monotone operator as a firmly nonexpansive map on all of H (IsFirmlyNonexpansive), J_{T⁻¹} = id - J_T, and weak convergence of the proximal point algorithm with constant step to a zero of T; completeness of H is necessary |
ConvexAnalysis/Yosida.lean |
resolvent identities; the Yosida approximation T_γ = γ⁻¹(id - J_{γT}): γ-cocoercive, γ⁻¹-Lipschitz, maximal monotone, same zeros as T, T_{γ+μ} = (T_μ)_γ, (∂f)_γ = ∇ e_γ f; the graph of a maximal monotone operator is closed in strong × weak, its zeros are closed and convex |
Algorithms and their convergence
| File | Content |
|---|---|
ConvexAnalysis/Smoothing.lean |
Nesterov's smoothing of nonsmooth max-type functions: the smoothed function is convex with an ‖A‖²/(μσ)-Lipschitz gradient and approximates f within μ D; the Huber function as the smoothing of the norm, and the Moreau envelope as the case d = ½‖·‖² |
ConvexAnalysis/SmoothingComplexity.lean |
the O(1/N) complexity of the smoothing technique: FISTA on the smoothed problem (S-FISTA) reaches H (x (N + 1)) - H z ≤ 2√2 ‖A‖ R √(D/σ) / (N + 2) + 2 L_f R² / (N + 2)² for every comparison point z with ‖x 0 - z‖ ≤ R, where L_f is the Lipschitz constant of the gradient of the smooth part; also for any smooth approximation in Beck's sense (Huber, Moreau envelope) |
ConvexAnalysis/Algorithms.lean |
first-order methods with rates: the descent lemma, gradient descent and ISTA O(1/k) with any step γ ≤ 1/L, FISTA O(1/k²) (Beck–Teboulle momentum; the rate holds against every point of dom g), the proximal point method, and the subgradient method with constant and diminishing steps; sufficient decrease, Fejér monotonicity and the linear rate for strongly convex f |
ConvexAnalysis/Cocoercive.lean |
the Baillon–Haddad theorem: the gradient of a convex L-smooth f is 1/L-cocoercive; gradient descent with steps γ ∈ (0, 2/L) (Fejér monotonicity, sufficient decrease, an O(1/k) rate, ∇f (x k) → 0); the forward–backward step with γ ∈ (0, 2/L) is averaged and its fixed points are the minimizers of f + g |
ConvexAnalysis/WeakConvergence.lean |
weak convergence in Hilbert spaces with Mathlib's WeakSpace: every bounded sequence has a weakly convergent subsequence, closed convex sets are weakly closed, convex lsc f : H → EReal are weakly lsc, and Opial's lemma |
ConvexAnalysis/Averaged.lean |
averaged and firmly nonexpansive maps (IsAveraged, IsFirmlyNonexpansive): T is α-averaged iff T = (1 - α) id + α R with R nonexpansive, firmly nonexpansive iff ½-averaged, id - T firmly nonexpansive with T |
ConvexAnalysis/Fejer.lean |
Fejér monotone sequences: bounded, weakly convergent if their weak cluster points lie in the set, in norm in finite dimension; the demiclosedness principle; the Krasnosel'skiĭ–Mann theorem and the Picard iteration of averaged maps |
ConvexAnalysis/IterateConvergence.lean |
convergence of the iterates: the proximal point method, the proximal gradient method (ISTA) and gradient descent with steps in (0, 2/L) converge weakly to a minimizer, in norm in finite dimension; the Picard iteration of a nonexpansive map with x (k + 1) - x k → 0 |
ConvexAnalysis/FistaConvergence.lean |
convergence of the iterates of FISTA: for the Beck–Teboulle momentum and t k = (k + a) / a, a ≥ 2, the iterates converge weakly to a minimizer of f + g, in norm in finite dimension (the 2025 result of Jang–Ryu and Boţ–Fadili–Nguyen, after Bauschke–Moursi) |
ConvexAnalysis/Splitting.lean |
operator splitting for maximal monotone A, B: forward–backward with a cocoercive B (relaxed) converges weakly to a zero of A + B; Douglas–Rachford (relaxed): the governing sequence converges weakly to a fixed point and the shadow sequence J_{γA} x k to a zero of A + B; Douglas–Rachford for min f + g; in norm in finite dimension |
Nonsmooth analysis
| File | Content |
|---|---|
ConvexAnalysis/Ekeland.lean |
Ekeland's variational principle on complete metric spaces for lower semicontinuous f : X → EReal bounded below (strong and weak form, also real-valued), Caristi's fixed point theorem (also set-valued), Takahashi's theorem, the converse (the principle characterizes completeness), and approximate critical points ‖∇f x‖ ≤ ε of differentiable functions bounded below |
ConvexAnalysis/ClarkeDeriv.lean |
Clarke's generalized directional derivative f°(x; ·) on normed spaces for functions Lipschitz near x: finite, sublinear, Lipschitz, upper semicontinuous; scaling, sum and chain inequalities, strictly differentiable and convex f, and Lebourg's mean value theorem in terms of f° |
ConvexAnalysis/Clarke.lean |
Clarke's generalized gradient ∂_C f x in Hilbert spaces, derived from ClarkeBanach.lean through the Riesz map: nonempty, convex, closed and bounded, the max formula, Fermat's rule, ∂_C (c f) = c ∂_C f, {∇f x} for strictly differentiable f, the sum rule, agreement with ∂f for continuous convex f, the chain rule ∂_C (f ∘ G) x ⊆ G'(x)† ∂_C f (G x) for strictly differentiable G, with equality if G'(x) is surjective, f or -f is regular, or f is convex; equality in the sum rule for regular functions; the max rule ∂_C (max Fᵢ) x ⊆ co ⋃ active ∂_C Fᵢ x, with equality for regular functions; the closed graph |
ConvexAnalysis/ClarkeRegular.lean |
Clarke regularity in normed spaces: convex, strictly differentiable and C¹ functions, nonnegative multiples, sums, maxima and compositions with strictly differentiable maps of regular functions are regular; equality for f° in the sum, max and chain rules |
ConvexAnalysis/ClarkeGradientLimits.lean |
Clarke's theorem: in finite dimension ∂_C f x is the convex hull of the limits of gradients ∇f (x k), x k → x, avoiding any null set (via Rademacher's theorem), and f°(x; v) = limsup ⟪∇f y, v⟫ |
ConvexAnalysis/ClarkeBanach.lean |
Clarke's generalized gradient in normed spaces, as a set of continuous linear functionals, and the single source of the subdifferential calculus: nonempty, convex, weak-* compact; the max formula, Fermat's rule, C¹ and convex functions, sum, finite-sum and chain rules with equality under regularity, the ⊇ half of the max rule for regular functions, Lebourg's mean value theorem, the closed graph |
Fixed points and games
| File | Content |
|---|---|
ConvexAnalysis/Simplex.lean |
the probability simplex {p : ι → ℝ | p ≥ 0, ∑ p = 1}: convex, compact, Brouwer on it |
ConvexAnalysis/Brouwer.lean |
Brouwer's fixed point theorem for continuous self-maps of nonempty compact convex sets in finite-dimensional real normed spaces (also closed balls, boxes, retracts and homeomorphic spaces), and the no-retraction theorem (continuous and smooth form); an analytic proof with Milnor's volume polynomial and the change of variables formula |
ConvexAnalysis/PoincareMiranda.lean |
the Poincaré–Miranda theorem: a continuous f on a box whose i-th component has opposite signs on the two faces xᵢ = aᵢ, xᵢ = bᵢ has a zero in the box |
ConvexAnalysis/KKM.lean |
the KKM lemma for KKM maps (IsKKMMap) in real topological vector spaces and on the probability simplex, and Ky Fan's version for infinite families with one compact member |
ConvexAnalysis/Schauder.lean |
Schauder's fixed point theorem: a continuous self-map of a nonempty compact convex set in a real normed space has a fixed point; also if f maps a convex C into a compact subset of C (no completeness), and in Banach spaces for closed convex C with a totally bounded image |
ConvexAnalysis/Tychonoff.lean |
Tychonoff's fixed point theorem: a continuous self-map of a nonempty compact convex set in a Hausdorff locally convex space has a fixed point |
ConvexAnalysis/Hemicontinuity.lean |
correspondences: for compact range, a closed graph is the same as upper hemicontinuity with closed values |
ConvexAnalysis/KakutaniFanGlicksberg.lean |
the Kakutani–Fan–Glicksberg theorem: a correspondence with closed graph (or upper hemicontinuous with closed values) and nonempty convex values on a nonempty compact convex set of a locally convex space has a fixed point; Himmelberg's theorem (convex domain, values in a compact subset), from which it follows; Kakutani's theorem in real normed spaces and the form of Bohnenblust–Karlin as corollaries |
ConvexAnalysis/HairyBall.lean |
the hairy ball theorem: on an even-dimensional sphere (the unit sphere of a space of odd dimension) every continuous tangent vector field vanishes somewhere, and every continuous map g of it has a point with g x = c x (Milnor's analytic proof) |
ConvexAnalysis/Nash.lean |
finite games in mixed strategies: expected payoffs, best responses, and Nash's theorem, every finite game has a Nash equilibrium; deviations to pure strategies suffice, pure equilibria, the indifference principle |
Newton-type methods, interval methods and global optimization
| File | Content |
|---|---|
ConvexAnalysis/Kantorovich.lean |
the Kantorovich theorem for Newton's method between Banach spaces, in the classical and the affine covariant form: semilocal (no zero is assumed), the iterates converge to a zero, with the majorant bounds, quadratic error bounds and uniqueness; local quadratic convergence near a regular zero; for minimization the limit is a strict local minimizer |
ConvexAnalysis/CubicNewton.lean |
cubic regularization of Newton's method (Nesterov–Polyak) for functions whose Hessian is Lipschitz near the level set: global minimizers of the cubic model, descent, convergence of the gradients, the rate O(N^(-2/3)) for the best of the first N + 1 iterates, second-order stationarity of cluster points, and the O(1/k²) rate for convex functions |
ConvexAnalysis/IntervalArithmetic.lean |
interval arithmetic: operations with the inclusion property and isotonicity, the natural interval extension of arithmetic expressions and Moore's fundamental theorem, the dependency problem and the single-use theorem, outward rounding, convergence of the natural extension (linear if square roots stay away from 0) and quadratic convergence of the mean value form with Neumaier's a posteriori bound, convergence of interval branch and bound, and the relation to Mathlib's inclusion tactic (its +, - are exact, its * an outward rounding) |
ConvexAnalysis/IntervalDerivative.lean |
interval differentiation of arithmetic expressions: symbolic partial derivatives with their correctness (smooth where no inverse, logarithm or square root has the argument 0), derivative enclosures from Moore's fundamental theorem (exact or with outward rounding) and their linear convergence, the mean value form with computed derivatives (range enclosure, quadratic approximation, convergent interval branch and bound), and slope enclosures of systems, which give the interval Krawczyk test with no hypothesis besides the computed inclusions (the interval Newton test also needs a regular interval matrix) |
ConvexAnalysis/IntervalDyadic.lean |
verified interval computation: the bridge for the exp, log, √, powers, rounding and constants of Mathlib's inclusion tactic (outward roundings of the exact operations) and a dyadic inverse; expressions with rational constants and a computable dyadic evaluator whose results are outward roundings (IsRoundedEval), so every interval theorem applies to them; a dyadic Krawczyk test with symbolic derivatives, evaluated by the kernel, that proves existence and uniqueness of a zero in a box |
ConvexAnalysis/IntervalBranchAndBound.lean |
verified bounds and global minima by dyadic branch and bound: adaptive bisection of dyadic boxes evaluated by the kernel, with the natural interval extension or the mean value form (symbolic derivatives) on each piece; tests for c ≤ e, c < e, e ≤ c, e < c on a box, an exclusion test for systems of equations, and a global minimum test that proves that the minimum on a box exists and lies in [L, U] |
ConvexAnalysis/HansenSengupta.lean |
the Hansen–Sengupta operator (one preconditioned interval Gauss–Seidel sweep) in real interval arithmetic (rows with 0 ∈ Gᵢᵢ skipped, intersections in Mathlib's Interval ℝ): it contains every zero in the box (exclusion test), and if the new box lies in the interior of the old, every matrix of the interval matrix is invertible and there is exactly one zero, in the new box, so the test certifies regularity itself; the dyadic Hansen–Sengupta operator evaluated by the kernel, with exclusion, enclosure of the zeros and the existence test, proved through the real-interval theorem |
ConvexAnalysis/BallArithmetic.lean |
ball (midpoint–radius) arithmetic in normed rings: sums, products, powers, polynomials and inverses with the inclusion property and isotonicity, rounding as enlargement; in ℝ balls are intervals (an order isomorphism), and the ball product overestimates the interval product by at most 3/2 (Rump) |
ConvexAnalysis/RadiiPolynomial.lean |
the radii polynomial theorem of rigorous numerics (a norm form of Day–Lessard–Mischaikow's contraction theorem), on real and complex Banach spaces: existence and uniqueness of a zero in a ball from a bound on the defect at the center and a bound on 1 - A F' over the ball, with the affine and Lipschitz forms and the relation to Kantorovich and Krawczyk; the Krawczyk test with the operator computed in interval arithmetic |
ConvexAnalysis/ComputerAssistedProofs.lean |
computer-assisted existence proofs checked by Lean: x = exp (-x) has exactly one solution in 0.5671432904 ± 10⁻¹⁰ (bounds computed by Mathlib's dyadic_interval tactic), and polynomial examples, one with a derivative bound computed in ball arithmetic; x = exp (-x) within 10⁻¹⁵, x log x = 1 and circle ∩ hyperbola within 10⁻¹³ by a Krawczyk test computed in the kernel, with no hand-proved bound; with bridges from a unique zero of a real system (the conclusion of every test) to ℂ and to Mathlib's Matrix: a complex root of z³ - 2z + 2 in a rectangle, an eigenpair of a 3×3 matrix with eigenvalue 3 + √3, and a square root of a 2×2 matrix, each within 10⁻¹⁴; circle ∩ hyperbola on a box of half-widths 1/2 × 1/20 by the Hansen–Sengupta test, where the Krawczyk test fails, with the enclosure [1.9246, 1.9391] × [0.5166, 0.5187] from the operator; by branch and bound, the global minimum of the six-hump camel function on [-2, 2] × [-1, 1] in [-1.035, -1.03162], the strict bounds x e⁻ˣ < 0.3679 and (x - 1)(x - 2)(x - 3)(x - 4) > -1.01, and the exclusion of all real solutions of x² + y² = 1, x y = 0.51 |
ConvexAnalysis/GlobalComplexity.lean |
the exact complexity of global optimization: finding an ε-optimal point of an L-Lipschitz function on [0, 1]ⁿ needs exactly (⌊L / (2ε)⌋ + 1)ⁿ evaluations in the worst case (for n ≥ 1, ε ≤ L/2), attained by the uniform grid; this sharpens Nesterov's lower bound ⌊L / (2ε)⌋ⁿ and repairs two gaps in its textbook proof; for the non-strict goal the count is ⌈L / (2ε)⌉ⁿ; as an optimal error the value is due to Sukharev (1971) and, for arbitrary answers, Novak (1988, Prop. 1.3.6) |
ConvexAnalysis/SmoothLowerBound.lean |
Nesterov's lower bound for smooth convex optimization (Theorem 2.1.7): for 2k + 1 ≤ n there is a convex L-smooth function on which every method whose test points lie in x0 plus the span of the past gradients has f (x k) - f* ≥ 3 L ‖x0 - x*‖² / (32 (k + 1)²), x* the minimizer nearest to x0; so FISTA is optimal up to the factor 64/3 |
ConvexAnalysis/IntervalNewton.lean |
interval Newton and Krawczyk on boxes: existence and uniqueness tests (from Brouwer and Kakutani), the exclusion test N(X) ∩ X = ∅, quadratic convergence of the nested boxes, and the localization of minimizers in global optimization |
ConvexAnalysis/Box.lean |
boxes Icc a b in ι → ℝ: the interior is the open box, the diameter in the sup norm is the width ‖b - a‖, and the interval hull Icc (sInf s) (sSup s) of a bounded set is the smallest box containing it and has the same diameter; shared by interval Newton and branch and bound, with Mathlib imports only |
ConvexAnalysis/BranchAndBound.lean |
convergence of branch and bound (Horst–Tuy): for consistent lower bounds (with an exhaustive subdivision, or in Horst–Tuy's form along the run), the bounds and the incumbent converge to the infimum and cluster points are global minimizers; the Lipschitz method on a box with an explicit iteration bound, and interval bounds from inclusion functions |
The optimality condition extends math-nonsmooth-optimality
from ℝⁿ to Hilbert spaces.
Design
DESIGN.md records the choices and the reasons for them. In short:
- real Hilbert spaces, with subgradients as vectors;
- extended real values in Mathlib's
EReal; - convexity of
f : E → ERealdefined by a convex epigraph, with bridge lemmas to Mathlib'sConvexOn; - all names in the namespace
ConvexAnalysis, aligned with open Mathlib PRs where they exist.
Related work
- optlib (Apache-2.0) formalizes much of optimization, but on Lean 4.13 and a Mathlib from 2024. It has subgradients, proximal operators, KKT conditions under constraint qualifications and convergence rates. It does not have conjugate functions, strong duality or minimax. Code adapted from optlib names its source and authors.
- ReasBook (Apache-2.0) formalizes all 39 sections of Rockafellar's Convex
Analysis (1970) on
ℝⁿ, on Lean 4.26.0: about 420,000 lines in 557 files on itsv4.26.0branch, with nosorryin its sources. It follows the book section by section and is built on its own Mathlib pin. This library instead follows Bauschke–Combettes in Hilbert spaces, as a library on current Mathlib. - Mathlib has convex functions, Hahn–Banach separation, cones and Farkas-type lemmas, and Sion's minimax
theorem (
Mathlib/Topology/Sion.lean). An open Mathlib PR, #45868, proposes subgradients along a bilinear pairing.
Build
Toolchain and Mathlib follow Mathlib master. The exact commit is pinned in lake-manifest.json.
lake update moves to a newer Mathlib.
lake exe cache get # Mathlib build cache
lake build ConvexAnalysis --wfail # any warning, including `sorry`, fails the build
verify/check_sources.sh # every file imported, no kernel bypass
lake env lean verify/Axioms.lean # axioms of every declaration
CI runs all three on every push. The axiom check covers every declaration of the library and allows only propext,
Classical.choice and Quot.sound; it also catches a sorry hidden from --wfail by set_option warn.sorry false.
Documentation
The website https://dev.harald.schil.ly/math-convex-analysis/ has this overview, the roadmap, the design notes and
the API documentation generated by doc-gen4, and a
declaration map made with
LeanViz by Keith Adler (MIT license): every declaration with its statement,
docstring, what it uses and what uses it, read from the built .olean files. The workflow
.github/workflows/docs.yml builds and deploys it on every push to main. To build it locally:
(cd docbuild && lake build ConvexAnalysis:docs) # API docs in docbuild/.lake/build/doc
python3 site/build.py _site --api-docs docbuild/.lake/build/doc # needs `pip install markdown`
python3 -m http.server -d _site
docbuild pins doc-gen4 to the tag of lean-toolchain and the same Mathlib as the library: after lake update at
the root, run MATHLIB_NO_CACHE_ON_UPDATE=1 lake update doc-gen4 in docbuild. Docstrings follow Mathlib's
documentation style. Every cited work has an entry
in docs/references.bib; a citation [BC, Theorem 5.5][BC] (or a bare [BC]) links to it on the references page.
Use of AI
This library is written with substantial assistance from Claude (Anthropic), which drafts statements and proofs. Lean checks every proof. Whether each statement says what its docstring claims, and whether it matches the cited source, is checked by independent AI review agents, not by a human reading every statement; the author sets the goals and makes the decisions. Contributions to Mathlib, if any, follow Mathlib's own rules on AI use.
In practice a lead agent plans the work from ROADMAP.md, helper agents draft independent files in parallel, and the
lead integrates, builds and commits them. After each milestone, or a substantial part of one, an independent review
agent checks the new statements against the literature, the hypotheses, the definitions and the API; ROADMAP.md
records every review and what it changed.
License
Apache-2.0.