Skip to main content

Including and Excluding

Hi, I am Emon and I am back this time to provide you with some ideas regarding the ''Inclusion and Exclusion Principle", which is a really important topic that we should learn for olympiads.  

The Inclusion-Exclusion Principle is a counting technique which generalizes the familiar method of obtaining the number of elements in the union of two finite sets, which is given by the formula 

$$\left|A\cup B\right| = \left|A\right|+\left|B\right| - \left|A\cap B\right|.$$

where $A$ and $B$ are two finite sets and $|X|:=$ cardinality of set $X$, $i.e.$ the number of elements present in the set $X$. 

The proof of this formula can be understood directly from the above venn diagram.

Additional Note (though a bit out of context). Let $\mathcal{S}$ be a discrete sample space. Then, if $A, B\subset \mathcal{S}$ are two events, then we may write

$$\mathbb{P}(A\cup B)=\mathbb{P}(A)+\mathbb{P}(B)-\mathbb{P}(A\cap B),$$ which is equivalent to the previous formula $$|A\cup B|=|A|+|B|-|A\cap B|.$$

Similarly, for $3$ finite sets, we will have, 

$$|A\cup B\cup C|=|A|+|B|+|C|-|A\cap B|-|B\cap C|-|C\cap A|+|A\cap B\cap C|.$$

The proof of this is also direct from the venn diagram. 

Now, let's state the original, generalised version of the Inclusion-Exclusion Principle.

Formula. If $A_1, A_2, \ldots, A_n$ be $n$ finite sets. Then, we can write
$$|A_1\cup A_2\cup \cdots \cup A_n|=\sum_{i=1}^n|A_i| - \sum_{i<j}|A_i\cap A_j|+\cdots+(-1)^{n+1}|A_1\cap A_2\cap \cdots \cap A_n|.$$

$Proof.$ You may look into the proofs here or here

Consider the following 2 examples.

Example 1. A postman has to deliver $n$ letters in $n$ houses. Suppose the letter $\ell_i$ should be delivered at house $h_i$. But, the postman, being a naughty one, decides to deliver the letters in such a way that $\ell_i$ is not delivered to $h_i$ for all $i$. In how many ways can he do so?
Example 2. Suppose that a professor gave a test to $n$ students $\mathcal{S}_1, \mathcal{S}_2, \ldots, \mathcal{S}_n$ and wants to let them grade each other's tests. Of course, no student should grade their own test. How many ways could the professor hand the tests back to the students for grading, such that no student received their own test back?

The above problems are the typical examples of derangements. A derangement can be defined as the permuatation(s) of the elements of a set such that no element appear in it's original position, or in other words, have no fixed points.

Formula (Derangement). The number of derangements of an $n$ element set, $D_n$ or $!n$, is given by the formula
$$D_n = n!\sum_{k=0}^n\frac{(-1)^k}{k!}.$$
$Proof.$ We can prove this using the PIE. So, at first, we consider the all possible arrangements of the whole sequence, which is given by $n!$. Next, we must remove all the arrangements in which each element appears in its original position, $i.e.$ we have to subtract $\binom{n}{1}(n-1)!$. Again, we have to add back the permutations in which each set of two elements stay in their original positions, as we subtracted them twice, so we must add $\binom{n}{2}(n-2)!$ and so on. Thus, we have, 
$$D_n=n!-\binom{n}{1}(n-1)!+\binom{n}{2}(n-2)!-\cdots + (-1)^n\binom{n}{n}(n-n)!.$$
But, since $\displaystyle \binom{n}{k}(n-k)!=\frac{n!}{(n-k)!k!}(n-k)!=\frac{n!}{k!}$, we have, 
$$\begin{aligned} D_n &=n!-\frac{n!}{1!}+\frac{n!}{2!}-\cdots+(-1)^n\left(\frac{n!}{n!}\right) \\ &= n!\left(1-\frac{1}{1!}+\frac{1}{2!}-\cdots+(-1)^n\left(\frac{1}{n!}\right)\right) \\  &= n!\sum_{k=0}^n\frac{(-1)^k}{k!},\end{aligned}$$ as desired. 
Note. The probability of a derangement is $\displaystyle\frac{1}{e}.$

