Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Positions relative to Hik(1)H^{(1)}_{ik}Hik(1)​ and Hik(2)H^{(2)}_{ik}Hik(2)​ determine the position relative to HiH_iHi​ or HkH_kHk​

Proved
MegiddoLP.FixedDim.pair_opposite_slopes

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

computational-geometrymultidimensional-searchp2o-batch-p100ap2o-gran-per-chapterp2o-plan-paperp2o-v1

Let d≥2d\ge2d≥2, let Hi={x∈Rd:aiTx=bi}H_i=\{x\in\mathbb{R}^d: a_i^Tx=b_i\}Hi​={x∈Rd:aiT​x=bi​} have nonnegative slope and Hk={x:akTx=bk}H_k=\{x: a_k^Tx=b_k\}Hk​={x:akT​x=bk​} nonpositive slope in the (x1,x2)(x_1,x_2)(x1​,x2​) plane, and assume

δ=ak1ai2−ak2ai1≠0.\delta=a_{k1}a_{i2}-a_{k2}a_{i1}\ne0.δ=ak1​ai2​−ak2​ai1​=0.

Let Hik(1)H^{(1)}_{ik}Hik(1)​ and Hik(2)H^{(2)}_{ik}Hik(2)​ be the paired hyperplanes. Then there is a rule FFF, depending only on ai,ak,bi,bka_i,a_k,b_i,b_kai​,ak​,bi​,bk​, that takes the two oracle answers (the position of xxx relative to Hik(1)H^{(1)}_{ik}Hik(1)​ and relative to Hik(2)H^{(2)}_{ik}Hik(2)​) and returns one of the two hyperplanes HiH_iHi​, HkH_kHk​ together with a position. For every point x∈Rdx\in\mathbb{R}^dx∈Rd the returned position is the true position of xxx relative to the returned hyperplane.

This is the claim of p. 119 that "if we know the position of x∗x^*x∗ relative to both of these hyperplanes, then we can readily tell the position of x∗x^*x∗ relative to one of either HiH_iHi​ or HkH_kHk​". Because the slopes have opposite signs, each pair of queries settles one member of each pair of hyperplanes.

Formalization Note The dimension is d+2d+2d+2 in Lean and x1,x2x_1,x_2x1​,x2​ are the indices 0, 1. The hypothesis δ≠0\delta\ne0δ=0 is the one the page's argument uses ("depending on the sign of ak1ai2−ak2ai1a_{k1}a_{i2}-a_{k2}a_{i1}ak1​ai2​−ak2​ai1​"). The page's own hypothesis, "the defining equations of HiH_iHi​ and HkH_kHk​ are linearly independent", does not imply δ≠0\delta\ne0δ=0: ai=(0,1,1)a_i=(0,1,1)ai​=(0,1,1) and ak=(0,1,0)a_k=(0,1,0)ak​=(0,1,0) are independent, both have slope 000, and δ=0\delta=0δ=0. Under the section's standing normalisation (p. 119: a basis in which aij≠0a_{ij}\ne0aij​=0 for all i,ji,ji,j), opposite slopes are nonzero and distinct, so δ=ai2ak2(si−sk)≠0\delta=a_{i2}a_{k2}(s_i-s_k)\ne0δ=ai2​ak2​(si​−sk​)=0; the hypothesis δ≠0\delta\ne0δ=0 therefore holds in the setting where the page applies the claim. The page's displayed inequalities print bnb_nbn​ where bkb_kbk​ is meant, and the Lean uses bkb_kbk​. The rule FFF returns a flag (true for HiH_iHi​, false for HkH_kHk​) and an Ordering.

Preamble
import Mathlib
import Definitions.Def_MegiddoLP_FixedDim_Pairing
Formal statement
/-!
Megiddo, J. ACM 31 (1984), §3.2 pp. 119–120 (Figure 1): if `Hᵢ` has nonnegative slope and
`H_k` nonpositive slope, then the positions of `x*` relative to `H⁽¹⁾_ik` and `H⁽²⁾_ik`
determine its position relative to one of `Hᵢ`, `H_k`. The paper's `x₁, x₂` are the indices
`0, 1` of `Fin (d + 2)`.
-/

namespace MegiddoLP.FixedDim

