Construct the three color-class lists with their exact contents
ProvedThreeSum.LightColorClasses.Procs.meets3sumalgorithmsfine-grained-complexitythree-sum-1962word-ram
Let be a two-bit coloring parameter of width , and let integers () satisfy and . Memory stores at . Place the color cells at , the three class buffers at , and scratch at , with , , , , and . Assume the specified procedures and , , and .
The routine writes each index's actual color and length-prefixed class lists
retaining original index order and repetitions. It takes at most steps and preserves all memory below .
This produces the concrete lists whose two-sum relation represents a zero sum across the three colors.
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 -/ import Definitions.Def_APSPSource_RemainingDefinitions import Definitions.Def_APSPSource_ThreeSumApsp_Lang_Logic import Definitions.Def_APSPSource_ThreeSumApsp_Lang_Regions import Definitions.Def_APSPSource_ThreeSumApsp_Lang_Syntax import Definitions.Def_ThreeSum1962Source_Bundle01 import Definitions.Def_ThreeSum1962Source_Bundle02 import Definitions.Def_ThreeSum1962Source_Bundle03 import Definitions.Def_ThreeSum1962Source_Bundle04 import Definitions.Def_ThreeSum1962Source_Bundle06 import Definitions.Def_ThreeSum1962Source_Bundle07 import Lean.Elab.Tactic.Omega import Mathlib.Algebra.BigOperators.Fin import Mathlib.Algebra.BigOperators.Group.Finset.Basic import Mathlib.Algebra.BigOperators.Ring.Finset import Mathlib.Algebra.Group.Int.Defs import Mathlib.Algebra.GroupWithZero.Nat import Mathlib.Algebra.Order.BigOperators.Group.List import Mathlib.Algebra.Order.BigOperators.Group.Multiset import Mathlib.Algebra.Order.Field.Basic import Mathlib.Algebra.Order.Group.Abs import Mathlib.Algebra.Order.Group.Int import Mathlib.Algebra.Order.Group.Nat import Mathlib.Algebra.Order.Group.Unbundled.Abs import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Algebra.Order.Ring.Int import Mathlib.Combinatorics.Colex import Mathlib.Data.Fin.Embedding import Mathlib.Data.Finset.Image import Mathlib.Data.Finset.Powerset import Mathlib.Data.Fintype.BigOperators import Mathlib.Data.Fintype.Card import Mathlib.Data.Fintype.Pi import Mathlib.Data.Fintype.Prod import Mathlib.Data.Int.Basic import Mathlib.Data.Int.Cast.Lemmas import Mathlib.Data.Int.Notation import Mathlib.Data.Int.SuccPred import Mathlib.Data.List.Basic import Mathlib.Data.List.GetD import Mathlib.Data.List.Nodup import Mathlib.Data.Nat.Bitwise import Mathlib.Data.Nat.Cast.Order.Ring import Mathlib.Data.Nat.Choose.Basic import Mathlib.Data.Nat.Choose.Bounds import Mathlib.Data.Nat.Count import Mathlib.Data.Nat.Notation import Mathlib.Data.Nat.Size import Mathlib.Data.Nat.SuccPred import Mathlib.LinearAlgebra.Matrix.Defs import Mathlib.Logic.Function.Basic import Mathlib.Order.ConditionallyCompleteLattice.Basic import Mathlib.Tactic.GCongr import Mathlib.Tactic.Linarith import Mathlib.Tactic.NormNum import Mathlib.Tactic.Positivity import Mathlib.Tactic.Push import Mathlib.Tactic.Ring import Theorems.Thm_ThreeSum_LightClassFilter_meets import Theorems.Thm_ThreeSum_LightColorArray_meets set_option autoImplicit false set_option relaxedAutoImplicit false set_option Elab.async false namespace Light end Light namespace ThreeSum.ColorClassLists end ThreeSum.ColorClassLists namespace ThreeSum.LightClassFilter end ThreeSum.LightClassFilter namespace ThreeSum.LightSubsetAddress end ThreeSum.LightSubsetAddress namespace ThreeSumApsp end ThreeSumApsp
Formal statement
theorem ThreeSum.LightColorClasses.Procs.meets : ∀ {lim : Light.Limits} {P : Light.Program} {d pMain src n W colors dst0 dst1 dst2 work U : Nat} {μ : Nat → Int}
(C : ThreeSum.LightColorClasses.Procs P pMain) (p : ThreeSum.Coloring.Parameter W) (x : Fin n → Int)
(hw : @LE.le.{0} Int Int.instLEInt (@Nat.cast.{0} Int instNatCastInt lim.space) lim.word)
(hn :
@LE.le.{0} Nat instLENat n
(@HPow.hPow.{0, 0, 0} Nat Nat Nat
(@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid)))
(@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) W))
(hsrc : @LE.le.{0} Nat instLENat (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) src n) colors)
(hcolors : @LE.le.{0} Nat instLENat (@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) colors n) dst0)
(h0 :
@LE.le.{0} Nat instLENat
(@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) dst0
(@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) n
(@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))))
dst1)
(h1 :
@LE.le.{0} Nat instLENat
(@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) dst1
(@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) n
(@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))))
dst2)
(h2 :
@LE.le.{0} Nat instLENat
(@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) dst2
(@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) n
(@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))))
work)
(hspace :
@LE.le.{0} Nat instLENat
(@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) work
(@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) W
(@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))))
lim.space)
(hword :
@LE.le.{0} Int Int.instLEInt
(@Nat.cast.{0} Int instNatCastInt
(@HPow.hPow.{0, 0, 0} Nat Nat Nat
(@instHPow.{0, 0} Nat Nat (@NPow.toPow.{0} Nat (@Monoid.toNPow.{0} Nat Nat.instMonoid)))
(@OfNat.ofNat.{0} Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))
(@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) W
(@OfNat.ofNat.{0} Nat (nat_lit 1) (instOfNatNat (nat_lit 1))))))
lim.word)
(hU : @LE.le.{0} Int Int.instLEInt (@Nat.cast.{0} Int instNatCastInt U) lim.word)
(hd :
@LE.le.{0} Nat instLENat
(@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat)
(@HAdd.hAdd.{0, 0, 0} Nat Nat Nat (@instHAdd.{0} Nat instAddNat) d W)
(@OfNat.ofNat.{0} Nat (nat_lit 3) (instOfNatNat (nat_lit 3))))
lim.depth)
(hread : Light.Seg μ src (@List.ofFn.{0} Int n x))
(hbound :
∀ (i : Fin n),
@LE.le.{0} Int Int.instLEInt (@abs.{0} Int instLatticeInt Int.instAddGroup (x i))
(@Nat.cast.{0} Int instNatCastInt U)),
Light.Meets lim P pMain d
(@List.cons.{0} Int (@Nat.cast.{0} Int instNatCastInt src)
(@List.cons.{0} Int (@Nat.cast.{0} Int instNatCastInt n)
(@List.cons.{0} Int (@Nat.cast.{0} Int instNatCastInt W)
(@List.cons.{0} Int
(@Nat.cast.{0} Int instNatCastInt
(@Fin.val W
(@Prod.fst.{0, 0} (Fin W) (Fin W)
(@Prod.fst.{0, 0} (Prod.{0, 0} (Fin W) (Fin W))
(Prod.{0, 0} Bool Bool → Fin (@OfNat.ofNat.{0} Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) p))))
(@List.cons.{0} Int
(@Nat.cast.{0} Int instNatCastInt
(@Fin.val W
(@Prod.snd.{0, 0} (Fin W) (Fin W)
(@Prod.fst.{0, 0} (Prod.{0, 0} (Fin W) (Fin W))
(Prod.{0, 0} Bool Bool → Fin (@OfNat.ofNat.{0} Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) p))))
(@List.cons.{0} Int
(@Nat.cast.{0} Int instNatCastInt
(@Fin.val (@OfNat.ofNat.{0} Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))
(@Prod.snd.{0, 0} (Prod.{0, 0} (Fin W) (Fin W))
(Prod.{0, 0} Bool Bool → Fin (@OfNat.ofNat.{0} Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) p
(@Prod.mk.{0, 0} Bool Bool Bool.false Bool.false))))
(@List.cons.{0} Int
(@Nat.cast.{0} Int instNatCastInt
(@Fin.val (@OfNat.ofNat.{0} Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))
(@Prod.snd.{0, 0} (Prod.{0, 0} (Fin W) (Fin W))
(Prod.{0, 0} Bool Bool → Fin (@OfNat.ofNat.{0} Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) p
(@Prod.mk.{0, 0} Bool Bool Bool.false Bool.true))))
(@List.cons.{0} Int
(@Nat.cast.{0} Int instNatCastInt
(@Fin.val (@OfNat.ofNat.{0} Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))
(@Prod.snd.{0, 0} (Prod.{0, 0} (Fin W) (Fin W))
(Prod.{0, 0} Bool Bool → Fin (@OfNat.ofNat.{0} Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) p
(@Prod.mk.{0, 0} Bool Bool Bool.true Bool.false))))
(@List.cons.{0} Int
(@Nat.cast.{0} Int instNatCastInt
(@Fin.val (@OfNat.ofNat.{0} Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))
(@Prod.snd.{0, 0} (Prod.{0, 0} (Fin W) (Fin W))
(Prod.{0, 0} Bool Bool → Fin (@OfNat.ofNat.{0} Nat (nat_lit 3) (instOfNatNat (nat_lit 3))))
p (@Prod.mk.{0, 0} Bool Bool Bool.true Bool.true))))
(@List.cons.{0} Int (@Nat.cast.{0} Int instNatCastInt colors)
(@List.cons.{0} Int (@Nat.cast.{0} Int instNatCastInt dst0)
(@List.cons.{0} Int (@Nat.cast.{0} Int instNatCastInt dst1)
(@List.cons.{0} Int (@Nat.cast.{0} Int instNatCastInt dst2)
(@List.cons.{0} Int (@Nat.cast.{0} Int instNatCastInt work)
(@List.nil.{0} Int)))))))))))))))
μ (ThreeSum.LightColorClasses.time W n) fun (x_1 : Int) (ν : Nat → Int) =>
@ThreeSum.LightColorClasses.Output n W p x μ ν colors dst0 dst1 dst2 := by
sorry
Source