Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Worst-case bound on the run time of the all-edges host at the middle dimension after the choice of the prime

Proved
Light.Sec3.MidTime.midRunTime_le

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

apsp-299791apsp-exponentexact-triangleprogram-verification

Let xxx be an Exact Triangle instance with nnn vertices per part and weight bound UUU satisfying the precondition of the host in a memory μ\muμ with free pointer fff, let 16≤D≤n16\le D\le n16≤D≤n and 1≤g≤⌊D⌋1\le g\le\lfloor\sqrt D\rfloor1≤g≤⌊D​⌋, and let TnT_nTn​ be any time function of the Lop-AE-SparseTri solver. Write s=⌊D⌋s=\lfloor\sqrt D\rfloors=⌊D​⌋, q=⌈s/g⌉q=\lceil s/g\rceilq=⌈s/g⌉ and Dm=qsD_{\mathrm m}=qsDm​=qs. Then the time of the run after the choice of the prime, for the host data with inner dimension DmD_{\mathrm m}Dm​, is bounded by an expression that no longer depends on the prime or on the instance data:

trun≤tdbl(β)+3 tres(n2,β)+tclasses(n,s)+tchunks(s,4ng)+B(Tn,n,U,D,g)+80,β=bitLen(U),t_{\mathrm{run}}\le t_{\mathrm{dbl}}(\beta)+3\,t_{\mathrm{res}}(n^2,\beta)+t_{\mathrm{classes}}(n,s)+t_{\mathrm{chunks}}(s,4ng)+B(T_n,n,U,D,g)+80,\qquad\beta=\mathrm{bitLen}(U),trun​≤tdbl​(β)+3tres​(n2,β)+tclasses​(n,s)+tchunks​(s,4ng)+B(Tn​,n,U,D,g)+80,β=bitLen(U),

where the loop bound is

B=4ng(twrites(n,D,q)+sup⁡Tn(n,Dm,⌊n2/D⌋)+tanswers(⌊n2/D⌋))+(tscan(q)+20)(F(n,U,D)+n2)+14.B=4ng\Big(t_{\mathrm{writes}}(n,D,q)+\sup T_n\big(n,D_{\mathrm m},\lfloor n^2/\sqrt D\rfloor\big)+t_{\mathrm{answers}}\big(\lfloor n^2/\sqrt D\rfloor\big)\Big)+\big(t_{\mathrm{scan}}(q)+20\big)\big(F(n,U,D)+n^2\big)+14 .B=4ng(twrites​(n,D,q)+supTn​(n,Dm​,⌊n2/D​⌋)+tanswers​(⌊n2/D​⌋))+(tscan​(q)+20)(F(n,U,D)+n2)+14.

Here sup⁡Tn(n,Dm,w)\sup T_n(n,D_{\mathrm m},w)supTn​(n,Dm​,w) is the largest time of the solver on nnn vertices, inner dimension DmD_{\mathrm m}Dm​ and at most www query pairs, and F(n,U,D)=⌊cF κ(n,U) n3log⁡n/D⌋F(n,U,D)=\lfloor c_F\,\kappa(n,U)\,n^3\log n/\sqrt D\rfloorF(n,U,D)=⌊cF​κ(n,U)n3logn/D​⌋ is the bound on the false positives of the hashing (with κ(n,U)=max⁡(1,log⁡U/log⁡n)\kappa(n,U)=\max(1,\log U/\log n)κ(n,U)=max(1,logU/logn) and cFc_FcF​ the constant of the hashing lemma).

The bound uses that the prime is at most D\sqrt DD​, that there are at most 4ng4ng4ng instances and chunks, that each instance has inner dimension Dm≤DD_{\mathrm m}\le DDm​≤D and at most ⌊n2/D⌋\lfloor n^2/\sqrt D\rfloor⌊n2/D​⌋ query pairs, and that the scans are at most the false positives plus the n2n^2n2 pairs (each pair is scanned to success at most once). It is the step from the time of one run to the bound of Theorem 17 at the middle dimension.

Formalization Note The statement is aeRunTime Tn (midHostData x D g) x.U ≤ tDblTable (bitLen x.U) + 3 * tResidues (x.n * x.n) (bitLen x.U) + tClasses x.n (Nat.sqrt D) + tChunks (Nat.sqrt D) (4 * x.n * g) + midLoopBound Tn x.n x.U D g + 80, under x.Pre μ fr and BigCase x.n D g; all quantities are natural numbers.

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.Spec
variable {P₀ R : Program} {ν : Et17Nums} {pAEBrute pAELoop pScanPairsAE pCore pFill : ℕ}
  {Tn : List ℕ → ℕ} {need : List ℕ → Need} {Dfun Gfun tD tG wD wG : ℕ → ℕ}
open Light.Sec3.MidTime
variable {x : TriInst} {μ : ℕ → ℤ} {fr D g : ℕ}
Formal statement
theorem Light.Sec3.MidTime.midRunTime_le (hpre : x.Pre μ fr) (hbig : BigCase x.n D g) (Tn : List ℕ → ℕ) :
    aeRunTime Tn (midHostData x D g) x.U
      ≤ tDblTable (bitLen x.U) + 3 * tResidues (x.n * x.n) (bitLen x.U)
        + tClasses x.n (Nat.sqrt D) + tChunks (Nat.sqrt D) (4 * x.n * g)
        + midLoopBound Tn x.n x.U D g + 80 := 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/MidHost.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 17 (p. 33) and its proof. 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