/-- **The pairing claim.** Let `Hᵢ = {aᵢ ⬝ᵥ x = bᵢ}` have nonnegative slope and
`H_k = {a_k ⬝ᵥ x = b_k}` nonpositive slope in the `(x₁, x₂)` plane, with
`a_k1 a_i2 - a_k2 a_i1 ≠ 0`. There is a rule `F`, depending only on the data, which maps the
oracle's answers for `H⁽¹⁾_ik` and `H⁽²⁾_ik` to a choice of `Hᵢ` (`true`) or `H_k` (`false`)
together with the correct position of `x` relative to the chosen hyperplane, for every `x`. -/
theorem pair_opposite_slopes {d : ℕ} (ai ak : Fin (d + 2) → ℝ) (bi bk : ℝ)
    (hi : HasNonnegSlope ai) (hk : HasNonposSlope ak)
    (hdet : ak 0 * ai 1 - ak 1 * ai 0 ≠ 0) :
    ∃ F : Ordering → Ordering → Bool × Ordering, ∀ x : Fin (d + 2) → ℝ,
      let r := F (compare (pairNormal1 ai ak ⬝ᵥ x) (pairRhs1 ai ak bi bk))
                 (compare (pairNormal2 ai ak ⬝ᵥ x) (pairRhs2 ai ak bi bk))
      (r.1 = true → compare (ai ⬝ᵥ x) bi = r.2) ∧
      (r.1 = false → compare (ak ⬝ᵥ x) bk = r.2) := 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.2, pp. 119–120 and Figure 1 (the pairing argument)
Read-back

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

Setting. Let d∈Nd \in \mathbb{N}d∈N, let ai,ak∈Rd+2a^i, a^k \in \mathbb{R}^{d+2}ai,ak∈Rd+2, and let bi,bk∈Rb_i, b_k \in \mathbb{R}bi​,bk​∈R. Write a1,a2a_1, a_2a1​,a2​ for the first two coordinates of a vector (positions 000 and 111 in the code).

Hypotheses.

  • aia^iai has nonnegative slope: a2i=0a^i_2 = 0a2i​=0, or −a1i/a2i≥0-a^i_1/a^i_2 \ge 0−a1i​/a2i​≥0.
  • aka^kak has nonpositive slope: a2k≠0a^k_2 \ne 0a2k​=0 and −a1k/a2k≤0-a^k_1/a^k_2 \le 0−a1k​/a2k​≤0.
  • The determinant condition:
a1ka2i−a2ka1i≠0.a^k_1 a^i_2 - a^k_2 a^i_1 \ne 0.a1k​a2i​−a2k​a1i​=0.

Derived hyperplanes. Define, for every coordinate jjj,

nj(1)=a1kaji−a1iajk,r(1)=a1kbi−a1ibk,nj(2)=a2kaji−a2iajk,r(2)=a2kbi−a2ibk.n^{(1)}_j = a^k_1 a^i_j - a^i_1 a^k_j,\quad r^{(1)} = a^k_1 b_i - a^i_1 b_k, \qquad n^{(2)}_j = a^k_2 a^i_j - a^i_2 a^k_j,\quad r^{(2)} = a^k_2 b_i - a^i_2 b_k.nj(1)​=a1k​aji​−a1i​ajk​,r(1)=a1k​bi​−a1i​bk​,nj(2)​=a2k​aji​−a2i​ajk​,r(2)=a2k​bi​−a2i​bk​.

Claim. There exists a single function FFF with two inputs, each in {<,=,>}\{<,=,>\}{<,=,>}. Its output is a pair (β,o)(\beta, o)(β,o), where β\betaβ is true or false and o∈{<,=,>}o \in \{<,=,>\}o∈{<,=,>}. The function FFF is chosen depending only on ai,ak,bi,bka^i, a^k, b_i, b_kai,ak,bi​,bk​.

For every x∈Rd+2x \in \mathbb{R}^{d+2}x∈Rd+2, let σ1\sigma_1σ1​ be the relation of n(1)⋅xn^{(1)}\cdot xn(1)⋅x to r(1)r^{(1)}r(1), and σ2\sigma_2σ2​ the relation of n(2)⋅xn^{(2)}\cdot xn(2)⋅x to r(2)r^{(2)}r(2). Put (β,o)=F(σ1,σ2)(\beta,o) = F(\sigma_1,\sigma_2)(β,o)=F(σ1​,σ2​). Then:

  • if β\betaβ is true, ai⋅xa^i\cdot xai⋅x stands in relation ooo to bib_ibi​;
  • if β\betaβ is false, ak⋅xa^k\cdot xak⋅x stands in relation ooo to bkb_kbk​.

Which of the two original hyperplanes gets reported may vary with the pair of answers.

Degenerate cases.

  • d=0d = 0d=0. Everything is in R2\mathbb{R}^2R2.
  • The determinant hypothesis excludes a1i=a2i=0a^i_1 = a^i_2 = 0a1i​=a2i​=0, so aia^iai cannot vanish in both of its first two coordinates.
  • No division by zero affects the hypotheses:
    • in the nonnegative-slope disjunction, the division occurs only in the branch where a2ia^i_2a2i​ may be nonzero;
    • the nonpositive slope requires a2k≠0a^k_2 \ne 0a2k​=0.
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