Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

APSP in O(n2.996001)O(n^{2.996001})O(n2.996001) word-RAM steps

Proved
TrulySubcubicAPSP.apsp_bound_2996001

by xuanji · Oct 7, 2026 · Mathlib 0df444a (Lean v4.33.1)

algorithmsapspfine-grained-complexityshortest-pathsword-ram

For every fixed κ∈N\kappa\in\mathbb Nκ∈N, there exist one finite deterministic word-RAM program PPP, one natural constant bbb, and one step-bound function TTT that work for every input size nnn, including n=0,1n=0,1n=0,1, and for every word width W≥b(Nat.log2⁡(n)+1)W\ge b(\operatorname{Nat.log2}(n)+1)W≥b(Nat.log2(n)+1). All encoded input numbers have absolute value at most nκn^\kappanκ. The run must halt with the specified verdict and output within T(n)T(n)T(n) steps.

For a directed nnn-vertex graph with integer weights and no negative-weight closed walk, accept and compute every exact shortest-path distance in

T(n)=O(n2.996001).T(n)=O(n^{2.996001}).T(n)=O(n2.996001).

Each ordered vertex pair receives a flag and a distance. Reachable pairs have flag one and an attained minimum path weight; unreachable pairs have flag zero and an unconstrained distance slot. Negative edge weights and missing edges are permitted. Empty paths give diagonal distance zero. No assumptions about other algorithms appear in the theorem.

Establish this bound using the shared APSP and word-RAM definitions of the foundation mission.

Preamble
/-
Copyright (c) 2026 Anthropic, PBC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
SPDX-License-Identifier: Apache-2.0
-/

import Definitions.Def_TrulySubcubicAPSP_Problems

set_option autoImplicit false
set_option relaxedAutoImplicit false
Formal statement
theorem TrulySubcubicAPSP.apsp_bound_2996001 :
    TrulySubcubicAPSP.APSP.SolvedInTime 2.996001 := by sorry
Source
Deterministic APSP via thin products: technical note (6 October 2026) refining arXiv:2610.06783 (Alman–Vassilevska Williams); Theorem 1.1, with deterministic prime-by-prime filtering, pruned encodings and exact binomial tail; parameters c=21.2733, θ=0.111731, ε=0.056846 (Lemma 5.1).
Read-back

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

Read-back of TrulySubcubicAPSP.apsp_bound_2996001.

The statement. The problem "APSP" (defined below) is solved in time rrr with r=2.996001r = 2.996001r=2.996001, read as the rational number

r=29960011000000r = \frac{2996001}{1000000}r=10000002996001​

(already in lowest terms: numerator 299600129960012996001, denominator 10610^6106). Unfolding "solved in time rrr", the claim is:

For every natural number κ\kappaκ there exist a program PPP (a finite list of machine instructions, below), a natural number bbb, and a function T:N→NT:\mathbb N\to\mathbb NT:N→N such that

  1. (time bound) there is a natural number KKK with
T(n)1000000≤K⋅n2996001for all n≥2T(n)^{1000000} \le K\cdot n^{2996001}\qquad\text{for all } n\ge 2T(n)1000000≤K⋅n2996001for all n≥2

(this is the stand-in for T(n)=O(n2.996001)T(n)=O(n^{2.996001})T(n)=O(n2.996001); nothing is required of T(0)T(0)T(0) or T(1)T(1)T(1)); 2. (correctness) for every n∈Nn\in\mathbb Nn∈N, every APSP instance xxx of size nnn all of whose input numbers aaa satisfy ∣a∣≤nκ|a|\le n^{\kappa}∣a∣≤nκ, and every word length W≥b⋅(⌊log⁡2n⌋+1)W\ge b\cdot(\lfloor\log_2 n\rfloor+1)W≥b⋅(⌊log2​n⌋+1) (with ⌊log⁡20⌋\lfloor\log_2 0\rfloor⌊log2​0⌋ taken as 000), the program PPP solves xxx at word length WWW within T(n)T(n)T(n) steps (meaning made precise below).

The order of quantifiers is ∀κ  ∃P,b,T\forall\kappa\;\exists P,b,T∀κ∃P,b,T: the program, constant bbb and time function may depend on κ\kappaκ, but not on nnn, xxx or WWW. There is no upper limit on WWW: the same PPP must be correct with the same step budget T(n)T(n)T(n) at every word length from the threshold upward.

The instance. An APSP instance of size nnn is a function www assigning to each ordered pair (i,j)(i,j)(i,j) of vertices i,j∈{0,…,n−1}i,j\in\{0,\dots,n-1\}i,j∈{0,…,n−1} either "no edge" or an edge with integer weight w(i,j)∈Zw(i,j)\in\mathbb Zw(i,j)∈Z (self-loops i=ji=ji=j allowed, any sign of weight allowed), subject to the hypothesis that every closed walk has non-negative total weight. Here a walk/path from iii to kkk of weight eee is defined inductively: the empty walk at iii goes from iii to iii with weight 000; and if there is an edge i→ji\to ji→j of weight ddd and a walk from jjj to kkk of weight e′e'e′, then there is a walk from iii to kkk of weight d+e′d+e'd+e′. Walks may repeat vertices and edges, and have any finite length. The hypothesis says: for all iii and ddd, if there is a walk from iii to iii of weight ddd, then d≥0d\ge 0d≥0. For n=0n=0n=0 there is exactly one (empty) instance.

