APSP in word-RAM steps
ProvedTrulySubcubicAPSP.apsp_bound_2996001For every fixed , there exist one finite deterministic word-RAM program , one natural constant , and one step-bound function that work for every input size , including , and for every word width . All encoded input numbers have absolute value at most . The run must halt with the specified verdict and output within steps.
For a directed -vertex graph with integer weights and no negative-weight closed walk, accept and compute every exact shortest-path distance in
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.
/- 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
theorem TrulySubcubicAPSP.apsp_bound_2996001 :
TrulySubcubicAPSP.APSP.SolvedInTime 2.996001 := by sorryRead-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 with , read as the rational number
(already in lowest terms: numerator , denominator ). Unfolding "solved in time ", the claim is:
For every natural number there exist a program (a finite list of machine instructions, below), a natural number , and a function such that
- (time bound) there is a natural number with
(this is the stand-in for ; nothing is required of or ); 2. (correctness) for every , every APSP instance of size all of whose input numbers satisfy , and every word length (with taken as ), the program solves at word length within steps (meaning made precise below).
The order of quantifiers is : the program, constant and time function may depend on , but not on , or . There is no upper limit on : the same must be correct with the same step budget at every word length from the threshold upward.
The instance. An APSP instance of size is a function assigning to each ordered pair of vertices either "no edge" or an edge with integer weight (self-loops allowed, any sign of weight allowed), subject to the hypothesis that every closed walk has non-negative total weight. Here a walk/path from to of weight is defined inductively: the empty walk at goes from to with weight ; and if there is an edge of weight and a walk from to of weight , then there is a walk from to of weight . Walks may repeat vertices and edges, and have any finite length. The hypothesis says: for all and , if there is a walk from to of weight , then . For there is exactly one (empty) instance.
Input encoding. The input is the list of integers consisting of
- the 0/1 adjacency matrix, row by row (entry is if there is an edge , else ), followed by
- the weight matrix, row by row (entry is if there is an edge, else ).
So the input has length . The bound applies to every entry of this list (so to every edge weight; for it forces weights in , for the list is empty).
Machine model. Memory is a map from all integers (negative addresses included) to -bit words. Initially cell holds , cells hold the input list in order, and every other cell (including all negative-address cells) holds ; each integer is stored as its -bit two's-complement representation (i.e. reduced modulo ). Writing for the word in cell , the instructions are:
- (the only constant);
- , , , all modulo ;
- load and store , where a word used as an address is read as a signed (-bit two's-complement) integer;
- conditional jump: if , read as signed, is , go to position , else continue;
- accept; reject.
The cell indices in instructions are fixed integers in the program text. Execution starts at position ; running past the end of the program counts as reject. "Halts within steps" means that an accept or reject is executed as one of the first steps, the halting step itself counted (so never suffices).
Required behaviour ("solves within steps"). Starting from the initial memory above, halts within 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 meaning cell : for every pair , letting
exactly one of the following holds (inclusive "or" of mutually exclusive cases):
- , there is a walk from to of weight exactly , and every walk from to has weight (so dist is the minimum walk weight); or
- and there is no walk from to of any weight.
In particular, for the empty walk exists, so flag must be and dist the minimum closed-walk weight at , which by the hypothesis is . Output values must be representable as signed -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 integer matrices , input their row-by-row concatenation, accept iff some have ); the rational constant ; and the problem MinPlusProduct (two integer matrices ; output cell must equal , phrased as attained by some and every such sum; for vacuous). None of these enter the APSP statement.
Confirmed by the mission captain (proposal self-audit).