Problem $1$ (IMO $1987/1$). Let $p_n(k)$ be the number of permutations of the set $\{1,2,3,\ldots,n\}$ which have exactly $k$ fixed points. Prove that $$\sum_{k=0}^nk p_n(k)=n!.$$

Solution. Firstly, observe that $\displaystyle p_n(k)=\binom{n}{k}(n-k)!\sum_{i=0}^{n-k} \frac{(-1)^i}{i!}$, $i.e.$ $p_n(k)=D_{n-k}$ where $D_i:=$ the number of derangements of $\{1, 2, \ldots, i\}$. Now, observe that, $$\begin{aligned} \frac{p_n(k)}{p_{n-1}(k-1)} &= \frac{n}{k}\\ \iff p_n(k) &= \frac{n}{k}p_{n-1}(k-1)\\ \implies \sum_{k=0}^nkp_n(k) &= n\sum_{k=1}^np_{n-1}(k-1)\\ &= n(n-1)! = n!,\text{ as desired.} \end{aligned}$$

That's all for today. If you want to try some problems, consider looking at this problem set made by me. Also, if you are interested to learn something more about PIE, then maybe go through thisthisthisthis and this. Hope to see you soon.


Popular posts from this blog

EGMO solutions, motivations and reviews ft. Atul, Pranjal and Abhay

The  European Girls' Mathematical Olympiad a.k.a EGMO 2022 just ended. Congrats to Jessica Wan from USA, Taisiia Korotchenko, and Galiia Sharafetdinova for the perfect scores! Moreover, the Indian girls brought home 4 bronze medals! By far, this is the best result the EGMO India Team has ever achieved! To celebrate the brilliant result, here's a compilation of EGMO 2022 solutions and motivations written by my and everyone's favorite IMOTCer Atul ! And along with that, we also have reviews of each problem written by everyone's favorite senior, Pranjal !  These solutions were actually found by Atul, Pranjal,  and Abhay  during the 3-hour live solve. In the live solve, they solved all the 6 problems in 3 hours 😍!!! Okie Dokie, I think we should get started with the problems! Enjoy! Problem 1:  Let $ABC$ be an acute-angled triangle in which $BC<AB$ and $BC<CA$. Let point $P$ lie on segment $AB$ and point $Q$ lie on segment $AC$ such that $P \neq B$, $Q \neq C$ and

Kőnig-Egerváry theorem

Graph theory has been my most favourite thing to learn in maths and and in this blog i hope to spread the knowledge about Kőnig's theorem. It is advised that the readers are aware about basic graph theory terminologies including bipartite graphs. Before going on to the theorem i would like to go on about matchings and vertex cover which we are going to use in the theorem  Matchings A matching $M$ of a graph $G$ is a subset of the edges of a graph in which no two edge share a common vertex (non adjacent edges). For example :- The Matching $M$ over here is edge $\{ 3 - 5 , 1-2 , \}$ or $\{ 1 - 2 , 4 - 3 \}$ etc .  Maximum Matching is a matching that contains the largest possible number of edges for instance in the above example the maximum matching is 2 edges as there cannot be a subset of non adjacent edges having greater than 2 edges (Readers are advised to try so they can convince themselves) A Perfect Matching  is a matching that matches all vertices of the graph or in other sen

Algorithms, or Mathematics?!

Hi everyone! In my last blog, I spoke about a couple of very interesting algorithmic techniques and how they can be used to solve a variety of very interesting problems. This blog however, is going to be completely different.   When we’re young we begin by learning the steps to add – we’re given the rules and we must learn to repeat them – no questions asked. Why does carry forward work the way it does? Well, no questions asked. To some extent, it is important to know how exactly to do a certain set of things while first learning maths. We may not be able to get anywhere in a subject if we’re unable to learn a few basic rules and know how to use them. However, after a certain point it is important to bring in the spirit of mathematical thinking within each student too – something missing in almost every form of school math education. Mathematical miseducation is so common, we wouldn’t even see it. We practically expect a math class to look like repetition and memorisation of disjointed