Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Uniform magnitude bound for a sparse box sum

Proved
ThreeSum.BoxBounds.boxSum_abs_le

by wurtle · Oct 14, 2026 · Mathlib 0df444a (Lean v4.33.1)

3sumalgorithmsfine-grained-complexitythree-sum-1962word-ram

Let L,c,U∈NL,c,U\in\mathbb NL,c,U∈N, and let F,R⊆{0,…,L−1}F,R\subseteq\{0,\ldots,L-1\}F,R⊆{0,…,L−1}. Let www assign an integer weight to every subset of this ground set. Assume ∣F∣≤c|F|\le c∣F∣≤c and ∣w(S)∣≤U|w(S)|\le U∣w(S)∣≤U whenever ∣S∣≤c|S|\le c∣S∣≤c. The box sum ranges over subsets between the required set F∖RF\setminus RF∖R and the allowed set FFF. It satisfies

∣∑F∖R⊆S⊆Fw(S)∣≤2LU.\left|\sum_{F\setminus R\subseteq S\subseteq F}w(S)\right|\le 2^L U.​F∖R⊆S⊆F∑​w(S)​≤2LU.

This gives an explicit integer bound for stored box values, without requiring R⊆FR\subseteq FR⊆F or any sign restriction on the weights.

Preamble
import Aesop
import Definitions.Def_ThreeSum1962Source_Bundle01
import Lean.Elab.Tactic.Omega
import Mathlib.Algebra.BigOperators.Group.Finset.Powerset
import Mathlib.Algebra.BigOperators.Group.Finset.Sigma
import Mathlib.Algebra.BigOperators.Ring.Finset
import Mathlib.Algebra.Order.BigOperators.Group.Finset
import Mathlib.Combinatorics.Colex
import Mathlib.Data.Fin.Embedding
import Mathlib.Data.Finset.Card
import Mathlib.Data.Finset.Max
import Mathlib.Data.Finset.Powerset
import Mathlib.Data.List.Basic
import Mathlib.Data.List.Nodup
import Mathlib.Data.Nat.Choose.Basic
import Mathlib.Tactic.ByContra
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Push
import Mathlib.Tactic.Ring
import Mathlib.Tactic.SplitIfs


set_option autoImplicit false
set_option relaxedAutoImplicit false
set_option Elab.async false
namespace ThreeSum.SubsetAddress
end ThreeSum.SubsetAddress

Formal statement
theorem ThreeSum.BoxBounds.boxSum_abs_le : ∀ {L cut U : Nat} (flags free : Finset.{0} (Fin L)) (weight : Finset.{0} (Fin L) → Int)
  (hflags : @LE.le.{0} Nat instLENat (@Finset.card.{0} (Fin L) flags) cut)
  (hweight :
    ∀ (S : Finset.{0} (Fin L)),
      @LE.le.{0} Nat instLENat (@Finset.card.{0} (Fin L) S) cut →
        @LE.le.{0} Int Int.instLEInt (@abs.{0} Int instLatticeInt Int.instAddGroup (weight S))
          (@Nat.cast.{0} Int instNatCastInt U)),
  @LE.le.{0} Int Int.instLEInt
    (@abs.{0} Int instLatticeInt Int.instAddGroup
      (@ThreeSum.SparseBoxes.boxSum.{0} (Fin L) (@Fin.instLinearOrder L) flags free weight))
    (@Nat.cast.{0} Int instNatCastInt
      (@HMul.hMul.{0, 0, 0} Nat Nat Nat (@instHMul.{0} Nat instMulNat)
        (@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))) L)
        U)) := by
  sorry
Source
https://github.com/c0ldzy17/three-sum-lean/blob/2b639655e07421b9ac743de9090459bab473a7c0/Submission/ThreeSum/BoxBounds.lean#L9-L28

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 paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me