Input encoding. The input is the list of integers consisting of

  1. the n×nn\times nn×n 0/1 adjacency matrix, row by row (entry (i,j)(i,j)(i,j) is 111 if there is an edge i→ji\to ji→j, else 000), followed by
  2. the n×nn\times nn×n weight matrix, row by row (entry (i,j)(i,j)(i,j) is w(i,j)w(i,j)w(i,j) if there is an edge, else 000).

So the input has length 2n22n^22n2. The bound ∣a∣≤nκ|a|\le n^{\kappa}∣a∣≤nκ applies to every entry of this list (so to every edge weight; for n=1n=1n=1 it forces weights in {−1,0,1}\{-1,0,1\}{−1,0,1}, for n=0n=0n=0 the list is empty).

Machine model. Memory is a map from all integers (negative addresses included) to WWW-bit words. Initially cell 000 holds nnn, cells 1,…,2n21,\dots,2n^21,…,2n2 hold the input list in order, and every other cell (including all negative-address cells) holds 000; each integer is stored as its WWW-bit two's-complement representation (i.e. reduced modulo 2W2^W2W). Writing [i][i][i] for the word in cell iii, the instructions are:

  • [i]:=1[i]:=1[i]:=1 (the only constant);
  • [i]:=[j]+[k][i]:=[j]+[k][i]:=[j]+[k], [i]:=[j]−[k][i]:=[j]-[k][i]:=[j]−[k], [i]:=[j]⋅[k][i]:=[j]\cdot[k][i]:=[j]⋅[k], all modulo 2W2^W2W;
  • load [i]:=[[j]][i]:=[[j]][i]:=[[j]] and store [[i]]:=[j][[i]]:=[j][[i]]:=[j], where a word used as an address is read as a signed (WWW-bit two's-complement) integer;
  • conditional jump: if [i][i][i], read as signed, is <0<0<0, go to position ℓ\ellℓ, else continue;
  • accept; reject.

The cell indices i,j,ki,j,ki,j,k in instructions are fixed integers in the program text. Execution starts at position 000; running past the end of the program counts as reject. "Halts within ttt steps" means that an accept or reject is executed as one of the first ttt steps, the halting step itself counted (so t=0t=0t=0 never suffices).

Required behaviour ("solves xxx within T(n)T(n)T(n) steps"). Starting from the initial memory above, PPP halts within T(n)T(n)T(n) steps, and:

  • the verdict is accept (APSP's acceptance condition is the trivially true one, so the verdict must always be accept);
  • reading the final memory cells as signed integers, with output position aaa meaning cell 1+2n2+a1+2n^2+a1+2n2+a: for every pair (i,j)(i,j)(i,j), letting
flag=out(2(in+j)),dist=out(2(in+j)+1),\text{flag}=\text{out}\bigl(2(in+j)\bigr),\qquad \text{dist}=\text{out}\bigl(2(in+j)+1\bigr),flag=out(2(in+j)),dist=out(2(in+j)+1),

exactly one of the following holds (inclusive "or" of mutually exclusive cases):

  • flag=1\text{flag}=1flag=1, there is a walk from iii to jjj of weight exactly dist\text{dist}dist, and every walk from iii to jjj has weight ≥dist\ge \text{dist}≥dist (so dist is the minimum walk weight); or
  • flag=0\text{flag}=0flag=0 and there is no walk from iii to jjj of any weight.

In particular, for i=ji=ji=j the empty walk exists, so flag must be 111 and dist the minimum closed-walk weight at iii, which by the hypothesis is 000. Output values must be representable as signed WWW-bit words to be read back correctly. No other memory cells are constrained.

Defined but unused. The imported file also defines, without being used by this statement: the problem ExactTriangle (three n×nn\times nn×n integer matrices wAB,wBC,wACw_{AB},w_{BC},w_{AC}wAB​,wBC​,wAC​, input their row-by-row concatenation, accept iff some a,b,ca,b,ca,b,c have wAB(a,b)+wBC(b,c)+wAC(a,c)=0w_{AB}(a,b)+w_{BC}(b,c)+w_{AC}(a,c)=0wAB​(a,b)+wBC​(b,c)+wAC​(a,c)=0); the rational constant εT=0.0017\varepsilon_T=0.0017εT​=0.0017; and the problem MinPlusProduct (two n×nn\times nn×n integer matrices A,BA,BA,B; output cell in+jin+jin+j must equal min⁡k(A(i,k)+B(k,j))\min_k (A(i,k)+B(k,j))mink​(A(i,k)+B(k,j)), phrased as attained by some kkk and ≤\le≤ every such sum; for n=0n=0n=0 vacuous). None of these enter the APSP statement.

Human review
  • Endorsed by marwahaha · Oct 7, 2026

  • Endorsed by xuanji · Oct 7, 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 paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me