Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

queryCore computes the sum of Lemma 28 from the encodings and the trie of a tile (pruned encodings)

Proved
Light.Sec4.queryCore_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 535353 is the body of queryCore, and in which the routines nineFirst, nineNext, scatter, horner and lookup meet their specifications for the limits lim\mathrm{lim}lim. Then queryCore meets its specification for lim\mathrm{lim}lim:

consider the encodings encA,encB\mathrm{enc}_A,\mathrm{enc}_BencA​,encB​ of a tile at aA,aBa_A,a_BaA​,aB​ (10L10^L10L cells each), a trie array TTT at tr\mathit{tr}tr with the root root\mathit{root}root of the tile's trie, an output string η\etaη of LLL symbols with exactly mmm inner levels whose digits are stored at wd\mathit{wd}wd, and scratch areas ss\mathit{ss}ss (mmm cells) and box\mathit{box}box (LLL cells). Assume the standing assumptions on the limits, t≤mt\le mt≤m, that every box the query reads is found in the trie, that every partial sum of the query and every product encA(τ) encB(τ)\mathrm{enc}_A(\tau)\,\mathrm{enc}_B(\tau)encA​(τ)encB​(τ) at a leaf τ\tauτ with at most mmm nines fits in a word, 10L≤word10^L\le\mathrm{word}10L≤word, and that the scratch areas are disjoint from each other and from the data, all within memory. Then for every depth ddd with d+1≤depthd+1\le\mathrm{depth}d+1≤depth, the call queryCore(aA,aB,tr,root,wd,ss,box,L,m,t)\mathrm{queryCore}(a_A,a_B,\mathit{tr},\mathit{root},\mathit{wd},\mathit{ss},\mathit{box},L,m,t)queryCore(aA​,aB​,tr,root,wd,ss,box,L,m,t) ends within

2 tnineFirst(m)+ℓ (tscatter(L)+thorner(L)+tnineNext(m)+90)+k (tscatter(L)+tlookup(L)+tnineNext(m)+90)+1202\,t_{\mathrm{nineFirst}}(m)+\ell\,\big(t_{\mathrm{scatter}}(L)+t_{\mathrm{horner}}(L)+t_{\mathrm{nineNext}}(m)+90\big)+k\,\big(t_{\mathrm{scatter}}(L)+t_{\mathrm{lookup}}(L)+t_{\mathrm{nineNext}}(m)+90\big)+1202tnineFirst​(m)+ℓ(tscatter​(L)+thorner​(L)+tnineNext​(m)+90)+k(tscatter​(L)+tlookup​(L)+tnineNext​(m)+90)+120

steps, where ℓ\ellℓ is the number of leaves of order below ttt and kkk the number of boxes that the query reads, and returns

∑τ of order<tencA(τ) encB(τ)  +∑boxes b of ηvalT(b),\sum_{\tau\text{ of order}<t}\mathrm{enc}_A(\tau)\,\mathrm{enc}_B(\tau)\;+\sum_{\text{boxes }\mathbf b\text{ of }\eta}\mathrm{val}_T(\mathbf b),τ of order<t∑​encA​(τ)encB​(τ)+boxes b of η∑​valT​(b),

the products at the leaves of η\etaη of order below ttt plus the values the trie holds for the boxes of η\etaη; only the two scratch areas change. When the trie holds the true box values this is the sum of Lemma 28, i.e. the entry of the product for the query.

All leaves read have at most mmm nines, so the routine is correct on pruned encodings.

“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.

Formalization Note The statement is P[Proc.queryCore]? = some queryCoreBody → Light.Sec4.Query.Callees lim P → QueryCoreSpecP lim P, where Callees bundles the specifications of the five routines; the returned value is trieQuery m t (arrT encA) (arrT encB) T root (digitsO η).

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
open Query
Formal statement
theorem Light.Sec4.queryCore_spec {lim : Limits} {P : Program} (hP : P[Proc.queryCore]? = some queryCoreBody)
    (K : Light.Sec4.Query.Callees lim P) : QueryCoreSpecP 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/QuerySum.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