Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

APSP in O(n2.995561)O(n^{2.995561})O(n2.995561) word-RAM steps

Proved
TrulySubcubicAPSP.apsp_bound_2995561

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.995561).T(n)=O(n^{2.995561}).T(n)=O(n2.995561).

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_2995561 :
    TrulySubcubicAPSP.APSP.SolvedInTime 2.995561 := by sorry
Source
Deterministic APSP via thin products: technical note (revised 7 October 2026) refining arXiv:2610.06783 (Alman–Vassilevska Williams); Theorem 1.1 and Theorem 4.3, with deterministic prime-by-prime filtering, two-digit residue lifting, batched tensor slots, pruned encodings and exact binomial tail; parameters c=20, θ=0.113138, ε=0.067235 (Lemma 5.1).
Read-back

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

Read-back of TrulySubcubicAPSP.apsp_bound_2995561. The theorem has no hypotheses or arguments. It asserts that the problem "APSP" (defined below) is solved in time O(nr)O(n^{r})O(nr) on a particular word-RAM model, for the rational exponent

r=2.995561=29955611000000r = 2.995561 = \tfrac{2995561}{1000000}r=2.995561=10000002995561​

(this fraction is already in lowest terms, so its numerator is 299556129955612995561 and its denominator is 10610^6106).

What "solved in time rrr" means. For every natural number κ\kappaκ there exist a program PPP (a finite list of machine instructions), a natural number bbb, and a function T:N→NT:\mathbb{N}\to\mathbb{N}T:N→N such that:

  1. Time bound: there is a natural number KKK with
T(n)106≤K⋅n2995561for all n≥2,T(n)^{10^6} \le K \cdot n^{2995561} \quad\text{for all } n \ge 2,T(n)106≤K⋅n2995561for all n≥2,

i.e. T(n)≤K10−6n2.995561T(n) \le K^{10^{-6}} n^{2.995561}T(n)≤K10−6n2.995561 for n≥2n\ge 2n≥2. 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{N}n∈N (including n=0n = 0n=0 and n=1n = 1n=1) and every APSP instance xxx of size nnn such that every integer aaa in the input list of xxx satisfies ∣a∣≤nκ|a| \le n^{\kappa}∣a∣≤nκ (with 00=10^0 = 100=1), and for every word length WWW with

W≥b⋅(⌊log⁡2n⌋+1)W \ge b\cdot(\lfloor \log_2 n\rfloor + 1)W≥b⋅(⌊log2​n⌋+1)

(where ⌊log⁡20⌋\lfloor\log_2 0\rfloor⌊log2​0⌋ is taken to be 000; there is no upper limit on WWW), the run of PPP on xxx with word length WWW and step budget T(n)T(n)T(n) succeeds in the sense below.

The program PPP, the constant bbb and the function TTT may depend on κ\kappaκ, but not on nnn, xxx or WWW.

The machine. Memory is a map from all integers (including negative ones) to WWW-bit words. Arithmetic is modulo 2W2^W2W; when a word is used as an address, as a branch test, or read as output, it is interpreted as a signed two's-complement integer in [−2W−1,2W−1)[-2^{W-1}, 2^{W-1})[−2W−1,2W−1). Instruction operands i,j,ki,j,ki,j,k are fixed integer addresses written in the program, and [i][i][i] denotes the word in cell iii. The instructions are:

  • [i]:=1[i] := 1[i]:=1 (the word whose unsigned value is 1 mod 2W1 \bmod 2^W1mod2W; this is 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] (indirect addressing via the signed value of a word);
  • conditional jump: if [i]<0[i] < 0[i]<0 (signed) go to program position ℓ\ellℓ, else continue to the next instruction;
  • accept; reject (both halt).

There is no division, shift, comparison other than sign test, or bitwise operation. Execution starts at position 000; executing at a position beyond the end of the program counts as reject. Every executed instruction, including the halting one, costs one step. A run "halts within ttt steps" if it executes accept or reject at or before its ttt-th step; otherwise it is a failure.

