Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Proof of Theorem 1 (p. 340) — a query answered in kkk steps reaches only nodes accessible in kkk steps

Proved
HarelTarjan.PointerLB.answered_mem_acc

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

lower-boundp2o-batch-p100bp2o-gran-per-chapterp2o-plan-paperp2o-v1pointer-machine

Consider a list structure in which every node has two pointer fields. Let a,ba, ba,b be the input nodes of a query and ccc a node. If the query with answer ccc can be answered in kkk steps, that is, some run of at most kkk pointer-following steps from a,ba, ba,b holds a pointer to ccc, then

c∈acck(a)∪acck(b),c \in \mathrm{acc}_k(a) \cup \mathrm{acc}_k(b),c∈acck​(a)∪acck​(b),

where acck(a)\mathrm{acc}_k(a)acck​(a) is the set of nodes accessible from aaa in kkk steps or less.

Contrapositively, a node accessible from neither input in kkk steps cannot be returned in kkk steps. This is the step from the machine to accessibility in the proof of Theorem 1: "w would be accessible from neither x nor y in k steps, and an nca query on x and y would be unanswerable in k steps."

Preamble
import Mathlib
import Definitions.Def_HarelTarjan_PointerLB_BinaryTree
import Definitions.Def_HarelTarjan_PointerLB_PointerMachine
Formal statement
namespace HarelTarjan.PointerLB

theorem answered_mem_acc {N : Type*} (ptr : N → Fin 2 → Option N) (a b target : N) (k : ℕ)
    (hans : AnsweredIn ptr a b target k) :
    target ∈ acc ptr k a ∪ acc ptr k b := by sorry

end HarelTarjan.PointerLB
Source
Harel, Tarjan, Fast Algorithms for Finding Nearest Common Ancestors, SIAM J. Comput. 13 (1984), p. 340, proof of Theorem 1, first paragraph, last sentence
Read-back

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

Let NNN be any type of nodes. Let ptr\mathrm{ptr}ptr be a pointer structure: it assigns to each node mmm and field i∈{0,1}i\in\{0,1\}i∈{0,1} either a node ptr(m,i)\mathrm{ptr}(m,i)ptr(m,i) or nil. Let aaa, bbb and τ\tauτ be nodes, and let k∈Nk\in\mathbb{N}k∈N.

The accessible sets are defined by:

acc0(a)={a},accj+1(a)=accj(a)∪{n:∃m∈accj(a), ∃i, ptr(m,i)=n}.\mathrm{acc}_0(a)=\{a\},\qquad \mathrm{acc}_{j+1}(a)=\mathrm{acc}_j(a)\cup\{n:\exists m\in\mathrm{acc}_j(a),\ \exists i,\ \mathrm{ptr}(m,i)=n\}.acc0​(a)={a},accj+1​(a)=accj​(a)∪{n:∃m∈accj​(a), ∃i, ptr(m,i)=n}.

A run works as follows:

  • It starts at step 000 holding the list [a,b][a,b][a,b].
  • Each step picks a held node mmm and a field iii with ptr(m,i)=n\mathrm{ptr}(m,i)=nptr(m,i)=n non-nil, and adds nnn to the held list.

Hypothesis: some run of t≤kt\le kt≤k steps holds τ\tauτ.

Conclusion:

τ∈acck(a) ∪ acck(b).\tau\in\mathrm{acc}_k(a)\ \cup\ \mathrm{acc}_k(b).τ∈acck​(a) ∪ acck​(b).

Degenerate cases. With k=0k=0k=0, the hypothesis means τ∈{a,b}\tau\in\{a,b\}τ∈{a,b}, and the conclusion is the same statement. If a=ba=ba=b, the conclusion is τ∈acck(a)\tau\in\mathrm{acc}_k(a)τ∈acck​(a). No finiteness or other condition is placed on NNN or ptr\mathrm{ptr}ptr.

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