Repository navigation
feat: FTRL with composite losses, proximal steps and soft thresholding - #373
Merged
lmlexplore-automation[bot] merged 2 commits intoNov 14, 2026
Conversation
Co-Authored-By: Claude Code <noreply@github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RemyDegenne
commented
Nov 14, 2026
Contributor
Author
AI review — approvedEach rubric is judged independently by multiple review agents; the PR merges only once every rubric is green — any rubric that is not green (changes requested, blocked, errored, stale, or not yet run) blocks the merge. See the rubrics.
♻️ = approved on an earlier commit, re-run before merge. Reviewing this diff at head |
Co-Authored-By: Claude Code <noreply@github.com>
Merged
via the queue into
LeanMachineLearning:main
with commit Nov 14, 2026
8302734
23 of 25 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR completes OnlineLearning Layer 5.4, Composite losses [Ora, §7.8, Example 7.24]. With it, every item of Layer 5 (FTRL for convex losses) is on
main. Bullet 1 is FTRL with a fixed known partrof the losses kept exact. Bullets 2–3 cover the proximal steps that compute such plays, read through Tau Ceti'smoreauYosidaResolvent, and soft thresholding for theℓ¹penalty. It is one topic: the algorithm, its regret, and the closed form of its plays.Roadmap: OnlineLearning
New file
OnlineLearning/FTRL/Composite.lean(bullet 1, normed space, subgradients withinVas in LML'sHasSubgradientWithinAt):regret_le_ftrl_composite_of_strongConvexOn. Each playx tminimizes overVthe objectiveψ t + (t + 1) * r + ∑ s < t, ℓ s, which anticipates the current round'sr(the book'sλ t ‖x‖₁at book roundtis Lean roundt - 1).g tis a subgradient ofℓ talone, andψ t + (t + 1) * r + ∑ s ≤ t, ℓ sislam t-strongly convex. Ifx ndoes at least as well asuon the non-anticipating last objectiveψ n + n * r + ∑ s < n, ℓ s, thenregret (ℓ + r) ≤ ψ n u - ψ 0 (x 0) + ∑ ‖g t‖² / (2 lam t) + ∑ (ψ t (x (t+1)) - ψ (t+1) (x (t+1))). This is the bound of item 2 (regret_le_ftrl_of_strongConvexOn) for the composite losses.ris never differentiated and need not be convex, andr = 0gives backregret_le_ftrl_of_strongConvexOn. The proof is the FTRL equalityregret_le_ftrlfor the non-anticipating objectives plusftrl_stability_le_norm_sq_div_of_strongConvexOnfor the anticipating regularizersψ t + (t + 1) * r. Therterms then cancel exactly, which is how [Ora] avoids the boundary term by "setting ψ_{T+1} = ψ_T".regret_le_ftrl_linearized_composite_of_strongConvexOn. This is the roadmap's form, "FTRL on∑ s < t, g s + t r + ψ t": the plays minimizeψ t + (t + 1) * r + ∑ s < t, g s, whereg sare subgradients of convex lossesf s. Ifψ t + (t + 1) * rislam t-strongly convex, the same bound holds forf t + r. It is derived from the previous theorem and the linearization lemmasum_sub_le_sum_apply_sub_of_hasSubgradientWithinAt.isMinOn_norm_sq_div_add_mul_sum_abs_add_inner_iff[Ora, Example 7.24]. OnEuclideanSpace ℝ α, the unique minimizer of‖x‖² / (2η) + c ∑ |x a| + ⟪θ, x⟫has coordinatesη * softThreshold c (-θ a). These are the unconstrained plays of the linearized composite FTRL withψ t = ‖·‖² / (2 η t)andr = lam ‖·‖₁, so they are sparse.New file
Analysis/Convex/Proximal.lean(bullets 2 and 3):mem_moreauYosidaResolvent_ite_iff. Restrictr : E → ℝto a nonemptyVwith Tau Ceti's conventionif x ∈ V then (r x : EReal) else ⊤(TauCeti.mem_subdifferential_ite_iff,EffectiveDomain.lean). Forη > 0its resolventJ_η zis{y ∈ V | IsMinOn (η * r + ‖· - z‖² / 2) V y}.mem_moreauYosidaResolvent_coe_iffis the unconstrained case: the proximal step is the minimizer ofη r(x) + ½‖x − z‖².mem_moreauYosidaResolvent_ite_zero_iff. For the indicator of a nonemptyK, the resolvent is the set of points ofKnearest toz. This is the projection convention ofisMirrorDescentStep_norm_sq_div_two_iff.exists_moreauYosidaResolvent_ite_zero_eq_singletonadds that on a nonempty complete convex set of a real inner product space (e.g. closed convex in a Hilbert space) the resolvent is a single point.softThreshold c z = Real.sign z * max (|z| - c) 0(the book's formula), withsoftThreshold_def,_of_abs_le,_of_lt,_of_lt_neg,_negand_mul(positive homogeneity).mul_abs_softThreshold_add_leshows it minimizesc |x| + (x − z)² / 2with quadratic growth.isMinOn_mul_sum_abs_add_norm_sub_sq_iffandmoreauYosidaResolvent_mul_sum_absshow that the proximal step oflam ∑ |x a|onEuclideanSpace ℝ α(that is,PiLp 2, so that‖x − z‖is Euclidean, as the roadmap's coordinate convention allows) is the single point given by coordinatewise soft thresholding at levelη * lam.Reuse:
softThreshold, proximal/projection characterizations ofmoreauYosidaResolvent: no hits in Mathlib, Tau Ceti, LML, Statlib or LMLExplore (searchedthreshold,shrink,prox,proximal, and everymoreauYosidaResolventlemma outsideMoreauYosida/Basic.lean). The proofs use Tau Ceti'smem_moreauYosidaResolvent_iff_isMinOnandcoe_edist_sq_div_eq_coe_dist_sq_div.exists_norm_eq_iInf_of_complete_convex. Uniqueness comes fromstrongConvexOn_div_two_mul_norm_sub_sqandStrictConvexOn.eq_of_isMinOn. Tau Ceti'sPenalizedConvex.subsingleton_moreauYosidaResolventwould first need penalized convexity of the indicator along CAT(0) geodesics, which is longer than this two-line argument.TauCeti.Analysis.GradientFlow.MoreauYosida.Basicis light: it and its four new dependencies build in about 4 s.No public declaration is removed or renamed.
What remains: Layer 5 is complete. The next consumers are Layer 7.2 (optimistic FTRL, from Layers 0.3 and 5.1) and Layer 13.5, which uses the kept regularizer increments of item 2.
Local checks only (CI verifies the pushed PR):
scope: scoped: against 278c9ec81caf4b9f07ee007af57df29ce0d0151b.local-axioms: checked 2 changed module(s), 26 declaration(s); 0 violation(s). The whole-librarylake build --iofail, the source guards, the module-system audit, the header check and the environment lint (checked 2 changed module(s), 26 declarations; 1 documentation checks; 14 environment linters) passed, and the verify script exited 0.🤖 Prepared with Claude Code