Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Proof of Lemma 9, p. 345 — at most n/2k−1n/2^{k-1}n/2k−1 vertices have rank kkk or greater

Proved
HarelTarjan.Compressed.rank_ge_count

by mikedeng1 · Sep 27, 2026 · Mathlib 0df444a (Lean v4.33.1)

heavy-pathnearest-common-ancestorp2o-batch-p100bp2o-gran-per-chapterp2o-plan-paperp2o-v1trees

Let TTT be a rooted tree on nnn vertices and CCC its compressed tree. For every k≥0k \ge 0k≥0, the number of vertices with rank kkk or greater satisfies

#{ v:rank(v)≥k }≤∑i=k∞n2i=n2k−1.\#\{\, v : \mathrm{rank}(v) \ge k \,\} \le \sum_{i=k}^{\infty} \frac{n}{2^i} = \frac{n}{2^{k-1}}.#{v:rank(v)≥k}≤i=k∑∞​2in​=2k−1n​.

This is the first sentence of the proof of Lemma 9 and yields the sizes of plies two and three.

Formalization Note The bound is stated without division as #{v:rank(v)≥k}⋅2k≤2n\#\{v : \mathrm{rank}(v) \ge k\}\cdot 2^k \le 2n#{v:rank(v)≥k}⋅2k≤2n, which is n/2k−1n/2^{k-1}n/2k−1 over the reals, including k=0k = 0k=0.

Preamble
import Mathlib
import Definitions.Def_HarelTarjan_Compressed_RootedTree
import Definitions.Def_HarelTarjan_Compressed_HeavyPath
import Definitions.Def_HarelTarjan_Compressed_CompressedTree
Formal statement
namespace HarelTarjan.Compressed

theorem rank_ge_count {V : Type*} [Fintype V] [DecidableEq V] (T : RootedTree V) (k : ℕ) :
    (Finset.univ.filter (fun v => k ≤ rank T v)).card * 2 ^ k ≤ 2 * Fintype.card V := by sorry

end HarelTarjan.Compressed
Source
Harel, Tarjan, Fast Algorithms for Finding Nearest Common Ancestors, SIAM J. Comput. 13 (1984), p. 345, proof of Lemma 9, first sentence
Read-back

What the Lean code literally says, in plain math · claude-opus-5-5

Setting. VVV is any finite type with decidable equality. TTT is any rooted tree on VVV with root rrr and parent map ppp, where:

  • p(r)=rp(r) = rp(r)=r;
  • every vertex reaches rrr under some iterate pip^ipi, i≥0i \ge 0i≥0.

kkk is any natural number.

Definitions used.

  • size⁡T(w)\operatorname{size}_T(w)sizeT​(w) is the number of uuu with pj(u)=wp^j(u) = wpj(u)=w for some j≥0j \ge 0j≥0, including www itself.
  • A vertex xxx is heavy when x≠rx \ne rx=r and size⁡T(p(x))<2 size⁡T(x)\operatorname{size}_T(p(x)) < 2\,\operatorname{size}_T(x)sizeT​(p(x))<2sizeT​(x).
  • apex⁡(x)=pm(x)\operatorname{apex}(x) = p^m(x)apex(x)=pm(x) for the least m≥0m \ge 0m≥0 with pm(x)p^m(x)pm(x) not heavy.
  • The compressed parent is pC(r)=rp_C(r) = rpC​(r)=r, and pC(x)=apex⁡(p(x))p_C(x) = \operatorname{apex}(p(x))pC​(x)=apex(p(x)) for x≠rx \ne rx=r.
  • size⁡C(w)\operatorname{size}_C(w)sizeC​(w) is the number of uuu with pCj(u)=wp_C^j(u) = wpCj​(u)=w for some j≥0j \ge 0j≥0, including www itself.
  • rank⁡(v)=⌊log⁡2size⁡C(v)⌋\operatorname{rank}(v) = \lfloor \log_2 \operatorname{size}_C(v) \rfloorrank(v)=⌊log2​sizeC​(v)⌋.

Statement. The theorem asserts

#{v∈V:rank⁡(v)≥k}⋅2k≤2 ∣V∣.\#\{v \in V : \operatorname{rank}(v) \ge k\} \cdot 2^k \le 2\,|V|.#{v∈V:rank(v)≥k}⋅2k≤2∣V∣.

In words: at most 2∣V∣/2k2|V|/2^k2∣V∣/2k vertices have rank at least kkk.

Degenerate cases.

  • For k=0k = 0k=0 every vertex qualifies, and the claim is ∣V∣≤2∣V∣|V| \le 2|V|∣V∣≤2∣V∣, which is trivially true.
  • For kkk exceeding every attained rank, the left side is 000.
  • If ∣V∣=1|V| = 1∣V∣=1, the claim is 1≤21 \le 21≤2 for k=0k = 0k=0 and 0≤20 \le 20≤2 otherwise.
Human review
  • Endorsed by Shuze Chen · Sep 27, 2026

    Confirmed by the moderator at approval.

  • Endorsed by mikedeng1 · Sep 27, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me