Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Lemma 9 (explicit form proved on p. 345) — ply three ≤ 4n/lg n, ply two ≤ 4n/lg⁽²⁾ n, ply-one components ≤ lg⁽²⁾ n

Proved
HarelTarjan.Compressed.lemma9_plies

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 n≥4n \ge 4n≥4 vertices, CCC its compressed tree, and divide CCC into plies one, two and three by rank, with thresholds ⌊lg⁡(3)n⌋\lfloor \lg^{(3)} n\rfloor⌊lg(3)n⌋ and ⌊lg⁡(2)n⌋\lfloor \lg^{(2)} n \rfloor⌊lg(2)n⌋. Then:

  1. Ply three contains at most 4n/lg⁡n4n/\lg n4n/lgn vertices:
∣ply three∣≤4nlg⁡n.|\text{ply three}| \le \frac{4n}{\lg n}.∣ply three∣≤lgn4n​.
  1. Ply two contains at most 4n/lg⁡(2)n4n/\lg^{(2)} n4n/lg(2)n vertices:
∣ply two∣≤4nlg⁡(2)n.|\text{ply two}| \le \frac{4n}{\lg^{(2)} n}.∣ply two∣≤lg(2)n4n​.
  1. Each connected component of ply one is a subtree of CCC containing at most lg⁡(2)n\lg^{(2)} nlg(2)n vertices. Precisely: for every vertex vvv in ply one, all descendants of vvv in CCC lie in ply one, and
sizeC(v)≤lg⁡(2)n.\mathrm{size}_C(v) \le \lg^{(2)} n .sizeC​(v)≤lg(2)n.

The paper states Lemma 9 with O(n/log⁡n)O(n/\log n)O(n/logn) and O(n/log⁡(2)n)O(n/\log^{(2)} n)O(n/log(2)n); its proof on p. 345 establishes the explicit constants 444 and 444 given here. The lemma is what makes the depth problem on CCC solvable with linear preprocessing: the tables for plies two and three have total size O(n)O(n)O(n), and ply one splits into tiny subtrees.

