14.1 Logic, Set Theory, Algorithms, and Combinatorics

Key Takeaways

  • The stars-and-bars method establishes that the number of non-negative integer solutions to x_1 + ... + x_k = n is C(n+k-1, k-1), whereas strictly positive integer solutions number C(n-1, k-1).
  • The Principle of Inclusion-Exclusion calculates the size of arbitrary finite unions and yields the derangement formula D_n = n! sum_{k=0}^n (-1)^k / k! ~ n! / e, which satisfies the recurrence D_n = (n-1)(D_{n-1} + D_{n-2}).
  • The generalized Pigeonhole Principle states that if N items occupy k boxes, at least one box contains at least ceil(N/k) items, providing sharp existence proofs in modular arithmetic and geometric configurations.
  • Linear homogeneous recurrence relations with constant coefficients are solved via the roots of the characteristic polynomial, with root multiplicity m introducing polynomial factors (C_0 + C_1 n + ... + C_{m-1} n^{m-1}) r^n.
  • Propositional equivalences, quantifier negation, set operations, relations, functions, and asymptotic algorithm analysis form the logical framework in which discrete proofs and counting arguments operate.
Last updated: September 2026

14.1 Combinatorics, Binomial Coefficients, and Pigeonhole Principle

Combinatorics on the GRE Mathematics Subject Test evaluates enumerative methods, algebraic identities of binomial coefficients, partition models, the Principle of Inclusion-Exclusion (PIE), the Pigeonhole Principle (PHP), and linear recurrence relations. Mastery of these counting principles and algebraic structures is vital for rapid problem solving.


Permutations, Combinations, and Binomial Identities

For a finite set of $n$ distinct elements:

  • Permutations ($k$-arrangements): $P(n, k) = \frac{n!}{(n-k)!}$
  • Combinations ($k$-subsets): $\binom{n}{k} = \frac{n!}{k!(n-k)!}$

Fundamental Binomial Identities

  • Symmetry & Pascal's Recurrence: $\binom{n}{k} = \binom{n}{n-k}$ and $\binom{n}{k} = \binom{n-1}{k-1} + \binom{n-1}{k}$
  • Binomial Theorem: For any $x, y \in \mathbb{R}$: (x+y)n=∑k=0n(nk)xn−kyk(x + y)^n = \sum_{k=0}^n \binom{n}{k} x^{n-k} y^k Standard specializations include $\sum_{k=0}^n \binom{n}{k} = 2^n$, $\sum_{k=0}^n (-1)^k \binom{n}{k} = 0$, and $\sum_{k=0}^n k \binom{n}{k} = n 2^{n-1}$.
  • Chu-Vandermonde Identity: $\sum_{j=0}^k \binom{m}{j} \binom{n}{k-j} = \binom{m+n}{k}$
  • Hockey-Stick Identity: $\sum_{i=r}^n \binom{i}{r} = \binom{n+1}{r+1}$

Multinomial Theorem and Integer Partitions

Distributing $n$ distinct elements into $r$ distinct labeled categories of sizes $k_1, \dots, k_r$ with $\sum k_i = n$ is given by the multinomial coefficient: (nk1,k2,…,kr)=n!k1!k2!⋯kr!\binom{n}{k_1, k_2, \dots, k_r} = \frac{n!}{k_1! k_2! \cdots k_r!} The multinomial expansion is: (x1+x2+⋯+xr)n=∑k1+⋯+kr=n(nk1,…,kr)x1k1⋯xrkr(x_1 + x_2 + \dots + x_r)^n = \sum_{k_1 + \dots + k_r = n} \binom{n}{k_1, \dots, k_r} x_1^{k_1} \cdots x_r^{k_r} The number of distinct monomials in this expansion is $\binom{n+r-1}{r-1}$.


Stars and Bars (Balls and Urns)

The stars-and-bars method counts compositions of integers, equivalent to placing $n$ indistinguishable objects into $k$ distinguishable bins:

  • Non-Negative Solutions ($x_i \ge 0$): The number of integer solutions to $x_1 + \dots + x_k = n$ is $\binom{n + k - 1}{k - 1}$.
  • Positive Solutions ($x_i \ge 1$): Substituting $y_i = x_i - 1 \ge 0$ gives $y_1 + \dots + y_k = n - k$, yielding $\binom{n - 1}{k - 1}$.
  • General Lower Bounds ($x_i \ge c_i$): Substituting $y_i = x_i - c_i \ge 0$ gives $\sum y_i = n - \sum c_i$.

