Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Lemma 6 — every edge v→pC(v)v \to p_C(v)v→pC​(v) of CCC satisfies 2⋅sizeC(v)≤sizeC(pC(v))2\cdot\mathrm{size}_C(v) \le \mathrm{size}_C(p_C(v))2⋅sizeC​(v)≤sizeC​(pC​(v))

Proved
HarelTarjan.Compressed.lemma6_sizeC_doubles

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 with root rrr and CCC its compressed tree. Every edge v→pC(v)v \to p_C(v)v→pC​(v) of CCC, that is, every vertex v≠rv \ne rv=r, satisfies

2⋅sizeC(v)≤sizeC(pC(v)).2\cdot \mathrm{size}_C(v) \le \mathrm{size}_C(p_C(v)).2⋅sizeC​(v)≤sizeC​(pC​(v)).

Sizes in CCC at least double from child to parent. This is the fact behind the shallow depth of CCC (Lemma 7) and the rank counting of Lemma 8.

Formalization Note The hypothesis v≠rv \ne rv=r expresses that v→pC(v)v \to p_C(v)v→pC​(v) is an edge of CCC; for the root, where the Lean map has pC(r)=rp_C(r) = rpC​(r)=r, the inequality would be false.

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 lemma6_sizeC_doubles {V : Type*} [Fintype V] [DecidableEq V] (T : RootedTree V) (v : V)
    (hv : v ≠ T.root) :
    2 * sizeC T v ≤ sizeC T (pC T v) := by sorry

end HarelTarjan.Compressed
Source
Harel, Tarjan, Fast Algorithms for Finding Nearest Common Ancestors, SIAM J. Comput. 13 (1984), p. 344, Lemma 6
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.

vvv is any vertex with v≠rv \ne rv=r.

Definitions used.

  • size⁡T(w)\operatorname{size}_T(w)sizeT​(w) is the number of uuu with pi(u)=wp^i(u) = wpi(u)=w for some i≥0i \ge 0i≥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)=pk(x)\operatorname{apex}(x) = p^k(x)apex(x)=pk(x) for the least k≥0k \ge 0k≥0 with pk(x)p^k(x)pk(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 pCi(u)=wp_C^i(u) = wpCi​(u)=w for some i≥0i \ge 0i≥0, including www itself.

Statement. The theorem asserts

2 size⁡C(v)≤size⁡C(pC(v)),2\,\operatorname{size}_C(v) \le \operatorname{size}_C\big(p_C(v)\big),2sizeC​(v)≤sizeC​(pC​(v)),

where pC(v)=apex⁡(p(v))p_C(v) = \operatorname{apex}(p(v))pC​(v)=apex(p(v)) because v≠rv \ne rv=r. The inequality is non-strict.

The statement applies to every non-root vertex. It is not restricted to apex vertices.

Degenerate cases. If VVV has exactly one element, no vertex satisfies v≠rv \ne rv=r, so the statement is vacuously true. For the root itself nothing is asserted.

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