Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Exact rational LP systems and certificate checks

Definition
Kepler_LPLinearSystem

by Minghui · Sep 27, 2026 · Mathlib c5ea003 (Lean v4.30.0)

discrete-geometrykeplersphere-packing

For arbitrary natural numbers m,nm,nm,n, including 000, a rational linear system is a matrix A∈Qm×nA\in\mathbb Q^{m\times n}A∈Qm×n together with bounds b∈Qmb\in\mathbb Q^mb∈Qm. A real vector x∈Rnx\in\mathbb R^nx∈Rn is feasible exactly when ∑j=0n−1Aijxj≤bi\sum_{j=0}^{n-1}A_{ij}x_j\leq b_i∑j=0n−1​Aij​xj​≤bi​ for every 0≤i<m0\leq i<m0≤i<m, with rational coefficients interpreted in R\mathbb RR; there is no sign restriction on xxx. For any rational vector y∈Qmy\in\mathbb Q^my∈Qm, the Boolean test returns true exactly when yi≥0y_i\geq0yi​≥0 for every row, ∑i=0m−1yiAij=0\sum_{i=0}^{m-1}y_iA_{ij}=0∑i=0m−1​yi​Aij​=0 for every column, and ∑i=0m−1yibi<0\sum_{i=0}^{m-1}y_ib_i<0∑i=0m−1​yi​bi​<0. All three conditions are tested with exact rational arithmetic. If m=0m=0m=0, feasibility is vacuous and the test is false because its final sum is 000. If n=0n=0n=0, there is one empty real vector, its feasibility means 0≤bi0\leq b_i0≤bi​ for every row, and the column conditions on yyy are vacuous. This bundle defines the system, feasibility predicate and test; it contains no assertion that a particular system is infeasible or that a test input exists.

Source and scope. Primary §9 pp.21–24; Solovyev–Hales (2011), Efficient Formal Verification of Bounds of Linear Programs, §§2–3 pp.2–7; final more_arith/prove_lp.hl:215–228,339–349. Generic rational-system and multiplier semantics; no solver verdict is assumed.

Definition code
/-
Flyspeck source material is reproduced and adapted under this license:
MIT License

Copyright (c) 2014 Thomas C. Hales

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

-/
import Mathlib.Data.Matrix.Basic
import Mathlib.Algebra.BigOperators.Ring.Finset
import Mathlib.Data.Rat.Cast.Order
import Mathlib.Data.Real.Basic

set_option autoImplicit false

open scoped BigOperators

namespace KeplerMission

/-- Rational linear inequalities, with real-valued feasible vectors. -/
structure RationalSystem (m n : ℕ) where
  matrix : Matrix (Fin m) (Fin n) ℚ
  rhs : Fin m → ℚ

def RationalSystem.Feasible {m n : ℕ} (S : RationalSystem m n) (x : Fin n → ℝ) : Prop :=
  ∀ i, ∑ j, (S.matrix i j : ℝ) * x j ≤ (S.rhs i : ℝ)

/-- Exact Farkas-style nonnegative row multipliers, not a floating-point solver verdict.
Source interface: Hales et al. (2017), §9, published PDF pp. 23–24. -/
def RationalSystem.checkInfeasibility {m n : ℕ} (S : RationalSystem m n)
    (y : Fin m → ℚ) : Bool :=
  decide ((∀ i, 0 ≤ y i) ∧
    (∀ j, ∑ i, y i * S.matrix i j = 0) ∧ (∑ i, y i * S.rhs i) < 0)

end KeplerMission
Source
Hales et al. (2017), A Formal Proof of the Kepler Conjecture, https://doi.org/10.1017/fmp.2017.1; Primary §9 pp.21–24; Solovyev–Hales (2011), Efficient Formal Verification of Bounds of Linear Programs, §§2–3 pp.2–7; final more_arith/prove_lp.hl:215–228,339–349. Generic rational-system and multiplier semantics; no solver verdict is assumed.; https://github.com/flyspeck/flyspeck/tree/1ce0353008eba83d3c76ae9a25c3c242e4802d53
Read-back

What the Lean code literally says, in plain math · gpt-6

For arbitrary natural numbers m,nm,nm,n, including 000, a rational linear system is a matrix A∈Qm×nA\in\mathbb Q^{m\times n}A∈Qm×n together with bounds b∈Qmb\in\mathbb Q^mb∈Qm. A real vector x∈Rnx\in\mathbb R^nx∈Rn is feasible exactly when ∑j=0n−1Aijxj≤bi\sum_{j=0}^{n-1}A_{ij}x_j\leq b_i∑j=0n−1​Aij​xj​≤bi​ for every 0≤i<m0\leq i<m0≤i<m, with rational coefficients interpreted in R\mathbb RR; there is no sign restriction on xxx. For any rational vector y∈Qmy\in\mathbb Q^my∈Qm, the Boolean test returns true exactly when yi≥0y_i\geq0yi​≥0 for every row, ∑i=0m−1yiAij=0\sum_{i=0}^{m-1}y_iA_{ij}=0∑i=0m−1​yi​Aij​=0 for every column, and ∑i=0m−1yibi<0\sum_{i=0}^{m-1}y_ib_i<0∑i=0m−1​yi​bi​<0. All three conditions are tested with exact rational arithmetic. If m=0m=0m=0, feasibility is vacuous and the test is false because its final sum is 000. If n=0n=0n=0, there is one empty real vector, its feasibility means 0≤bi0\leq b_i0≤bi​ for every row, and the column conditions on yyy are vacuous. This bundle defines the system, feasibility predicate and test; it contains no assertion that a particular system is infeasible or that a test input exists.

Human review
  • Endorsed by Shuze Chen · Sep 27, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Minghui · 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