Truly subcubic all-pairs shortest paths
Lax350013.APSP · concepts/Lax350013/APSP.lean · lax-350013
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Theorem
All-pairs shortest paths in a directed graph with vertices, polynomially bounded integer edge weights and no negative cycles can be computed deterministically in word-RAM steps (Theorem 22). Each output pair contains a reachability flag and, when reachable, the minimum weight of a path. Paths may repeat vertices.
Concept map
Evidence
Each proof establishes this claim relative to its assumptions.
Lean source view on GitHub
| 1 | /- |
| 2 | Copyright (c) 2026 Anthropic, PBC. All rights reserved. |
| 3 | Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | SPDX-License-Identifier: Apache-2.0 |
| 5 | -/ |
| 6 | /- |
| 7 | Modified for the independent Lax packaging by Édouard Bonnet, 2026. |
| 8 | Derived from 3sum-apsp/EndStatement.lean / PaperStatements.lean at upstream commit e1a4e6508154ea59f030480661590a9fe3018011. |
| 9 | Changes: Lax module/namespace layout, separated concepts and proofs, archive |
| 10 | annotations, and compatibility with the archive Lean/mathlib environment. |
| 11 | See NOTICE and README.md in the submission root for provenance and scope. |
| 12 | -/ |
| 13 | |
| 14 | import Lax350013.PolynomialTime |
| 15 | |
| 16 | /-! |
| 17 | --- |
| 18 | title: Truly subcubic all-pairs shortest paths |
| 19 | type: theorem |
| 20 | --- |
| 21 | All-pairs shortest paths in a directed graph with vertices, polynomially bounded integer edge weights and no negative cycles can be computed deterministically in word-RAM steps (Theorem 22). Each output pair contains a reachability flag and, when reachable, the minimum weight of a path. Paths may repeat vertices. |
| 22 | -/ |
| 23 | |
| 24 | namespace Lax350013.APSP |
| 25 | |
| 26 | open Lax350013.PolynomialTime |
| 27 | |
| 28 | /-- A path and its total weight; it may repeat vertices. -/ |
| 29 | inductive Path {n : Nat} (w : Fin n → Fin n → Option Int) : Fin n → Fin n → Int → Prop |
| 30 | | nil (i : Fin n) : Path w i i 0 |
| 31 | | cons {i j k : Fin n} {d e : Int} : w i j = some d → Path w j k e → Path w i k (d + e) |
| 32 | |
| 33 | /-- Input: the 0/1 matrix of the edges, then the weights, with 0 for no edge. Output, two cells for each `(i, j)`: 1 if |
| 34 | there is a path, else 0; then the distance. -/ |
| 35 | def APSP : Problem where |
| 36 | Instance n := {w : Fin n → Fin n → Option Int // ∀ i d, Path w i i d → 0 ≤ d} |
| 37 | input := fun ⟨w, _⟩ => rowByRow (fun i j => if (w i j).isSome then 1 else 0) ++ rowByRow fun i j => (w i j).getD 0 |
| 38 | output := fun {n} ⟨w, _⟩ out => ∀ i j : Fin n, |
| 39 | let flag := out (2 * (i.val * n + j.val)) |
| 40 | let dist := out (2 * (i.val * n + j.val) + 1) |
| 41 | (flag = 1 ∧ Path w i j dist ∧ ∀ e, Path w i j e → dist ≤ e) ∨ (flag = 0 ∧ ∀ e, ¬ Path w i j e) |
| 42 | |
| 43 | /-- Theorem 22: «APSP on directed n-vertex graphs … and no negative cycles», in time «O(n^2.99942)». -/ |
| 44 | def Theorem_22_APSP : Prop := |
| 45 | APSP.SolvedInTime 2.99942 |
| 46 | |
| 47 | /-- Truly subcubic all-pairs shortest paths: Theorem 22 APSP. -/ |
| 48 | axiom algorithm : Theorem_22_APSP |
| 49 | |
| 50 | end Lax350013.APSP |
| 51 |
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments