Counting on Sets, Relations, and Functions
Every counting tool we have built across Sections 01–09—the Multiplication Principle, Combinations, Stars and Bars, Inclusion–Exclusion, Stirling Numbers, and Bell Numbers—comes together naturally when counting the three core structures of discrete mathematics: subsets, relations, and functions on finite sets.
1. Counting Subsets§
Let be a finite set containing elements. Recall that the collection of all subsets of is called the power set of , denoted .
- Total subsets of : , because each of the elements independently has choices (either included in the subset or excluded).
- Proper subsets of : Excluding itself leaves proper subsets (and excluding both and leaves non-empty proper subsets).
- Subsets of exact size : .
- Subsets always containing particular elements: Those fixed elements have only choice (must be included), while the remaining elements have choices each, giving subsets. (For a single particular element, .)
Example 1 (Pairs of Subsets Under Set Conditions): Let . Find the number of ordered pairs of subsets of such that: (a) , (b) , (c) .
Solution: Decide the fate of each element independently! In general, any element has possibilities across : (1) ; (2) ; (3) ; (4) .
- (a) : Possibility (1) is forbidden, leaving independent choices for each of the elements ordered pairs. (If we instead ask for unordered disjoint pairs , notice is the unique pair with ; the remaining ordered pairs come in symmetric twins and , giving unordered pairs.)
- (b) : Possibility (4) ( in neither set) is forbidden, leaving choices per element ordered pairs.
- (c) : Possibility (2) ( but ) is forbidden, leaving choices per element ordered pairs.
2. Counting Relations on Finite Sets§
Let and be finite sets containing and elements respectively. Recall that the Cartesian product is the set of all ordered pairs:
Because the first entry can be chosen from in ways and the second entry from in ways, .
By definition, any relation from to is a subset of . Since contains elements:
Visualizing Relations on a Set via a Square Matrix Grid§
Now focus on relations defined on a single set —that is, subsets of . To count special classes of relations effortlessly, arrange all ordered pairs of in an matrix:
Notice the exact geometry of these entries:
- main-diagonal entries: for .
- non-diagonal entries, split evenly into upper-triangular entries () and lower-triangular entries (), where each upper entry sits directly opposite its mirror pair across the diagonal.

Now count every major type of relation on directly from this matrix:
1. Total Relations on : Each of the entries independently has choices (in or not in ):
2. Reflexive Relations: A relation on is reflexive if for all (e.g., on , is reflexive).
In the matrix of , all main-diagonal entries must be included ( choice each), while each of the non-diagonal entries is free ( choices each):
3. Irreflexive Relations: A relation on is irreflexive if for all . All diagonal entries are forced to be excluded ( choice each), while the off-diagonal entries remain free:
4. Symmetric Relations: A relation on is symmetric if whenever , we also have . For example, on :
- and are symmetric.
- The empty relation is vacuously symmetric (there is no pair that violates the rule!).
- and are not symmetric because is missing.
Look at the matrix of :
- Each of the diagonal entries is its own mirror, so it freely has choices (included or excluded).
- Each of the upper-triangular entries () has choices—and once that choice is made, its lower-triangular mirror has only forced choice (it must match)!
By the Multiplication Principle:
5. Relations That Are Both Reflexive and Symmetric: All diagonal entries are forced to be included ( choice each), and the off-diagonal mirror pairs have choices each:
6. Antisymmetric Relations: A relation on is antisymmetric if whenever and , we must have . (In other words, for distinct , we can never include both and simultaneously!)
Look at the matrix of :
- Each of the diagonal entries has , so it never violates antisymmetry: choices each.
- For each of the off-diagonal pairs (), including both is forbidden, leaving exactly valid choices: include neither, include only , or include only .
By the Multiplication Principle:
7. Equivalence Relations (The Bell Number Connection): A relation on is an equivalence relation if it is simultaneously reflexive, symmetric, and transitive.
Why is counting equivalence relations not a simple power of or ? Because transitivity links triples of entries across the matrix! Fortunately, a fundamental theorem of Set Theory gives an exact bijection:
- Every equivalence relation on partitions into pairwise disjoint, non-empty equivalence classes.
- Conversely, every partition of into non-empty subsets uniquely defines an equivalence relation ( if and only if and lie in the same block of the partition).
By the Bijection Principle (Section 01) and Stirling / Bell Numbers (Section 09):

