组合数学 (Fall 2025)/Sieve methods

From TCS Wiki
Revision as of 16:07, 12 March 2025 by Etone (talk | contribs) (Created page with "== Principle of Inclusion-Exclusion == Let <math>A</math> and <math>B</math> be two finite sets. The cardinality of their union is :<math>|A\cup B|=|A|+|B|-{\color{Blue}|A\cap B|}</math>. For three sets <math>A</math>, <math>B</math>, and <math>C</math>, the cardinality of the union of these three sets is computed as :<math>|A\cup B\cup C|=|A|+|B|+|C|-{\color{Blue}|A\cap B|}-{\color{Blue}|A\cap C|}-{\color{Blue}|B\cap C|}+{\color{Red}|A\cap B\cap C|}</math>. This is illu...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Principle of Inclusion-Exclusion

Let A and B be two finite sets. The cardinality of their union is

|AB|=|A|+|B||AB|.

For three sets A, B, and C, the cardinality of the union of these three sets is computed as

|ABC|=|A|+|B|+|C||AB||AC||BC|+|ABC|.

This is illustrated by the following figure.

Generally, the Principle of Inclusion-Exclusion states the rule for computing the union of n finite sets A1,A2,,An, such that

|i=1nAi|=I{1,,n}(1)|I|1|iIAi|.


In combinatorial enumeration, the Principle of Inclusion-Exclusion is usually applied in its complement form.

Let A1,A2,,AnU be subsets of some finite set U. Here U is some universe of combinatorial objects, whose cardinality is easy to calculate (e.g. all strings, tuples, permutations), and each Ai contains the objects with some specific property (e.g. a "pattern") which we want to avoid. The problem is to count the number of objects without any of the n properties. We write Ai¯=UAi. The number of objects without any of the properties A1,A2,,An is

|A1¯A2¯An¯|=|Ui=1nAi|=|U|+I{1,,n}(1)|I||iIAi|.

For an I{1,2,,n}, we denote

AI=iIAi

with the convention that A=U. The above equation is stated as:

Principle of Inclusion-Exclusion
Let A1,A2,,An be a family of subsets of U. Then the number of elements of U which lie in none of the subsets Ai is
I{1,,n}(1)|I||AI|.

Let Sk=|I|=k|AI|. Conventionally, S0=|A|=|U|. The principle of inclusion-exclusion can be expressed as

|A1¯A2¯An¯|=S0S1+S2++(1)nSn.

Surjections

In the twelvefold way, we discuss the counting problems incurred by the mappings f:NM. The basic case is that elements from both N and M are distinguishable. In this case, it is easy to count the number of arbitrary mappings (which is mn) and the number of injective (one-to-one) mappings (which is (m)n), but the number of surjective is difficult. Here we apply the principle of inclusion-exclusion to count the number of surjective (onto) mappings.

Theorem
The number of surjective mappings from an n-set to an m-set is given by
k=1m(1)mk(mk)kn.
Proof.

Let U={f:[n][m]} be the set of mappings from [n] to [m]. Then |U|=mn.

For i[m], let Ai be the set of mappings f:[n][m] that none of j[n] is mapped to i, i.e. Ai={f:[n][m]{i}}, thus |Ai|=(m1)n.

More generally, for I[m], AI=iIAi contains the mappings f:[n][m]I. And |AI|=(m|I|)n.

A mapping f:[n][m] is surjective if f lies in none of Ai. By the principle of inclusion-exclusion, the number of surjective f:[n][m] is

I[m](1)|I||AI|=I[m](1)|I|(m|I|)n=j=0m(1)j(mj)(mj)n.

Let k=mj. The theorem is proved.

Recall that, in the twelvefold way, we establish a relation between surjections and partitions.

  • Surjection to ordered partition:
For a surjective f:[n][m], (f1(0),f1(1),,f1(m1)) is an ordered partition of [n].
  • Ordered partition to surjection:
For an ordered m-partition (B0,B1,,Bm1) of [n], we can define a function f:[n][m] by letting f(i)=j if and only if iBj. f is surjective since as a partition, none of Bi is empty.

Therefore, we have a one-to-one correspondence between surjective mappings from an n-set to an m-set and the ordered m-partitions of an n-set.

The Stirling number of the second kind {nm} is the number of m-partitions of an n-set. There are m! ways to order an m-partition, thus the number of surjective mappings f:[n][m] is m!{nm}. Combining with what we have proved for surjections, we give the following result for the Stirling number of the second kind.

Proposition
{nm}=1m!k=1m(1)mk(mk)kn.

Derangements

We now count the number of bijections from a set to itself with no fixed points. This is the derangement problem.

For a permutation π of {1,2,,n}, a fixed point is such an i{1,2,,n} that π(i)=i. A derangement of {1,2,,n} is a permutation of {1,2,,n} that has no fixed points.

Theorem
The number of derangements of {1,2,,n} given by
n!k=0n(1)kk!n!e.
Proof.

Let U be the set of all permutations of {1,2,,n}. So |U|=n!.

Let Ai be the set of permutations with fixed point i; so |Ai|=(n1)!. More generally, for any I{1,2,,n}, AI=iIAi, and |AI|=(n|I|)!, since permutations in AI fix every point in I and permute the remaining points arbitrarily. A permutation is a derangement if and only if it lies in none of the sets Ai. So the number of derangements is

I{1,2,,n}(1)|I|(n|I|)!=k=0n(1)k(nk)(nk)!=n!k=0n(1)kk!.

By Taylor's series,

1e=k=0(1)kk!=k=0n(1)kk!±o(1n!).

It is not hard to see that n!k=0n(1)kk! is the closest integer to n!e.

Therefore, there are about 1e fraction of all permutations with no fixed points.

Permutations with restricted positions

We introduce a general theory of counting permutations with restricted positions. In the derangement problem, we count the number of permutations that π(i)i. We now generalize to the problem of counting permutations which avoid a set of arbitrarily specified positions.

It is traditionally described using terminology from the game of chess. Let B{1,,n}×{1,,n}, called a board. As illustrated below, we can think of B as a chess board, with the positions in B marked by "×".

a b c d e f g h
8 a8 __ b8 cross c8 cross d8 __ e8 cross f8 __ g8 __ h8 cross 8
7 a7 cross b7 __ c7 __ d7 cross e7 __ f7 __ g7 cross h7 __ 7
6 a6 cross b6 __ c6 cross d6 cross e6 __ f6 cross g6 cross h6 __ 6
5 a5 __ b5 cross c5 __ d5 __ e5 cross f5 __ g5 cross h5 __ 5
4 a4 cross b4 __ c4 __ d4 __ e4 cross f4 cross g4 cross h4 __ 4
3 a3 __ b3 cross c3 __ d3 cross e3 __ f3 __ g3 __ h3 cross 3
2 a2 __ b2 __ c2 cross d2 __ e2 cross f2 __ g2 __ h2 cross 2
1 a1 cross b1 __ c1 __ d1 cross e1 __ f1 cross g1 __ h1 __ 1
a b c d e f g h

For a permutation π of {1,,n}, define the graph Gπ(V,E) as

Gπ={(i,π(i))i{1,2,,n}}.

This can also be viewed as a set of marked positions on a chess board. Each row and each column has only one marked position, because π is a permutation. Thus, we can identify each Gπ as a placement of n rooks (“城堡”,规则同中国象棋里的“车”) without attacking each other.

For example, the following is the Gπ of such π that π(i)=i.

a b c d e f g h
8 a8 white rook b8 __ c8 __ d8 __ e8 __ f8 __ g8 __ h8 __ 8
7 a7 __ b7 white rook c7 __ d7 __ e7 __ f7 __ g7 __ h7 __ 7
6 a6 __ b6 __ c6 white rook d6 __ e6 __ f6 __ g6 __ h6 __ 6
5 a5 __ b5 __ c5 __ d5 white rook e5 __ f5 __ g5 __ h5 __ 5
4 a4 __ b4 __ c4 __ d4 __ e4 white rook f4 __ g4 __ h4 __ 4
3 a3 __ b3 __ c3 __ d3 __ e3 __ f3 white rook g3 __ h3 __ 3
2 a2 __ b2 __ c2 __ d2 __ e2 __ f2 __ g2 white rook h2 __ 2
1 a1 __ b1 __ c1 __ d1 __ e1 __ f1 __ g1 __ h1 white rook 1
a b c d e f g h

Now define

N0=|{πBGπ=}|rk=number of k-subsets of B such that no two elements have a common coordinate=|{S(Bk)|(i1,j1),(i2,j2)S,i1i2,j1j2}|

Interpreted in chess game,

  • B: a set of marked positions in an [n]×[n] chess board.
  • N0: the number of ways of placing n non-attacking rooks on the chess board such that none of these rooks lie in B.
  • rk: number of ways of placing k non-attacking rooks on B.

Our goal is to count N0 in terms of rk. This gives the number of permutations avoid all positions in a B.

Theorem
N0=k=0n(1)krk(nk)!.
Proof.

For each i[n], let Ai={π(i,π(i))B} be the set of permutations π whose i-th position is in B.

N0 is the number of permutations avoid all positions in B. Thus, our goal is to count the number of permutations π in none of Ai for i[n].

For each I[n], let AI=iIAi, which is the set of permutations π such that (i,π(i))B for all iI. Due to the principle of inclusion-exclusion,

N0=I[n](1)|I||AI|=k=0n(1)kI([n]k)|AI|.

The next observation is that

I([n]k)|AI|=rk(nk)!,

because we can count both sides by first placing k non-attacking rooks on B and placing nk additional non-attacking rooks on [n]×[n] in (nk)! ways.

Therefore,

N0=k=0n(1)krk(nk)!.

Derangement problem

We use the above general method to solve the derange problem again.

Take B={(1,1),(2,2),,(n,n)} as the chess board. A derangement π is a placement of n non-attacking rooks such that none of them is in B.

a b c d e f g h
8 a8 cross b8 __ c8 __ d8 __ e8 __ f8 __ g8 __ h8 __ 8
7 a7 __ b7 cross c7 __ d7 __ e7 __ f7 __ g7 __ h7 __ 7
6 a6 __ b6 __ c6 cross d6 __ e6 __ f6 __ g6 __ h6 __ 6
5 a5 __ b5 __ c5 __ d5 cross e5 __ f5 __ g5 __ h5 __ 5
4 a4 __ b4 __ c4 __ d4 __ e4 cross f4 __ g4 __ h4 __ 4
3 a3 __ b3 __ c3 __ d3 __ e3 __ f3 cross g3 __ h3 __ 3
2 a2 __ b2 __ c2 __ d2 __ e2 __ f2 __ g2 cross h2 __ 2
1 a1 __ b1 __ c1 __ d1 __ e1 __ f1 __ g1 __ h1 cross 1
a b c d e f g h

Clearly, the number of ways of placing k non-attacking rooks on B is rk=(nk). We want to count N0, which gives the number of ways of placing n non-attacking rooks such that none of these rooks lie in B.

By the above theorem

N0=k=0n(1)krk(nk)!=k=0n(1)k(nk)(nk)!=k=0n(1)kn!k!=n!k=0n(1)k1k!n!e.

Problème des ménages

Suppose that in a banquet, we want to seat n couples at a circular table, satisfying the following constraints:

  • Men and women are in alternate places.
  • No one sits next to his/her spouse.

In how many ways can this be done?

(For convenience, we assume that every seat at the table marked differently so that rotating the seats clockwise or anti-clockwise will end up with a different solution.)

First, let the n ladies find their seats. They may either sit at the odd numbered seats or even numbered seats, in either case, there are n! different orders. Thus, there are 2(n!) ways to seat the n ladies.

After sitting the wives, we label the remaining n places clockwise as 0,1,,n1. And a seating of the n husbands is given by a permutation π of [n] defined as follows. Let π(i) be the seat of the husband of he lady sitting at the i-th place.

It is easy to see that π satisfies that π(i)i and π(i)i+1(modn), and every permutation π with these properties gives a feasible seating of the n husbands. Thus, we only need to count the number of permutations π such that π(i)i,i+1(modn).

Take B={(0,0),(1,1),,(n1,n1),(0,1),(1,2),,(n2,n1),(n1,0)} as the chess board. A permutation π which defines a way of seating the husbands, is a placement of n non-attacking rooks such that none of them is in B.

a b c d e f g h
8 a8 cross b8 cross c8 __ d8 __ e8 __ f8 __ g8 __ h8 __ 8
7 a7 __ b7 cross c7 cross d7 __ e7 __ f7 __ g7 __ h7 __ 7
6 a6 __ b6 __ c6 cross d6 cross e6 __ f6 __ g6 __ h6 __ 6
5 a5 __ b5 __ c5 __ d5 cross e5 cross f5 __ g5 __ h5 __ 5
4 a4 __ b4 __ c4 __ d4 __ e4 cross f4 cross g4 __ h4 __ 4
3 a3 __ b3 __ c3 __ d3 __ e3 __ f3 cross g3 cross h3 __ 3
2 a2 __ b2 __ c2 __ d2 __ e2 __ f2 __ g2 cross h2 cross 2
1 a1 cross b1 __ c1 __ d1 __ e1 __ f1 __ g1 __ h1 cross 1
a b c d e f g h

We need to compute rk, the number of ways of placing k non-attacking rooks on B. For our choice of B, rk is the number of ways of choosing k points, no two consecutive, from a collection of 2n points arranged in a circle.

We first see how to do this in a line.

Lemma
The number of ways of choosing k non-consecutive objects from a collection of m objects arranged in a line, is (mk+1k).
Proof.

We draw a line of mk black points, and then insert k red points into the mk+1 spaces between the black points (including the beginning and end).

This gives us a line of m points, and the red points specifies the chosen objects, which are non-consecutive. The mapping is 1-1 correspondence. There are (mk+1k) ways of placing k red points into mk+1 spaces.

The problem of choosing non-consecutive objects in a circle can be reduced to the case that the objects are in a line.

Lemma
The number of ways of choosing k non-consecutive objects from a collection of m objects arranged in a circle, is mmk(mkk).
Proof.

Let f(m,k) be the desired number; and let g(m,k) be the number of ways of choosing k non-consecutive points from m points arranged in a circle, next coloring the k points red, and then coloring one of the uncolored point blue.

Clearly, g(m,k)=(mk)f(m,k).

But we can also compute g(m,k) as follows:

  • Choose one of the m points and color it blue. This gives us m ways.
  • Cut the circle to make a line of m1 points by removing the blue point.
  • Choose k non-consecutive points from the line of m1 points and color them red. This gives (mkk) ways due to the previous lemma.

Thus, g(m,k)=m(mkk). Therefore we have the desired number f(m,k)=mmk(mkk).

By the above lemma, we have that rk=2n2nk(2nkk). Then apply the theorem of counting permutations with restricted positions,

N0=k=0n(1)krk(nk)!=k=0n(1)k2n2nk(2nkk)(nk)!.

This gives the number of ways of seating the n husbands after the ladies are seated. Recall that there are 2n! ways of seating the n ladies. Thus, the total number of ways of seating n couples as required by problème des ménages is

2n!k=0n(1)k2n2nk(2nkk)(nk)!.

Inversion

Posets

A partially ordered set or poset for short is a set P together with a binary relation denoted P (or just if no confusion is caused), satisfying

  • (reflexivity) For all xP,xx.
  • (antisymmetry) If xy and yx, then x=y.
  • (transitivity) If xy and yz, then xz.

We say two elements x and y are comparable if xy or yx; otherwise x and y are incomparable.

Notation
  • xy means yx.
  • x<y means xy and xy.
  • x>y means y<x.

The Möbius function

Let P be a finite poset. Consider functions in form of α:P×PR defined over domain P×P. It is convenient to treat such functions as matrices whose rows and columns are indexed by P.

Incidence algebra of poset
Let
I(P)={α:P×PRα(x,y)=0 for all xPy}
be the class of α such that α(x,y) is non-zero only for xPy.
Treating α as matrix, it is trivial to see that I(P) is closed under addition and scalar multiplication, that is,
  • if α,βI(P) then α+βI(P);
  • if αI(P) then cαI(P) for any cR;
where α,β are treated as matrices.
With this spirit, it is natural to define the matrix multiplication in I(P). For α,βI(P),
(αβ)(x,y)=zPα(x,z)β(z,y)=xzyα(x,z)β(z,y).
The second equation is due to that for α,βI(P), for all z other than xzy, α(x,z)β(z,y) is zero.
By the transitivity of relation P, it is also easy to prove that I(P) is closed under matrix multiplication (the detailed proof is left as an exercise). Therefore, I(P) is closed under addition, scalar multiplication and matrix multiplication, so we have an algebra I(P), called incidence algebra, over functions on P×P.
Zeta function and Möbius function
A special function in I(P) is the so-called zeta function ζ, defined as
ζ(x,y)={1if xPy,0otherwise.
As a matrix (or more accurately, as an element of the incidence algebra), ζ is invertible and its inversion, denoted by μ, is called the Möbius function. More precisely, μ is also in the incidence algebra I(P), and μζ=I where I is the identity matrix (the identity of the incidence algebra I(P)).

There is an equivalent explicit definition of Möbius function.

Definition (Möbius function)
μ(x,y)={xz<yμ(x,z)if x<y,1if x=y,0if xy.

To see the equivalence between this definition and the inversion of zeta function, we may have the following proposition, which is proved by directly evaluating μζ.

Proposition
For any x,yP,
xzyμ(x,z)={1if x=y,0otherwise.
Proof.

It holds that

(μζ)(x,y)=xzyμ(x,z)ζ(z,y)=xzyμ(x,z).

On the other hand, μζ=I, i.e.

(μζ)(x,y)={1if x=y,0otherwise.

The proposition follows.

Note that μ(x,y)=xzyμ(x,z)xz<yμ(x,z), which gives the above inductive definition of Möbius function.

Computing Möbius functions

We consider the simple poset P=[n], where is the total order. It follows directly from the recursive definition of Möbius function that

μ(i,j)={1if i=j,1if i+1=j,0otherwise.

Usually for general posets, it is difficult to directly compute the Möbius function from its definition. We introduce a rule helping us compute the Möbius function by decomposing the poset into posets with simple structures.

Theorem (the product rule)
Let P and Q be two finite posets, and P×Q be the poset resulted from Cartesian product of P and Q, where for all (x,y),(x,y)P×Q, (x,y)(x,y) if and only if xx and yy. Then
μP×Q((x,y),(x,y))=μP(x,x)μQ(y,y).
Proof.

We use the recursive definition

μ(x,y)={xz<yμ(x,z)if x<y,1if x=y,0if xy.

to prove the equation in the theorem.

If (x,y)=(x,y), then x=x and y=y. It is easy to see that both sides of the equation are 1. If (x,y)(x,y), then either xx or yy. It is also easy to see that both sides are 0.

The only remaining case is that (x,y)<(x,y), in which case either x<x or y<y.

(x,y)(u,v)(x,y)μP(x,u)μQ(y,v)=(xuxμP(x,u))(yvyμQ(y,v))=I(x,x)I(y,y)=0,

where the last two equations are due to the proposition for μ. Thus

μP(x,x)μQ(y,y)=(x,y)(u,v)<(x,y)μP(x,u)μQ(y,v).

By induction, assume that the equation μP×Q((x,y),(u,v))=μP(x,u)μQ(y,v) is true for all (u,v)<(x,y). Then

μP×Q((x,y),(x,y))=(x,y)(u,v)<(x,y)μP×Q((x,y),(u,v))=(x,y)(u,v)<(x,y)μP(x,u)μQ(y,v)=μP(x,x)μQ(y,y),

which complete the proof.

Poset of subsets
Consider the poset defined by all subsets of a finite universe U, that is P=2U, and for S,TU, SPT if and only if ST.
Möbius function for subsets
The Möbius function for the above defined poset P is that for S,TU,
μ(S,T)={(1)|T||S|if ST,0otherwise.
Proof.

We can equivalently represent each SU by a boolean string S{0,1}U, where S(x)=1 if and only if xS.

For each element xU, we can define a poset Px={0,1} with 01. By definition of Möbius function, the Möbius function of this elementary poset is given by μx(0,0)=μx(1,1)=1, μx(0,1)=1 and μ(1,0)=0.

The poset P of all subsets of U is the Cartesian product of all Px, xU. By the product rule,

μ(S,T)=xUμx(S(x),T(x))=xSxT1xSxT1xSxT0xSxT(1)={(1)|T||S|if ST,0otherwise.
Note that the poset P is actually the Boolean algebra of rank |U|. The proof relies only on that the fact that the poset is a Boolean algebra, thus the theorem holds for Boolean algebra posets.
Posets of divisors
Consider the poset defined by all devisors of a positive integer n, that is P={a>0a|n}, and for a,bP, aPb if and only if a|b.
Möbius function for divisors
The Möbius function for the above defined poset P is that for a,b>0 that a|n and b|n,
μ(a,b)={(1)rif ba is the product of r distinct primes,0otherwise, i.e. if ab or ba is not squarefree.
Proof.

Denote n=p1n1p2n2pknk. Represent n by a tuple (n1,n2,,nk). Every aP corresponds in this way to a tuple (a1,a2,,ak) with aini for all 1ik.

Let Pi={1,2,,ni} be the poset with being the total order. The poset P of divisors of n is thus isomorphic to the poset constructed by the Cartesian product of all Pi, 1ik. Then

μ(a,b)=1ikμ(ai,bi)=1ikai=bi11ikbiai=1(1)1ikbiai{0,1}0={(1)i(biai)if all biai{0,1},0otherwise.={(1)rif ba is the product of r distinct primes,0otherwise.

Principle of Möbius inversion

We now introduce the the famous Möbius inversion formula.

Möbius inversion formula
Let P be a finite poset and μ its Möbius function. Let f,g:PR. Then
xP,g(x)=yxf(y),
if and only if
xP,f(x)=yxg(y)μ(y,x).

The functions f,g:PR are vectors. Evaluate the matrix multiplications fζ and gμ as follows:

(fζ)(x)=yPf(y)ζ(y,x)=yxf(y),

and

(gμ)(x)=yPg(y)μ(y,x)=yxg(y)μ(y,x).

The Möbius inversion formula is nothing but the following statement

fζ=gf=gμ,

which is trivially true due to μζ=I by basic linear algebra.

The following dual form of the inversion formula is also useful.

Möbius inversion formula, dual form
Let P be a finite poset and μ its Möbius function. Let f,g:PR. Then
xP,g(x)=yxf(y),
if and only if
xP,f(x)=yxμ(x,y)g(y).

To prove the dual form, we only need to evaluate the matrix multiplications on left:

ζf=gf=μg.
Principle of Inclusion-Exclusion
Let A1,A2,,AnU. For any J{1,2,,n},
  • let f(J) be the number of elements that belongs to exactly the sets Ai,iJ and to no others, i.e.
f(J)=|(iJAi)(iJAi)|;
  • let g(J)=|iJAi|.
For any J{1,2,,n}, the following relation holds for the above defined f and g:
g(J)=IJf(I).
Applying the dual form of the Möbius inversion formula, we have that for any J{1,2,,n},
f(J)=IJμ(J,I)g(I)=IJμ(J,I)|iIAi|,
where the Möbius function is for the poset of all subsets of {1,2,,n}, ordered by , thus it holds that μ(J,I)=(1)|I||J| for JI. Therefore,
f(J)=IJ(1)|I||J||iIAi|.
We have a formula for the number of elements with exactly those properties Ai,iJ for any J{1,2,,n}. For the special case that J=, f() is the number of elements satisfying no property of A1,A2,,An, and
f()=|UiAi|=I{1,,n}(1)|I||iIAi|
which gives precisely the Principle of Inclusion-Exclusion.
Möbius inversion formula for number theory
The number-theoretical Möbius inversion formula is stated as such: Let N be a positive integer,
g(n)=d|nf(d) for all n|N
if and only if
f(n)=d|ng(d)μ(nd) for all n|N,
where μ is the number-theoretical Möbius function, defined as
μ(n)={1if n is product of an even number of distinct primes,1if n is product of an odd number of distinct primes,0otherwise.
The number-theoretical Möbius inversion formula is just a special case of the Möbius inversion formula for posets, when the poset is the set of divisors of N, and for any a,bP, aPb if a|b.

Sieve Method in Number Theory

The Euler totient function

Two integers m,n are said to be relatively prime if their greatest common diviser gcd(m,n)=1. For a positive integer n, let ϕ(n) be the number of positive integers from {1,2,,n} that are relative prime to n. This function, called the Euler ϕ function or the Euler totient function, is fundamental in number theory.

We now derive a formula for this function by using the principle of inclusion-exclusion.

Theorem (The Euler totient function)

Suppose n is divisible by precisely r different primes, denoted p1,,pr. Then

ϕ(n)=ni=1r(11pi).
Proof.

Let U={1,2,,n} be the universe. The number of positive integers from U which is divisible by some pi1,pi2,,pis{p1,,pr}, is npi1pi2pis.

ϕ(n) is the number of integers from U which is not divisible by any p1,,pr. By principle of inclusion-exclusion,

ϕ(n)=n+k=1r(1)k1i1<i2<<iknnpi1pi2pik=n1innpi+1i<jnnpipj1i<j<knnpipjpk++(1)rnp1p2pr=n(11in1pi+1i<jn1pipj1i<j<kn1pipjpk++(1)r1p1p2pr)=ni=1r(11pi).


Reference

  • Stanley, Enumerative Combinatorics, Volume 1, Chapter 2.
  • van Lin and Wilson, A course in combinatorics, Chapter 10, 25.