The loop of the all-edges Exact Triangle host writes the marks of all pairs (aeLoop)
ProvedLight.Sec3.aeLoop_specCorrectness and running time of the main loop aeLoop of the all-edges host of Theorem 17.
Let a program contain a solver of Lop-AE-SparseTri (procedure of solves the detection task within steps under the need ) and the procedures writeX, writeY, scanPairsAE and scan at their numbers. Let be the data of a run of the host (sizes , , prime , piece size, number of instances, the hashed weights, the pieces and the query pairs of every instance) and the addresses of its arrays, and assume that the data are consistent with the bound , the memory holds the arrays of at , the arrays are laid out without overlap, the limits allow all calls (including the need of the solver at every instance), the cells from that receive the marks lie apart from everything else, and they hold initially.
Then the body of aeLoop, run at depth on its arguments, ends within
steps (with the piece size, the number of query pairs and the number of scans of instance ), and the final memory agrees, below the address , with in which the cells from hold the marks after all instances.
Setting. The all-edges host solves All-Edges Exact Triangle: given integer weight matrices with entries of absolute value at most , it writes for every pair a flag that is exactly if some has . As in the proof of Theorem 17 it chooses a prime , hashes the weights, splits the third part into about pieces of at most vertices (), builds one Lop-AE-SparseTri instance per piece and residue class with at most query pairs, calls a detection solver on each, and scans the candidate pairs it reports, skipping pairs that are already marked. The marks are the flags; after the last instance they are the answer.
The number of scans of an instance counts only pairs that are not yet marked, so over the whole loop the scans are at most the false positives plus ; this is what makes the all-edges variant cost no more than the decision version.
Formalization Note The statement is Ends lim (P₀ ++ R) d (aeLoopBody pS pWriteX pWriteY pScanPairs) ⟨frame (aeLoopArgs X A fl), μ⟩ (tAELoop Tn X) (fun σ' => Kept (aeBase X fl μ X.m) σ'.mem A.x), under the hypotheses AEHostCtx, HostOk X U, HostMem X A μ, HostLay X A, HostLim lim d X U A need, AEMarksLay X A fl and the zero marks; the sum in the time is exactly tAELoop.
/-
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.Spec
variable {lim : Limits} {d : ℕ}
open HostLocal AELocal
variable {P₀ R : Program} {pS pWriteX pWriteY pScanPairs pScan : ℕ} {Tn : List ℕ → ℕ}
{need : List ℕ → Need} {X : HostData} {U : ℕ} {A : HostAddr} {fl : ℕ} {μ μ' : ℕ → ℤ} {t : ℕ}
theorem Light.Sec3.aeLoop_spec (C : AEHostCtx P₀ R pS pWriteX pWriteY pScanPairs pScan Tn need)
(hok : HostOk X U) (hmem : HostMem X A μ) (hlay : HostLay X A)
(hlim : HostLim lim d X U A need) (L : AEMarksLay X A fl)
(hzero : ∀ q < X.n * X.n, μ (fl + q) = 0) :
Ends lim (P₀ ++ R) d (aeLoopBody pS pWriteX pWriteY pScanPairs)
⟨Light.frame (aeLoopArgs X A fl), μ⟩ (tAELoop Tn X) fun σ' =>
Light.Kept (aeBase X fl μ X.m) σ'.mem A.x := by sorry