Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Correctness and time of a query of the Theorem 30 data structure with pruned encodings (queryAt)

Proved
Light.Sec4.queryAtP_spec

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

apsp-299791apsp-exponentdata-structuresprogram-verification

Let PPP be a program of the light language whose procedure number 555555 is the body of queryAt, and in which the routines outDigits (number 525252) and queryCore (number 535353) meet their specifications for the limits lim\mathrm{lim}lim. Then queryAt meets its specification for lim\mathrm{lim}lim:

for all parameters p=(L,m,N)p=(L,m,N)p=(L,m,N) with m≤Lm\le Lm≤L, t≤mt\le mt≤m, block address b0b_0b0​, matrices X,YX,YX,Y with ∣Xik∣,∣Ykj∣≤U|X_{ik}|,|Y_{kj}|\le U∣Xik​∣,∣Ykj​∣≤U, limits satisfying Lim30(p,t,b0,U)\mathrm{Lim30}(p,t,b_0,U)Lim30(p,t,b0​,U), every memory μ\muμ that holds the data structure for X,YX,YX,Y at b0b_0b0​, every pair I,J<NI,J<NI,J<N and every depth ddd with d+2≤depthd+2\le\mathrm{depth}d+2≤depth, the call queryAt(I,J,b0)\mathrm{queryAt}(I,J,b_0)queryAt(I,J,b0​) ends within

toutDigits(L)+tqueryCore(L,m,t)+400t_{\mathrm{outDigits}}(L)+t_{\mathrm{queryCore}}(L,m,t)+400toutDigits​(L)+tqueryCore​(L,m,t)+400

steps, returns (XY)IJ(XY)_{IJ}(XY)IJ​, the final memory still holds the data structure, and it differs from μ\muμ only in the 3L+m3L+m3L+m scratch cells from the address WD(b0)\mathrm{WD}(b_0)WD(b0​).

Setting. The data structure of Theorem 30 is built for parameters p=(L,m,N)p=(L,m,N)p=(L,m,N) with m≤Lm\le Lm≤L (LLL levels, mmm inner levels), integer matrices X∈ZN×4mX\in\mathbb Z^{N\times 4^m}X∈ZN×4m and Y∈Z4m×NY\in\mathbb Z^{4^m\times N}Y∈Z4m×N with entries of absolute value at most UUU, and a threshold t≤mt\le mt≤m. It lives in a block of memory starting at an address b0b_0b0​: the shared tables of Section 2 with the pruned encodings of the nBn_BnB​ row bands of XXX and column bands of YYY (only the leaves whose LLL decimal digits contain at most mmm nines are stored), the directory, the table of trie roots (one per tile) and the trie array (one trie per tile, holding the values of its boxes). The limits must satisfy the bounds Lim30\mathrm{Lim30}Lim30: the standing assumptions (an address fits in a word and 100≤word100\le\mathrm{word}100≤word), the block fits in memory, and 10m(7LU)210^m(7^LU)^210m(7LU)2, 7L+1U7^{L+1}U7L+1U and 10L+110^{L+1}10L+1 fit in a word.

The query finds the tile of (I,J)(I,J)(I,J) from the bands of row III and column JJJ, writes the digits of its output string η\etaη, reads the root of the trie of the tile, and evaluates the sum of Lemma 28 from the two encodings and the trie. With pruned encodings the encodings are correct only at the leaves with at most mmm nines, which are exactly the leaves the query reads.

“Procedure ppp meets its specification within TTT steps” means: called at any depth ddd allowed by the hypothesis, with the given argument values and a memory μ\muμ satisfying the precondition, the body of ppp terminates within TTT steps without violating the limits, and the returned value and final memory satisfy the postcondition. Programs are those of the library's light language (procedures numbered by their position in a list PPP, local variables, a memory of integer cells μ:N→Z\mu:\mathbb N\to\mathbb Zμ:N→Z, calls with a nesting depth), which the library compiles to the word RAM; runs are checked against limits lim=(word,space,depth)\mathrm{lim}=(\mathrm{word},\mathrm{space},\mathrm{depth})lim=(word,space,depth) on the absolute value of every word, the number of memory cells and the call depth.

Formalization Note The name carries a P because the platform already has Light.Sec4.queryAt_spec, the same lemma for the unpruned data structure of the foundation development. The statement is P[Proc.queryAt]? = some queryAtBody → OutDigitsSpec lim P → QueryCoreSpecP lim P → QueryAtSpecP lim P. The invariant "holds the data structure" is DSReadyP, built on Sec2.SharedReadyP (pruned encodings).

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 ThreeSumApsp
open Light
open Light.Sec4
open ThreeSumApsp.Spec
variable {lim : Limits} {P : Program} {d : ℕ} {p : Sec2.Par} {t : ℕ} {hmL : p.m ≤ p.L}
  {aX aY b0 : ℕ} {X : Matrix (Fin p.N) (Fin (D p.m)) ℤ} {Y : Matrix (Fin (D p.m)) (Fin p.N) ℤ}
  {U : ℤ} {μ : ℕ → ℤ}
Formal statement
theorem Light.Sec4.queryAtP_spec (hP : P[Proc.queryAt]? = some queryAtBody) (hOut : OutDigitsSpec lim P)
    (hCore : QueryCoreSpecP lim P) : QueryAtSpecP lim P := 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/Programs/Sec4/Theorem30/Query.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), Lemma 28 (p. 44) and Theorem 30 (pp. 46-47), "Query". 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