Principle of Inclusion-Exclusion and Derangements

For finite subsets $A_1, \dots, A_n$ of a universe $U$: ∣A1∪⋯∪An∣=∑i∣Ai∣−∑i<j∣Ai∩Aj∣+⋯+(−1)n−1∣A1∩⋯∩An∣|A_1 \cup \dots \cup A_n| = \sum_{i} |A_i| - \sum_{i < j} |A_i \cap A_j| + \dots + (-1)^{n-1} |A_1 \cap \dots \cap A_n| The count of elements satisfying none of properties $A_1, \dots, A_n$ is: ∣U∖⋃i=1nAi∣=∣U∣−∑∣Ai∣+∑∣Ai∩Aj∣−⋯+(−1)n∣A1∩⋯∩An∣|U \setminus \bigcup_{i=1}^n A_i| = |U| - \sum |A_i| + \sum |A_i \cap A_j| - \dots + (-1)^n |A_1 \cap \dots \cap A_n|

Derangements

A derangement is a permutation $\sigma \in S_n$ with no fixed points ($\sigma(i) \neq i$ for all $i$). By PIE: Dn=n!∑k=0n(−1)kk!=n!(1−1+12!−⋯+(−1)nn!)D_n = n! \sum_{k=0}^n \frac{(-1)^k}{k!} = n! \left( 1 - 1 + \frac{1}{2!} - \dots + \frac{(-1)^n}{n!} \right) As $n \to \infty$, $D_n / n! \to e^{-1} \approx 0.3679$. The derangement numbers satisfy the recurrences: Dn=(n−1)(Dn−1+Dn−2),Dn=nDn−1+(−1)nD_n = (n-1)(D_{n-1} + D_{n-2}), \qquad D_n = n D_{n-1} + (-1)^n with initial terms $D_1 = 0, D_2 = 1, D_3 = 2, D_4 = 9, D_5 = 44$.


The Pigeonhole Principle (PHP)

  • Basic PHP: If $N$ items occupy $k$ boxes and $N > k$, at least one box contains $\ge 2$ items.
  • Generalized PHP: If $N$ items occupy $k$ boxes, at least one box contains $\ge \lceil N/k \rceil$ items.
  • Applications: Finding identical remainders modulo $m$ among $m+1$ integers, bounding pairwise distances of points in compact sets, and Ramsey number bounds (such as $R(3,3) = 6$).

Linear Recurrence Relations

A homogeneous linear recurrence of order $k$ with constant coefficients has the form: an+c1an−1+⋯+ckan−k=0a_n + c_1 a_{n-1} + \dots + c_k a_{n-k} = 0 Its characteristic polynomial is $P(r) = r^k + c_1 r^{k-1} + \dots + c_k = 0$.

  • Distinct Roots: If roots $r_1, \dots, r_k$ are distinct, the general solution is $a_n = \sum_{i=1}^k C_i r_i^n$.
  • Repeated Roots: A root $r$ of multiplicity $m$ contributes $(C_0 + C_1 n + \dots + C_{m-1} n^{m-1}) r^n$.
  • Non-Homogeneous Recurrences: For $a_n + c_1 a_{n-1} = f(n)$, solve $a_n = a_n^{(h)} + a_n^{(p)}$ using undetermined coefficients.

Combinatorial Counting Reference Table

ModelObject NatureBin / Group TypeFormula
Ordered SelectionsDistinctDistinct (no replacement)$P(n, k) = \frac{n!}{(n-k)!}$
Unordered SelectionsDistinctDistinct (no replacement)$\binom{n}{k} = \frac{n!}{k!(n-k)!}$
Multinomial PartitionsDistinctLabeled Categories$\binom{n}{k_1, \dots, k_r} = \frac{n!}{\prod k_i!}$
Stars & Bars ($x_i \ge 0$)IndistinguishableDistinguishable$\binom{n+k-1}{k-1}$
Stars & Bars ($x_i \ge 1$)IndistinguishableDistinguishable$\binom{n-1}{k-1}$
DerangementsDistinctFixed-point free$D_n = n! \sum_{j=0}^n \frac{(-1)^j}{j!}$

