Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Lemma 1 — the height of vvv is the largest hhh with 2h∣sym(v)2^h \mid \mathrm{sym}(v)2h∣sym(v)

Proved
HarelTarjan.SymOrder.lemma1_height_eq_max_pow_two_dvd

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

binary-treenumber-theoryp2o-batch-p100bp2o-gran-per-chapterp2o-plan-paperp2o-v1trees

Let TTT be the complete binary tree of depth ddd, numbered in symmetric order. The height h(v)h(v)h(v) of a vertex vvv is the largest integer hhh such that 2h2^h2h divides sym(v)\mathrm{sym}(v)sym(v):

2h(v)∣sym(v)and2h(v)+1∤sym(v).2^{h(v)} \mid \mathrm{sym}(v) \quad\text{and}\quad 2^{h(v)+1} \nmid \mathrm{sym}(v).2h(v)∣sym(v)and2h(v)+1∤sym(v).

Lemma 1 lets the height of a vertex be read off its number, the 2-adic valuation of sym(v)\mathrm{sym}(v)sym(v).

Preamble
import Mathlib
import Definitions.Def_HarelTarjan_SymOrder_Tree
import Definitions.Def_HarelTarjan_SymOrder_Sym
Formal statement
namespace HarelTarjan.SymOrder

/-- Lemma 1 (p. 342): the height of a vertex `v` is the largest integer `h` such that `2^h`
divides `sym(v)`. -/
theorem lemma1_height_eq_max_pow_two_dvd {d : ℕ} (v : Vertex d) :
    2 ^ height v ∣ sym v ∧ ¬ 2 ^ (height v + 1) ∣ sym v := by sorry

end HarelTarjan.SymOrder
Source
Harel, Tarjan, Fast Algorithms for Finding Nearest Common Ancestors, SIAM J. Comput. 13 (1984), p. 342, Lemma 1
Read-back

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

This theorem relates height to divisibility of sym⁡\operatorname{sym}sym. Let d∈Nd\in\mathbb Nd∈N and let TdT_dTd​ be the set of boolean sequences of length ≤d\le d≤d. The height of vvv is h(v)=d−∣sv∣h(v)=d-|s_v|h(v)=d−∣sv​∣. The number sym⁡(v)\operatorname{sym}(v)sym(v) counts the u∈Tdu\in T_du∈Td​ with κ(u)≤lexκ(v)\kappa(u)\le_{\mathrm{lex}}\kappa(v)κ(u)≤lex​κ(v). The key κ\kappaκ replaces false by 000 and true by 222 and appends 111, and the order is lexicographic with a proper prefix counting as smaller.

For every vertex vvv, the theorem asserts

2h(v)∣sym⁡(v)and2h(v)+1∤sym⁡(v).2^{h(v)}\mid\operatorname{sym}(v)\quad\text{and}\quad 2^{h(v)+1}\nmid\operatorname{sym}(v).2h(v)∣sym(v)and2h(v)+1∤sym(v).

In other words, h(v)h(v)h(v) is exactly the exponent of 222 in sym⁡(v)\operatorname{sym}(v)sym(v).

Degenerate cases:

  • Leaves have h=0h=0h=0, so the claim there is that sym⁡(v)\operatorname{sym}(v)sym(v) is odd.
  • For d=0d=0d=0, the claim is that the root's number, 111, is odd.
  • Since sym⁡(v)≥1\operatorname{sym}(v)\ge1sym(v)≥1, the case "2k2^k2k divides 000" never arises.
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 paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me