The k-th largest value, padded with zeros #
Finset.kthLargest k s h is the k-th largest member of the multiset of values h x, x ∈ s,
padded with infinitely many zeros. It is the largest value h x that is reached or exceeded by at
least k of the values, or 0 if that is larger. So it is nonnegative, and it is 0 when fewer
than k of the values are positive. This is the order statistic rank_k of the detectors in the
OpenAI preprint [OpenAI2026LogSpace, Section 4.2].
It is characterized by threshold counts: for 0 < k and 0 ≤ t, the k-th largest value exceeds
t exactly when at least k values exceed t (Finset.lt_kthLargest_iff), and for 0 < t it
is at least t exactly when at least k values are at least t (Finset.le_kthLargest_iff).
Main definitions #
Finset.kthLargest: thek-th largest value, padded with zeros.Finset.abs_le_kthLargest_one: absolute values are bounded by the full-slice maximum.
Main results #
Finset.kthLargest_nonneg,Finset.kthLargest_le: bounds.Finset.kthLargest_congr: congruence under pointwise equality ons.Finset.lt_kthLargest_iff,Finset.le_kthLargest_iff: the threshold characterizations.Finset.kthLargest_le_of_lt_imp: comparing ranks of two functions through a threshold.Finset.kthLargest_eq_of_eq_or_gt: replacing values strictly above a bounded rank preserves it.Finset.kthLargest_le_kthLargest_add,Finset.abs_kthLargest_sub_kthLargest_le: stability under perturbation of the values.
References #
- OpenAI, Exact Derandomization of Logarithmic Space: L = RL = BPL, Section 4.2 (preprint, not peer reviewed)
The k-th largest value of h on s, padded with zeros: the largest value h x,
x ∈ s, that at least k values h w, w ∈ s, reach or exceed, or 0 if that is larger.
The k-th largest value is at most any nonnegative upper bound of the values.
kthLargest depends only on the values of the function on s.
Comparing ranks through a threshold. If every value of f above t ≥ 0 has the value of
g above t too, a bound t on the k-th largest value of g bounds the m-th largest value
of f for every m ≥ k > 0.
Changing only values strictly above a ceiling preserves every rank at most that ceiling. The bound may be an equality, and other values may be negative.
Rank stability, one side [OpenAI2026LogSpace, (5.4)]: if every value of h₁ exceeds the
corresponding value of h₂ by at most ε ≥ 0, so does the k-th largest value.
Rank stability [OpenAI2026LogSpace, (5.4)]: |rank_k h₁ − rank_k h₂| ≤ sup |h₁ − h₂|.
If the values differ by at most ε ≥ 0 everywhere on s, so do their k-th largest values.
A retained endpoint's magnitude is bounded by the full row maximum, including zero.