Step-by-Step Worked Problem

Problem: How many integer solutions satisfy $x_1 + x_2 + x_3 + x_4 = 20$ subject to $1 \le x_1, x_2 \le 6$ and $x_3, x_4 \ge 0$?

Solution:

  1. Shift lower bounds: Set $y_1 = x_1 - 1 \ge 0$ and $y_2 = x_2 - 1 \ge 0$. The conditions become $0 \le y_1, y_2 \le 5$ and $x_3, x_4 \ge 0$.
  2. Transform equation: $(y_1 + 1) + (y_2 + 1) + x_3 + x_4 = 20 \implies y_1 + y_2 + x_3 + x_4 = 18$.
  3. Unrestricted non-negative count: By stars and bars, $\binom{18 + 4 - 1}{4 - 1} = \binom{21}{3} = 1330$.
  4. Violations via PIE:
    • Let $A_1$ be $y_1 \ge 6$: substitute $z_1 = y_1 - 6 \ge 0 \implies z_1 + y_2 + x_3 + x_4 = 12$, yielding $|A_1| = \binom{12+3}{3} = \binom{15}{3} = 455$.
    • By symmetry, $|A_2| = 455$ for $y_2 \ge 6$.
    • For $A_1 \cap A_2$ ($y_1, y_2 \ge 6$): $z_1 + z_2 + x_3 + x_4 = 6$, yielding $|A_1 \cap A_2| = \binom{6+3}{3} = \binom{9}{3} = 84$.
  5. Compute valid count: By PIE, $|A_1 \cup A_2| = 455 + 455 - 84 = 826$. Valid Solutions=1330−826=504\text{Valid Solutions} = 1330 - 826 = 504

GRE Exam Traps & Pitfalls

Trap 1: Indistinguishable vs. Distinguishable Bins Stars and bars applies strictly when bins are distinguishable ($x_1 + x_2 + x_3 = n$). If bins are indistinguishable, the problem requires integer partition numbers $p(n)$ or Stirling numbers of the second kind, not binomial coefficients.

Trap 2: Omitting Powers of $n$ for Repeated Characteristic Roots When a characteristic root has multiplicity $m > 1$, omitting factors of $n^j$ ($n r^n, n^2 r^n$) produces a defective basis that cannot satisfy arbitrary initial values.

Trap 3: Double Counting Violations in Bounded Stars & Bars Subtracting single-variable upper-bound violations without adding back their intersections over-penalizes the count and violates PIE.

Trap 4: Conflating Strict with Weak Inequality in Compositions Pay careful attention to whether variables satisfy $x_i \ge 0$ ($\binom{n+k-1}{k-1}$) or $x_i \ge 1$ ($\binom{n-1}{k-1}$). Shifting bounds before applying stars and bars eliminates indexing errors.

Logic, Set Theory, Relations, and Algorithms

Discrete mathematics begins with precise statements and finite procedures. These ideas support combinatorial proofs and prevent common errors with negation, quantifiers, and asymptotic comparisons.

Propositional logic and quantifiers

An implication $p\Rightarrow q$ is false only when $p$ is true and $q$ is false. It is logically equivalent to $\neg p\lor q$ and to its contrapositive $\neg q\Rightarrow\neg p$, but not to its converse $q\Rightarrow p$. De Morgan's laws are

