In this section we extend the formula of Proposition1.5for the number of elements of the union of two finite sets. The following result is known as the inclusion- exclusion principle, and is usually attributed to the French mathematician of the eighteenth century Abraham de Moivre.
Theorem 2.1 (de Moivre) IfA1,A2, . . . ,Anare finite sets, then
|A1∪A2∪. . .∪An| = n k=1
(−1)k−1
i1<ããã<ik
|Ai1∩. . .∩Aik|, (2.1)
with the last sum above extending over all sequences(i1,i2, . . . ,ik)of integers such that1≤i1< i2<ã ã ã< ik≤n.
Proof Fix anx ∈ A1∪A2∪. . .∪Anand suppose thatx belongs to exactlyl of the setsA1,A2, . . . , An. We shall show that the expression at the right hand side of (2.1) countsxexactly once.
© Springer International Publishing AG, part of Springer Nature 2018
A. Caminha Muniz Neto,An Excursion through Elementary Mathematics, Volume III, Problem Books in Mathematics,https://doi.org/10.1007/978-3-319-77977-5_2
33
Note that, for a fixed 1≤k≤n,xis counted in the sum
i1<ããã<ik
|Ai1∩. . .∩Aik|
as many times as the number of sequences(i1, . . . , ik)such that 1≤ i1 <ã ã ã <
ik ≤nandx∈Ai1∩. . .∩Aik.
Sincexbelongs to exactlylof the given sets, we can restrict ourselves to the case in whichk ≤ l; indeed, ifk > l, thenx will not belong to at least one of the sets Ai1, . . . ,Aik, so thatx /∈Ai1∩. . .∩Aik.
Fork ≤ l, the number of sequences(i1, . . . , ik)as above equals the number of ways of choosingkof thelsets containingx. Therefore, there are exactlyl
k
such sequences, and we conclude thatxis counted at the right hand side of (2.1) exactly
l k=1
(−1)k−1 l
k
times. However, with the aid of the binomial expansion we get l
k=1
(−1)k−1 l
k
= l
0
− l k=0
(−1)k l
k
=1−(1−1)l =1,
as wished.
Example 2.2 Letn≥3 be a natural number. Show that there does not exist setsA1, A2, . . . ,An, withnelements each and satisfying the following conditions:
(a) Any two of theAi’s have exactly two elements in common.
(b) Any three of theAi’s have no elements in common.
Solution By the sake of contradiction, assume that there does exist setsA1,A2, . . . , Ansatisfying the stated conditions. If we show that|A1∪A2∪. . .∪An| =n, we would haveAi ⊂A1∪A2∪. . .∪Anand|Ai| = |A1∪A2∪. . .∪An|for 1≤i≤n, so thatAi = A1∪A2∪. . .∪An for 1 ≤ i ≤ n. In particular, this would give A1=A2= ã ã ã =An, and item (b) will give us a contradiction.
To what is left, let’s compute the number of elements ofA1∪A2∪. . .∪Anwith the aid of the inclusion-exclusion principle:
|A1∪. . .∪An| = n k=1
(−1)k−1
i1<ããã<ik
|Ai1∩. . .∩Aik|
=
i1
|Ai1| −
i1<i2
|Ai1∩Ai2|,
2.1 The Inclusion-Exclusion Principle 35 where, in the last equality above, we used the fact thatAi1 ∩Ai2 ∩Ai3 = ∅for 1≤i1< i2< i3≤n. Now, note that
i1
|Ai1| = n i=1
|Ai| = n i=1
n=n2 and
i1<i2
|Ai1∩Ai2| =
i1<i2
2=2 n
2
=n(n−1), for, there are exactlyn
2
= n(n2−1) possible choices of indicesi1andi2satisfying 1 ≤ i1 < i2 ≤ n. Hence,A1∪A2∪. . .∪An has exactlyn2−n(n−1) = n elements.
Another proof of the inclusion-exclusion principle can be given by using characteristic functions of sets (cf. Definition1.12). To this end, we shall need two preliminary results on such functions.
Lemma 2.3 LetAbe a nonempty set. IfBandCare subsets ofA, then:
(a) χB =χC ⇔B =C.
(b) χB∩C =χBχC. (c) χBc =1−χB.
(d) χB∪C =χB+χC−χBχC. Proof Exercise (see Problem1).
Proposition 2.4 LetAbe a finite set andA1,A2, . . . ,Anbe subsets ofA. Ifχ , χj : A→ {0,1}respectively denote the characteristic functions ofA1∪. . .∪An and AjinA, then
χ (x)=1− n j=1
(1−χj(x)) (2.2)
for everyx∈A.
Proof Forx∈A, we have
χ (x)=1 ⇔x ∈A1∪. . .∪An
⇔ ∃ 1≤j ≤n;x ∈Aj
⇔ ∃ 1≤j ≤n; χj(x)=1
⇔ n j=1
(1−χj(x))=0
⇔1− n j=1
(1−χj(x))=1.
Therefore, both sides of (2.2) coincide at everyx∈A, as wished.
Now, observe that ifB⊂Ais finite, then
|B| =
x∈A
χB(x). (2.3)
On the other hand, in the notations of the former proposition, we have χ (x) =1−
n j=1
(1−χj(x))
=1−
⎛
⎝1+
1≤k≤n
i1<ããã<ik
(−1)kχi1(x) . . . χik(x)
⎞
⎠
=
1≤k≤n
i1<ããã<ik
(−1)k−1χi1...ik(x),
whereχi1...ik denotes the characteristic function ofAi1∩. . .∩Aik and we used item (b) of Lemma2.3in the last equality. Hence, the above and (2.3) give
|A1∪. . .∪An| =
x∈A
χ (x)
=
x∈A
1≤k≤n
i1<ããã<ik
(−1)k−1χi1...ik(x)
=
1≤k≤n
i1<ããã<ik
(−1)k−1
x∈A
χi1...ik(x)
=
1≤k≤n
i1<ããã<ik
(−1)k−1|Ai1 ∩. . .∩Aik|.
We now present two classical applications of the inclusion-exclusion principle.
For the first one, we say that a permutation(a1, a2, . . . , an)ofInis aderangement ifai =ifor 1≤ i≤n. This is the same as saying that the functionf :In →In, such that f (i) = ai for 1 ≤ i ≤ n, has no fixed points. The coming example computes how many are these permutations ofIn(in this respect, see also Problem6, page79).
Example 2.5 Given an integern >1, there are precisely dn=n!
n j=0
(−1)j
j! (2.4)
derangements ofIn.
2.1 The Inclusion-Exclusion Principle 37 Proof LetDnbe the set of derangements ofInand, for 1≤i≤n, letCibe the set of those permutations(a1, . . . , an)ofInfor whichai =i. LettingPndenote the set of all permutations ofIn, we clearly have
Pn\Dn=C1∪C2∪. . .∪Cn. Hence, the inclusion-exclusion principle gives
|Pn\Dn| = |C1∪. . .∪Cn|
= n k=1
(−1)k−1
i1<ããã<ik
|Ci1∩. . .∩Cik|. (2.5)
Sincedn= |Dn|, we have
|Pn\Dn| = |Pn| − |Dn| =n! −dn. On the other hand, since
(a1, . . . , an)∈Ci1 ∩. . .∩Cik ⇔ai1 =i1, . . . , aik =ik,
in order to count how many permutations(a1, . . . , an)ofInbelong toCi1∩. . .∩Cik, it suffices to count how many are the permutations ofIn\ {i1, . . . , ik}. Since this is a set ofn−kelements, it follows that
|Ci1 ∩. . .∩Cik| = |Pn−k| =(n−k)!. Substituting both these equalities in (2.5), we get
n! −dn = n k=1
(−1)k−1
i1<ããã<ik
(n−k)!
= n k=1
(−1)k−1 n
k
(n−k)!
=n! n k=1
(−1)k−1 k! ,
where, in the next to last equality, we used the fact that there are exactlyn
k
ways of choosing integers 1≤i1<ã ã ã< ik ≤n. Therefore,
dn =n! −n! n k=1
(−1)k−1 k! =n!
n k=0
(−1)k k! .
Example 2.6 We are givenm, n ∈ Nand finite setsAandB, such that|A| = m and|B| =n. Prove that the number of surjective functionsf :A→Bequals
n k=0
(−1)k n
k
(n−k)m.
Proof LetFm,ndenote the set of functionsf :A→B, andSm,nthe subset ofFm,n
consisting of the surjective ones. Also, letB = {b1, . . . , bn}and, for 1≤i≤n,Fi
be the set of functionsf :A→Bsuch thatbi ∈/ Im(f ). Then, Fm,n\Sm,n=F1∪. . .∪Fn, and the inclusion-exclusion principle gives
|Fm,n\Sm,n| = |F1∪. . .∪Fn|
= n k=1
(−1)k−1
i1<ããã<ik
|Fi1∩. . .∩Fik|. (2.6)
Lettingsm,n= |Sm,n|, we have
|Fm,n\Sm,n| = |Fm,n| − |Sm,n| =nm−sm,n,
where in the last equality we used the discussion in the last paragraph of Sect.1.1.
On the other hand, for a given functionf :A→B, we obviously have f ∈Fi1∩. . .∩Fik ⇔bi1, . . . , bik ∈/ Im(f );
in turn, this is equivalent to the fact thatf can be seen as a function fromAinto B\ {bi1, . . . , bik}. However, since|B\ {bi1, . . . , bik}| =n−k(and invoking once more the discussion in the last paragraph of Sect.1.1), we get
|Fi1∩. . .∩Fik| = |Fm,n−k| =(n−k)m. Substituting these relations in (2.6), we obtain
nm−sm,n = n k=1
(−1)k−1
i1<ããã<ik
(n−k)m
= n k=1
(−1)k−1 n
k
(n−k)m,
2.1 The Inclusion-Exclusion Principle 39
where, in the last equality, we used the fact that there aren
k
ways of choosing integers 1≤i1<ã ã ã< ik≤n. Hence,
sm,n=nm− n k=1
(−1)k−1 n
k
(n−k)m= n k=0
(−1)k n
k
(n−k)m.
We shall reobtain the results of the two examples above, by other means, in Chap.3(cf. Problem7, page91, and Problem9, page92).
Example 2.7 (Romania) Compute the number of ways of coloring the vertices of a regular dodecagon using two colors, in such a way that no monochromatic set of vertices is the set of vertices of a regular polygon.
Solution A regular polygon having its vertices among those of the dodecagon is either an equilateral triangle, a square, a regular hexagon or the regular dodecagon itself. Since alternating vertices of a regular hexagon form an equilateral triangle, we conclude that it suffices to avoid equilateral triangles and squares. Let red (R) and blue (B) be the used colors.
There are four equilateral triangles whose vertices are among those of the given regular dodecagon, and such equilateral triangles have pairwise disjoint sets of vertices. Since each one of them can be colored in exactly six distinct and non monochromatic ways, the number of distinct colorings of the vertices of the dodecagon without monochromatic equilateral triangles equals 64=1296.
Let’s calculate how many of these 1296 colorings contain at least one monochro- matic square. To this end assume, without loss of generality, that such a coloring contains a red square. Each one of its vertices is a vertex of exactly one of the four possible equilateral triangles. Since such a vertex is red, the other two vertices of the corresponding equilateral triangle could be colored BB, BR or RB. By the fundamental principle of counting, exactly 2ã3ã34=486 (2 colors, 3 squares and 3 possible colorings for the other two vertices of each one of the four equilateral triangles) of the 1296 colorings without monochromatic equilateral triangles contain a monochromatic square.
Let’s now compute how many of the 1296 colorings without monochromatic equilateral triangles contain at least two monochromatic squares. We do this considering two separate cases, according to whether the two monochromatic squares have equal or different colors. For each equilateral triangle, exactly one of its vertices is not a vertex of any of the two monochromatic squares. Assuming (without loss of generality) them to be red, we conclude that there is exactly one possible color (blue) for the third vertex. Assuming them to be one red and the other one blue, we conclude that there are two possible colors (either red or blue) for the third vertex. Since there are3
2
=3 ways of choosing two of the three squares, the number of colorings with at least two monochromatic squares equals
3 2
ã
2ã14+2ã24
=102
(note that if both squares have the same color, then there are two possibilities:
they are both blue or both red; if they have different colors, there are also two possibilities: BR ou RB).
Finally, let’s calculate how many of the 1296 colorings without monochro- matic equilateral triangles have three monochromatic squares. The nonexistence of monochromatic equilateral triangles forbids the three squares to have a single color.
Hence, there are six possible distinct colorings for their sets of vertices: BBR, BRB, RBB, RRB, RBR and BRR.
Therefore, by the inclusion-exclusion principle, the number of colorings we wish to count is
1296−486+102−6=906.
Problems: Sect. 2.1
1. * Prove Lemma2.3.
2. How many natural numbers from 1 to 1000 have a prime factor less than 10?
3. * Givenm, n∈N, withm < n, prove that
n−1
k=0
(−1)k n
k
(n−k)m=0.
4. Givenn∈N, compute the number of ways of forming a line withncouples, in such a way that no wife is a neighbor of her husband and vice-versa.
5. (England) How many are the permutations(a1, a2, . . . , a6)ofI6such that, for 1≤j ≤5, the sequence(a1, . . . , aj)is not a permutation ofIj? Explain your answer.
The next two problems admit from the reader a certain degree of acquain- tance with the decomposition of a natural numbern >1 as a product of powers of distinct primes, as well as with the notion of greatest common divisor of two nonzero integers. Specifically for Problem7, the reader may find it useful to recall the following fact: ifn > 1 is natural but not prime, thennadmits a prime divisor which is less than or equal to√
n. The necessary material is collected in Chap.6. Alternatively, the reader can safely skip these problems without loss of continuity.
6. Letn >1 be a natural number andn=pα11. . . pkαkits factorisation as a product of powers of distinct primesp1<ã ã ã< pk. Prove that there are exactly
2.1 The Inclusion-Exclusion Principle 41
n
1− 1 p1
ã ã ã
1− 1 pk
(2.7) integers 1≤m≤nsuch that gcd(m, n)=1.
For the next problem, we letxstand for theinteger partofx ∈R, i.e., the greatest integer which is less than or equal tox. Thus, we have (for instance) 1 =1,√
2 =1 andπ =3.
7. Letn >1 be natural andp1< p2<ã ã ã< pk be the prime numbers less than or equal to√
n. Prove that the quantity of prime numbers less than or equal to nis given by the formula
n− k j=1
(−1)j−1
1≤i1<ããã<ij≤k
n pi1. . . pij
.
8. Forn∈N, we letp(n)denote the number of distinct partitions ofnin naturals summands. Also, for 1 ≤ k ≤ n we write pk(n) to denote the number of partitions ofninto exactlykdistinct natural summands. Prove that
p(n)=
1≤k<√ 2n
(−1)k−1
k2 2<l<n
pk(l)p(n−l).
9. (Mongolia) Given k, m, n ∈ N, let p = min
n,km+1
. Show that equation x1+x2+ ã ã ã +xn=mhas exactly
p j=0
(−1)j n
j
m−j (k+1)+n−1 n−1
solutions(x1, x2, . . . , xn)withxt ∈Zand 0≤xt ≤k, for 1≤t ≤n.
10. Lucas’ problem1 aims at counting the number of ways in which n couples can sit in 2nchairs around a circle, such that no wife sits beside her husband and no two people of the same sex sit on adjacent chairs. The purpose of this problem is to present I. Kaplansky’s solution to this problem. To this end, do the following items:
(a) Conclude that there are 2(n!) ways of choosing the chairs of the hus- bands. Once we are done with (a), conclude that the number of desired configurations is equal to 2(n!)an, whereancounts the number of ways of distributing the wives in thenleft chairs, in such a way that no wife sits beside her husband.
1After Édouard Lucas, French mathematician of the nineteenth century.
(b) Label the chairs of the husbands, counterclockwisely, as h1,h2, . . . ,hn, and those to be occupied by the wives (in some allowed order) as 1, 2, . . . , n, with chair 1 situated betweenh1andh2, chair 2 situated betweenh2and h3, and so on. For 1≤i≤n, letwidenote the wife ofhi, andA2i−1(resp.
A2i) denote the set of ways of distributing the wives such thatwi sits in chairi−1 (resp. chairi. Here, chair 0 is the same as chairn). Conclude that
an=n! − |A1∪A2∪A3∪A4∪. . .∪A2n−1∪A2n|.
(c) If{i1, i2, . . . , ik} ⊂ {1,2, . . . ,2n}has two consecutive elements (with 2n and 1 seen as consecutive), show thatAi1 ∩Ai2 ∩. . .∩Aik = ∅.
(d) If{i1< i2< . . . < ik} ⊂ {1,2, . . . ,2n}has no consecutive elements (also with 2nand 1 seen as consecutive), show that
|Ai1∩Ai2∩. . .∩Aik| =(n−k)!.
(e) Apply Kaplansky’s second lemma (cf. Problem12, page29) to conclude that there are exactly
2n 2n−k
2n−k k
ways of composing an intersection of the formAi1∩Ai2∩. . .∩Aik, with {i1< i2< . . . < ik} ⊂ {1,2, . . . ,2n}having no consecutive elements (and 2nand 1 seen as consecutive).
(f) Conclude that an=
n k=0
(−1)k 2n 2n−k
2n−k k
(n−k)!.