Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

One query settles half of nnn hyperplanes in R1\mathbb{R}^1R1: A(1)=1A(1)=1A(1)=1, B(1)=12B(1)=\tfrac12B(1)=21​

Proved
MegiddoLP.FixedDim.one_query_halves

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

medianmultidimensional-searchp2o-batch-p100ap2o-gran-per-chapterp2o-plan-paperp2o-v1query-complexity

Let n≥0n\ge0n≥0 and let a1,…,ana_1,\dots,a_na1​,…,an​ be nonzero reals and b1,…,bnb_1,\dots,b_nb1​,…,bn​ reals, defining the "hyperplanes" Hi={x∈R:aix=bi}H_i=\{x\in\mathbb{R}: a_ix=b_i\}Hi​={x∈R:ai​x=bi​} of the line. Then there is a query strategy TTT (a hyperplane-query decision tree built from the data) such that for every unknown point x∈Rx\in\mathbb{R}x∈R:

  1. TTT makes at most one query on xxx;
  2. every position that TTT reports for xxx is correct: if TTT reports "<<<", "===" or ">>>" for HiH_iHi​, then aix<bia_ix<b_iai​x<bi​, aix=bia_ix=b_iai​x=bi​ or aix>bia_ix>b_iai​x>bi​ respectively;
  3. TTT reports a position for at least half of the hyperplanes:
n≤2⋅#{i: T reports the position of x relative to Hi}.n\le 2\cdot\#\{i:\ T \text{ reports the position of } x \text{ relative to } H_i\}.n≤2⋅#{i: T reports the position of x relative to Hi​}.

This is the one-dimensional base of Megiddo's multidimensional search. A query at the median of the points bi/aib_i/a_ibi​/ai​ settles every point on the far side of the median. In the paper's notation, A(1)=1A(1)=1A(1)=1 query suffices for a fraction B(1)=12B(1)=\tfrac12B(1)=21​ of the hyperplanes.

Formalization Note Points are Fin 1 → ℝ, and each aia_iai​ is a nonzero vector in R1\mathbb{R}^1R1. The strategy's output assigns to each iii either nothing or a position (Option Ordering). "Half" is stated as n≤2⋅#n\le2\cdot\#n≤2⋅#settled, which for odd nnn means at least ⌈n/2⌉\lceil n/2\rceil⌈n/2⌉.

Preamble
import Mathlib
import Definitions.Def_MegiddoLP_FixedDim_QueryTree
Formal statement
/-!
Megiddo, J. ACM 31 (1984), §3.1 p. 117 and §3.2 p. 118: in dimension one a single query
(at the median) settles the position of `x*` relative to at least half of `n` given
hyperplanes, i.e. `A(1) = 1`, `B(1) = 1/2`.
-/

namespace MegiddoLP.FixedDim

/-- **`A(1) = 1`, `B(1) = 1/2`.** For `n` hyperplanes `{x ∈ ℝ | aᵢ x = bᵢ}` with `aᵢ ≠ 0`
there is a strategy making at most one query which, for every unknown point `x`, reports
correct positions (`lt`/`eq`/`gt` of `aᵢ x` against `bᵢ`) for at least half of the hyperplanes
(`n ≤ 2 · #settled`). -/
theorem one_query_halves (n : ℕ) (a : Fin n → Fin 1 → ℝ) (b : Fin n → ℝ)
    (ha : ∀ i, a i ≠ 0) :
    ∃ T : QTree 1 (Fin n → Option Ordering), ∀ x : Fin 1 → ℝ,
      T.numQueries x ≤ 1 ∧
      (∀ i o, T.eval x i = some o → compare (a i ⬝ᵥ x) (b i) = o) ∧
      n ≤ 2 * (Finset.univ.filter fun i => (T.eval x i).isSome).card := by sorry

end MegiddoLP.FixedDim
Source
Megiddo, Linear Programming in Linear Time When the Dimension Is Fixed, J. ACM 31(1) (1984) 114–127, §3.1, p. 117 (median query) and §3.2, p. 118 (A(1) = 1, B(1) = 1/2)
Read-back

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

Setting. Let n∈Nn \in \mathbb{N}n∈N. For each index i∈{0,…,n−1}i \in \{0,\dots,n-1\}i∈{0,…,n−1} let ai∈R1a_i \in \mathbb{R}^1ai​∈R1, viewed as a real number, and bi∈Rb_i \in \mathbb{R}bi​∈R. The only hypothesis is that each ai≠0a_i \ne 0ai​=0.

Claim. There exists a query tree TTT, as in the QueryTree definition: a finite ternary tree of hyperplane queries in R1\mathbb{R}^1R1. Its leaves carry functions assigning to each index iii either "no report" or a report oi∈{<,=,>}o_i \in \{<,=,>\}oi​∈{<,=,>}. For every point x∈Rx \in \mathbb{R}x∈R, with T(x)T(x)T(x) the resulting assignment and NT(x)N_T(x)NT​(x) the number of queries on the path followed by xxx:

  1. At most one query: NT(x)≤1N_T(x) \le 1NT​(x)≤1.
  2. Correctness: for every iii and every o∈{<,=,>}o \in \{<,=,>\}o∈{<,=,>}, if T(x)T(x)T(x) reports ooo for index iii, then aixa_i xai​x stands in relation ooo to bib_ibi​. That is, aix<bia_i x < b_iai​x<bi​, aix=bia_i x = b_iai​x=bi​, or aix>bia_i x > b_iai​x>bi​ respectively.
  3. Coverage:
n≤2⋅#{i:T(x) gives a report for i}.n \le 2\cdot\#\{i : T(x) \text{ gives a report for } i\}.n≤2⋅#{i:T(x) gives a report for i}.

Equivalently, at least ⌈n/2⌉\lceil n/2\rceil⌈n/2⌉ indices receive a report.

The tree TTT is chosen once, depending on nnn, aaa and bbb, and must then work for every xxx. Its reports depend on xxx only through the answer to the at most one query.

Degenerate cases.

  • n=0n = 0n=0. The claim holds with a single leaf that reports nothing.
  • n=1n = 1n=1. Coverage forces the single index to be reported, correctly, for every xxx, using at most one query.
  • The hypothesis ai≠0a_i \ne 0ai​=0 is satisfiable for every nnn.
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