Example 2: On the set (), find the number of: (a) total relations, (b) reflexive relations, (c) symmetric relations, (d) antisymmetric relations, (e) equivalence relations.
Solution:
- (a) Total relations: .
- (b) Reflexive relations: .
- (c) Symmetric relations: .
- (d) Antisymmetric relations: .
- (e) Equivalence relations: .
3. Counting Functions Between Finite Sets§
Let and be finite sets with (the domain) and (the codomain). According to the definition of a function, a mapping assigns to every element one and only one image .
Look closely at what that definition means combinatorially: defining a function is 100% identical to distributing distinct objects (elements of ) into distinct boxes (elements of )!

1. Total Number of Functions§
Each of the elements in independently chooses its image from the elements in . By the Multiplication Principle:
2. Injective (One-One) Functions§
A function is injective (one-one) if distinct inputs always produce distinct outputs: (no two balls land in the same box).
- If : By the Pigeonhole Principle (Section 01), placing domain elements into codomain elements guarantees a collision—so there are injective functions.
- If : The first element of has choices, the second has , ..., and the -th has choices:
3. Bijective (One-One and Onto) Functions§
A function is bijective if it is both injective and surjective. This requires (for injectivity) and (for surjectivity), so is mandatory! When , every injective function automatically covers all elements of :
4. Surjective (Onto) Functions§
A function is surjective (onto) if every element is hit by at least one element of (its range equals the entire codomain ).
- If : Not enough domain elements exist to cover all elements of , so there are surjective functions.
- If : Covering every element of is literally identical to distributing distinct objects into distinct non-empty boxes (Section 09)! By PIE and Stirling numbers of the second kind:
Example 3: Let () and (). Find the number of functions that are: (a) unrestricted, (b) injective, (c) surjective, (d) into (not onto).
Solution:
(a) Unrestricted: .
(b) Injective: Since , there are injective functions.
(c) Surjective: Using PIE with and :
(Notice also !)
(d) Into (not onto): By the Subtraction Principle, .
5. Monotonic Functions§
Suppose both and are ordered sets of numbers, and we want to count functions that respect order.
Strictly Increasing Functions (): Every strictly increasing function outputs distinct values from . Conversely, once you choose any unordered subset of distinct values from , there is only way to assign them in strictly increasing order (smallest value to , next smallest to , ..., largest to )! By the Bijection Principle (for ):
(By the exact same reasoning, the number of strictly decreasing functions is also .)
Non-Decreasing (Weakly Increasing) Functions (): Now output values are allowed to repeat! A non-decreasing function is completely determined by choosing values from with repetition allowed (unordered) and writing them in non-decreasing order! Equivalently, let be the number of domain elements mapping to (); then with . By Stars and Bars (Section 07):
(And by symmetry, the number of non-increasing functions is also .)
Example 4: How many functions are: (a) strictly increasing, (b) non-decreasing, (c) monotonic (either non-decreasing or non-increasing)?
Solution: Here and .
- (a) Strictly increasing: .
- (b) Non-decreasing: .
- (c) Monotonic: There are non-decreasing functions and non-increasing functions. Watch out for overlap! Which functions are both non-decreasing and non-increasing? Precisely the constant functions ( for )! By PIE (avoiding overcounting):
Master Summary Table§
| Discrete Structure | Count | Condition |
|---|---|---|
| Subsets of an -element set | ||
| Relations from to | ||
| Reflexive / Irreflexive relations on | ||
| Symmetric relations on | ||
| Reflexive & Symmetric relations on | ||
| Antisymmetric relations on | ||
| Equivalence relations on | ||
| Total functions | ||
| Injective (one-one) functions | ( if ) | |
| Bijective functions | ( if ) | |
| Surjective (onto) functions | ( if ) | |
| Strictly increasing / decreasing functions | ||
| Non-decreasing / non-increasing functions |
Mark this section complete when you have worked through its proofs.