Appendix B, (B.6) — optimality conditions of the Lasso
ProvedLassoDantzig.Lasso.eq_B6_kktLet , with columns , and . A vector minimises (the Lasso (7.2)) if and only if, for every ,
These conditions are used in the proof of Lemma B.1 to bound the number of non-zero coordinates of the Lasso solution, which yields the sparsity bound (7.9).
Formalization Note The paper writes (B.6) for the weighted Lasso (2.1) with right-hand sides ; for the Lasso (7.2), whose weights are (the unit-diagonal case ), the right-hand sides are , and the equivalence holds for every design . is the real sign function.
import Mathlib import Definitions.Def_LassoDantzig_Lasso_Model open MeasureTheory ProbabilityTheory
namespace LassoDantzig.Lasso
/-- (B.6), p. 22, for the Lasso (7.2): for `r > 0`, `β̂` is a Lasso solution if and only if,
for every `j`, `(1/n) x_{(j)}ᵀ(y − Xβ̂) = r sign(β̂ⱼ)` when `β̂ⱼ ≠ 0` and
`|(1/n) x_{(j)}ᵀ(y − Xβ̂)| ≤ r` when `β̂ⱼ = 0`, where `x_{(j)}` is the `j`-th column of `X`. -/
theorem eq_B6_kkt {n M : ℕ} (hn : 1 ≤ n)
(X : Matrix (Fin n) (Fin M) ℝ) (y : Fin n → ℝ) (r : ℝ) (hr : 0 < r)
(βhat : Fin M → ℝ) :
IsLasso X y r βhat ↔
∀ j : Fin M,
(βhat j ≠ 0 →
(1 / (n : ℝ)) * ∑ i, X i j * (y i - X.mulVec βhat i) = r * Real.sign (βhat j)) ∧
(βhat j = 0 →
|(1 / (n : ℝ)) * ∑ i, X i j * (y i - X.mulVec βhat i)| ≤ r) := by sorry
end LassoDantzig.Lasso
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
Setting.
- and are natural numbers.
- is any real matrix and .
- is a real number and .
Claim. is a global minimiser over all of
if and only if every coordinate satisfies the following, where :
- if , then , where takes the values , , ;
- if , then .
No assumption is made on (no unit diagonal, no rank condition).
Degenerate cases. For , both sides hold trivially. The hypotheses exclude and .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.