APSP in word-RAM steps
ProvedTrulySubcubicAPSP.apsp_bound_2995561For 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_2995561 :
TrulySubcubicAPSP.APSP.SolvedInTime 2.995561 := by sorryRead-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 on a particular word-RAM model, for the rational exponent
(this fraction is already in lowest terms, so its numerator is and its denominator is ).
What "solved in time " means. For every natural number there exist a program (a finite list of machine instructions), a natural number , and a function such that:
- Time bound: there is a natural number with
i.e. for . Nothing is required of or . 2. Correctness: for every (including and ) and every APSP instance of size such that every integer in the input list of satisfies (with ), and for every word length with
(where is taken to be ; there is no upper limit on ), the run of on with word length and step budget succeeds in the sense below.
The program , the constant and the function may depend on , but not on , or .
The machine. Memory is a map from all integers (including negative ones) to -bit words. Arithmetic is modulo ; 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 . Instruction operands are fixed integer addresses written in the program, and denotes the word in cell . The instructions are:
- (the word whose unsigned value is ; this is the only constant);
- , , , all modulo ;
- load and store (indirect addressing via the signed value of a word);
- conditional jump: if (signed) go to program position , 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 ; 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 steps" if it executes accept or reject at or before its -th step; otherwise it is a failure.
Initial memory. Cell holds ; cells hold the input list of (length ), each entry reduced to a -bit word (modulo ); all other cells (all negative addresses and all addresses ) hold .
Success of a run. The run halts within 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 defined as the signed integer in cell for , satisfies the APSP output condition below.
The APSP problem. An instance of size is a function assigning to every ordered pair of vertices (self-pairs included) either "no edge" or an integer edge weight (weights may be negative or zero), subject to the condition that every closed walk has nonnegative total weight: for every vertex and every walk from back to of total weight , . Here a walk from to is a finite sequence of edges (with , vertices and edges may repeat), each being an edge present in , and its weight is the sum of the edge weights; the empty walk from to has weight .
- Input list (length ): first the adjacency matrix in row-major order (entry is if the edge exists, else ), then the weight matrix in row-major order (entry is if the edge exists, else ). The bound thus applies to the entries and to all edge weights.
- Output condition: for every pair , with , and , exactly one of the following holds (they are mutually exclusive):
- , there is a walk from to of weight exactly , and for the weight of every walk from to (so is the minimum walk weight); or
- and there is no walk at all from to (in this case is unconstrained).
In particular, for the empty walk exists, so the flag must be and, by the nonnegative-closed-walk condition, must be .
Edge cases. For the input list is empty, the size bound is vacuous, the word-length condition is , and the output condition is vacuous, so the program need only accept within steps. For the size bound forces all input entries into . For , all edge weights must lie in for every . If is chosen, the requirement includes word length (every word is ). Correctness is demanded simultaneously for all sufficiently large , however large. The integer placed in cell , the input entries, and the outputs are all subject to reduction modulo and signed reading.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.