Inclusion-exclusion and double counting
This chapter rigorously introduces advanced combinatorial techniques, including the Inclusion-Exclusion Principle and Double Counting. Mastery of these methods is crucial for effectively addressing complex enumeration problems, a common requirement in CMI examinations.
---
Chapter Contents
|
| Topic |
|---|-------| | 1 | Counting through cases | | 2 | Complement counting | | 3 | Inclusion-exclusion principle | | 4 | Double counting |---
We begin with Counting through cases.
Part 1: Counting through cases
Counting through Cases
Overview
Counting through cases is one of the most reliable combinatorial methods. The idea is simple: split a complicated counting problem into simpler, non-overlapping cases, count each case separately, and then add the answers. In harder problems, the challenge is not arithmetic but choosing a case split that is both complete and disjoint. ---Learning Objectives
After studying this topic, you will be able to:
- Partition a counting problem into valid cases.
- Ensure the cases are exhaustive and non-overlapping.
- Use addition and multiplication principles inside each case.
- Detect bad case splits that overcount or miss possibilities.
- Solve medium-level combinatorics questions by structured classification.
Core Idea
Suppose a set of objects can be divided into cases
such that:
- every desired object belongs to at least one case
- no object belongs to more than one case
Then the total number of objects is
What Makes a Good Case Split?
A case split is useful only if it is:
- Exhaustive
Every valid object must fall into some case.
- Disjoint
No valid object should be counted in two different cases.
A case split that is not disjoint leads to overcounting.
A case split that is not exhaustive misses valid objects.
Both errors are common in exam problems.
Standard Reasons to Split into Cases
You often split according to:
- whether a specific element is chosen or not chosen
- the first position or last position
- parity: even / odd
- number of repeated objects
- largest or smallest element
- whether a restriction is active or inactive
- how many times a special symbol appears
Addition and Multiplication Principles Together
After splitting into cases, each case is usually counted using:
- the multiplication principle
- permutations
- combinations
- simple arrangement logic
Then all case-counts are added.
Minimal Worked Examples
Example 1 How many 3-digit numbers have distinct digits? Split into two cases according to whether the first digit is or not. But since a 3-digit number cannot begin with , the better approach is direct counting. First digit: choices to Second digit: choices Third digit: choices So total: This example shows that not every problem needs a case split. --- Example 2 How many 4-letter strings over contain at least one and at least one ? Split into cases by number of 's:- exactly one :
- exactly two 's:
- exactly three 's:
When Cases Are Better Than Formulas
Use counting through cases when:
- there is a visible special element
- different configurations behave differently
- a direct formula is messy
- the condition says βat least oneβ, βexactly oneβ, βeither-orβ, or βdepending onβ
- restrictions change according to the arrangement
Complement vs Cases
Sometimes a problem can be solved either:
- by splitting into cases, or
- by complement counting
For example, βat least oneβ often suggests complement.
But when the complement is not simpler, casework is usually better.
Common Patterns
- Count objects with exactly special features.
- Count objects with at least one special feature by splitting into exact-count cases.
- Count arrangements depending on where a distinguished object sits.
- Count integers or strings according to parity or repeated symbols.
- Count selections by whether a special group contributes elements.
Common Mistakes
- β Cases overlap
- β Cases do not cover everything
- β Counting the same structure in two different languages
- β Using casework when one direct count is easier
CMI Strategy
- Identify the feature that causes different behaviour.
- Split according to that feature.
- Check the cases are disjoint.
- Check the cases cover all possibilities.
- Count each case independently and add.
- At the end, do a quick sanity check on size.
Practice Questions
:::question type="MCQ" question="A counting-by-cases solution is valid only when the cases are" options=["equal in size","disjoint and exhaustive","all symmetric","all nonempty"] answer="B" hint="Think about when addition of case-counts works." solution="Counting by cases works when every valid object lies in exactly one case. So the cases must be disjoint and exhaustive. Therefore the correct option is ." ::: :::question type="NAT" question="How many binary strings of length contain exactly two 's?" answer="6" hint="Choose the positions of the 's." solution="A binary string of length with exactly two 's is determined by choosing which of the positions contain . Hence the count is Therefore the answer is ." ::: :::question type="MSQ" question="Which of the following are good ways to split a counting problem into cases?" options=["according to the number of selected special elements","according to whether a distinguished object is chosen or not","using overlapping cases and subtracting later without checking","according to parity when parity changes the structure"] answer="A,B,D" hint="A good split should simplify the problem and avoid uncontrolled overlap." solution="1. True. This is a very standard case split.- exactly one :
- exactly two 's:
- exactly three 's:
- exactly four 's:
Summary
- Counting through cases is addition after a correct partition.
- The cases must be exhaustive and disjoint.
- Good casework is about choosing the right classification.
- Each case is usually counted using simpler principles.
- In many combinatorics problems, the hard part is choosing the cases, not counting them.
---
Proceeding to Complement counting.
---
Part 2: Complement counting
Complement Counting
Overview
Complement counting is a counting strategy where we count the total number of objects first and then subtract the number of unwanted objects. It is especially useful when the direct count of the desired set is messy but the opposite set is easy to count. ---Learning Objectives
After studying this topic, you will be able to:
- Recognise when complement counting is more efficient than direct counting.
- Use the formula
correctly.
- Solve βat least oneβ, βnot allβ, and βrepetitionβ type counting problems.
- Combine complement counting with basic inclusion-exclusion ideas when needed.
- Avoid counting the complement incorrectly.
Core Idea
If is the universal set and is the set we want to count, then
where is the complement of inside .
- is easy to count
- is simpler than
Standard Patterns
- At least one
- Contains repetition
- Not all satisfy a condition
- At least one forbidden digit / object / property
Why It Works Well
Many problems ask for a condition like:
- at least one zero
- at least one repeated digit
- at least one success
- not all chosen from one category
Such conditions are difficult to count directly because there may be many overlapping cases.
The opposite event is often cleaner:
- no zero
- no repeated digit
- no success
- all chosen from one category
Standard Examples of Complement Choice
Use complement counting when the desired condition involves:
- βat least oneβ
- βnot allβ
- βat least one repeatedβ
- βnot equal to a special caseβ
- many overlapping bad cases that collapse into one clean opposite case
Minimal Worked Examples
Example 1 How many binary strings of length contain at least one ? Total number of binary strings: Complement: strings with no , that is, all zeros: So the answer is --- Example 2 How many -digit numbers have at least one repeated digit? Total -digit numbers: Complement: all digits distinct.- First digit: choices
- Second digit: choices
- Third digit: choices
- Fourth digit: choices
Relation with Inclusion-Exclusion
Sometimes the complement itself is a union of several bad cases. Then:
but to compute , you may need inclusion-exclusion.
So complement counting and inclusion-exclusion are not rivals; they often work together.
Common Traps
- β Forgetting to define the universe first
- β Counting the complement in a different universe
- β Missing restrictions such as first digit nonzero
- β Directly counting βat least oneβ by adding cases
- β Using complement when the complement is actually harder
CMI Strategy
- Define the total set clearly.
- Translate the wanted condition into its exact opposite.
- Check whether the opposite condition is easier to count.
- Count total and complement in the same sample space.
- Subtract only at the very end.
Practice Questions
:::question type="MCQ" question="How many binary strings of length contain at least one ?" options=["","","",""] answer="A" hint="Count total strings and subtract the all-zero string." solution="Total binary strings of length : Complement: the string with no , namely : So required number: Hence the correct option is ." ::: :::question type="NAT" question="How many -digit numbers contain no digit ?" answer="648" hint="Count directly in the complement-friendly form." solution="For a -digit number with no digit :- Hundreds place: choices, namely
- Tens place: choices, namely all digits except
- Units place: choices, namely all digits except
- First digit: choices
- Second digit: choices
- Third digit: choices
- Fourth digit: choices
Summary
- Complement counting uses
.
- It is especially useful for βat least oneβ and repetition-type conditions.
- The universe must be fixed before taking complements.
- Leading-digit and restriction issues must be handled carefully.
- In many problems, complement counting is the cleanest way to avoid overlapping cases.
---
Proceeding to Inclusion-exclusion principle.
---
Part 3: Inclusion-exclusion principle
Inclusion-Exclusion Principle
Overview
The inclusion-exclusion principle is the standard tool for counting objects that satisfy at least one of several conditions, especially when direct counting causes overcounting because some objects belong to multiple categories. In CMI-style problems, it appears in:- union of sets,
- passwords with multiple required character types,
- onto functions,
- club membership problems,
- arrangements with forbidden patterns,
- exact-count conditions after subtracting overlaps.
Learning Objectives
After studying this topic, you will be able to:
- Use inclusion-exclusion for two sets and three sets.
- Count objects with at least one of several properties.
- Count onto functions by excluding functions that miss one or more values.
- Handle counting questions with letters, digits, vowels, consonants, and similar classes.
- Decide when inclusion-exclusion is the right tool and when a gap method or direct counting is cleaner.
Core Formulas
For finite sets and ,
For finite sets ,
When you add , an element in all three sets is counted three times.
Then subtracting pairwise intersections removes it three times.
So it disappears completely, and must be added back once.
General Pattern
To count objects having at least one of several properties:
- Count everything.
- Subtract objects missing one property.
- Add back objects missing two properties.
- Subtract objects missing three properties.
- Continue with alternating signs.
Counting With Complements
Very often, the fastest route is:
But if the bad objects themselves break into overlapping classes, then inclusion-exclusion is used inside the bad count.
- total passwords
- subtract passwords with no digit
- subtract passwords with no letter
- add back passwords with neither digit nor letter
Onto Functions
Let and .
Total functions from to :
To count onto functions, subtract those that miss at least one image:
- miss :
- miss :
- miss :
This subtracts too much, since functions using only one symbol were subtracted twice too many times. Add them back:
- only :
- only :
- only :
Hence
Password and String Problems
Suppose length- strings are formed from:
- vowels:
- consonants:
- digits:
Total alphabet size:
Number of length- strings with at least one vowel, at least one consonant, and at least one digit:
because:
- no vowel
- no consonant
- no digit
- no vowel and no consonant
- no vowel and no digit
- no consonant and no digit
Exact Distribution Questions
If a function from an -element set to has:
- exactly elements mapped to
- exactly mapped to
- exactly mapped to
with , then the count is
This is not inclusion-exclusion itself, but it often appears next to onto counting in the same problems.
Club Membership Problems
If three clubs each have known size, then the total number of students in at least one club is
This can be used to get:
- exact totals when intersections are known,
- largest possible total by minimizing overlaps,
- smallest possible total by maximizing overlaps.
When Inclusion-Exclusion Is Not the Best Tool
Some restriction problems are better solved by a gap method rather than inclusion-exclusion.
Example:
- arranging letters so that no two are consecutive
For such problems, first place the unrestricted objects, then choose allowed gaps for the restricted objects.
So inclusion-exclusion is powerful, but not every restriction problem should be forced into it.
Minimal Worked Examples
Example 1: Union of three sets If and then So the union has size . --- Example 2: Onto functions to from a 5-element set So the answer is . --- Example 3: Passwords with at least one letter and one digit Using letters and digits for length passwords: Total passwords: Subtract:- all-letter passwords:
- all-digit passwords:
Common Mistakes
- β Forgetting to add back the triple intersection in the three-set formula.
- β Subtracting βbad casesβ that overlap, but never correcting the overlap.
- β Using inclusion-exclusion when a gap method is simpler.
- β Counting onto functions by subtracting only one missing image class.
- β Forgetting that βat least one from each classβ usually needs alternating subtraction and addition.
CMI Strategy
- Decide what the βbadβ conditions are.
- Count total objects first.
- Count objects violating one condition.
- Count overlaps of bad conditions.
- Use alternating signs carefully.
- Simplify only after the structure is correct.
- If the problem is about adjacency, first ask whether the gap method is better.
Practice Questions
:::question type="MCQ" question="If , , and , then equals" options=["","","",""] answer="A" hint="Use the two-set formula." solution="We use So Hence the correct option is ." ::: :::question type="NAT" question="How many onto functions are there from a -element set to a -element set?" answer="14" hint="Subtract the two constant functions from all functions." solution="Total functions: Non-onto functions are the two constant functions, one using only the first value and one using only the second. Hence the number of onto functions is So the answer is ." ::: :::question type="MSQ" question="Which of the following statements are true?" options=[""," for all sets","The number of onto functions from an -element set to a -element set is ","Inclusion-exclusion is often used with complement counting"] answer="A,C,D" hint="One option is missing the triple-intersection term." solution="1. True.- miss :
- miss :
- miss :
- all values are
- all values are
- all values are
Summary
- Inclusion-exclusion corrects overcounting by alternating subtraction and addition.
- For two sets, subtract the overlap once.
- For three sets, subtract pairwise overlaps and add back the triple overlap.
- Onto functions are counted naturally by excluding functions that miss one or more images.
- Password and string problems with βat least one from each classβ are classic inclusion-exclusion applications.
- The hardest part is usually identifying the bad conditions correctly.
---
Proceeding to Double counting.
---
Part 4: Double counting
Double Counting
Overview
Double counting is one of the most elegant methods in combinatorics. The principle is to count the same set or quantity in two different ways and then equate the results. This often converts a difficult counting problem into a simple identity. In CMI-style problems, double counting is used not only for formulas, but also for proving relations and extracting hidden structure. ---Learning Objectives
After studying this topic, you will be able to:
- Recognise when a set or quantity can be counted in two ways.
- Build a valid double-counting argument.
- Use double counting to prove identities.
- Count incidences between two kinds of objects.
- Avoid invalid arguments where the two counts are not counting the same thing.
Core Idea
Suppose a quantity can be counted in two different correct ways. Then the two answers must be equal.
Symbolically,
but with two different expressions on the two sides.
This gives a useful identity or formula.
Most Common Model: Counting Incidences
Suppose we have two types of objects:
- objects of type
- objects of type
and we count the number of incidences between them.
Then we may count:
- first by fixing an object of type
- then by fixing an object of type
Both counts must agree.
- studentβclub memberships
- edgeβendpoint incidences in a graph
- committeeβmember incidences
- subsetβelement incidences
Classic Combinatorial Identity
Count the number of pairs such that:
- is a -element subset of an -element set
Count in two ways:
Way 1: choose the set first, then the element inside it
Way 2: choose the element first, then complete the set
Hence,
Why Double Counting Works
A double-counting proof is valid only if both sides count exactly the same collection of objects.
Not similar objects. Not related objects. The same objects.
A wrong double-counting argument often happens when:
- the left side counts one structure
- the right side counts a slightly different structure
So always state clearly: what exactly is being counted?
Standard Situations for Double Counting
- Counting pairs where belongs to
- Counting edge-endpoint incidences in a graph
- Counting committee-member or object-container incidences
- Proving algebraic identities involving binomial coefficients
- Summing row counts and column counts of a matrix of 's and 's
Minimal Worked Examples
Example 1 Prove Count subsets of an -element set in two ways.- Directly: each element is either included or not included, so there are subsets.
- By size: the number of subsets with exactly elements is .
- Each edge contributes incidences.
- A vertex of degree contributes incidences.
Incidence Table View
Imagine a table whose rows are objects of type and columns are objects of type .
Write when there is an incidence, and otherwise.
Then:
- summing rows gives one count
- summing columns gives another count
Both must give the same total number of 's.
How to Build a Double Count
- Decide what set of objects, pairs, or incidences to count.
- Count it one way using one feature.
- Count it another way using a different feature.
- Equate the two expressions.
- Simplify the result.
Common Patterns
- Count pairs with
- Count selections with a distinguished chosen element
- Count total appearances of elements across subsets
- Count graph incidences
- Count a set by grouping in two different ways
Common Mistakes
- β Counting different objects on the two sides
- β Forgetting multiplicity
- β Proving a formula without explaining the combinatorial meaning
- β Mixing ordered and unordered choices
CMI Strategy
Ask:
- Is there a natural set of pairs here?
- Can the quantity be grouped by one variable or the other?
- Is there an identity with binomial coefficients hiding in the background?
- Is there a graph or incidence interpretation available?
If yes, try double counting before doing algebra.
Practice Questions
:::question type="MCQ" question="In a valid double-counting proof, the two expressions must count" options=["equal numbers by luck","the same set of objects in two ways","different objects of equal size","approximate values"] answer="B" hint="This is the central principle of the method." solution="A double-counting argument works only when both expressions count exactly the same set or quantity, but in two different ways. Therefore the correct option is ." ::: :::question type="NAT" question="How many incidences are contributed by a graph with edges when counted edge-wise?" answer="14" hint="Each edge has two endpoints." solution="Each edge contributes exactly edge-endpoint incidences. So a graph with edges contributes incidences. Therefore the answer is ." ::: :::question type="MSQ" question="Which of the following are standard settings for double counting?" options=["counting pairs with ","counting graph edge-endpoint incidences","counting the same family by size and also directly","blindly splitting into overlapping cases"] answer="A,B,C" hint="Double counting requires two valid counts of the same quantity." solution="1. True. This is a standard subset-incidence setup.- is a -element subset of an -element set
Summary
- Double counting means counting the same quantity in two valid ways.
- The most useful setup is incidence counting.
- Many binomial identities are easiest through double counting.
- Always define clearly what is being counted.
- The method is powerful because it converts structure into an identity.
---
Chapter Summary
- Complement Counting: Effectively determine the size of a set by subtracting the size of its complement from the total universe, particularly useful for "at least one" scenarios or when direct counting is complex.
- Inclusion-Exclusion Principle (IEP): Precisely count the union of sets by summing individual set sizes, then subtracting the sizes of all pairwise intersections, adding the sizes of all triple intersections, and so on, to correct for initial over- or under-counting.
- General IEP Formula: For sets , the size of their union is given by
- Double Counting (Combinatorial Proof): A powerful technique to prove combinatorial identities by counting the same set of objects or the same property of a configuration in two distinct ways, leading to an equality.
- Careful Set Definition: Success in applying these principles hinges on precisely defining the sets involved, their properties, and their intersections, to ensure accurate counting.
- Applications: These principles are fundamental for solving a wide range of problems in combinatorics, including those involving divisibility, derangements, permutations with restrictions, and various arrangements of objects.
---
Chapter Review Questions
:::question type="MCQ" question="How many integers between 1 and 100 (inclusive) are divisible by 2 or 3 or 5?" options=["70","72","74","76"] answer="74" hint="Use the Inclusion-Exclusion Principle for three sets. Let be the set of integers divisible by 2, by 3, and by 5." solution="Let .
Let be the set of numbers in divisible by 2. .
Let be the set of numbers in divisible by 3. .
Let be the set of numbers in divisible by 5. .
Intersections:
(divisible by 6): .
(divisible by 10): .
(divisible by 15): .
(divisible by 30): .
By the Inclusion-Exclusion Principle:
.
The number of integers is 74."
:::
:::question type="NAT" question="A group of 7 friends is to be seated in a row. In how many ways can they be seated if two specific friends, Alice and Bob, must NOT sit next to each other?" answer="3600" hint="Use complement counting. First, find the total number of arrangements without any restrictions. Then, find the number of arrangements where Alice and Bob do sit together." solution="Total number of ways to seat 7 friends in a row is .
Now, consider the case where Alice and Bob do sit next to each other. Treat Alice and Bob as a single block (AB).
There are now effectively 6 items to arrange: (AB), C, D, E, F, G. This can be done in ways.
Within the (AB) block, Alice and Bob can swap positions (AB or BA), so there are ways for them to sit together.
So, the number of ways Alice and Bob sit together is .
The number of ways Alice and Bob must NOT sit next to each other is the total arrangements minus the arrangements where they do sit together:
."
:::
:::question type="MCQ" question="Consider the identity for . Which of the following scenarios best illustrates a combinatorial proof of this identity using double counting?" options=["Counting committees of members from people and a president from the remaining people.","Counting ways to select a captain and team members from players.","Counting permutations of objects taken at a time.","Counting subsets of size from a set of elements."] answer="Counting ways to select a captain and team members from players." hint="Think about how to form a group of people with one designated leader. Count this in two different ways." solution="The identity counts the number of ways to choose a committee of members from people and then select a president from that committee.
Method 1 (LHS):
First, choose a committee of members from people. There are ways to do this.
Then, from these chosen members, select one to be the president. There are ways to do this.
Total ways = .
Method 2 (RHS):
First, choose one person from the people to be the president. There are ways to do this.
Then, choose the remaining members for the committee from the remaining people. There are ways to do this.
Total ways = .
Since both methods count the same set of configurations (a committee of with a designated president), the expressions must be equal. The option 'Counting ways to select a captain and team members from players' perfectly describes this scenario, where the captain is the president and the team members complete the committee."
:::
---
What's Next?
Having mastered the fundamental techniques of counting through cases, complement counting, inclusion-exclusion, and double counting, you are well-equipped to tackle more advanced combinatorial challenges. These principles form the bedrock for understanding topics such as the Pigeonhole Principle, which often complements inclusion-exclusion in existence proofs, and Generating Functions, which provide an algebraic framework for solving complex counting problems, especially those involving partitions and compositions. Furthermore, a solid grasp of these concepts is crucial for approaching various problems in Graph Theory, where counting paths, cycles, and specific substructures is a common task, and in Discrete Probability, where precise enumeration of outcomes is essential.