Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

The threshold graph and its median threshold

Proved
DetANN.HPIM.median_threshold

by milia · Nov 16, 2026 · Mathlib 0df444a (Lean v4.33.1)

approximate-nearest-neighborcomputational-geometrydata-structures

Let P1,…,Pn∈RmP_1,\dots,P_n\in\mathbb R^mP1​,…,Pn​∈Rm (definition DetANN_HPIMThreshold).

  1. If d≥0d\ge0d≥0, two points in the same component of the threshold graph at ddd are within (n−1)d(n-1)d(n−1)d.
  2. Every component has a representative.
  3. If some component at ddd has at least ⌊n/2⌋+1\lfloor n/2\rfloor+1⌊n/2⌋+1 points, there are at most ⌈n/2⌉\lceil n/2\rceil⌈n/2⌉ representatives at ddd.
  4. If n≥2n\ge2n≥2 and the points are distinct, let d∗d^\astd∗ be the median threshold. Then some component at d∗d^\astd∗ has at least ⌊n/2⌋+1\lfloor n/2\rfloor+1⌊n/2⌋+1 points, d∗>0d^\ast>0d∗>0, and for every d<d∗d<d^\astd<d∗ every component at ddd has at most ⌊n/2⌋\lfloor n/2\rfloor⌊n/2⌋ points.

These are the facts about rmed=d∗/2r_{\mathrm{med}}=d^\ast/2rmed​=d∗/2 that the tree of Har-Peled, Indyk and Motwani (2012, §2) uses. Recursing into a component at the lower threshold, or into the representatives at d∗d^\astd∗, at least halves the point set, so the tree has depth O(log⁡n)O(\log n)O(logn). Item 1 bounds the diameters, and with them the length of the ladder of radii.

Preamble
import Mathlib
import Definitions.Def_DetANN_HPIMThreshold
Formal statement
namespace DetANN.HPIM

open Classical in
/-- **The threshold graph and its median threshold.** For points `P_1, …, P_n ∈ ℝ^m` and `d ∈ ℝ`:
1. points in the same component of the threshold graph at `d ≥ 0` are within `(n − 1) d`;
2. every component has a representative (its least index);
3. if some component has at least `⌊n/2⌋ + 1` points, there are at most `⌈n/2⌉` representatives;
4. if `n ≥ 2` and the points are distinct, then at `d = medThreshold P` some component has at least
   `⌊n/2⌋ + 1` points, `medThreshold P > 0`, and at every `d < medThreshold P` every component has at
   most `⌊n/2⌋` points. -/
theorem median_threshold {m n : ℕ} (P : Fin n → EuclideanSpace ℝ (Fin m)) :
    (∀ d : ℝ, 0 ≤ d → ∀ i j, thrReach P d i j → dist (P i) (P j) ≤ ((n : ℝ) - 1) * d) ∧
    (∀ (d : ℝ) (i : Fin n), ∃ j, thrReach P d i j ∧ IsRep P d j) ∧
    (∀ (d : ℝ) (i₀ : Fin n), n / 2 + 1 ≤ (Finset.univ.filter (thrReach P d i₀)).card →
      (Finset.univ.filter (IsRep P d)).card ≤ (n + 1) / 2) ∧
    (2 ≤ n → Function.Injective P →
      (∃ i, n / 2 + 1 ≤ (Finset.univ.filter (thrReach P (medThreshold P) i)).card) ∧
      0 < medThreshold P ∧
      ∀ d < medThreshold P, ∀ i, (Finset.univ.filter (thrReach P d i)).card ≤ n / 2) := by sorry

end DetANN.HPIM
Source
Original, written for the mission 'Deterministic Approximate Nearest Neighbors in High Dimensions' as part of a floor-free proof of DetANN.lemma_3_3 (Feng, Indyk, STOC 2027 submission, Lemma 3.3, p.7). The search tree follows Har-Peled, Indyk, Motwani, Approximate nearest neighbor: towards removing the curse of dimensionality, Theory of Computing 8 (2012), §2, made deterministic and floor-free.

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