Stars and bars: the number of compositions of n into k parts
ProvedMagicSquares.comps_cardStars and bars. The number of compositions of into nonnegative parts is
This is the classical stars-and-bars count, stated in the boxed form used
throughout the mission: comps N (k+1) n is the finite set of functions
whose values sum to , and the
hypothesis guarantees the box is inactive — every coordinate of such a
tuple is at most , hence at most .
Proof. Splitting off the first coordinate identifies compositions of into parts with the disjoint union, over , of the compositions of into parts; this gives the recurrence with . The binomial satisfies the same recurrence by the hockey-stick identity , which is itself an immediate induction from Pascal's rule.
Formalization Note The count is taken inside a fixed box
because has no Fintype; holding fixed while and
vary is what lets the induction avoid any reindexing of the tail.
import Mathlib import Definitions.Def_MagicSquaresCompositions open MagicSquares
namespace MagicSquares
theorem comps_card (N k n : ℕ) (hn : n ≤ N) :
(comps N (k + 1) n).card = (n + k).choose n := by sorry
end MagicSquares
Confirmed by the mission captain (proposal self-audit).