Initial memory. Cell 000 holds nnn; cells 1,2,…,L1, 2, \dots, L1,2,…,L hold the input list of xxx (length LLL), each entry reduced to a WWW-bit word (modulo 2W2^W2W); all other cells (all negative addresses and all addresses >L> L>L) hold 000.

Success of a run. The run halts within T(n)T(n)T(n) steps, its verdict is accept (the APSP problem specifies no yes/no condition, so the required verdict is always "accept"), and the final memory, with output value out(a)\mathrm{out}(a)out(a) defined as the signed integer in cell 1+L+a1 + L + a1+L+a for a∈Na \in \mathbb{N}a∈N, satisfies the APSP output condition below.

The APSP problem. An instance of size nnn is a function www assigning to every 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} (self-pairs i=ji=ji=j included) either "no edge" or an integer edge weight w(i,j)∈Zw(i,j)\in\mathbb{Z}w(i,j)∈Z (weights may be negative or zero), subject to the condition that every closed walk has nonnegative total weight: for every vertex iii and every walk from iii back to iii of total weight ddd, 0≤d0 \le d0≤d. Here a walk from iii to kkk is a finite sequence of edges i=v0→v1→⋯→vm=ki = v_0 \to v_1 \to \dots \to v_m = ki=v0​→v1​→⋯→vm​=k (with m≥0m \ge 0m≥0, vertices and edges may repeat), each vs→vs+1v_{s}\to v_{s+1}vs​→vs+1​ being an edge present in www, and its weight is the sum of the edge weights; the empty walk from iii to iii has weight 000.

  • Input list (length L=2n2L = 2n^2L=2n2): first the n×nn\times nn×n 0/10/10/1 adjacency matrix in row-major order (entry (i,j)(i,j)(i,j) is 111 if the edge (i,j)(i,j)(i,j) exists, else 000), then the n×nn\times nn×n weight matrix in row-major order (entry (i,j)(i,j)(i,j) is w(i,j)w(i,j)w(i,j) if the edge exists, else 000). The bound ∣a∣≤nκ|a|\le n^\kappa∣a∣≤nκ thus applies to the 0/10/10/1 entries and to all edge weights.
  • Output condition: for every pair (i,j)(i,j)(i,j), with p=i⋅n+jp = i\cdot n + jp=i⋅n+j, flag=out(2p)\mathrm{flag} = \mathrm{out}(2p)flag=out(2p) and dist=out(2p+1)\mathrm{dist} = \mathrm{out}(2p+1)dist=out(2p+1), exactly one of the following holds (they are mutually exclusive):
    • flag=1\mathrm{flag} = 1flag=1, there is a walk from iii to jjj of weight exactly dist\mathrm{dist}dist, and dist≤e\mathrm{dist} \le edist≤e for the weight eee of every walk from iii to jjj (so dist\mathrm{dist}dist is the minimum walk weight); or
    • flag=0\mathrm{flag} = 0flag=0 and there is no walk at all from iii to jjj (in this case dist\mathrm{dist}dist is unconstrained).

In particular, for i=ji = ji=j the empty walk exists, so the flag must be 111 and, by the nonnegative-closed-walk condition, dist\mathrm{dist}dist must be 000.

Edge cases. For n=0n = 0n=0 the input list is empty, the size bound is vacuous, the word-length condition is W≥bW \ge bW≥b, and the output condition is vacuous, so the program need only accept within T(0)T(0)T(0) steps. For n=1n = 1n=1 the size bound forces all input entries into {−1,0,1}\{-1,0,1\}{−1,0,1}. For κ=0\kappa = 0κ=0, all edge weights must lie in {−1,0,1}\{-1,0,1\}{−1,0,1} for every nnn. If b=0b = 0b=0 is chosen, the requirement includes word length W=0W = 0W=0 (every word is 000). Correctness is demanded simultaneously for all sufficiently large WWW, however large. The integer nnn placed in cell 000, the input entries, and the outputs are all subject to reduction modulo 2W2^W2W and signed reading.

Human review
  • Endorsed by Shuze Chen · Oct 7, 2026

    Confirmed by the moderator at approval.

  • 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