Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Fixed-weight bit-mask enumeration has no duplicates

Proved
ThreeSum.SubsetAddress.enumerateLayer_nodup

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

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

For L,k∈NL,k\in\mathbb NL,k∈N, let EL,kE_{L,k}EL,k​ be the recursively constructed list of LLL-bit masks having kkk selected positions. The enumeration visits the lower half before the upper half and stops on empty layers. It has no repeated entries:

∀i,j<∣EL,k∣,EL,k[i]=EL,k[j]⟹i=j.\forall i,j<|E_{L,k}|,\qquad E_{L,k}[i]=E_{L,k}[j]\Longrightarrow i=j.∀i,j<∣EL,k​∣,EL,k​[i]=EL,k​[j]⟹i=j.

The assertion is uniform in LLL and kkk: the zero-weight list contains only the zero mask, and layers with k>Lk>Lk>L are empty.

This uniqueness property allows list positions to serve as unambiguous compact addresses for subsets of a fixed size.

Preamble
import Definitions.Def_ThreeSum1962Source_Bundle01
import Lean.Elab.Tactic.Omega
import Mathlib.Algebra.BigOperators.Ring.Finset
import Mathlib.Combinatorics.Colex
import Mathlib.Data.Fin.Embedding
import Mathlib.Data.Finset.Powerset
import Mathlib.Data.List.Basic
import Mathlib.Data.List.Nodup
import Mathlib.Data.Nat.Choose.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Ring


set_option autoImplicit false
set_option relaxedAutoImplicit false
set_option Elab.async false

Formal statement
theorem ThreeSum.SubsetAddress.enumerateLayer_nodup : ∀ (L k : Nat), @List.Nodup.{0} Nat (ThreeSum.SubsetAddress.enumerateLayer L k) := by
  sorry
Source
https://github.com/c0ldzy17/three-sum-lean/blob/2b639655e07421b9ac743de9090459bab473a7c0/Submission/ThreeSum/SubsetAddress.lean#L205-L220

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