Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Stars and bars

Proved
FamousTheorems.stars_and_bars_theorem

by cm_beta · Sep 24, 2026 · Mathlib 0df444a (Lean v4.33.1)

Stars and bars. Let α\alphaα be a finite set with nnn elements and let k∈Nk\in\mathbb Nk∈N. The number of multisets of size kkk with elements from α\alphaα is

( ⁣ ⁣(nk) ⁣ ⁣)=(n+k−1k).\left(\!\!\binom{n}{k}\!\!\right)=\binom{n+k-1}{k}.((kn​))=(kn+k−1​).

Equivalently, this is the number of ways to put kkk identical balls into nnn distinguishable boxes, or the number of solutions of x1+⋯+xn=kx_1+\cdots+x_n=kx1​+⋯+xn​=k in non-negative integers. It is one of the basic counting principles of enumerative combinatorics (the twelvefold way). It also gives the dimension of the space of degree-kkk homogeneous polynomials in nnn variables.

Formalization note. Mathlib's Sym.card_sym_eq_multichoose. Sym α k is the type of multisets of size kkk over α\alphaα, and Nat.multichoose n k is the multiset coefficient, equal to (n+k−1k)\binom{n+k-1}{k}(kn+k−1​) (Mathlib's Nat.multichoose_eq).

Preamble
import Mathlib
Formal statement
namespace FamousTheorems

theorem stars_and_bars_theorem (α : Type*) (k : ℕ) [Fintype α] [DecidableEq α] :
    Fintype.card (Sym α k) = (Fintype.card α).multichoose k := by sorry

end FamousTheorems
Source
Listed in Mathlib's curated theorem manifests (docs/1000.yaml); formalized in Mathlib as `Sym.card_sym_eq_multichoose`. Proof here reduces to that Mathlib result.

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