Inclusion-Exclusion and its various Applications

Last Updated : 1 Jun, 2026

The Inclusion-Exclusion Principle is a counting technique used to determine the number of elements in the union of two or more sets when some elements are common between the sets. It helps avoid double-counting by subtracting the overlapping elements.

inclusion

The principle is widely used in set theory, probability, combinatorics, surveys, and counting problems.

Inclusion-Exclusion Principle Formula

When the sizes of sets are added directly, the common elements are counted more than once.

  • In the case of two sets, elements common to both sets are counted twice, so the intersection is subtracted once.
  • In the case of three sets, pairwise intersections are subtracted, but elements common to all three sets are removed three times, so the triple intersection is added back once.

For any two finite sets A and B:

n(A∪B) = n(A) + n(B) − n(A∩B)

For three finite sets A, B, and C:

n(A∪B∪C) = n(A) + n(B) + n(C) − n(A∩B) − n(B∩C) − n(C∩A) + n(A∩B∩C)

General Formula for n Sets

For finite sets A1,A2,A3,…,An​, the Inclusion-Exclusion Principle is given by:

n\left(\bigcup_{i=1}^{n} A_i\right)=\sum n(A_i)-\sum n(A_i \cap A_j)+\sum n(A_i \cap A_j \cap A_k)-\cdots+(-1)^{n+1}n(A_1 \cap A_2 \cap \cdots \cap A_n)

where,

  • Add the sizes of all individual sets
  • Subtract all pairwise intersections
  • Add all triple intersections
  • Subtract all four-set intersections
  • Continue alternately until the last intersection

Disjoint Sets: If two sets have no common elements, then they are called disjoint sets.

For disjoint sets: n(A∩B)=0 , hence

n(A∪B) = n(A) + n(B)

Applications

Derangements: The Inclusion-Exclusion Principle is used to find the number of derangements.

A derangement is a permutation in which no element remains in its original position. The number of derangements of n objects is denoted by !n and is given by:

!n = n!\left(1 - \frac{1}{1!} + \frac{1}{2!} - \frac{1}{3!} + \cdots + (-1)^n \frac{1}{n!}\right)

Example: Find the number of derangements of 3 objects.

Using the formula: !3=3!\left(1-\frac{1}{1!}+\frac{1}{2!}-\frac{1}{3!}\right)=2

Therefore, there are 2 derangements of 3 objects.

Set Theory: The principle is used to find the total number of elements belonging to one or more sets without counting common elements multiple times.For two sets A and B: n(A∪B) = n(A) + n(B) − n(A∩B)

Probability: The Inclusion-Exclusion Principle is used to calculate the probability that at least one event occurs. For two events A and B: P(A∪B) = P(A) + P(B)−P(A∩B)

Counting Problems: The principle is frequently used to count numbers satisfying at least one condition. E.g Find the number of integers from 1 to 100 divisible by 2 or 5.

Surveys and Data Analysis: The principle is used in surveys to determine the number of people belonging to one or more categories.

Computer Science: The Inclusion-Exclusion Principle is used in: Database query optimization , Boolean logic , Network analysis , Combinatorics.

Solved Examples

Example 1: 3 finite sets A, B and C with their corresponding values are given. Compute A∪B∪C.
 

The values of the corresponding regions, as can be noted from the diagram are - ∣A∣=2, ∣B∣=2, ∣C∣=2, ∣A∩B∣=3, ∣B∩C∣=3, ∣A∩C∣=3, ∣A∩B∩C∣=4

Using the Inclusion-Exclusion Principle for three sets: ∣A∪B∪C∣ = ∣A∣ + ∣B∣ + ∣C∣ − ∣A∩B∣ − ∣B∩C∣ − ∣A∩C∣ + ∣A∩B∩C∣

Substituting the given values: ∣A∪B∪C∣ = 2 + 2 + 2 − 3 − 3 − 3 + 4 = 1

Example 2: In a class, 45 students study Mathematics, 30 study Physics, and 12 study both subjects. Find the number of students studying at least one subject.

Let, A = students studying Mathematics , B = students studying Physics

Given:

  • n(A)=45
  • n(B)=30
  • n(A∩B)=12

Using the Inclusion-Exclusion Principle: n(A∪B) = 45+30−12 = 63

Therefore, 63 students study at least one subject.

Comment
Article Tags:

Explore