\neg(p\lor q)\equiv \neg p\land\neg q.$$ Quantifier order matters. The negations are $$\neg(\forall x\,P(x))\equiv\exists x\,\neg P(x),\qquad \neg(\exists x\,P(x))\equiv\forall x\,\neg P(x).$$ Thus the negation of “for every real $x$ there exists an integer $n$ with $n>x$” is “there exists a real $x$ such that every integer $n$ satisfies $n\le x$.” Each quantifier changes and the predicate is negated. Standard proof methods include direct proof, contrapositive, contradiction, cases, and induction. Strong induction allows the entire collection of earlier cases in the induction step. To disprove a universal statement, one counterexample suffices; examples cannot prove a universal statement. ## Sets, functions, and cardinality For sets $A,B$, $$A\setminus B=A\cap B^c,\qquad (A\cup B)^c=A^c\cap B^c,\qquad (A\cap B)^c=A^c\cup B^c.$$ The Cartesian product $A\times B$ contains ordered pairs, so for finite sets $|A\times B|=|A||B|$. The power set $\mathcal P(A)$ contains every subset and has size $2^{|A|}$ when $A$ is finite. Cantor's theorem says there is no surjection $A\to\mathcal P(A)$ for any set $A$. A function is injective when equal outputs force equal inputs, surjective when every codomain element is attained, and bijective when both hold. For finite sets of equal size, injective, surjective, and bijective are equivalent. For infinite sets they are not: $n\mapsto n+1$ on the nonnegative integers is injective but not surjective. ## Relations and equivalence classes A relation on $A$ is a subset of $A\times A$. An equivalence relation is reflexive, symmetric, and transitive. Its equivalence classes form a partition of $A$; conversely, every partition defines an equivalence relation by putting elements in the same block. A partial order is reflexive, antisymmetric, and transitive. In a poset, two elements need not be comparable. A total order adds comparability. Divisibility on positive integers is a partial order, while congruence modulo $n$ is an equivalence relation. ## Algorithms, correctness, and growth An algorithm is a finite, unambiguous procedure. A correctness proof usually establishes a precondition, a loop invariant preserved by each iteration, and a postcondition obtained when the loop terminates. Termination needs a quantity that moves monotonically toward a bound, such as a nonnegative integer that strictly decreases. Big-O gives an eventual upper bound: $f(n)=O(g(n))$ if constants $C,n_0>0$ exist with $|f(n)|\le C|g(n)|$ for $n\ge n_0$. Big-Omega is an eventual lower bound, and Big-Theta means both. Constant factors and lower-order terms disappear, so $3n^2+7n+4=\Theta(n^2)$. The usual growth hierarchy is $$1\prec\log n\prec n^a\prec b^n\prec n!$$ for fixed $a>0$ and $b>1$. A loop performing constant work $n$ times is $\Theta(n)$. Two nested loops each running $n$ times are usually $\Theta(n^2)$. Repeatedly halving the problem size produces $\Theta(\log n)$ iterations, which explains binary search. Correctness and running time are different claims: a fast algorithm may be wrong, and a correct algorithm may be inefficient. ### Worked example Consider Euclid's algorithm: while $b\ne0$, replace $(a,b)$ by $(b,a\bmod b)$. The invariant is $\gcd(a,b)=\gcd(b,a\bmod b)$. The second nonnegative coordinate strictly decreases, so the process terminates. At termination $b=0$, and the invariant gives the answer $\gcd(a,0)=|a|$. ## Common traps The converse is not the contrapositive. Negating a quantified statement changes every quantifier. Antisymmetry does not mean “not symmetric.” Big-O is not exact equality, and an upper bound need not be tight. A loop invariant must hold before the loop, remain true after each iteration, and imply the desired result at termination.
Loading diagram...
Combinatorial Counting Strategy Selection
Test Your Knowledge

A secret Santa gift exchange involves 5 participants, each bringing one distinct gift. If the 5 gifts are randomly redistributed such that each participant receives exactly one gift, what is the probability that no person receives their own gift?

A
B
C
D
Test Your Knowledge

Consider the second-order linear homogeneous recurrence relation a_n - 6a_{n-1} + 9a_{n-2} = 0 for n >= 2, with initial conditions a_0 = 1 and a_1 = 9. What is the explicit formula for a_n?

A
B
C
D
Test Your Knowledge

How many integer solutions (x_1, x_2, x_3) satisfy the equation x_1 + x_2 + x_3 = 15 subject to the constraints 0 <= x_1 <= 6, 0 <= x_2 <= 7, and 0 <= x_3 <= 8?

A
B
C
D
Test Your Knowledge

What is the logical negation of: For every real x, there exists an integer n such that n > x?

A
B
C
D
Test Your Knowledge

Which property distinguishes a partial order from an equivalence relation?

A
B
C
D
Test Your Knowledge

An algorithm has an outer loop running n times and an inner loop running from 1 through the current outer index i. What is its asymptotic running time when the body is constant time?

A
B
C
D