Formalization Note lg⁡\lglg is Real.logb 2, nnn is Fintype.card V, and the plies use the iterated Nat.log thresholds of the definition Plies (equal to the real floors for n≥4n \ge 4n≥4). The hypothesis n≥4n \ge 4n≥4 is added: it is not on the page, where the O(⋅)O(\cdot)O(⋅) hides it, and it makes lg⁡n≥2\lg n \ge 2lgn≥2 and lg⁡(2)n≥1\lg^{(2)} n \ge 1lg(2)n≥1, so that the divisions are honest (Lean's x/0=0x/0 = 0x/0=0) and lg⁡(3)n≥0\lg^{(3)} n \ge 0lg(3)n≥0. Part 3 is the vertex-wise reading of "each connected component of ply one is a subtree of CCC with at most lg⁡(2)n\lg^{(2)} nlg(2)n vertices": since ply one is closed under taking CCC-descendants, the component of a ply-one vertex is the CCC-subtree of its shallowest ply-one ancestor, and that subtree's size is bounded because its root lies in ply one.

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

theorem lemma9_plies {V : Type*} [Fintype V] [DecidableEq V] (T : RootedTree V)
    (hn : 4 ≤ Fintype.card V) :
    ((ply3 T).card : ℝ) ≤ 4 * (Fintype.card V : ℝ) / Real.logb 2 (Fintype.card V) ∧
    ((ply2 T).card : ℝ) ≤
      4 * (Fintype.card V : ℝ) / Real.logb 2 (Real.logb 2 (Fintype.card V)) ∧
    ∀ v ∈ ply1 T,
      (∀ u : V, IsAncestorC T v u → u ∈ ply1 T) ∧
      (sizeC T v : ℝ) ≤ Real.logb 2 (Real.logb 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, Lemma 9 and its proof
Read-back

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

Fix a finite type VVV with decidable equality, and write n=∣V∣n = |V|n=∣V∣ for its number of elements. Let TTT be any value of type RootedTree V, a structure from the imported bundle HarelTarjan.Compressed. Its definition is not included in the code under audit. The only hypothesis is

n≥4.n \ge 4 .n≥4.

The statement uses four more objects from the imported bundle, and their definitions are not given here either. They are used only as follows:

  • ply1(T)\mathrm{ply}_1(T)ply1​(T), ply2(T)\mathrm{ply}_2(T)ply2​(T) and ply3(T)\mathrm{ply}_3(T)ply3​(T) are finite collections, since each one has a cardinality and supports membership. The statement treats ply1(T)\mathrm{ply}_1(T)ply1​(T) as a collection of elements of VVV.
  • IsAncestorCT(v,u)\mathrm{IsAncestorC}_T(v,u)IsAncestorCT​(v,u) is a relation between two elements v,uv, uv,u of VVV. The code does not say which direction counts as "ancestor".
  • sizeCT(v)\mathrm{sizeC}_T(v)sizeCT​(v) is a quantity attached to each v∈Vv \in Vv∈V, converted to a real number for the comparison.

Nothing in the statement says what these objects are. In particular it does not say that the three plies are disjoint or that together they cover VVV. Every property below is a property of whatever these definitions compute.

The theorem claims that all three of the following hold together, with log⁡2\log_2log2​ the real base-2 logarithm:

  1. The third ply is small:
∣ply3(T)∣  ≤  4nlog⁡2n.|\mathrm{ply}_3(T)| \;\le\; \frac{4n}{\log_2 n}.∣ply3​(T)∣≤log2​n4n​.
  1. The second ply is small:
∣ply2(T)∣  ≤  4nlog⁡2log⁡2n.|\mathrm{ply}_2(T)| \;\le\; \frac{4n}{\log_2 \log_2 n}.∣ply2​(T)∣≤log2​log2​n4n​.
  1. The first ply has two properties. For every v∈ply1(T)v \in \mathrm{ply}_1(T)v∈ply1​(T):
    • (a) every u∈Vu \in Vu∈V with IsAncestorCT(v,u)\mathrm{IsAncestorC}_T(v,u)IsAncestorCT​(v,u) is also in ply1(T)\mathrm{ply}_1(T)ply1​(T), so the first ply is closed under that relation, in the argument order written; and
    • (b) the size is bounded:
sizeCT(v)  ≤  log⁡2log⁡2n.\mathrm{sizeC}_T(v) \;\le\; \log_2 \log_2 n .sizeCT​(v)≤log2​log2​n.

The three parts are joined by "and". Each bound uses the constant 4, and the inequalities are non-strict (≤\le≤).

Degenerate cases. The hypothesis n≥4n \ge 4n≥4 rules out an empty or one-element VVV. It also means log⁡2n≥2\log_2 n \ge 2log2​n≥2 and log⁡2log⁡2n≥1\log_2 \log_2 n \ge 1log2​log2​n≥1. So both denominators are strictly positive, no division by zero happens, and no logarithm is taken of a non-positive number. Every bound is therefore a real, positive number, not a default value. At the smallest allowed size, n=4n = 4n=4:

  • the bound on ∣ply3(T)∣|\mathrm{ply}_3(T)|∣ply3​(T)∣ is 16/2=816/2 = 816/2=8;
  • the bound on ∣ply2(T)∣|\mathrm{ply}_2(T)|∣ply2​(T)∣ is 16/1=1616/1 = 1616/1=16;
  • the bound on sizeCT(v)\mathrm{sizeC}_T(v)sizeCT​(v) for v∈ply1(T)v \in \mathrm{ply}_1(T)v∈ply1​(T) is 111.

If ply1(T)\mathrm{ply}_1(T)ply1​(T) is empty, part 3 holds trivially. Whether any of the conclusions is trivial for other reasons, for example because a ply is always empty or sizeC\mathrm{sizeC}sizeC is always 000, depends on the imported definitions, which the code under audit does not show.

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