Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Model sanity, real RAM: one-variable LP in linear time

Proved
SmaleNinth.real_ram_decides_one_variable_lp_linear

by Zexuan Liu · Sep 8, 2026 · Mathlib 0df444a (Lean v4.33.1)

linear-programmingrandom-access-machinereal-computationupper-bounds

On the real pointer machine of Definitions.Def_SmaleNinth_RealRAM (real registers, integer pointer registers, a memory indexed by Z\mathbb{Z}Z, unit cost per instruction, indirect addressing through pointers), one-variable linear programming feasibility is decidable in linear time.

Precisely: there are a single program RRR and a constant CCC such that for every mmm, every A∈Rm×1A \in \mathbb{R}^{m \times 1}A∈Rm×1 and every b∈Rmb \in \mathbb{R}^mb∈Rm, the machine started with memory encodeLP A b halts within C (m+1)C\,(m+1)C(m+1) steps, and it accepts exactly when the system aix≥bia_i x \ge b_iai​x≥bi​, i<mi < mi<m, has a solution x∈Rx \in \mathbb{R}x∈R.

The algorithm is the obvious sweep: maintain the running lower bound L=max⁡{bi/ai:ai>0}L = \max\{b_i/a_i : a_i > 0\}L=max{bi​/ai​:ai​>0}, the running upper bound R=min⁡{bi/ai:ai<0}R = \min\{b_i/a_i : a_i < 0\}R=min{bi​/ai​:ai​<0}, presence flags for the two, and a flag recording whether some constraint with ai=0a_i = 0ai​=0 and bi>0b_i > 0bi​>0 has been seen; the system is feasible iff no such constraint occurs and L≤RL \le RL≤R whenever both bounds are present. Each constraint costs O(1)O(1)O(1) instructions because the coefficient aia_iai​ and the right-hand side bib_ibi​ are reached through two pointers that are incremented once per step.

This is the exact counterpart, in the random-access model, of the milestone statement SmaleNinth.bss_decides_one_variable_lp, which is false in the fixed-address tape model: there the two halves of a constraint sit mmm cells apart and a crossing-sequence argument forces Ω(m2)\Omega(m^2)Ω(m2) steps (SmaleNinth.bss_one_variable_lp_no_linear_program). Together the two statements separate the two machine models at linear time and show that the quadratic overhead of the compiler SmaleNinth.ram_to_bss_quadratic_nonneg is not an artifact of the construction.

Preamble
import Definitions.Def_Polyhedron
import Definitions.Def_SmaleNinth_BSSMachine
import Definitions.Def_SmaleNinth_RealRAM

/-!
Model sanity for the random-access model of `Definitions.Def_SmaleNinth_RealRAM`:
one-variable LP feasibility is decided in linear time by a uniform program of
the real pointer machine, on the same input encoding `encodeLP` used for the
tape machine.

Source: the standard sweep algorithm for one-dimensional linear programming
(maintain the running interval of feasible values, cf. N. Megiddo, *Linear-time
algorithms for linear programming in R^3 and related problems*, SIAM J.
Comput. 12 (1983) 759-776, the trivial case n = 1), implemented on a unit-cost
real random-access machine with indirect addressing.
-/

open Matrix LinearOptimization

/-- **Model sanity, random-access form: one-variable LP in linear time.**
There is a uniform program of the real pointer machine deciding, for every
`m` and every one-variable system `a_i x >= b_i`, its feasibility within
`C*(m+1)` steps on the standard input encoding. -/
Formal statement
theorem SmaleNinth.real_ram_decides_one_variable_lp_linear :
    ∃ (R : RAMProgram) (C : ℕ),
      ∀ (m : ℕ) (A : Matrix (Fin m) (Fin 1) ℝ) (b : Fin m → ℝ),
        ∃ result : Bool,
          RAMDecidesInTime R (encodeLP A b) (C * (m + 1)) result ∧
          (result = true ↔ (polyhedron A b).Nonempty) := by sorry
Source
Sweep algorithm for one-dimensional linear programming; cf. N. Megiddo, Linear-time algorithms for linear programming in R^3 and related problems, SIAM J. Comput. 12 (1983) 759-776 (case n = 1), on the unit-cost real random-access machine of Definitions.Def_SmaleNinth_RealRAM with the encodeLP input convention of Definitions.Def_SmaleNinth_BSSMachine.

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