Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Deterministic APSP in O(n2.99791)O(n^{2.99791})O(n2.99791) time on a word RAM

Proved
Light.Sec3.apsp_299791

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

apsp-299791apsp-exponentfine-grained-complexityword-ram

All-pairs shortest paths on directed graphs with integer weights and no negative cycles can be solved deterministically in time O(n2.99791)O(n^{2.99791})O(n2.99791) on a word RAM with O(log⁡n)O(\log n)O(logn)-bit words:

APSP.SolvedInTime(2.99791).\mathrm{APSP}.\mathrm{SolvedInTime}(2.99791).APSP.SolvedInTime(2.99791).

The problem. An instance of size nnn is a directed graph on the vertices 0,…,n−10,\dots,n-10,…,n−1 given by a partial weight function www: w(i,j)∈Zw(i,j)\in\mathbb Zw(i,j)∈Z is the weight of the edge i→ji\to ji→j, or undefined if there is no such edge. Instances have no negative cycle: every closed path has total weight at least 000. The input is the n×nn\times nn×n 0/10/10/1 adjacency matrix followed by the n×nn\times nn×n weight matrix (with 000 where there is no edge), both row by row. The output has two cells for every pair (i,j)(i,j)(i,j): the flag 111 followed by the distance d(i,j)d(i,j)d(i,j) (the weight of a path from iii to jjj that is at most the weight of every such path) if jjj is reachable from iii, and the flag 000 otherwise.

The machine and the time bound. Q.SolvedInTime(r)Q.\mathrm{SolvedInTime}(r)Q.SolvedInTime(r) means: for every κ∈N\kappa\in\mathbb Nκ∈N there are a program PPP of the word RAM, a number bbb and a function T:N→NT:\mathbb N\to\mathbb NT:N→N with T(n)=O(nr)T(n)=O(n^{r})T(n)=O(nr) (precisely, T(n)den r≤K nnum rT(n)^{\mathrm{den}\,r}\le K\,n^{\mathrm{num}\,r}T(n)denr≤Knnumr for some KKK and all n≥2n\ge2n≥2) such that on every instance of every size nnn whose input numbers have absolute value at most nκn^{\kappa}nκ, and for every word size W≥b (⌊log⁡2n⌋+1)W\ge b\,(\lfloor\log_2 n\rfloor+1)W≥b(⌊log2​n⌋+1), the program halts within T(n)T(n)T(n) steps, accepts, and leaves the correct output in the cells right after the input. The word RAM has nine instructions (write the constant 111; add, subtract or multiply modulo 2W2^W2W; load; store; jump if negative; accept; reject); there is no division, no shift, no bitwise operation and no randomness.

The bound improves the deterministic exponent 2.999422.999422.99942 of Theorem 22 of Alman and Vassilevska Williams. The algorithm saves δ=143/68400\delta=143/68400δ=143/68400, so 3−δ≈2.9979094<2.997913-\delta\approx2.9979094<2.997913−δ≈2.9979094<2.99791; the margin absorbs the polylogarithmic factors.

This is the library form of the campaign goal TrulySubcubicAPSP.apsp_bound_299791; the platform node TrulySubcubicAPSP.sourceSpecificationTransport carries it over to the campaign's own definitions.

Formalization Note APSP and Problem.SolvedInTime are those of the namespace EndStatement (the library file EndStatement.lean, on the platform the definition TrulySubcubicAPSP_SourceSpecification); the exponent is the rational numeral 2.997912.997912.99791.

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
-/
-- Generated by skeleton subtraction from the ThreeSumApsp library at commit 27a2fa4bab32.

import Definitions.Def_APSP299791_Defs5

set_option autoImplicit false
set_option relaxedAutoImplicit false

open Light
open Light.Sec3
open ThreeSumApsp ThreeSumApsp.WordRam
Formal statement
theorem Light.Sec3.apsp_299791 : EndStatement.APSP.SolvedInTime (2.99791 : ℚ) := by sorry
Source
Developed for the prove2.me APSP exponent campaign (https://prove2.me/campaigns/apsp-exponent) on top of the Lean formalization anthropics/formal-math, folder 3sum-apsp, commit e1a4e65 (https://github.com/anthropics/formal-math/tree/e1a4e6508154ea59f030480661590a9fe3018011/3sum-apsp; Lean v4.33.1, Mathlib v4.33.1). The statement comes from the file 3sum-apsp/ThreeSumApsp/AllEdges/Final.lean of the campaign's modified copy of that library, which is not published; the new and modified definitions it uses are in the platform definition bundles APSP299791_Defs1 to APSP299791_Defs5. It builds on J. Alman and V. Vassilevska Williams, "Truly Subquadratic 3SUM and Truly Subcubic APSP via Triangles in Sparse Lopsided Graphs", arXiv:2610.06783v1 (https://arxiv.org/abs/2610.06783v1), Theorem 22 (p. 36; deterministic APSP in O(n^2.99942)) and the definitions of the library file EndStatement.lean. This result belongs to an improvement of the paper's bounds developed for this campaign and is not stated in the paper.

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