Correctness of Condat's Proposed Algorithm (Fig. 2): the output is and counts its nonzeros
ProvedSimplexProj.Condat.condat_algorithm_correctLet , and . Run Condat's Proposed Algorithm (Fig. 2) on and ; it terminates with a threshold and a count . Set for (step 6). Then is the Euclidean projection of onto the simplex of radius , and is the number of nonzero entries of :
This is the correctness claim of Condat's algorithm (Fig. 2 and its caption, argued in Sect. 3): the algorithm computes the projection exactly and in finite time, for every input, with no assumption on the order or distinctness of the entries of .
Formalization Note. The algorithm is the total function condatAlgorithm a (List.ofFn y), returning ; termination is part of the definition (well-founded recursion), so the theorem is about every input. is the predicate IsSimplexProjection a y x; is compared with the number of indices with (a count over indices, not distinct values).
import Mathlib import Definitions.Def_SimplexProj_Condat_IsSimplexProjection import Definitions.Def_SimplexProj_Condat_condatAlgorithm
namespace SimplexProj.Condat
/-- Condat, Sect. 3, Fig. 2 and its caption (p. 6): for `N ≥ 1`, `y ∈ ℝ^N`, `a > 0`, the
Proposed Algorithm run on `(y_1, …, y_N)` terminates with `(τ, K)` such that
`x = (max {y_n - τ, 0})_{n=1}^N` (step 6) is the Euclidean projection `P_Δ(y)` of `y` onto the
simplex of radius `a`, and `K` is the number of nonzero elements of `x`. -/
theorem condat_algorithm_correct (N : ℕ) (hN : 1 ≤ N) (a : ℝ) (ha : 0 < a) (y : Fin N → ℝ)
(τ : ℝ) (K : ℕ) (hout : condatAlgorithm a (List.ofFn y) = (τ, K)) :
IsSimplexProjection a y (fun n => max (y n - τ) 0) ∧
K = (Finset.univ.filter (fun n => max (y n - τ) 0 ≠ 0)).card := by sorry
end SimplexProj.Condat
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
The statement concerns a whole number , a real number , a vector (indexed by ), a real number and a whole number . It assumes:
- ;
- ;
- . Here is a function defined in an imported file that is not shown. It takes the real number and the finite list of the entries of in index order, and returns a pair made of a real number and a whole number. The hypothesis says that the pair it returns on this input is exactly .
From these data, define the vector entry by entry:
The conclusion is the conjunction of two claims.
- holds. This is a predicate on a real number , a vector and a vector , defined in another imported file that is not shown. Its meaning is fixed entirely by that hidden definition and cannot be read from this declaration. The name suggests " is the Euclidean projection of onto a simplex of radius ," but only the imported definition decides what is actually asserted.
- is the number of indices with . Since every , this is the same as the number of indices with :
The text in the code comment above the theorem (it cites Condat, Sect. 3, Fig. 2) is documentation only and is not part of what is asserted.
Degenerate cases. is excluded by the hypothesis , and is excluded by , so the statement says nothing about the algorithm's output in those cases. is allowed: then is a single number , , and the claims are that holds and that is if and otherwise. Entries of may be equal, negative or arbitrarily large; nothing restricts them.
Because is a function, its output on the given input is a single pair. So the hypothesis fixes and to exactly that pair, and the theorem is a claim about the algorithm's actual output, not about arbitrary . The hypothesis can therefore always be satisfied, and the statement is not vacuous on that account. The function has to return some value on every input, whether or not the procedure it encodes "terminates" in an informal sense. Any default or placeholder values it produces internally (for example from division by zero or subtraction of whole numbers) are part of its hidden definition and are not visible here. The whole content of the first claim, including whether it is strong, weak or trivially satisfied, depends on the unseen definition of .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.