0% found this document useful (0 votes)
18 views

Notes

Chapter 1 of CS1231 introduces propositional logic, defining propositions as statements that can be true or false, and discussing truth values, Boolean connectives, and conditional propositions. It explains the significance of negation, conjunction, disjunction, and implications, along with their truth tables. The chapter also covers equivalence between compound expressions and emphasizes the importance of clarity in mathematical definitions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Notes

Chapter 1 of CS1231 introduces propositional logic, defining propositions as statements that can be true or false, and discussing truth values, Boolean connectives, and conditional propositions. It explains the significance of negation, conjunction, disjunction, and implications, along with their truth tables. The chapter also covers equivalence between compound expressions and emphasizes the importance of clarity in mathematical definitions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 184

CS1231 Chapter 1

Propositional logic

1.1 Propositions
Definition 1.1.1. (1) A proposition (or a statement) is a sentence that is either true or
false but not both.

(2) The truth value of a proposition is true if the proposition is true; it is false otherwise.
(3) Often we abbreviate the truth values true and false by T and F respectively.

Example 1.1.2. Each of the following is a proposition.


(1) 1 + 2 = 3.
(2) 2 + 3 < 4.
(3) Every even integer is the sum of two odd integers.
(4) Every even integer that is greater than four is the sum of two prime numbers.
The truth values of (1), (2), and (3) are T, F, and T respectively. The truth value of (4) is
unknown.
Remark 1.1.3. One does not need to know the truth value of a sentence to know that the
sentence has a unique truth value.
Remark 1.1.4. We consider only sentences whose truth or falsity depends neither on time
nor on anyone’s knowledge.
Example 1.1.5. None of the following is a proposition when x and y are variables.
(1) 1 + 2
(2) Good morning!
(3) Please explain this in more detail.
(4) Why is this true?
(5) x + y = 0.
When one substitutes numbers into the variables, the sentence in (5) would become a propo-
sition. We will discuss this more in Chapter 2.
Theorem 1.1.6 (Liar Paradox, extra material). The sentence below is not a proposition:

The sentence (∗) is not true. (∗)

1
Proof. We prove this by contradiction. Suppose (∗) is a proposition. The meaning of (∗)
tells us
(a) if (∗) is true, then (∗) is not true; and
(b) if (∗) is false, then (∗) is true.

Split into two cases.


• Case 1: assume (∗) is true. Then (∗) is not true by (a). This contradicts our assumption
that (∗) is true.
• Case 2: assume (∗) is false. Then (∗) is true by (b). This contradicts our assumption
that (∗) is false, as (∗) cannot be both true and false as a proposition.
In either case, we get a contradiction. So the proof is finished.

1.2 Boolean connectives


Definition 1.2.1. Let p be a proposition.
(1) We denote by ¬p (or ∼p) the proposition “it is not the case that p”. Often we read ¬p
as “not p”, and call it the negation of p.

(2) The proposition ¬p is true if p is false; it is false otherwise.

Definition 1.2.2. Let p, q be propositions.


(1) We denote by p ∧ q the proposition “p and q”. We call p ∧ q the conjunction of p and q.
(2) The conjunction p ∧ q is true if p and q are both true; it is false otherwise.

Definition 1.2.3. Let p, q be propositions.

(1) We denote by p ∨ q the proposition “p or q”. We call p ∨ q the disjunction of p and q.


(2) The disjunction p ∨ q is false if p and q are both false; it is true otherwise.

Remark 1.2.4. Let p, q be propositions. Note that the truth values of the negated propo-
sition ¬p, the conjunction p ∧ q, and the disjunction p ∨ q depend only on the truth values
of p and q, not on their other aspects. So one can summarize the behaviours of ¬, ∧ and ∨
as in Table 1.1, where each possible combination of the truth values of p and q appears as a
row. These tables are called truth tables.

p ¬p p q p∧q p q p∨q
T F T T T T T T
F T T F F T F T
F T F F T T
F F F F F F

Table 1.1: Truth tables for ¬, ∧ and ∨

Warning 1.2.5. In everyday English, if two propositions p and q are both true, then “p
or q” is false. However, in common mathematical parlance, if two propositions p and q are
both true, then “p or q” is true. Moreover, including the word “either” does not change this.
If we want to express the everyday English sense of “or” in mathematics, then we may write
“p or q but not both”, as we did in Definition 1.1.1.

2
p q r
T T T ...
T T F ...
T F T ...
T F F ...
F T T ...
F T F ...
F F T ...
F F F ...

Table 1.2: Listing out all possibilities in a truth table

Example 1.2.6. Consider a fixed (not a variable) real number x. Let p and q be the
propositions “x > 1” and “x2 > 1” respectively.
(1) p ∨ q is “x > 1 or x2 > 1”, or equivalently “x2 > 1”.
(2) ¬(p ∨ q) is “it is not the case that x > 1 or x2 > 1”, or equivalently “x2 ⩽ 1”.

(a) Suppose x = 12.31. Then p is true and q is true . So p ∨ q is true and ¬(p ∨ q) is false.
(b) Suppose x = 0. Then p is false and q is false. So p ∨ q is false and ¬(p ∨ q) is true.

(c) Suppose x = −2. Then p is false and q is true . So p ∨ q is true and ¬(p ∨ q) is false.

1.3 Conditional propositions


Note 1.3.1. Let p, q be propositions. In mathematics, we interpret the proposition “if p
then q” as a guarantee: it guarantees that whenever the proposition p is true, the proposition q
must also be true. This guarantee is false (or, more grammatically, this guarantee fails) only
when p is true but q is false; otherwise it is true. In this interpretation, the truth value of “if
p then q” depends only on the truth values of p and q; there is no requirement on whether p
and q have related subject matters, unlike in everyday English.

p q p→q p q p↔q
T T T T T T
T F F T F F
F T T F T F
F F T F F T

Table 1.3: Truth tables for → and ↔

Definition 1.3.2. Let p, q be propositions.


(1) We denote by p → q the proposition “if p then q”. Often we read this as “p implies q”,
and call it a conditional proposition or an implication.
(2) The conditional proposition p → q is false if p is true and q is false; it is true otherwise.

(3) In the conditional proposition p → q, we call p the hypothesis (or the antecedent) and
q the conclusion (or the consequent).

3
Terminology 1.3.3. In mathematics, the following are alternative ways to express “if p
then q” when p, q are propositions.

• q if p.
• q whenever p.
• p only if q.
• p is sufficient for q.

• p is a sufficient condition for q.


• q is necessary for p.
• q is a necessary condition for p.

Example 1.3.4. Consider a fixed (not a variable) real number x. Let p and q be the
propositions “x > 1” and “x2 > 1” respectively.
(1) p → q is “if x > 1, then x2 > 1”.

(2) q → p is “if x2 > 1, then x > 1”.

(a) Suppose x = 3. Then p is true and q is true. So p → q is true and q → p is true.


(b) Suppose x = 0. Then p is false and q is false. So p → q is true and q → p is true.
(c) Suppose x = −2. Then p is false and q is true. So p → q is true but q → p is false.

Terminology 1.3.5. A vacuously true conditional proposition is one in which the hypothesis
is false.

Example 1.3.6. In Example 1.3.4, the implication p → q is vacuously true when x = 0 and
when x = −2

Exercise 1.3.7. Why are all vacuously true conditional propositions true?  1a

Definition 1.3.8. Let p, q be propositions.


(1) The converse of p → q is q → p.

(2) The inverse of p → q is (¬p) → (¬q).


(3) The contrapositive of p → q is (¬q) → (¬p).

Note 1.3.9. Example 1.3.4 shows that a conditional proposition and its converse may have
a different truth values. The same goes for the inverse, but not for the contrapositive, as the
following truth table shows.

p q p→q q→p ¬p ¬q (¬p) → (¬q) (¬q) → (¬p)


T T T T F F T T
T F F T F T T F
F T T F T F F T
F F T T T T T T

Exercise 1.3.10. Let a, b, c, d be propositions. What are the converse, the inverse, and the  1b
contrapositive of (a ∧ b) → (c ∨ d)?

4
Definition 1.3.11. Let p, q be propositions.
(1) We denote by p ↔ q the proposition “p if and only if q”. Sometimes we read this as
“p is equivalent to q” and call it a biconditional proposition or an equivalence. Some
abbreviate “if and only if” to “iff”.
(2) The biconditional proposition p ↔ q is true if p and q have the same truth value; it is
false otherwise.
Terminology 1.3.12. In mathematics, the following are alternative ways to express “p if
and only if q” when p, q are propositions.
• p is necessary and sufficient for q.
• p is a necessary and sufficient condition for q.

• p exactly if q.
• p precisely if q.
• p exactly when q.
• p precisely when q.

Example 1.3.13. Consider a fixed (not a variable) real number x. As in Example 1.3.4, let
p and q be the propositions “x > 1” and “x2 > 1” respectively. Then p ↔ q is

“x > 1 if and only if x2 > 1”.

(a) Suppose x = 3. Then p is true and q is true. So p ↔ q is true.


(b) Suppose x = −2. Then p is false and q is true. So p ↔ q is false.
Exercise 1.3.14. Explain why a proposition is true if and only if it is not false.  1c

Remark 1.3.15. The phrase “if and only if” is rarely used in everyday English: frequently,
people state only one of “if” and “only if” and leave the other part implicit. For example,
in everyday English,
You will get ice cream if you behave.
sometimes actually means

You will get ice cream if and only if you behave.

Here the “only if” part is left implicit. In mathematical contexts, we leave no part implicit:
“if” means “if”, and “only if” means “only if”, except when following Convention 1.4.8.

1.4 Equivalence
Definition 1.4.1. (1) A propositional variable is a variable for substituting in an arbitrary
proposition.
(2) A compound expression is an expression constructed (grammatically) from propositional
variables using ¬, ∧, ∨, → and ↔.

Example 1.4.2. Let p, q be propositional variables. Then ¬(p∨q) and (¬p)∨q are compound
expressions.

5
p q p q

∨ ¬

p∨q ¬p

¬ ∨

¬(p ∨ q) (¬p) ∨ q

Figure 1.4: Building up compound expressions from propositional variables

Convention 1.4.3. (1) When there is a choice, one always performs first the propositional
connective nearer to the top in the following figure.

¬
∧ ∨
→ ↔

(2) We do not set up a rule to decide whether to perform ∧ or ∨ first when there is a choice,
except when following Convention 1.4.22. Do not leave it to the reader to choose which
of these to perform first. The same goes for → and ↔.
(3) Use parentheses (. . . ) to prevent ambiguities.

Example 1.4.4. Let p, q, r be propositional variables.


(1) One can write (¬p) ∨ q from Example 1.4.2 alternatively as ¬p ∨ q.
(2) One can write (¬q) → (¬p) from Definition 1.3.8(3) alternatively as ¬q → ¬p.

(3) Do not write p ∧ q ∨ r because our convention does not specify whether one should
perform ∧ or ∨ first.

Terminology 1.4.5. When one substitutes propositions into all the propositional variables
occurring in a compound expression, one obtains a proposition. If the proposition obtained
is true, then we say that the compound expression evaluates to T under this substitution;
else we say that it evaluates to F.

Exercise 1.4.6. Let p and q be propositional variables. When one substitutes a true  1d
proposition into p and a false proposition into q, what does the compound expression ¬p → ¬q
evaluates to?

Definition 1.4.7. Two compound expressions P, Q are equivalent if (and only if) they
evaluate to the same truth value under any substitution of propositions into the propositional
variables. In this case, we write P ≡ Q.

Convention 1.4.8. In mathematical definitions, people often use “if” between the term
being defined and the phrase being used to define the term. This is the only situation in
mathematics when “if” should be understood as a (special) “if and only if”.
Remark 1.4.9. Definition 1.3.11 and Definition 1.4.7 give two different notions of equiva-
lences. We will look into the relationship between two in Tutorial Exercise 1.7.
Exercise 1.4.10. Convince yourself that the following are true for all compound expressions  1e
P , Q, and R.

6
(1) P ≡ P .
(2) If P ≡ Q, then Q ≡ P .
(3) If P ≡ Q and Q ≡ R, then P ≡ R.
We will demonstrate in Chapter 6 that these are precisely the properties that a reasonable
notion of equivalence should satisfy.

Technique 1.4.11. One way to check whether two compound expressions are equivalent is
to draw a truth table for the two expressions: if the columns for the two expressions are
exactly the same, then the expressions are equivalent, else they are not.

Justification. Suppose the columns for the two compound expressions P and Q are exactly
the same. As all possible combinations of truth values of propositions (to be substituted into
P and Q) are listed in the truth table, this indicates that P and Q evaluate to the same truth
value under any substitution of propositions into the propositional variables. Thus P and Q
are equivalent. Note that we use here implicitly the fact that what a compound expression
evaluates to depends only on the truth values of the propositions being substituted in, not
on their other aspects, as alluded to in Remark 1.2.4.
Suppose the columns for P and Q are not exactly the same. Say, they differ in row i. This
row i corresponds to a way to substitute true and false propositions into the propositional
variables occurring in P and Q. As the columns for P and Q are different in row i, these
two expressions evaluate to different truth values under this substitution. This shows that
P and Q are not equivalent.

Theorem 1.4.12. Let p, q be propositional variables. Consider the conditional proposition


p → q.
(1) The conditional proposition p → q is equivalent to its contrapositive ¬q → ¬p.
(2) The converse q → p is equivalent to the inverse ¬p → ¬q.

(3) The conditional proposition p → q is not equivalent to its converse p → q.

Proof. (1) We see that the truth table in Note 1.3.9 the column for p → q is exactly the
same as that for ¬q → ¬p. So these two compound expressions are equivalent.
(2) Similarly, the compound expressions q → p and ¬p → ¬q are equivalent because their
columns in the truth table in Note 1.3.9 are exactly the same.
(3) In the truth table in Note 1.3.9, the columns for p → q and q → p differ in the row
where p is true and q is false. So these compound expressions are not equivalent.
Remark 1.4.13. For Theorem 1.4.12(3), the columns involved actually differ also in the row
where p is false and q is true, but one differing row is enough to show the non-equivalence.

Theorem 1.4.14. Let p, q be propositional variables. Then p → q is equivalent to ¬p ∨ q.

Proof. Here is the truth table for p → q and ¬p ∨ q.

p q p→q ¬p ¬p ∨ q
T T T F T
T F F F F
F T T T T
F F T T T

7
The columns for p → q and ¬p ∨ q are exactly the same. So the two compound expressions
are equivalent.

Technique 1.4.15. To prove that two compound expressions are not equivalent, it suffices
to find one way to substitute true and false propositions into the propositional variables to
make the expressions evaluate to different truth values.

Example 1.4.16. Let p, q be propositional variables. Then ¬(p ∨ q) and ¬p ∨ q are not
equivalent.
Proof. Let us substitute true propositions into both p and q. Under this substitution, the
expression p ∨ q evaluates to T, and thus ¬(p ∨ q) evaluates to F. However, under the same
substitution, the expression ¬p ∨ q evaluates to T. So these two compound expressions are
not equivalent.

Exercise 1.4.17. Let p, q, r be propositional variables. Is (p ∧ q) ∨ r equivalent to p ∧ (q ∨ r)?  1f


Give a proof for your answer.

Definition 1.4.18. (1) A tautology is a compound expression that evaluates to true no


matter what propositions are substituted into all its propositional variables.
(2) A contradiction is a compound expression that evaluates to false no matter what propo-
sitions are substituted into all its propositional variables.

Example 1.4.19. Let p be a propositional variable. Here is the truth table for p ∨ ¬p and
p ∧ ¬p.
p ¬p p ∨ ¬p p ∧ ¬p
T F T F
F T T F
Since all the entries in the column for p ∨ ¬p are T, we see that p ∨ ¬p is a tautology. Since
all the entries in the column for p ∧ ¬p are F, we see that p ∧ ¬p is a contradiction.

Theorem 1.4.20 (logical identities). Let t be a tautology and c be a contradiction. For all
propositional variables p, q, r, the following equivalences hold.

Commutativity p∨q ≡q∨p p∧q ≡q∧p


Associativity (p ∨ q) ∨ r ≡ p ∨ (q ∨ r) (p ∧ q) ∧ r ≡ p ∧ (q ∧ r)
Distributivity p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r) p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)
Idempotence p∨p≡p p∧p≡p
Absorption p ∨ (p ∧ q) ≡ p p ∧ (p ∨ q) ≡ p
De Morgan’s Laws ¬(p ∨ q) ≡ ¬p ∧ ¬q ¬(p ∧ q) ≡ ¬p ∨ ¬q
Identities p∨c≡p p∧t≡p
Annihilators p∨t≡t p∧c≡c
Negation p ∨ ¬p ≡ t p ∧ ¬p ≡ c
Double Negative Law ¬¬p ≡ p
Top and bottom ¬c ≡ t ¬t ≡ c
Implication p → q ≡ ¬p ∨ q

8
Proof. We saw the Negation and the Implication parts already in Theorem 1.4.14 and
Example 1.4.19 respectively. We will prove the Double Negative Law and De Morgan’s Laws
below. Distributivity, Idempotence, Absorption, and Top and bottom will appear in Tutorial
Exercise 1.3. The rest (i.e., Associativity, Commutativity, Identities, and Annihilators) are
left as exercises.  1g
For the Double Negative Law and the De Morgan Law on the left, we use the following
truth tables.

p ¬p ¬¬p p q p∨q ¬(p ∨ q) ¬p ¬q ¬p ∧ ¬q


T F T T T T F F F F
F T F T F T F F T F
F T T F T F F
F F F T T T T

We see that the columns for ¬¬p and p are exactly the same in the left truth table. So these
expressions are equivalent. Similarly, the columns for ¬(p ∨ q) and ¬p ∧ ¬q are exactly the
same in the right truth table. So these expressions are also equivalent.
For the De Morgan Law on the right, we can also use a truth table, but let us proceed as
follows to demonstrate another approach:

¬(p ∧ q) ≡ ¬(¬¬p ∧ ¬¬q) by the Double Negative Law;


≡ ¬¬(¬p ∨ ¬q) by the left De Morgan Law;
≡ ¬p ∨ ¬q by the Double Negative Law.

Remark 1.4.21. Our proof of the right De Morgan Law above used the fact that if one sub-
stitutes equivalent compound expressions into the same propositional variable in equivalent
compound expressions, then one obtains again equivalent compound expressions.
Convention 1.4.22. Let p, q, r be propositional variables. There are two reasonable inter-
pretations of p ∨ q ∨ r: it can stand for (p ∨ q) ∨ r or p ∨ (q ∨ r). These two interpretations
are equivalent by the associativity of ∨ from Theorem 1.4.20. It does not matter which in-
terpretation we take because we will treat equivalent compound expressions as “the same”.
So we may write p ∨ q ∨ r without parentheses. Similarly, in view of the commutativity of ∨,
we will not need to distinguish between p ∨ q and q ∨ p. These generalize to any number of
∨’s. The same goes for ∧, but not a mixture of the two; cf. Convention 1.4.3.
Example 1.4.23. Let p, q be propositional variables. Then ¬(p → q) ≡ p ∧ ¬q.
Proof.

¬(p → q) ≡ ¬(¬p ∨ q) by the logical identity on the implication;


≡ ¬¬p ∧ ¬q by De Morgan’s Laws;
≡ p ∧ ¬q by the Double Negative Law.

Note 1.4.24. Different (looking) compound expressions may be equivalent. Therefore, show-
ing that a compound expression P is equivalent (via the logical identities, say) to one that
is different from another compound expression Q alone is not sufficient to imply that P and
Q are not equivalent.
Example 1.4.25. Let A, B be sets. (For this example, it does not matter what “set” means.)
Consider the following propositions from Chapter 8.
(1) If A is a subset of B, then the countability of B implies the countability of A.
(2) If A is not countable and A is a subset of B, then B is not countable.

9
One can rewrite these two propositions symbolically as
p → (r → q) and (¬q ∧ p) → ¬r
respectively, where
• p denotes the proposition “A is a subset of B”;
• q denotes the proposition “A is countable”; and
• r denotes the proposition “B is countable”.
Treating p, q, r as propositional variables, we see that
p → (r → q) ≡ ¬p ∨ (¬r ∨ q) by the logical identity on the implication;
≡ (q ∨ ¬p) ∨ ¬r by the commutativity and the associativity of ∨;
≡ (¬¬q ∨ ¬p) ∨ ¬r by the Double Negative Law;
≡ ¬(¬q ∧ p) ∨ ¬r by De Morgan’s Laws;
≡ (¬q ∧ p) → ¬r by the logical identity on the implication.
So propositions (1) and (2) have the same truth value.

Example 1.4.26. Let p, q be propositional variables. Then (p → q) ∧ p → q is a tautology.
Proof.
 
(p → q) ∧ p → q ≡ ¬ (p → q) ∧ p ∨ q by the logical identity on the implication.
≡ ¬(p → q) ∨ ¬p ∨ q by De Morgan’s Laws;
≡ ¬(p → q) ∨ (p → q) by the logical identity on the implication.

So (p → q) ∧ p → q is a tautology by Example 1.4.19.
Remark 1.4.27. In Example 1.4.26, our proof used the fact that a compound expression is
a tautology if it is equivalent to one. In fact, it is also true that a compound expression is a
contradiction if it is equivalent to one.

Tutorial exercises
An asterisk (*) indicates a more challenging exercise.
1.1. Let p, q be false propositions and r be a true proposition. What are the truth values
of the following propositions?

(a) p ∧ q → r. (c) p ∧ q ∨ (¬r → p) .

(b) p ↔ q ∨ ¬r. (d) q ∨ r ∨ (¬p ↔ q) ∧ (q ∨ r).

1.2. Fix a graph G. (For this exercise, it does not matter what “graph” means.) Consider
the following propositions from Chapter 12.
(a) The graph G is a tree if and only if it is connected and acyclic.
(b) For G to be a tree, it is necessary that G is acyclic.
(c) Being a tree is a sufficient condition for the graph G to be connected.
Rewrite these propositions symbolically in terms of c, a, t, where
• c denotes the proposition “G is connected”;
• a denotes the proposition “G is acyclic”; and
• t denotes the proposition “G is a tree”.
1.3. Fix a tautology t and a contradiction c. Let p, q, r be propositional variables.
(a) Use truth tables to prove the following logical identities.

10
(i) p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r). (iii) p ∧ (p ∨ q) ≡ p.
(ii) p ∧ p ≡ p. (iv) ¬t ≡ c.

(b) Use part (a) and the logical identities proved (in the exercises) in the notes to
prove the following logical identities.

(i) p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r). (iii) p ∨ (p ∧ q) ≡ p.


(ii) p ∨ p ≡ p. (iv) ¬c ≡ t.

1.4. In this exercise, we show that “if and only if” really means “if” and “only if”.
Let p, q be propositional variables. Prove that p ↔ q ≡ (p → q) ∧ (q → p).

1.5. Let p, q, r be propositional variables. Prove that (p → q) ∧ (q → r) → (p → r) is a
tautology.
This tautology is sometimes called the transitivity of →. It is used all the time, albeit
implicitly, in proofs.

1.6. Let p, q be propositional variables. Is (p → q) → (q → p) is tautology? Give a proof


for your answer.
1.7.∗ We saw two different notions of equivalences: the symbol ↔ refers to one between
propositions, while the symbol ≡ refers to one between compound expressions. Al-
though these are different notions, they are closely related to each other, as we will
show in this exercise.
Let P and Q be compound expressions. Prove that P ↔ Q is a tautology if and only
if P ≡ Q.
(Hint: Study carefully the definitions of ↔, tautology, and ≡.)

Extra exercises
1.8. Let p, q, r be propositional variables. Consider the compound expressions

p∧q →r and (p → r) ∧ (q → r).

Are they equivalent? Give a proof for your answer.


1.9. Let p, q, r be propositional variables, and c be a contradiction. Prove that the following
compound expressions are tautologies:
(a) (p ∨ q) ∧ (p → r) ∧ (q → r) → r;
(b) (¬p → c) → p.
As we will see in Chapter 3, proofs that split into cases and proofs by contradictions
are based on these tautologies respectively.
1.10. We omitted the proof of Remark 1.4.21. Here let us get a taste of what the proof is
like by looking at a particular example.
Let P, Q be compound expressions. Prove that, if P ≡ Q, then ¬P ≡ ¬Q.

11
CS1231 Chapter 2

Predicate logic

2.1 Predicates
Definition 2.1.1. (1) A variable is a symbol that indicates a position in a sentence in
which one can substitute (the name of) an object.
(2) A valid substitution for a variable replaces all free occurrences of that variable in the
sentence by the same object.

(3) Saying a variable x takes an object a in a sentence means one substitutes the object a
into the variable x in the sentence.
(4) Sometimes we may want to allow only certain objects to be substituted into a variable x.
In this case, we call the set of all such objects the domain of x, and we may say that
x ranges over these objects.

Remark 2.1.2. A phrase or a symbol may use, or more technically speaking, bind a variable
occurring in the sentence. For example, the variable x in
For every real number x, we must have x2 ⩾ 0.
is already used, or bound, by the phrase “for every”: this sentence means
No matter what real number one substitutes into the variable x, the sentence
x2 ⩾ 0 becomes true.
A valid substitution should be applied only to the variable occurrences that are not already
used or bound by anything in the sentence. Such occurrences are said to be free.
Remark 2.1.3. (1) A set is a (possibly empty, possibly infinite) collection of objects; these
objects are called the elements of the set. We can write z ∈ A for “z is an element
of A”. Chapter 4 contains a more detailed treatment of sets.
(2) In Chapter 7, we will introduce the notion of the domain of a function. This is different
from the domain of a variable.
(3) Some people insist that every variable has a domain. We do not.

Note 2.1.4. We define the natural numbers to include 0, but some authors do not.
Definition 2.1.5. Let P be a sentence and let x1 , x2 , . . . , xn list all the variables that appear
free in P .
(1) We may write P as P (x1 , x2 , . . . , xn ).
(2) If z1 , z2 , . . . , zn are objects, then we denote by P (z1 , z2 , . . . , zn ) the sentence obtained
from P (x1 , x2 , . . . , xn ) by substituting each zi into xi .

12
Symbol Meaning Elements Non-elements
N the set of all natural numbers 0, 1, 2, 3, 31 −1, 12
1

Z the set of all integers 0, 1, −1, 2, −10 2, 2 √

Q the set of all rational numbers −1, 10, 12 , − 57 2, π, −1
√ √ √
R the set of all real numbers −1, 10, − 23 , 2, π −1, −10
C the set of all complex numbers all of the above
Z+ the set of all positive integers 1, 2, 3, 31 0, −1, −12
Z− the set of all negative integers −1, −2, −3, −31 0, 1, 12
Z⩾0 the set of all non-negative integers 0, 1, 2, 3, 31 −1, −12
Q+ , Q− , Q⩾m , R+ , R− , R⩾m , etc. are defined similarly.

Table 2.1: Common sets

Definition 2.1.6. (1) A predicate is a sentence that becomes a proposition whenever one
validly substitutes objects into all its variables.
(2) A sentence P (x1 , x2 , . . . , xn ) is a predicate over sets D1 , D2 , . . . , Dn if P (z1 , z2 , . . . , zn )
is a proposition whenever z1 , z2 , . . . , zn are respectively elements of D1 , D2 , . . . , Dn ; in
the case when a variable xi here has a domain, we additionally require this domain to
contain every element of Di .

(3) We may call a predicate over D, D, . . . , D simply a predicate on D.

Example 2.1.7. Let P (x) be “x2 ⩾ x”, where x is a variable with domain Q. Then
(1) P (x) is a predicate over Q;

(2) P (1231) is “12312 ⩾ 1231”, which is a true proposition; and


(3) P (1/2) is “(1/2)2 ⩾ 1/2”, which is a false proposition because (1/2)2 = 1/4 < 1/2.
Example 2.1.8. Let Q(x, y) be “x + y = 0”, where x and y are variables with domain Z.
Then

(1) Q(x, y) is a predicate on Z;


(2) Q(0, 1) is “0 + 1 = 0”, which is a false proposition; and
(3) Q(2, −2) is “2 + (−2) = 0”, which is a true proposition.

2.2 Quantifiers
Definition 2.2.1. Let P (x) be a sentence.
(1) We denote by ∀x P (x) the proposition “for all x, P (x)”.

(2) The symbol ∀, read as “for all”, is known as the universal quantifier.
(3) The proposition ∀x P (x) is true if and only if P (z) is true for all objects z.
(4) A counterexample to the proposition ∀x P (x) is an object z for which P (z) is not true.
(5) If D is a set, then we denote by∀x ∈ D P (x) the sentence “for all x in D, P (x)”, or
symbolically ∀x x ∈ D → P (x) .

13
Note 2.2.2. Let P (x) be a sentence and D be a set.
(1) The proposition ∀x P (x) is false if and only if it has a counterexample. In the case
when P (x) is a predicate, this in turn is equivalent to P (z) being false for at least one
object z.
(2) The proposition ∀x ∈ D P (x) is false if and only if it has a counterexample. In the
case when P (x) is a predicate over D, this in turn is equivalent to P (z) being false for
at least one element z of D.
Example 2.2.3. (1) Let D be the set that contains precisely 1, 2, 3, 4, 5. Then the propo-
sition ∀x ∈ D x2 ⩾ x is true because

12 ⩾ 1 and 22 ⩾ 2 and 32 ⩾ 3 and 42 ⩾ 4 and 52 ⩾ 5.

(2) The number 1/2 is a counterexample to ∀x ∈ Q x2 ⩾ x because 1/2 is an element of Q


and (1/2)2 = 1/4 < 1/2.
(3) So the proposition ∀x ∈ Q x2 ⩾ x is false.

Definition 2.2.4. Let P (x) be a sentence.

(1) We denote by ∃x P (x) the proposition “there exists x such that P (x)”.
(2) The symbol ∃, read as “there exists”, is known as the existential quantifier.
(3) The proposition ∃x P (x) is true if and only if P (z) is true for at least one object z.

(4) A witness to the proposition ∃x P (x) is an object z for which P (z) is true.
(5) If D is a set, then we denote by ∃x ∈ D P (x) the proposition “there exists x in D such
that P (x)”, or symbolically ∃x x ∈ D ∧ P (x) .

Note 2.2.5. Let P (x) be a sentence and D be a set.


(1) The proposition ∃x P (x) is true if and only if it has a witness.
(2) In the case when P (x) is a predicate, the proposition ∃x P (x) is false if and only if
P (z) is false for all objects z.
(3) The proposition ∃x ∈ D P (x) is true if and only if it has a witness.
(4) In the case when P (x) is a predicate over D, the proposition ∃x ∈ D P (x) is false if
and only if P (z) is false for all elements z of D.
Example 2.2.6. (1) The number 2 is a witness to ∃x ∈ Q x2 ⩾ x because 2 is an element
of Q and 22 = 4 ⩾ 2.
(2) So the proposition ∃x ∈ Q x2 ⩾ x is true.
(3) Let D be the set that contains precisely 1/2, 1/3, 1/4, 1/5. Then the proposition
∃x ∈ D x2 ⩾ x is false because
 1 2 1 1  1 2 1 1  1 2 1 1  1 2 1 1
= < and = < and = < and = < .
2 4 2 3 9 3 4 16 4 5 25 5
Convention 2.2.7. Let P (x) be a predicate.
(1) In mathematics,

“there exists one x such that P (x)” or “there is one x such that P (x)”

means “there exists at least one x such that P (x)”.

14
(2) More generally, if n is a non-negative integer, then
“there exist n x’s such that P (x)” or “there are n x’s such that P (x)”
means “there exist at least n x’s such that P (x)”.
(3) If the exact number is intended, then use the word “exactly”, as in “there are exactly
two x’s such that P (x)”.
Convention 2.2.8. (1) In informal contexts, some may write symbolically a quantifier,
say ∀x ∈ D or ∃x, after the expression it applies to.
(2) However, in this module, we do not do it: here a quantifier, when written symbolically,
always comes before the expression it applies to.
(3) More precisely, it applies only to the smallest predicate (over an appropriate set) that
follows it.

Terminology 2.2.9. (1) In addition to “all’, words that indicate universal quantification
in mathematics include “every”, “each”, and “any”.
(2) One may also express “for all x in D, P (x)”, where P (x) is a sentence and D is a set,
as
“P (x) whenever x ∈ D” or “If x ∈ D, then P (x)”.

(3) In addition to “exists”, phrases that indicate existential quantification in mathematics


include “some” and “there is”.

Example 2.2.10. Let Even(x) denote the predicate “x is even” over Z. (We will give a pre-
cise definition of this predicate in Chapter 3.) Express the following propositions symbolically
using Even(x).
(1) “The square of any even integer is even.”
(2) “Any integer whose square is even must itself be even.”
(3) “Some even integer n satisfies n2 = 2n.”

Solution. (1) ∀n ∈ Z Even(n) → Even(n2 ) .

A common mistake is to answer ∀n ∈ Z Even(n) ∧ Even(n2 ) ; this can be read as
“for every integer n, n is even and n2 is even”, whose meaning is different from that of
the given proposition.

(2) ∀n ∈ Z Even(n2 ) → Even(n) .

(3) ∃n ∈ Z Even(n) ∧ n2 = 2n .
Remark 2.2.11. (1) In certain areas of mathematics, all variables have the same domain.
This common domain is called the domain of discourse. For brevity, some authors may
omit this in quantified expressions in the particular context.
(2) In this module, there is no domain of discourse, as we often need to consider variables
with different domains. In particular, we will not abbreviate ∀x ∈ D and ∃x ∈ D as
∀x and ∃x.
Exercise 2.2.12. Which of the following is/are true for every predicate P (x) over R?  2a
(1) If ∀x ∈ Z P (x) is true, then ∀x ∈ R P (x) is true.
(2) If ∀x ∈ R P (x) is true, then ∀x ∈ Z P (x) is true.
(3) If ∃x ∈ Z P (x) is true, then ∃x ∈ R P (x) is true.
(4) If ∃x ∈ R P (x) is true, then ∃x ∈ Z P (x) is true.

15
2.3 Negation

Theorem 2.3.1. The following are true for all predicates P (x).
(1) ¬∀x P (x) ↔ ∃x ¬P (x).
(2) ¬∃x P (x) ↔ ∀x ¬P (x).

The following are true for all predicates P (x) over a set D.
(3) ¬∀x ∈ D P (x) ↔ ∃x ∈ D ¬P (x).
(4) ¬∃x ∈ D P (x) ↔ ∀x ∈ D ¬P (x).

Proof.
(1) Note that the following are true.

¬∀x P (x) is true ↔ ∀x P (x) is false


by the definition of ¬.
∀x P (x) is false ↔ P (z) is false for at least one object z
by Note 2.2.2(1).
P (z) is false for at least one object z ↔ ¬P (z) is true for at least one object z
by the definition of ¬.
¬P (z) is true for at least one object z ↔ ∃x ¬P (x) is true
by the definition of ∃.

From these, we deduce that ¬∀x P (x) is true if and only if ∃x ¬P (x) is true.
(2) The proof is similar: note that the following are true.

¬∃x P (x) is true ↔ ∃x P (x) is false by the definition of ¬.


∃x P (x) is false ↔ P (z) is false for all objects z
by Note 2.2.5(2).
P (z) is false for all objects z ↔ ¬P (z) is true for all objects z
by the definition of ¬.
¬P (z) is true for all objects z ↔ ∀x ¬P (x) is true by the definition of ∀.

From these, we deduce that ¬∃x P (x) is true if and only if ∀x ¬P (x) is true.
We can prove (3) and (4) in a similar way.
Remark 2.3.2. We will introduce a more succinct way to write the proof of Theorem 2.3.1
in Chapter 3.
Exercise 2.3.3. Alternatively, parts (3) and (4) of Theorem 2.3.1 can be proved directly  2b
using parts (1) and (2) together with the symbolic definitions from Definition 2.2.1(5) and
Definition 2.2.4(5). Verify this.
Example 2.3.4. Consider the following proposition:

“Not every integer is even.”

We can express this symbolically as

¬∀n ∈ Z Even(n),

where Even(n) denotes the predicate “n is even” over Z. In view of Theorem 2.3.1, this is
equivalent to
∃n ∈ Z ¬Even(n).

16
It follows that the given English proposition is equivalent to

“There is an integer that is not even.”

Example 2.3.5. Consider the following proposition:

“No integer is both odd and even.”

We can express this symbolically as



¬∃n ∈ Z Odd(n) ∧ Even(n) ,

where Even(n) and Odd(n) denote respectively the predicates “n is even” and “n is odd”
over Z. In view of Theorem 2.3.1, this is equivalent to

∀n ∈ Z ¬ Odd(n) ∧ Even(n) .

By De Morgan’s Laws, this is in turn equivalent to



∀n ∈ Z ¬Odd(n) ∨ ¬Even(n) .

It follows that the given English proposition is equivalent to

“For every integer, either it is not odd or it is not even.”

2.4 Nested quantification


Definition 2.4.1 (generalizing Definitions 2.2.1 and 2.2.4). Consider a sentence
Q(x1 , x2 , . . . , xn , y) and a set E. Let z1 , z2 , . . . , zn be objects. For each i, assume addi-
tionally that zi is in the domain of xi if xi has a domain.
(1) We denote by ∀y Q(x1 , x2 , . . . , xn , y) and ∃y Q(x1 , x2 , . . . , xn , y) the predicates “for
all y, Q(x1 , x2 , . . . , xn , y)” and “there exists y such that Q(x1 , x2 , . . . , xn , y)” respec-
tively. Both of these predicates may mention variables x1 , x2 , . . . , xn .
(2) Denote by ∀y Q(z1 , z2 , . . . , zn , y) and ∃y Q(z1 , z2 , . . . , zn , y) the propositions obtained
respectively from the predicates ∀y Q(x1 , x2 , . . . , xn , y) and ∃y Q(x1 , x2 , . . . , xn , y) by
substituting each zi into xi .
(3) The proposition ∀y Q(z1 , z2 , . . . , zn , y) is true if and only if Q(z1 , z2 , . . . , zn , w) is true
for all objects w.
(4) A counterexample to the proposition ∀y Q(z1 , z2 , . . . , zn , y) is an object w for which
Q(z1 , z2 , . . . , zn , w) is not true.
(5) The proposition ∃y Q(z1 , z2 , . . . , zn , y) is true if and only if Q(z1 , z2 , . . . , zn , w) is true
for at least one object w.
(6) A witness to the proposition ∃y Q(z1 , z2 , . . . , zn , y) is an object w for which
Q(z1 , z2 , . . . , zn , w) is true.
(7) We denote by ∀y ∈ E Q(x1 , x2 , . . . , xn , y) the predicate “for all y in E,
Q(x1 , x2 , . . . , xn , y)”, or symbolically ∀y y ∈ E → Q(x1 , x2 , . . . , xn , y) .
(8) We denote by ∃y ∈ E Q(x1 , x2 , . . . , xn , y) the predicate “there exists y in E such that
Q(x1 , x2 , . . . , xn , y)”, or symbolically ∃y y ∈ E ∧ Q(x1 , x2 , . . . , xn , y) .

Example 2.4.2. Let Q(x, y) be a predicate. Then ∃x ∀y Q(x, y) is the proposition ∃x P (x),
where P (x) denotes the predicate ∀y Q(x, y).

17
Example 2.4.3. Recall the predicate x + y = 0 over Z from Example 2.1.8.
(1) Consider the proposition “∀x ∈ Z ∃y ∈ Z x + y = 0”.
(a) This reads “for every integer x, there is an integer y, such that x + y = 0”.
(b) This is true because, given any integer x, one can set y = −x to make y an integer
and x + y = 0.
(2) Consider the proposition “∃x ∈ Z ∀y ∈ Z x + y = 0”.
(a) This reads “there is an integer x such that, for every integer y, x + y = 0”.
(b) Alternatively, one can express this as “there is an integer which, when added to
any integer, gives a sum of 0”.
(c) This is false because, given any integer x, one can set
(
0, if x ̸= 0;
y=
1, if x = 0,

so that y is an integer and x + y ̸= 0.


(3) Consider the proposition “∀x ∈ Z ∀y ∈ Z x + y = 0”.

(a) This reads “for every integer x, for every integer y, x + y = 0”.
(b) Alternatively, one can express this as “the sum of any two integers is 0”.
(c) This is false because 1 and 1 are integers and 1 + 1 = 2 ̸= 0.
(4) Consider the proposition “∃x ∈ Z ∃y ∈ Z x + y = 0”.

(a) This reads “there exists an integer x, there exists an integer y, such that x+y = 0”.
(b) Alternatively, one can express this as “there are two integers which, when added
together, gives 0”.
(c) This is true because 2 and −2 are integers and 2 + (−2) = 0.
Warning 2.4.4. As Example 2.4.3 demonstrates, there are predicates Q(x, y) for which

∀x ∃y Q(x, y) and ∃y ∀x Q(x, y)

are not equivalent. So the order of quantifiers matters.


Note 2.4.5. One can interpret the following sentences as any one of ∀y ∈ Z ∃x ∈ Z x+y = 0
and ∃x ∈ Z ∀y ∈ Z x + y = 0. As the two interpretations are not equivalent, avoid writing
such ambiguous sentences in mathematics.
(1) “One can add any integer to some integer to get a sum of 0.”
(2) “There is an integer x such that x + y = 0 for any integer y.”

Example 2.4.6. One can express the proposition

“Every even integer is the sum of two odd integers.”

from Example 1.1.2(3) symbolically as



∀n ∈ Z Even(n) → ∃k ∈ Z ∃ℓ ∈ Z (Odd(k) ∧ Odd(ℓ) ∧ n = k + ℓ) ,

where Even(n) and Odd(n) are respectively the predicates “n is even” and “n is odd” over Z.

18
Notation 2.4.7. Let Q(x1 , x2 , . . . , xn , y1 , y2 , . . . , ym ) be a sentence and E be a set.
(1) We may abbreviate

∀y1 ∀y2 . . . ∀ym Q(x1 , x2 , . . . , xn , y1 , y2 , . . . , ym )

as ∀y1 , y2 , . . . , ym Q(x1 , x2 , . . . , xn , y1 , y2 , . . . , ym ).
(2) We may abbreviate

∀y1 ∈ E ∀y2 ∈ E . . . ∀ym ∈ E Q(x1 , x2 , . . . , xn , y1 , y2 , . . . , ym )

as ∀y1 , y2 , . . . , ym ∈ E Q(x1 , x2 , . . . , xn , y1 , y2 , . . . , ym ).
(3) We may abbreviate

∃y1 ∃y2 . . . ∃ym Q(x1 , x2 , . . . , xn , y1 , y2 , . . . , ym )

as ∃y1 , y2 , . . . , ym Q(x1 , x2 , . . . , xn , y1 , y2 , . . . , ym ).
(4) We may abbreviate

∃y1 ∈ E ∃y2 ∈ E . . . ∃ym ∈ E Q(x1 , x2 , . . . , xn , y1 , y2 , . . . , ym )

as ∃y1 , y2 , . . . , ym ∈ E Q(x1 , x2 , . . . , xn , y1 , y2 , . . . , ym ).

Note 2.4.8. Let P (x1 , x2 , . . . , xn ) be a sentence.

(1) The proposition ∀x1 , x2 , . . . , xn P (x1 , x2 , . . . , xn ) is true if and only if P (z1 , z2 , . . . , zn )


is true for all objects z1 , z2 , . . . , zn .
(2) The proposition ∃x1 , x2 , . . . , xn P (x1 , x2 , . . . , xn ) is true if and only if P (z1 , z2 , . . . , zn )
is true for some objects z1 , z2 , . . . , zn .

The objects z1 , z2 , . . . , zn above are not necessarily different. The analogous statements for
∀x1 , x2 , . . . , xn ∈ D P (x1 , x2 , . . . , xn ) and ∃x1 , x2 , . . . , xn ∈ D P (x1 , x2 , . . . , xn ) are also
true when D is a set. If the zi ’s are really meant to be all different, then one can use the
word “distinct” to indicate it, as in “for all distinct z1 , z2 , . . . , zn ” and “there exist distinct
z1 , z2 , . . . , zn ”.

Theorem 2.4.9. The following are true for all predicates Q(x, y).
(1) ¬∀x ∀y Q(x, y) ↔ ∃x ∃y ¬Q(x, y).

(2) ¬∀x ∃y Q(x, y) ↔ ∃x ∀y ¬Q(x, y).


(3) ¬∃x ∃y Q(x, y) ↔ ∀x ∀y ¬Q(x, y).
(4) ¬∃x ∀y Q(x, y) ↔ ∀x ∃y ¬Q(x, y).

Proof. We consider here only (1) and (2); the proofs of parts (3) and (4) are left as exercises.  2c
(1) We have the following equivalences by Theorem 2.3.1.

¬∀x ∀y Q(x, y) ↔ ∃x ¬∀y Q(x, y).


∃x ¬∀y Q(x, y) ↔ ∃x ∃y ¬Q(x, y).

From these, we deduce that ¬∀x ∀y Q(x, y) is true if and only if ∃x ∃y ¬Q(x, y) is true.

19
(2) We have the following equivalences by Theorem 2.3.1.
¬∀x ∃y Q(x, y) ↔ ∃x ¬∃y Q(x, y).
∃x ¬∃y Q(x, y) ↔ ∃x ∀y ¬Q(x, y).
From these, we deduce that ¬∀x ∃y Q(x, y) is true if and only if ∃x ∀y ¬Q(x, y) is
true.
Exercise 2.4.10. Let D be the set that contains precisely −1, 0, 1. Let E be the set that  2d
contains precisely 1, −1, 2, −2. Which of the following propositions is/are true?
(1) ∃x ∈ D ∀y ∈ E xy = 0.
(2) ∀y ∈ E ∃x ∈ D xy = 0.
(3) ∃x ∈ D ∀y ∈ E xy < 0.
(4) ∀y ∈ E ∃x ∈ D xy < 0.
(5) ∃x1 , x2 ∈ D x1 + x2 = 2.
(6) ∀y1 , y2 ∈ E y1 = y2 .

Tutorial exercises
2.1. Fix a relation R on a set A. (For this exercise, it does not matter what “relation”
means.) Consider the following propositions from Chapter 6.
(a) x R x for any element x of A. (reflexivity)
(b) For all elements x, y of A such that x R y, one must have y R x. (symmetry)
(c) No distinct elements x, y of A satisfy both x R y and y R x. (antisymmetry)
Rewrite these propositions symbolically in terms of R and A.
2.2. Refer back to Exercise 2.1. Someone claims that the following is an equivalent formu-
lation of antisymmetry.
If x, y are elements of A satisfying x R y and y R x, then x and y must be equal.
Is this claim correct? Justify your answer.
2.3. Rewrite the following propositions symbolically.
(a) There is no largest natural number.
(b) Between any two distinct rational numbers, there exists another one.
2.4. Consider the following propositions, some of which come from Chapter 7.
(a) ∀x ∈ R ∃y ∈ R y = x2 .
(b) ∀y ∈ R ∃x ∈ R y = x2 .
(c) (y1 = x1 2 ∧ y2 = x2 2 ∧ x1 ̸= x2 → y1 ̸= y2 ).
∀x1 , x2 , y1 , y2 ∈ R
(d) (y1 = x1 2 ∧ y2 = x2 2 ∧ y1 ̸= y2 → x1 ̸= x2 ).
∀x1 , x2 , y1 , y2 ∈ R

(e) ∀x ∈ R (∃y ∈ R y = x2 ) → x ⩾ 0 .

(f) ∀y ∈ R (∃x ∈ R y = x2 ) → y ⩾ 0 .
Rewrite the negation of each of these into an equivalent proposition where no ¬ is
followed by a proposition that mentions ¬, ∧, ∨, →, ↔, ∀, or ∃. Do so with a minimal
amount of rewrites. Which of these propositions are true? Which of these are false?
Briefly explain your answers.
(Hint: to understand what these propositions and their negations mean, it may be
helpful to read them out in words.)

20
Extra exercises
2.5. Consider the following proposition from Chapter 6.
An integer d divides an integer n if and only if n is the product of d with
some integer.
Rewrite this proposition symbolically in terms of the predicate Divides(d, n), which
stands for “d divides n”.
2.6. Let D be the set that contains precisely 1, 3, 5, 7, 9, 11, 13. Let E be the set that
contains precisely 0, 2, 4, 6. Consider the following propositions, some of which come
from Chapter 7.
(a) ∀x ∈ D ∃y ∈ E y < x.
(b) ∃y ∈ E ∀x ∈ D y < x.
(c) ∀x ∈ D ∃y ∈ E y + 1 = x.

(d) ∀x ∈ D x < 6 → ∃y ∈ E (y + 1 = x) .
Rewrite the negation of each of these into an equivalent proposition where no ¬ is
followed by a proposition that mentions ¬, ∧, ∨, →, ↔, ∀, or ∃. Do so with a minimal
amount of rewrites. Which of these propositions are true? Which of these are false?
Briefly explain your answers.

21
CS1231 Chapter 3

Proofs

3.1 Mathematical theories


Terminology 3.1.1. A definition is a description of what a (newly introduced) piece of
terminology or notation exactly means and does not mean.

Definition 3.1.2. (1) An integer is even if it is 2x for some integer x.


(2) An integer is odd if it is 2x + 1 for some integer x.

Example 3.1.3. (1) The integer 0 is even because 0 = 2 × 0, where 0 is an integer.

(2) The integer −1231 is odd because −1231 = 2 × (−616) + 1, where −616 is an integer.

Definition 3.1.4. (1) An alphabet is a set of symbols.


(2) A string over an alphabet Γ is a finite sequence of symbols from Γ.

(3) The set of all strings over an alphabet Γ is denoted Γ∗ .


(4) The length of a string is the number of symbols the string has (including repetition).

Example 3.1.5. Let Γ be the set that consists precisely of the symbols A, B, . . . , Z, 0, 1, 2, . . . , 9,
and let Φ be the set that consists precisely of the symbols A, B, . . . , Z, a, b, . . . , z.

(1) Γ and Φ are alphabets.


(2) CS1231 is a string over Γ, but it is not a string over Φ.
(3) CS1231 ∈ Γ∗ , but CS1231 ̸∈ Φ∗ .
(4) The length of the string CS1231 is 6.

Terminology 3.1.6. Axioms are propositions that are taken (without proof) to be true in
a theory, to specify which objects the theory is about.

Note 3.1.7. Even for the same mathematical theory, one may choose different (but equiva-
lent) axioms in different contexts.

Terminology 3.1.8. In mathematics, a proof of a proposition is a carefully reasoned ar-


gument, which may invoke definitions, axioms and previously established propositions, for
convincing the reader/audience that the proposition is true beyond doubt.

22
R includes Q ∀x ∈ Q x ∈ R.
Q includes Z ∀x ∈ Z x ∈ Q.
Z includes N ∀x ∈ N x ∈ Z.
Closure of R under + ∀x, y ∈ R x + y ∈ R.
Closure of R under negatives ∀x ∈ R −x ∈ R.
Definition of − ∀x, y ∈ R x − y = x + (−y).
Closure of R under × ∀x, y ∈ R x · y ∈ R.
 1 
Closure of R under reciprocals ∀x ∈ R x ̸= 0 → ∈ R .
x
 x 1
Definition of / ∀x, y ∈ R y ̸= 0 → = x · .
y y
Naturality of 0 0 ∈ N.
Closure of N under + 1 ∀x ∈ N x + 1 ∈ N.
Induction Every set of natural numbers that contains 0 and is closed
under the successor function must contain all natural
numbers, i.e., for every set A of natural numbers,
0 ∈ A ∧ (∀x ∈ A x + 1 ∈ A) → ∀x ∈ N x ∈ A.
Definition of Z ∀x ∈ R (x ∈ Z ↔ x ∈ N ∨ −x ∈ N).
  y 
Definition of Q ∀x ∈ R x ∈ Q ↔ ∃y, z ∈ Z z ̸= 0 ∧ x = .
z
Associativity of + ∀x, y, z ∈ R (x + y) + z = x + (y + z).
Associativity of · ∀x, y, z ∈ R (x · y) · z = x · (y · z).
Identity for + ∀x ∈ R x + 0 = x.
Identity for · ∀x ∈ R x · 1 = x.
Inverse for + ∀x ∈ R x + (−x) = 0.
 1 
Inverse for · ∀x ∈ R x ̸= 0 → x · = 1 .
x
Commutativity of + ∀x, y ∈ R x + y = y + x.
Commutativity of · ∀x, y ∈ R x · y = y · x.
Distributivity of · over + ∀x, y, z ∈ R x · (y + z) = (x · y) + (x · z).
Irreflexivity of < ∀x ∈ R x ̸< x.
Trichotomy ∀x, y ∈ R (x < y ∨ x = y ∨ y < x).
Transitivity of < ∀x, y, z ∈ R (x < y ∧ y < z → x < z).
+ respects < ∀x, y, z ∈ R (x < y → x + z < y + z).
Closure of R+ under · ∀x, y ∈ R (x > 0 ∧ y > 0 → x · y > 0).
Completeness Every nonempty set of real numbers that has an upper
bound in R must have a smallest upper bound in R,
i.e., for every nonempty set A of real numbers,
∃b ∈ R ∀x ∈ A x < b
→ ∃b∗ ∈ R ∀x ∈ A x < b∗
∧ ∀b ∈ R (∀x ∈ A x < b) → b∗ ⩽ b .


Table 3.1: A list of axioms for N, Z, Q, and R

23
Notation 3.1.9. The end of a proof is often marked by . Some authors use ■, ⊣, or QED.
Here QED stands for quod erat demonstrandum, which means “which was to be demon-
strated” in Latin.
Terminology 3.1.10. One (logically) deduces or infers a proposition q from propositions
p1 , p2 , . . . , pn if the forms of p1 , p2 , . . . , pn , q alone (without involving the subject matter)
guarantee that q is true whenever p1 , p2 , . . . , pn are all true.

Example 3.1.11 (modus ponens). Let p, q be propositions. From p → q and p, one can
deduce q.
Justification. As one can see from the following truth table, the only situation when p → q
and p are both true is when q is also true.

p q p→q
T T T
T F F
F T T
F F T

Exercise 3.1.12. Let p, q be propositions. From p → q and ¬p, can one deduce ¬q in  3a
general?
Example 3.1.13 (universal instantiation). Let P (x) be a sentence and z be an object. From
∀x P (x), one can deduce P (z).

Justification. This follows directly from Definition 2.2.1(3), in which we defined exactly
when ∀x P (x) is true.
Example 3.1.14 (transitivity of the conditional). Let p, q, r be propositions. From p → q
and q → r, one can deduce p → r.
Justification. This is based on the tautology from Tutorial Exercise 1.5.

Example 3.1.15 (transitivity of the biconditional). Let p, q, r be propositions. From p ↔ q


and q ↔ r, one can deduce p ↔ r.
Justification. This is based on Tutorial Exercise 1.4 and the transitivity of the conditional.

Note 3.1.16. Typically, a proof in mathematics consists of a number of steps. Each step
either comes from the definitions, the axioms or previously established propositions, or is
deduced logically from the previous steps.

Notation 3.1.17. In a proof, one sometimes write ∴ p in the case when p is a proposition
to indicate that p is deduced logically from the immediately preceding step(s). One may read
∴ as “therefore”.
Notation 3.1.18. Like in Theorem 2.3.1 and Theorem 2.4.9, many proofs use the transitivity
of the biconditional in the form

p1 ↔ p2 .
p2 ↔ p3 .
..
.
pn−1 ↔ pn .
∴ p1 ↔ pn .

24
One may write this more succinctly as

p1 ⇔ p2
⇔ p3
..
.
⇔ pn .

Similarly, one may write a proof of the form

p1 → p2 .
p2 → p3 .
..
.
pn−1 → pn .
∴ p1 → pn .

more succinctly as

p1 ⇒ p2
⇒ p3
..
.
⇒ pn .

Note 3.1.19. (1) One may use ⇔ and ⇒ for ↔ and → respectively, but not vice versa,
because their meanings are essentially the same between two propositions.
(2) In fact, it is common practice to use ⇔ and ⇒ exclusively in mathematical contexts
where logic is not the subject matter. We will follow this common practice.

Terminology 3.1.20. (1) A theorem is a proposition that has a proof and is often of
considerable significance (in the particular context).
(2) A proposition sometimes refers to a proposition in the sense of Definition 1.1.1 that has
a proof and is of medium significance (in the particular context).
(3) A lemma is a proposition that has a proof and helps in the proofs of other propositions,
but on its own is of little significance (in the particular context).

(4) A corollary is a proposition that can be deduced easily from other previously established
propositions.

3.2 Proof techniques


Technique 3.2.1. To prove ∃x P (x), where P (x) is a sentence, produce a witness, i.e., an
object z for which P (z) is true.

Justification. This is based on Note 2.2.5(4).

Proposition 3.2.2. Some even integer n satisfies n2 = 2n.

25
Base clause for exp ∀x ∈ R x0 = 1.
y+1
Recursion clause for exp ∀x ∈ R ∀y ∈ N x = xy · x.
Definition of ⩽ ∀x, y ∈ R (x ⩽ y ↔ x < y ∨ x = y).
Closure of Z under + ∀x, y ∈ Z x + y ∈ Z.
Closure of Z under − ∀x, y ∈ Z x − y ∈ Z.
Closure of Z under × ∀x, y ∈ Z x · y ∈ Z.
Closure of Q under + ∀x, y ∈ Q x + y ∈ Q.
Closure of Q under − ∀x, y ∈ Q x − y ∈ Q.
Closure of Q under × ∀x, y ∈ Q x · y ∈ Q.
 x 
Closure of Q under / ∀x, y ∈ Q y ̸= 0 → ∈ Q .
y
N = Z⩾0 ∀x ∈ R (x ∈ N ↔ x ∈ Z ∧ x ⩾ 0)
Discreteness of N ∀x ∈ N (x > 0 → x ⩾ 1).
Cancellation Law for + ∀x, y1 , y2 ∈ R (x + y1 = x + y2 → y1 = y2 ).
Differences ∀x, z ∈ R x + (z − x) = z.
Differences and negatives ∀x, z ∈ R z − x = z + (−x).
Double negatives ∀x ∈ R −(−x) = x.
Distributivity of · over − ∀x, y, z ∈ R x · (y − z) = (x · y) − (x · z).
Annihilator for × ∀x ∈ R x · 0 = 0.
Cancellation Law for · ∀x, y1 , y2 ∈ R (x ̸= 0 ∧ x · y1 = x · y2 → y1 = y2 ).
 z 
Quotients ∀x, z ∈ R x ̸= 0 → x · = z .
x
 1 
Double reciprocals ∀x ∈ R x ̸= 0 → =x .
1/x
Zero divisors ∀x, y ∈ R (x · y = 0 → x = 0 ∨ y = 0). 
Products and negatives ∀x, y ∈ R (−x) · y = x · (−y) ∧ x · (−y) = −(x · y) .
∀x, y ∈ R (−x) · (−y) = x · y.
 −x x x x
Quotients and negatives ∀x, y ∈ R y ̸= 0 → = ∧ =− .
y −y −y y
 −x x
∀x, y ∈ R y ̸= 0 → = .
−y y
 x x · z
Fraction equivalence ∀x, y, z ∈ R y ̸= 0 ∧ z ̸= 0 → = .
y y·z
 u x u · y + v · x
Fraction addition ∀u, v, x, y ∈ R v ̸= 0 ∧ y ̸= 0 → + = .
v y v·y
 u x u·x 
Fraction multiplication ∀u, v, x, y ∈ R v ̸= 0 ∧ y ̸= 0 → · = .
v y v·y
 u/v u·y 
Fraction division ∀u, v, x, y ∈ R v ̸= 0 ∧ x ̸= 0 ∧ y ̸= 0 → = .
x/y v·x
Closure of R+ under + ∀x, y ∈ R (x > 0 ∧ y > 0 → x + y > 0). 
Positivity of negatives ∀x ∈ R (x > 0 ∨ x = 0 ∨ −x > 0) ∧ ¬(x > 0 ∧ −x > 0) .
∀x ∈ R (x < 0 → −x > 0).
Positivity of one 1 > 0. 
Positivity of products ∀x, y ∈ R x · y > 0 → (x > 0 ∧ y > 0) ∨ (x < 0 ∧ y < 0)) .
Positivity of squares ∀x ∈ R (x ̸= 0 → x2 > 0).
Positivity and < ∀x, y ∈ R (x < y ↔ y − x > 0).
+ respects < ∀u, v, x, y ∈ R (u < v ∧ x < y → u + x < v + y).
Negatives and < ∀x, y ∈ R (x < y → −y < −x).
· and < ∀x, y, z ∈ R (x < y ∧ z > 0 → x · z < y · z).
∀x, y, z ∈ R (x < y ∧ z < 0 → x · z > y · z).
∀u, v, x, y ∈ R (u > 0 ∧ x > 0 ∧ u < v ∧ x < y → u · x > 0 ∧ u · x < v · y). 
Strict trichotomy ∀x, y ∈ R ¬(x < y ∧ x = y) ∧ ¬(x = y ∧ y < x) ∧ ¬(y < x ∧ x < y) .
Archimedean property of R ∀x ∈ R ∃y ∈ N y > x.

Table 3.2: Some properties of N, Z, Q, and R bootstrapped from the axioms

26
Proof. The integer 2 is even because 2 = 2×1 where 1 is an integer. Also 22 = 4 = 2×2.

Technique 3.2.3. One way to prove p → q, where p, q are propositions, is to assume p is


true, then prove (from this assumption) that q must also be true.

Proposition 3.2.4. The square of any even integer is even.

Proof. We want to prove that if n is an even integer, then n2 is an even integer.


Let n be an even integer. Use the definition of even integers to find an integer x such that
n = 2x. Then n2 = (2x)2 = 2(2x2 ), where 2x2 is an integer. So n2 is even by the definition
of even integers.
Convention 3.2.5. In proofs, when there is no risk of ambiguity, it is sometimes convenient
and instructive to use the same letter for both a variable and an object to be substituted
into that variable.

Exercise 3.2.6. Let n be an integer. Prove that  3b


(1) if n is even, then −n is even;
(2) if n is odd, then −n is odd.

Technique 3.2.7 (proof by contraposition). One way to prove p → q, where p, q are propo-
sitions, is to assume q is false, then prove (from this assumption) that p must also be false.

Justification. This is based on the equivalence of a conditional proposition p → q and its


contrapositive ¬q → ¬p from Theorem 1.4.12(1).

Proposition 3.2.8. Any integer whose square is even must itself be even.

Proof. We want to prove that for every integer n, if n2 is even, then n is even. We will prove
instead the contrapositive, that for every integer n, if n is not even, then n2 is not even.
Let n be an integer that is not even. Then n is odd. Use the definition of odd integers to
find an integer x such that n = 2x + 1. Then n2 = (2x + 1)2 = 4x2 + 4x + 1 = 2(2x2 + 2x) + 1,
where x2 + 2x is an integer. So n2 is odd by the definition of odd integers. This implies n2 is
not even, as required.

Technique 3.2.9. One way to prove p ↔ q, where p, q are propositions, is to prove both
p → q and q → p.

Justification. This is based on the equivalence of p ↔ q and (p → q)∧(q → p) from Tutorial


Exercise 1.4.

Corollary 3.2.10. An integer is even if and only if its square is even.

Proof. The “←” part is given by Proposition 3.2.8. The “→” part is given by Proposi-
tion 3.2.4.

Technique 3.2.11 (splitting into cases). One way to prove a proposition r is to first find
two propositions p and q such that either p or q is true, and then prove r from each of p
and q.

27
Justification. This is based on the tautology (p ∨ q) ∧ (p → r) ∧ (q → r) → r from Extra
Exercise 1.8.

Proposition 3.2.12. If n is an integer, then n(n + 1) is even.

Proof. We split into two cases.


Case 1: suppose n is even. Use the definition of even integers to find an integer x such
that n = 2x. Then n(n + 1) = (2x)(2x + 1) = 2(x(2x + 1)), where x(2x + 1) is an
integer. So n(n + 1) is even.
Case 2: suppose n is odd. Use the definition of odd integers to find an integer x such
that n = 2x + 1. Then n(n + 1) = (2x + 1)((2x + 1) + 1) = 2((2x + 1)(x + 1)), where
(2x + 1)(x + 1) is an integer. So n(n + 1) is even.

So n(n + 1) is even in all cases.


Remark 3.2.13. One can split into more than two cases in a proof, say p1 , p2 , . . . , pn where
each pi is a proposition, but one must make sure that these pi ’s cover all possibilities, i.e., that
p1 ∨ p2 ∨ · · · ∨ pn must be true.
Note 3.2.14. (1) We used implicitly in the proof of Proposition 3.2.12 that every integer
is either even or odd, i.e., Proposition 3.2.21.
(2) In addition to Proposition 3.2.21, we used implicitly in the proof of Proposition 3.2.8
that no integer is both even and odd, i.e., Proposition 3.2.17.
(3) Formally Propositions 3.2.17 and 3.2.21 should appear before Propositions 3.2.12 and 3.2.8,
and we should not use Propositions 3.2.12 and 3.2.8 in our proofs of Propositions 3.2.17
and 3.2.21.
Exercise 3.2.15. Identify where we used Propositions 3.2.17 and 3.2.21 in our proof of  3c
Proposition 3.2.8.

Technique 3.2.16 (proof by contradiction, also known as reductio ad absurdum). One way
to prove a proposition p is to assume that p is false, then prove (from this assumption) a
contradiction.

Justification. This is based on the tautology (¬p → c) → p, where c is a contradiction,


from Extra Exercise 1.9.

Proposition 3.2.17. No integer is both even and odd.

Proof. Suppose some integer, say n, is both even and odd. Use the definition of even and
odd integers to find integers x, y such that n = 2x and n = 2y + 1. As x and y are both
integers, so is x − y, but
n n−1 1
x−y = − = ,
2 2 2
which is not an integer. So we have a contradiction. It follows that no integer can be both
even and odd.
Exercise 3.2.18 (extra). We used in the proof of Proposition 3.2.17 that 1/2 is not an  3d
integer. Try to prove this from the axioms in Table 3.1 and the properties in Table 3.2. Here
you may define 1/2 to be the (unique) real number x satisfying 2x = 1.

28
Technique 3.2.19 (Mathematical Induction (MI)). Let b be an integer and P (n) be a
predicate over Z⩾b . To prove that ∀n ∈ Z⩾b P (n) is true, it suffices to:
(base step) show that P (b) is true; and

(induction step) show that ∀k ∈ Z⩾b P (k) → P (k + 1) is true.

Justification. The two steps ensure the following are true:

P (b) by the base step;


P (b) → P (b + 1) by the induction step with k = b;
P (b + 1) → P (b + 2) by the induction step with k = b + 1;
P (b + 2) → P (b + 3) by the induction step with k = b + 2;
..
.

We deduce that P (b), P (b + 1), P (b + 2), . . . are all true by a series of modus ponens.

Terminology 3.2.20. In the induction step, we assume we have an integer k ⩾ b such that
P (k) is true, and then show P (k + 1) using this assumption. In this process, the assumption
that P (k) is true is called the induction hypothesis.

Proposition 3.2.21. Every integer is either even or odd.

Proof. In view of Exercise 3.2.6, it suffices to show that every non-negative integer is either
even or odd. We prove this by MI. Let P (n) be the predicate “n is either even or odd”
over Z⩾0 .

(Base step) We know 0 = 2 × 0, where 0 is an integer. So 0 is even. Thus P (0) is true.


(Induction step) Let k be a non-negative integer such that P (k) is true, i.e., that k is either
even or odd. If k is even, say k = 2x where x is an integer, then k + 1 = 2x + 1, which
is odd. If k is odd, say k = 2x + 1 where x is an integer, then k + 1 = 2x + 2 = 2(x + 1),
which is even. So k + 1 is either even or odd in all cases. This shows P (k + 1) is true.

Hence ∀n ∈ Z⩾0 P (n) is true by MI.

Terminology 3.2.22. We call the proof above an induction on n because n is the active
variable in it.
Technique 3.2.23 (Strong Mathematical Induction (Strong MI)). Let b be an integer and
P (n) be a predicate over Z⩾b . To prove that ∀n ∈ Z⩾b P (n) is true, it suffices to choose
some integer c ⩾ b and:

(base step) show that P (b), P (b + 1), . . . , P (c) are true;


(induction step) show that

∀k ∈ Z⩾c P (b) ∧ P (b + 1) ∧ · · · ∧ P (k) → P (k + 1)

is true.

29
Justification. The two steps ensure the following are true:

P (b) ∧ P (b + 1) ∧ · · · ∧ P (c)
by the base step;
P (b) ∧ P (b + 1) ∧ · · · ∧ P (c) → P (c + 1)
by the induction step with k = c;
P (b) ∧ P (b + 1) ∧ · · · ∧ P (c) ∧ P (c + 1) → P (c + 2)
by the induction step with k = c + 1;
P (b) ∧ P (b + 1) ∧ · · · ∧ P (c) ∧ P (c + 1) ∧ P (c + 2) → P (c + 3)
by the induction step with k = c + 2;
..
.

We deduce that P (b), P (b + 1), P (b + 2), P (b + 3), . . . are all true by a series of modus
ponens.

Proposition 3.2.24. For every positive integer n, there exist a non-negative integer a and
an odd integer b such that n = 2a b.

Proof. Let P (n) be the predicate “there exist a non-negative integer a and an odd integer b
such that n = 2a b” over Z⩾1 .
(Base step) P (1) is true because 1 = 20 × 1, where 0 is a non-negative integer and 1 is an
odd integer.
(Induction step) Let k be a positive integer such that P (1), P (2), . . . , P (k) are all true.
Proposition 3.2.21 tells us that k + 1 is either even or odd.
Case 1: suppose k + 1 is even. Use the definition of even integers to find an inte-
ger x such that k + 1 = 2x. As k ⩾ 1,
k+1 1+1
x= ⩾ =1 and 2k = k + k ⩾ k + 1 = 2x.
2 2
Thus 1 ⩽ x ⩽ k and so P (x) is true by the induction hypothesis. Find a non-
negative integer a and an odd integer b such that x = 2a b. Then k + 1 = 2x =
2(2a b) = 2a+1 b, where a + 1 is a non-negative integer.
Case 2: suppose k + 1 is odd. Then k + 1 = 20 (k + 1), where 0 is a non-negative
integer.
So P (k + 1) is true in all cases.
Hence ∀n ∈ Z⩾1 P (n) is true by Strong MI.
Exercise 3.2.25 (extra). In Strong MI, one can actually allow c = b − 1. How may one  3e
make sense of this?

Definition 3.2.26. Let P (x) be a sentence. Then “there exists a unique x such that P (x)”,
sometimes denoted ∃!x P (x), means the conjunction of the two propositions below.

(existence) “There is at least one x such that P (x)”, or symbolically ∃x P (x).


(uniqueness) “There is at most one x such that P (x)”, or symbolically

∀x1 , x2 P (x1 ) ∧ P (x2 ) → x1 = x2 .

30
Proposition 3.2.27. For all odd numbers m, n, there exists a unique integer a such that
m2 + n2 = 4a + 2.

Proof. (Existence) Use the definition of odd numbers to find integers x, y such that m =
2x + 1 and n = 2y + 1. Then m2 + n2 = (2x + 1)2 + (2y + 1)2 = 4x2 + 4x + 1 + 4y 2 + 4y + 1 =
4(x2 + x + y 2 + y) + 2, where x2 + x + y 2 + y is an integer.
(Uniqueness) Suppose a1 , a2 are integers such that m2 + n2 = 4a1 + 2 and m2 + n2 =
4a2 + 2. Then 4a1 + 2 = 4a2 + 2. Subtract 2 from both sides, then divide both sides by 4.
Then we see that a1 = a2 .
Exercise 3.2.28. Prove that the a and the b from Proposition 3.2.24 are unique, i.e., if a1 , a2  3f
are non-negative integers and b1 , b2 are odd integers such that 2a1 b1 = 2a2 b2 , then a1 = a2
and b1 = b2 .
Remark 3.2.29. In professional mathematical discourse, one may start a proof for Exer-
cise 3.2.28 by assuming a1 ⩽ a2 without loss of generality because the case when a2 ⩽ a1 can
be handled in exactly the same way by suitably renaming the numbers. In this module, we
suggest that students avoid making such assumptions: write out the proof in full, even if it
involves repeating some steps. The reason is that, at this level, many students still cannot
tell when one can make an assumption without loss of generality, and when not.

Tutorial exercises
An asterisk (*) indicates a more challenging exercise.
3.1. Someone tries to prove that x2 ⩾ 0 for all real numbers x as follows.
Suppose not. Then x2 < 0 for all real numbers x. However, we know 1 is a
real number and 12 = 1 ⩾ 0. This is a contradiction. So x2 ⩾ 0 for all real
numbers x.
What is wrong with this attempt?
3.2. Consider the proposition “there is a real number x such that x2 + 9 = 6x.”
(a) Someone tries to prove this proposition as follows.
Let x be a real number such that x2 + 9 = 6x. Then x2 − 6x + 9 = 0.
This implies (x − 3)2 = 0. Thus x − 3 = 0 and so x = 3.
What is wrong with this attempt?
(b) Give a correct proof of this proposition.

3.3.∗ In this exercise, we establish an equivalent formulation of the notion of symmetry from
Exercise 2.1.
Let P (x, y) be a predicate on a set A. Prove that the following are equivalent.

(a) ∀x, y ∈ A P (x, y) → P (y, x) .

(b) ∀x, y ∈ A (P (x, y) ∧ P (y, x)) ∨ (¬P (x, y) ∧ ¬P (y, x)) .
What techniques did you use in your proof? Indicate where you used them.

31
Extra exercises
3.4. Someone tries to prove that x2 − 6x + 7 > 0 for all real numbers x as follows.
Real numbers are negative, zero, or positive. We consider these three cases
separately.
• If x < 0, say x = −1, then x2 −6x+7 = (−1)2 −6×(−1)+7 = 1+6+7 =
14 > 0.
• If x = 0, then x2 − 6x + 7 = 02 − 6 × 0 + 7 = 7 > 0.
• If x > 0, say x = 1, then x2 − 6x + 7 = 12 − 6 × 1 + 7 = 1 − 6 + 7 = 2 > 0.
Since x2 − 6x + 7 > 0 in all the cases, the proposition is proved.
What is wrong with this attempt?

3.5.∗ Prove that, for all integers m and n, if m2 + n2 = k 2 for some integer k, then m and n
cannot be both odd.
(Hint: You may find many propositions proved in this chapter useful.)

32
CS1231 Chapter 4

Sets

4.1 Basics
Definition 4.1.1. (1) A set is an unordered collection of objects.
(2) These objects are called the members or elements of the set.
(3) Write x∈A for x is an element of A;
x ̸∈ A for x is not an element of A;
x, y ∈ A for x, y are elements of A;
x, y ̸∈ A for x, y are not elements of A; etc.

(4) We may read x ∈ A also as “x is in A” or “A contains x (as an element)”.

Warning 4.1.2. Some use “contains” for the subset relation, but in this module we do not.
We will also use “contains” for the subgraph relation in Chapters 11 and 12. The context
should make it clear which meaning is intended.

Definition 4.1.3 (roster notation). (1) The set whose only elements are x1 , x2 , . . . , xn is
denoted {x1 , x2 , . . . , xn }.
(2) The set whose only elements are x1 , x2 , x3 , . . . is denoted {x1 , x2 , x3 , . . . }.

Note 4.1.4. For all objects x1 , x2 , . . . , xn , z,

z ∈ {x1 , x2 , . . . , xn } ⇔ z appears in the list x1 , x2 , . . . , xn .

Example 4.1.5. (1) The only elements of A = {1, 5, 6, 3, 3, 3} are 1, 5, 6 and 3. So 6 ∈ A


but 7 ̸∈ A.
(2) The only elements of B = {0, 2, 4, 6, 8, . . . } are the non-negative even integers. So 4 ∈ B
but 5 ̸∈ B.

Definition 4.1.6 (set-builder notation). Let U be a set and P (x) be a predicate over U .
Then the set of all elements x ∈ U such that P (x) is true is denoted

{x ∈ U : P (x)} or {x ∈ U | P (x)}.

This is read as “the set of all x in U such that P (x)”.

Note 4.1.7. Let U be a set and P (x) be a predicate over U . For all objects z,

z ∈ {x ∈ U : P (x)} ⇔ z ∈ U and P (z) is true.

33
Example 4.1.8. (1) The elements of C = {x ∈ Z⩾0 : x is even} are precisely the elements
of Z⩾0 that are even, i.e., the non-negative even integers. So 6 ∈ C but 7 ̸∈ C.
(2) The elements of D = {x ∈ Z : x is a prime number} are precisely the elements of Z
that are prime numbers, i.e., the prime integers. So 7 ∈ D but 9 ̸∈ D.

Definition 4.1.9 (replacement notation). Let A be a set and t(x) be (the name of) an object
for each element x of A. Then the set of all objects of the form t(x) where x ranges over the
elements of A is denoted

{t(x) : x ∈ A} or {t(x) | x ∈ A}.

This is read as “the set of all t(x) where x ∈ A”.

Note 4.1.10. Let A be a set and t(x) be an object for each element x of A. For all objects z,

z ∈ {t(x) : x ∈ A} ⇔ ∃x ∈ A z = t(x).

Example 4.1.11. (1) The elements of E = {x + 1 : x ∈ Z⩾0 } are precisely those x + 1


where x ∈ Z⩾0 , i.e., the positive integers. So 1 = 0 + 1 ∈ E but 0 ̸∈ E.
(2) The elements of F = {x − y : x, y ∈ Z⩾0 }√are precisely those x − y where x, y ∈ Z⩾0 ,
i.e., the integers. So −1 = 1 − 2 ∈ F but 2 ̸∈ F .

Definition 4.1.12. Two sets are equal if they have the same elements, i.e., for all sets A, B,

A=B ⇔ ∀z (z ∈ A ⇔ z ∈ B).

Example 4.1.13. {1, 5, 6, 3, 3, 3} = {1, 5, 6, 3} = {1, 3, 5, 6}.


Slogan 4.1.14. Order and repetition do not matter.
Explanation. When specifying a set using roster notation, although one may choose to list
the elements in different orders or with repetition in the specification, the set being specified
stays the same, according to the definition of set equality; cf. Example 4.1.13.
In general, the elements of a set come in no inherent order. If there were such an order,
then re-ordering the elements of a set A should give a set B that does not equal A because
objects with different properties must (by convention) be different, but B equals A since
they have the same elements; this is a contradiction. There is hence no concept of the first
element, the second element, etc. of a set. Similarly, there is no concept of the number of
times an element appears in a set.
Example 4.1.15. {y 2 : y is an odd integer} = {x ∈ Z : x = y 2 for some odd integer y}
= {12 , 32 , 52 , . . . }.
Example 4.1.16. {x ∈ Z : x2 = 1} = {1, −1}.
Proof. (⇒) Take any z ∈ {x ∈ Z : x2 = 1}. Then z ∈ Z and z 2 = 1. So

z 2 − 1 = (z − 1)(z + 1) = 0.
∴ z − 1 = 0 or z + 1 = 0.
∴ z = 1 or z = −1.

This means z ∈ {1, −1}.


(⇐) Take any z ∈ {1, −1}. Then z = 1 or z = −1. In either case, we have z ∈ Z and
z 2 = 1. So z ∈ {x ∈ Z : x2 = 1}.
Exercise 4.1.17. Write down proofs of the claims made in Example 4.1.11. In other words,  4a
prove that E = Z+ and F = Z, where E and F are as defined in Example 4.1.11.

34
Theorem 4.1.18. There exists a unique set with no element, i.e.,
• there is a set with no element; and (existence part)

• for all sets A, B, if both A and B have no element, then A = B. (uniqueness part)

Proof. • (existence part) The set {} has no element.


• (uniqueness part) Let A, B be sets with no element. Then vacuously,

∀z (z ∈ A ⇒ z ∈ B) and ∀z (z ∈ B ⇒ z ∈ A)

because the hypotheses in the implications are never true. So A = B.

Definition 4.1.19. The set with no element is called the empty set. It is denoted by ∅.

4.2 Subsets
Definition 4.2.1. Let A, B be sets. Call A a subset of B, and write A ⊆ B, if

∀z (z ∈ A ⇒ z ∈ B).

Alternatively, we may say that B includes A, and write B ⊇ A in this case.

Note 4.2.2. We avoid using the symbol ⊂ because it may have different meanings to different
people.

Example 4.2.3. (1) {1, 5, 2} ⊆ {5, 2, 1, 4} but {1, 5, 2} ̸⊆ {2, 1, 4}.


(2) N ⊆ Z ⊆ Q ⊆ R ⊆ C.
Remark 4.2.4. Let A, B be sets.
(1) A ̸⊆ B ⇔ ∃z (z ∈ A and z ̸∈ B).

(2) A=B ⇔ A ⊆ B and B ⊆ A.


(3) A ⊆ A.

Definition 4.2.5. Let A, B be sets. Call A a proper subset of B, and write A ⊊ B, if A ⊆ B


and A ̸= B. In this case, we may say that the inclusion of A in B is proper or strict.

Example 4.2.6. All the inclusions in Example 4.2.3 are strict.

Proposition 4.2.7. The empty set is a subset of any set, i.e., for any set A,

∅ ⊆ A.

Proof. Vacuously,
∀z (z ∈ ∅ ⇒ z ∈ A)
because the hypothesis in the implication is never true. So ∅ ⊆ A by the definition of ⊆.

Note 4.2.8. Sets can be elements of sets.

35
Example 4.2.9. (1) The set A = {∅} has exactly 1 element, namely the empty set. So
A is not empty.
(2) The set B = {{1}, {2, 3}} has exactly 2 elements, namely {1}, {2, 3}. So {1} ∈ B, but
1 ̸∈ B.

Note 4.2.10. Membership and inclusion can be different.


Question 4.2.11. Let C = {{1}, 2, {3}, 3, {{4}}}. Which of the following are true?  4b
• {1} ∈ C. • {1} ⊆ C.

• {2} ∈ C. • {2} ⊆ C.
• {3} ∈ C. • {3} ⊆ C.
• {4} ∈ C. • {4} ⊆ C.

Definition 4.2.12. Let A be a set. The set of all subsets of A, denoted P(A), is called the
power set of A.

Example 4.2.13. (1) P(∅) = {∅}.

(2) P({1}) = {∅, {1}}.


(3) P({1, 2}) = {∅, {1}, {2}, {1, 2}}.
(4) The following are subsets of N and thus are elements of P(N).

∅, {0}, {1}, {2}, . . . {0, 1}, {0, 2}, {0, 3} . . . {1, 2}, {1, 3}, {1, 4} . . .
{2, 3}, {2, 4}, {2, 5} . . . {0, 1, 2}, {0, 1, 3}, {0, 1, 4}, . . .
{1, 2, 3}, {1, 2, 4}, {1, 2, 5}, . . . {2, 3, 4}, {2, 3, 5}, {2, 3, 6}, . . .
N, N⩾1 , N⩾2 , . . . {0, 2, 4, . . . }, {1, 3, 5, . . . }, {2, 4, 6, . . . }, {3, 5, 7, . . . }, . . .
{x ∈ N : (x − 1)(x − 2) < 0}, {x ∈ N : (x − 2)(x − 3) < 0}, . . .
{3x + 2 : x ∈ N}, {4x + 3 : x ∈ N}, {5x + 4 : x ∈ N}, . . .

4.3 Boolean operations


Definition 4.3.1. Let A, B be sets.

(1) The union of A and B, denoted A ∪ B, is defined by

A ∪ B = {x : x ∈ A or x ∈ B}.

Read A ∪ B as “A union B”.

(2) The intersection of A and B, denoted A ∩ B, is defined by

A ∩ B = {x : x ∈ A and x ∈ B}.

Read A ∩ B as “A intersect B”.


(3) The complement of B in A, denoted A − B or A \ B, is defined by

A \ B = {x : x ∈ A and x ̸∈ B}.

Read A \ B as “A minus B”.

36
U
A B A B A B B

A∪B A∩B A\B B

Figure 4.1: Boolean operations on sets

Convention and terminology 4.3.2. When working in a particular context, one usually
works within a fixed set U which includes all the sets one may talk about, so that one only
needs to consider the elements of U when proving set equality and inclusion (because no
other object can be the element of a set). This U is called a universal set.

Definition 4.3.3. Let B be a set. In a context where U is the universal set (so that implicitly
U ⊇ B), the complement of B, denoted B or B c , is defined by

B = U \ B.

Example 4.3.4. Let A = {x ∈ Z : x ⩽ 10} and B = {x ∈ Z : 5 ⩽ x ⩽ 15}. Then

A ∪ B = {x ∈ Z : (x ⩽ 10) ∨ (5 ⩽ x ⩽ 15)} = {x ∈ Z : x ⩽ 15};


A ∩ B = {x ∈ Z : (x ⩽ 10) ∧ (5 ⩽ x ⩽ 15)} = {x ∈ Z : 5 ⩽ x ⩽ 10};
A \ B = {x ∈ Z : (x ⩽ 10) ∧ ¬(5 ⩽ x ⩽ 15)} = {x ∈ Z : x < 5};
B = {x ∈ Z : ¬(5 ⩽ x ⩽ 15)} = {x ∈ Z : (x < 5) ∨ (x > 15)},

in a context where Z is the universal set. To show the first equation, one shows

∀x ∈ Z (x ⩽ 10) ∨ (5 ⩽ x ⩽ 15) ⇔ (x ⩽ 15) , etc.

Theorem 4.3.5 (set identities). For all set A, B, C in a context where U is the universal
set, the following hold.

Commutativity A∪B =B∪A A∩B =B∩A


Associativity (A ∪ B) ∪ C = A ∪ (B ∪ C) (A ∩ B) ∩ C = A ∩ (B ∩ C)
Distributivity A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C) A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C)
Idempotence A∪A=A A∩A=A
Absorption A ∪ (A ∩ B) = A A ∩ (A ∪ B) = A
De Morgan’s Laws A∪B =A∩B A∩B =A∪B
Identities A∪∅=A A∩U =A
Annihilators A∪U =U A∩∅=∅
Complement A∪A=U A∩A=∅
Double Complement Law (A) = A
Top and bottom ∅=U U =∅
Set difference A\B =A∩B

One of De Morgan’s Laws. Work in the universal set U . For all sets A, B,

A ∪ B = A ∩ B.

37
Venn Diagrams. In the left diagram below, hatch the regions representing A and B with
and respectively. In the right diagram below, hatch the regions representing A and B
with and respectively.

A B A B

U U

Then the region represents A ∪ B in the left diagram, and the region represents A ∩ B
in the right diagram. Since these regions occupy the same region in the respective diagrams,
we infer that A ∪ B = A ∩ B.
Note 4.3.6. This argument depends on the fact that each possibility for membership in A
and B is represented by a region in the diagram.

Proof using a truth table. The rows in the following table list all the possibilities for an
element x ∈ U :

x∈A x∈B x∈A∪B x∈A∪B x∈A x∈B x∈A∩B


T T T F F F F
T F T F F T F
F T T F T F F
F F F T T T T

Since the columns under “x ∈ A ∪ B” and “x ∈ A ∩ B” are the same, for any x ∈ U ,

x∈A∪B ⇔ x∈A∩B

no matter in which case we are. So A ∪ B = A ∩ B.

Direct proof. Let z ∈ U . Then

z ∈A∪B
⇔ z ̸∈ A ∪ B  by the definition of · ;
⇔ ¬ (z ∈ A) ∨ (z ∈ B) by the definition of ∪;
⇔ (z ̸∈ A) ∧ (z ̸∈ B) by De Morgan’s Laws for propositions;
⇔ (z ∈ A) ∧ (z ∈ B) by the definition of · ;
⇔ z ∈A∩B by the definition of ∩.

Example 4.3.7. Under the universal set U , show that (A ∩ B) ∪ (A \ B) = A for all sets
A, B.
Proof. (A ∩ B) ∪ (A \ B) = (A ∩ B) ∪ (A ∩ B) by the set identity on set difference;
= A ∩ (B ∪ B) by distributivity;
=A∩U by the set identity on complement;
=A as U is an identity for ∩.

Definition 4.3.8. Two set A and B are disjoint if A ∩ B = ∅.

Example 4.3.9. Let A, B be sets. Show the following.


(1) A ∩ B ⊆ A.
(2) A ⊆ A ∪ B.

38
Proof. (1) By the definition of ⊆, we need to show that

∀z (z ∈ A ∩ B ⇒ z ∈ A).

Let z ∈ A ∩ B. Then z ∈ A and z ∈ B by the definition of ∩. In particular, we know


z ∈ A, as required.
(2) This is left as an exercise.  4c
Exercise 4.3.10. Show that for all sets A, B, C, if A ⊆ B and A ⊆ C, then A ⊆ B ∩ C.  4d
Question 4.3.11. Is the following true?  4e

(A \ B) ∪ (B \ C) = A \ C for all sets A, B, C.

4.4 Russell’s Paradox (extra material)


Example 4.4.1. (1) ∅ ̸∈ ∅.
(2) Z ̸∈ Z.

(3) {∅} ̸∈ {∅}.


Question 4.4.2. Is there a set x such that x ∈ x?  4f

Theorem 4.4.3 (Russell 1901). There is no set R such that

∀x (x ∈ R ⇔ x ̸∈ x). (∗)

In words, there is no set R whose elements are precisely the sets x that are not elements of
themselves.

Proof. We prove this by contradiction. Suppose R is a set satisfying (∗). Applying (∗) to
x = R gives
R ∈ R ⇔ R ̸∈ R. (†)
Split into two cases.

• Case 1: assume R ∈ R. Then R ̸∈ R by the ⇒ part of (†). This contradicts our


assumption that R ∈ R.
• Case 2: assume R ̸∈ R. Then R ∈ R by the ⇐ part of (†). This contradicts our
assumption that R ∈
̸ R.
In either case, we get a contradiction. So the proof is finished.

Question 4.4.4 (tongue-in-cheek). Can you write a proof of Theorem 4.4.3 that does not  4g
mention contradiction?

Tutorial exercises
4.1. Which of the following are true? Which of them are false?

(a) ∅ ∈ ∅. (d) ∅ ⊆ {∅}.


(b) ∅ ⊆ ∅. (e) {∅, 1} = {1}.
(c) ∅ ∈ {∅}. (f) 1 ∈ {{1, 2}, {2, 3}, 4}.

39
(g) {1, 2} ⊆ {3, 2, 1}. (h) {3, 3, 2} ⊊ {3, 2, 1}.

4.2. Let A = {2n + 1 : n ∈ Z} and B = {2n − 1 : n ∈ Z}. Is A = B? Prove that your


answer is correct.
4.3. Write down P(P(∅)) in roster notation.
4.4. Let U = {5, 6, 7, . . . , 12}. Write down the following sets in roster notation.
(a) {n ∈ U : n is even}.
(b) {m − n : m, n ∈ U }.
(c) {−5, −4, −3, . . . , 5} \ {1, 2, 3, . . . , 10}.
(d) {5, 7, 9} ∪ {9, 11}, in a context where U is the universal set.
4.5. In this exercise, we study the notion of symmetric difference of sets, which is the set-
theoretic counterpart of the exclusive-or operation in propositional logic.
For sets A and B, define A △ B = (A \ B) ∪ (B \ A).
(a) Let A = {1, 4, 9, 16} and B = {2, 4, 6, 8, 10, 12, 14, 16}. Write down A△B in roster
notation.
(b) Show that, for all sets A, B,

A △ B = (A ∪ B) \ (A ∩ B).

4.6. In this exercise, we investigate one way of expressing the subset relation in terms of
Boolean operations.
Let A, B be sets. Show that A ⊆ B if and only if A ∪ B = B.
4.7. Let A = {5, 6, 7, 8, 9}. Consider

C1 = {{5, 6}, {7, 8}} and C2 = {{5}, {6, 7, 8}, {8, 9}}.

Define P1 (A, C ) and P2 (A, C ) to be respectively the sentences

∀x ∈ A ∃S ∈ C (x ∈ S) and ∀S1 , S2 ∈ C (S1 ∩ S2 ̸= ∅ ⇒ S1 = S2 ).

Which of P1 (A, C1 ), P2 (A, C1 ), P1 (A, C2 ), P2 (A, C2 ) are true? Which of them are false?
Briefly explain your answers.
We will encounter P1 and P2 again in Chapter 6.
4.8. De Morgan’s Laws, as we stated them, is about two sets only. Nevertheless, it is readily
generalizable to any finite number of sets, as we will show in this exercise.
Work in a context with a universal set. Prove by induction that for all n ∈ Z+ and all
sets A0 , A1 , A2 , . . . ,

A0 ∪ A1 ∪ . . . An = A0 ∩ A1 ∩ · · · ∩ An .

Extra exercises
4.9. Let A and B be sets. Define A0 = A \ B and B0 = B. Prove that A0 ∩ B0 = ∅ and
A0 ∪ B0 = A ∪ B.
4.10. In this exercise, we investigate another way of expressing the subset relation in terms
of Boolean operations; cf. Tutorial Exercise 4.6.
Let A, B be sets. Show that A ⊆ B if and only if A ∩ B = A.

40
P Q T S
4.11. Similar to for addition and for multiplication, we have for intersection and
for union. This notation will be useful in the tutorial exercises for Chapter 8.
Let A0 , A1 , A2 , . . . be sets. For each n ∈ N, define
n
\ ∞
\
Ai = A0 ∩ A1 ∩ · · · ∩ An and Ai = {x : x ∈ Ai for all i ∈ N},
i=0 i=0
[n [∞
Ai = A0 ∪ A1 ∪ · · · ∪ An and Ai = {x : x ∈ Ai for some i ∈ N}.
i=0 i=0

1
Fix n ∈ N. Consider the case when each Ai = {x ∈ Q : i+1 ⩽ x ⩽ i + 1}. What are
Tn T∞ Sn S∞
i=0 Ai , i=0 Ai , i=0 Ai , and i=0 Ai ?

41
CS1231 Chapter 5

Relations

5.1 Basics
Definition 5.1.1. An ordered pair is an expression of the form

(x, y).

Let (x1 , y1 ) and (x2 , y2 ) be ordered pairs. Then

(x1 , y1 ) = (x2 , y2 ) ⇔ x1 = x2 and y1 = y2 .

Example 5.1.2. (1) (1, 2) ̸= (2, 1), although {1, 2} = {2, 1}.

(2) (3, 0.5) = ( 9, 12 ).

Definition 5.1.3. Let A, B be sets. The Cartesian product of A and B, denoted A × B, is


defined to be
{(x, y) : x ∈ A and y ∈ B}.
Read A × B as “A cross B”.

Example 5.1.4. {a, b} × {1, 2, 3} = {(a, 1), (a, 2), (a, 3), (b, 1), (b, 2), (b, 3)}.
Definition 5.1.5. Let A, B be sets.
(1) A relation from A to B is a subset of A × B.
(2) Let R be a relation from A to B and (x, y) ∈ A × B. Then we may write

x R y for (x, y) ∈ R and x ̸R y for (x, y) ̸∈ R.

We read “x R y” as “x is R-related to y” or simply “x is related to y”.

Example 5.1.6. Let Γ = {A, B, . . . , Z, 0, 1, 2, . . . , 9} and Φ = {A, B, . . . , Z, a, b, . . . , z}. As


in Figure 5.1, define
SN = {(001R, Gates), (012B, Brin), (062E, Bezos), (126N, Ma), (254E, Zuckerberg)}.
Then SN is a relation from Γ∗ to Φ∗ .
Example 5.1.7. Let A = {0, 1, 2} and B = {1, 2, 3, 4}. Define the relation R from A to B
by setting
x R y ⇔ x < y.
Then 0 R 1 and 0 R 2, but 2 ̸R 1. Thus
R = {(0, 1), (0, 2), (0, 3), (0, 4), (1, 2), (1, 3), (1, 4), (2, 3), (2, 4)}.

42
identity 
Student ID name SN = (001R, Gates ),
001R Gates (012B, Brin ),
012B Brin (062E, Bezos ),
062E Bezos (126N, Ma ),
126N Ma (254E, Zuckerberg)
254E Zuckerberg

is enrolled in 
Student ID module SM = (126N, CS3234 ),
126N CS3234 (254E, CS3234 ),
254E CS3234 (001R, MA2001),
001R MA2001 (012B, MA2001),
012B MA2001 (062E, MA2001),
062E MA2001 (126N, MA2001),
126N MA2001 (012B, MU2109),
012B MU2109 (001R, PC2130 ),
001R PC2130 (062E, PL3103 ),
062E PL3103 (254E, PL3103 )
254E PL3103

progress 
Student ID faculty year SFY = (062E, Arts, 1),
062E Arts 1 (254E, Arts, 2),
254E Arts 2 (012B, Science, 2),
012B Science 2 (001R, Science, 1),
001R Science 1 (126N, Science, 3)
126N Science 3

teaching
module department faculty instructor
CS3234 CS Computing Turing
MA2001 Mathematics Science Gauss
MU2109 Music Arts Mozart
PC2130 Physics Science Newton
PL3103 Psychology Arts Freud

MDFI = (CS3234, CS, Computing, Turing ),
(MA2001, Mathematics, Science, Gauss ),
(MU2109, Music, Arts, Mozart ),
(PC2130, Physics, Science, Newton),
(PL3103, Psychology, Arts, Freud )

The set {SM , SN , SFY , MDFI } represents the relational database.

Figure 5.1: A fictitious miniature university database and its set-theoretic representation

43
Definition 5.1.8. One can draw a diagram representing a relation R from a set A to a set B
as follows.
(1) On the left, draw all the elements x ∈ A that satisfy x R y for some y ∈ B.

(2) On the right, draw all the elements y ∈ B that satisfy x R y for some x ∈ A.
(3) For all x ∈ A and all y ∈ B that are drawn, draw an arrow from x to y if and only if
x R y.
Such a diagram is called an arrow diagram for R.

Example 5.1.9. The following is an arrow diagram for the relation R in Example 5.1.7.

0
1 1
2 2
3
4
A B

Definition 5.1.10. Let n ∈ Z⩾2 .


(1) An expression of the form (x1 , x2 , . . . , xn ) is called an ordered n-tuple.
(2) Ordered n-tuples are defined recursively by setting, for all objects x1 , x2 , . . . , xn+1 ,

(x1 , x2 , . . . , xn+1 ) = (x1 , x2 , . . . , xn ), xn+1 .

Exercise 5.1.11. Prove by induction on n that, for all n ∈ Z⩾2 and all ordered n-tuples  5a
(x1 , x2 , . . . , xn ) and (y1 , y2 , . . . , yn ),
(x1 , x2 , . . . , xn ) = (y1 , y2 , . . . , yn ) ⇔ x1 = y1 and x2 = y2 and . . . and xn = yn .
Example 5.1.12. (1) (1, 2, 5) ̸= (2, 1, 5), although {1, 2, 5} = {2, 1, 5}.

(2) (3, (−2)2 , 0.5, 0) = ( 9, 4, 12 , 0)

Definition 5.1.13. Let n ∈ Z⩾2 and A1 , A2 , . . . , An be sets. The Cartesian product of


A1 , A2 , . . . , An , denoted A1 × A2 × · · · × An , is defined to be

{(x1 , x2 , . . . , xn ) : x1 ∈ A1 and x2 ∈ A2 and . . . and xn ∈ An }.

If A is a set, then An = A × A × · · · × A.
| {z }
n-many A’s

Example 5.1.14. {0, 1}×{0, 1}×{a, b} = {(0, 0, a), (0, 0, b), (0, 1, a), (0, 1, b), (1, 0, a), (1, 0, b), (1, 1, a), (1, 1, b)}.

Definition 5.1.15. Let n ∈ Z⩾2 and A1 , A2 , . . . , An be sets. A n-ary relation over


A1 , A2 , . . . , An is a subset of A1 × A2 × · · · × An .

Example 5.1.16. Following Example 5.1.6, let Γ = {A, B, . . . , Z, 0, 1, 2, . . . , 9} and Φ =


{A, B, . . . , Z, a, b, . . . , z}. As in Figure 5.1, define
MDFI = {(CS3234, CS, Computing, Turing), (MA2001, Mathematics, Science, Gauss),
(MU2109, Music, Arts, Mozart), (PC2130, Physics, Science, Newton),
(PL3103, Psychology, Arts, Freud)}.
Then MDFI is a 4-ary relation over Γ∗ , Φ∗ , Φ∗ , Φ∗ .

44
5.2 Operations on relations

A B C A B
R
y
R S
x y
z
x S◦R
R−1

Figure 5.2: Relation composition and inversion

Definition 5.2.1. Let R be a relation from A to B, and S be a relation from B to C. Then


S ◦ R is the relation from A to C defined by

S ◦ R = {(x, z) ∈ A × C : (x, y) ∈ R and (y, z) ∈ S for some y ∈ B}.

We read S ◦ R as “S composed with R” or “S circle R”.

Note 5.2.2. We compose two binary relations together only when there is a common middle
set.
Definition 5.2.3. The floor of a real number x, denoted ⌊x⌋, is the greatest integer that is
less than or equal to x.

Example 5.2.4. Define a relation R from Q⩾0 to Z⩾0 and a relation S from Z⩾0 to R by:
R = {(x, y) ∈ Q⩾0 × Z⩾0 : ⌊x⌋ = y}, and
2
S = {(y, z) ∈ Z⩾0 × R : y = z }.
• (4.8, 2) ∈ S ◦ R because 4 ∈ Z⩾0 such that (4.8, 4) ∈ R and (4, 2) ∈ S.
√ √
• (5/2, − 2) ∈ S ◦ R because 2 ∈ Z⩾0 such that (5/2, 2) ∈ R and (2, − 2) ∈ S.
In general, we have S ◦ R = {(x, z) ∈ Q⩾0 × R : ⌊x⌋ = z 2 }.

Q⩾0 Z⩾0 R
.. ..
4 . .
4

3
3

2 2√
2
√3
2
1 1
1

0 0
R 0 S

−1

−√2
− 3
−2

45
Definition 5.2.5. Let R be a relation from A to B. Then the inverse of R is the relation
R−1 from B to A defined by

R−1 = {(y, x) ∈ B × A : (x, y) ∈ R}.

Example 5.2.6. As in Example 5.1.7, let R be the relation from A to B where

A = {0, 1, 2}, B = {1, 2, 3, 4},


R = {(0, 1), (0, 2), (0, 3), (0, 4), (1, 2), (1, 3), (1, 4), (2, 3), (2, 4)}.

Then R−1 = {(1, 0), (2, 0), (3, 0), (4, 0), (2, 1), (3, 1), (4, 1), (3, 2), (4, 2)}.

0
1 1
2 2
3
4
B A

Proposition 5.2.7. Let R be a relation from A to B, and S be a relation from B to C.


Then (S ◦ R)−1 = R−1 ◦ S −1 .

A B C
S
R y
S −1
R−1
z
x S◦R

R−1 ◦ S −1

Proof. Since S ◦ R is a relation from A to C, we know (S ◦ R)−1 is a relation from C to A.


Since S −1 is a relation from C to B, and R−1 is a relation from B to A, we know R−1 ◦ S −1
is a relation from C to A as well. Now for all (z, x) ∈ C × A,

(z, x) ∈ (S ◦ R)−1 ⇔ (x, z) ∈ S ◦ R by the definition of inverses;


⇔ (x, y) ∈ R and (y, z) ∈ S for some y ∈ B by the definition of composition;
−1 −1
⇔ (y, x) ∈ R and (z, y) ∈ S for some y ∈ B by the definition of inverses;
−1 −1
⇔ (z, x) ∈ R ◦S by the definition of composition.

So (S ◦ R)−1 = R−1 ◦ S −1 .
Exercise 5.2.8. Let A = {0, 1, 2}. Define two relations R, S from A to A by:  5b

R = {(x, y) ∈ A2 : x < y} and S = {(0, 1), (1, 2), (2, 0)}.

Is R ◦ S = S ◦ R? Prove that your answer is correct.

46
5.3 Graphs
Definition 5.3.1. A (binary) relation on a set A is a relation from A to A.

Remark 5.3.2. It follows from Definition 5.1.5 and Definition 5.3.1 that the relations on a
set A are precisely the subsets of A × A.

Definition 5.3.3. One can draw a diagram representing a relation R on a set A as follows.
(1) Draw all the elements of A.

(2) For all x, y ∈ A, draw an arrow from x to y if and only if x R y.


Such a diagram is called an arrow diagram for R.

Example 5.3.4. Let

V = {B, P, F, M, K, N}, and


D = {(B, P), (P, B), (F, M), (M, F), (B, B), (P, P), (F, F), (M, M), (K, K), (N, N)}.

Then the following is an arrow diagram for D as a relation on V .

B P

F K

M N

Definition 5.3.5. A directed graph is an ordered pair (V, D) where V is a set and D is a
binary relation on V . In the case when (V, D) is a directed graph,
(1) the vertices or the nodes are the elements of V ;
(2) the edges are the elements of D;

(3) an edge from x to y is the element (x, y) ∈ D;


(4) a loop is an edge from a vertex to itself;
(5) a drawing of (V, D) is an arrow diagram for D as a relation on A in the sense of
Definition 5.3.3.

Example 5.3.6. Let V and D be as defined in Example 5.3.4. Then (V, D) is a directed
graph. The diagram in Example 5.3.4 is a drawing of (V, D).

Definition 5.3.7. An undirected graph is an ordered pair (V, E) where V is a set and E is
a set all of whose elements are of the form {x, y} with x, y ∈ V . In the case when (V, E) is
an undirected graph,

(1) the vertices or the nodes are the elements of V ;


(2) the edges are the elements of E;
(3) an edge between x and y is the element {x, y} ∈ E;
(4) a loop is an edge between a vertex and itself.

47
Example 5.3.8. Following Example 5.3.4, define

V = {B, P, F, M, K, N}, and


E = {{B, P}, {F, M}, {B, B}, {P, P}, {F, F}, {M, M}, {K, K}, {N, N}}.

Then (V, E) is an undirected graph.

Definition 5.3.9 (drawings of undirected graphs). One can draw a diagram representing an
undirected graph (V, E) as follows:
(1) Draw all the elements of V .

(2) For all x, y ∈ V , draw a line between x and y if and only if {x, y} ∈ E.
Such a diagram is called a drawing of (V, E).

Example 5.3.10. Here is a drawing of the undirected graph from Example 5.3.8.

B P

F K

M N

Tutorial exercises
An asterisk (*) indicates a more challenging exercise.
5.1. Let M = {MA1100, CS1231}, G = {A, B, C}, and S = {+, −}. Write the following sets
in roster notation:

(a) M × G; (b) M × G × S; (c) P(P(∅)) × S.

5.2. Consider the database relations in Figure 5.1.


−1
(a) Draw arrow diagrams for SN , SM and SM ◦ (SN ) .
−1
(b) What does x SM ◦ (SN ) y say about x and y?
5.3. Let A = {1, 2, 3, 4}, let B = {−1, 0, 1}, and let C = {2, 3, 5, 7}. Consider the relation R
from A to B and the relation S from B to C where

R = {(a, b) ∈ A × B : ab is even}, and


S = {(b, c) ∈ B × C : b + 2c is odd}.

Draw arrow diagrams for R, S, R−1 , S −1 , S ◦ R, and R−1 ◦ S −1 .


5.4. In this exercise, we look at a commonly studied relation in number theory called con-
gruence modulo 2. Intuitively, two integers are congruent modulo 2 if and only if they
have the same parity, i.e., they are both odd or both even. Here we adopt a slightly
different, yet equivalent, formulation of the definition.
Define a relation R on Z by setting, for all a, b ∈ Z,

aRb ⇔ a − b is even.

(a) Prove that R−1 = R.

48
(b) Prove that R ◦ R = R.
5.5. The aim of this exercise is to show the associativity of relation composition.
Let R be a relation from A to B, let S be a relation from B to C, and let T be a
relation from C to D. Prove that T ◦ (S ◦ R) = (T ◦ S) ◦ R.

5.6. The following are drawings of a directed graph (V, D) and an undirected graph (W, E).

2
a
1 3
b c
6 4
d e 5

Write down V, D, W, E in roster notation.


5.7.∗ (Induction corner) To help you gradually get used to induction, we will have one tu-
torial exercise on induction in each of the chapters to come. This exercise need not be
related to the topic of the chapter.
An L-tromino is the following L-shape formed by three squares of the checkerboard:

We are interested in whether it is possible to use non-overlapping L-trominos to cover


an ℓ × ℓ checkerboard with one square removed for various choices of the integer ℓ.
• No matter which square is removed from a 4 × 4 checkerboard, one can always
cover the remaining squares using L-trominos. Here are two examples.

• For a 5 × 5 checkerboard, it depends on which square we remove. For the left one
below, we can cover the remaining squares by L-trominos, but we cannot do it for
the right one, as one can verify by exhaustion.

• No matter which square is removed from a 6 × 6 checkerboard, one can never cover
the remaining squares using L-trominos because the number of remaining squares
is 6 × 6 − 1 = 35, which is not a multiple of 3.

Prove by induction that, for all n ∈ Z+ , if one square is removed from a 2n × 2n


checkerboard, then the remaining squares can be covered by L-trominos.

49
Extra exercises
5.8. The following is an arrow diagram for a relation R from a set A to a set B.

a 1
b 2
c 3
d 4
e 5

(a) Write down R, R−1 , R−1 ◦ R, and R ◦ R−1 in roster notation.


(b) Draw the directed graphs (A, R−1 ◦ R) and (B, R ◦ R−1 ).
5.9. Let R be a relation from A to B. Prove that (R−1 )−1 = R.

50
CS1231 Chapter 6

Equivalence relations and partial


orders

6.1 Equivalence relations


Definition 6.1.1. Let A be a set and R be a relation on A.

(1) R is reflexive if every element of A is R-related to itself, i.e.,

∀x ∈ A (x R x).

(2) R is symmetric if x is R-related to y implies y is R-related to x, for all x, y ∈ A, i.e.,

∀x, y ∈ A (x R y ⇒ y R x).

(3) R is transitive if x is R-related to y and y is R-related to z imply x is R-related to z,


for all x, y, z ∈ A, i.e.,

∀x, y, z ∈ A (x R y ∧ y R z ⇒ x R z).

∀ ∀
∀ ∀
∃ ∃

Figure 6.1: Reflexivity, symmetry, and transitivity

Example 6.1.2. Let R be the relation represented by the following arrow diagram.

51
Then R is reflexive. It is not symmetric because b R a but a ̸R b. It is transitive, as one can
show by exhaustion:

a R a ∧ a R a ⇒ a R a; c R a ∧ a R a ⇒ c R a;
b R a ∧ a R a ⇒ b R a; c R b ∧ b R a ⇒ c R a;
b R b ∧ b R a ⇒ b R a; c R b ∧ b R b ⇒ c R b;
b R b ∧ b R b ⇒ b R b; c R b ∧ b R c ⇒ c R c;
b R b ∧ b R c ⇒ b R c; c R c ∧ c R a ⇒ c R a;
b R c ∧ c R a ⇒ b R a; c R c ∧ c R b ⇒ c R b;
b R c ∧ c R b ⇒ b R b; cRc∧cRc⇒cRc
b R c ∧ c R c ⇒ b R c;

and all the others instances are vacuously true.

Example 6.1.3. Let R denote the equality relation on a set A, i.e., for all x, y ∈ A,

xRy ⇔ x = y.

Then R is reflexive, symmetric, and transitive.


Example 6.1.4. Let R0 denote the subset relation on a set U of sets, i.e., for all x, y ∈ U ,

x R0 y ⇔ x ⊆ y.

Then R0 is reflexive, may not be symmetric (when U contains x, y such that x ⊊ y), but is
transitive.
Exercise 6.1.5. Let R denote the non-strict less-than relation on Q, i.e., for all x, y ∈ Q,

xRy ⇔ x ⩽ y.

Is R reflexive? Is R symmetric? Is R transitive? Briefly explain your answers.  6a


Exercise 6.1.6. Let R′ denote the strict less-than relation on Q, i.e., for all x, y ∈ Q,

x R′ y ⇔ x < y.

Is R reflexive? Is R symmetric? Is R transitive? Briefly explain your answers.  6b

Definition 6.1.7. Let n, d ∈ Z. Then d is said to divide n if

n = dk for some k ∈ Z.

We write d | n for “d divides n”, and d ∤ n for “d does not divide n”. We also say

“n is divisible by d” or “n is a multiple of d” or “d is a factor/divisor of n”

for “d divides n”.

Example 6.1.8. Let R denote the divisibility relation on Z+ , i.e., for all x, y ∈ Z+ ,

xRy ⇔ x | y.

Then R is reflexive, not symmetric, but transitive.


Proof. (reflexivity) For each a ∈ Z+ , we know a = a × 1 and so a | a by the definition of
divisibility.

52
(non-symmetry) Note 1 | 2 but 2 ∤ 1.
(transitivity) Let a, b, c ∈ Z+ such that a | b and b | c. Use the definition of divisibility to
find k, ℓ ∈ Z such that b = ak and c = bℓ. Then c = bℓ = (ak)ℓ = a(kℓ), where kℓ ∈ Z.
Thus a | c by the definition of divisibility.

Exercise 6.1.9. Let A = {1, 2, 3} and R = {(1, 1), (1, 2), (2, 1), (3, 2)}. View R as a relation
on A. Is R reflexive? Is R symmetric? Is R transitive?  6c
Exercise 6.1.10. Let R be a relation on a set A. Prove that R is transitive if and only if
R ◦ R ⊆ R.  6d

Definition 6.1.11. An equivalence relation is a relation that is reflexive, symmetric and


transitive.

Example 6.1.12. The equality relation on a set, as defined in Example 6.1.3, is an equiva-
lence relation.
Convention 6.1.13. People usually use equality-like symbols such as ∼, ≈, ≃, ∼ =, and ≡ to
denote equivalence relations. These symbols are often defined and redefined to mean different
equivalence relations in different situations. We may read ∼ as “is equivalent to”.
Example 6.1.14. Let R be the relation represented by the following arrow diagram.

b
a
c

Then R is reflexive, symmetric, and transitive. So it is an equivalence relation on {a, b, c}.

6.2 Equivalence classes


Definition 6.2.1. Let ∼ be an equivalence relation on a set A. For each x ∈ A, the
equivalence class of x with respect to ∼, denoted [x]∼ , is defined to be the set of all elements
of A that x is ∼-related to, i.e.,

[x]∼ = {y ∈ A : x ∼ y}.

When there is no risk of confusion, we may drop the subscript and write simply [x].

Example 6.2.2. Let A be a set. The equivalence classes with respect to the equality relation
on A are of the form
[x] = {y ∈ A : x = y} = {x},
where x ∈ A.
Example 6.2.3. If R is the equivalence relation represented by the arrow diagram in Ex-
ample 6.1.14, then
[a] = {a} and [b] = {b, c} = [c].

53
6.3 Partitions
Definition 6.3.1. Call C a partition of a set A if
(0) C is a set of nonempty subsets of A;

(1) every element of A is in some element of C ; and


(2) if two elements of C have a nonempty intersection, then they are equal.
Elements of a partition are called components of the partition.

Remark 6.3.2. One can rewrite the three conditions in the definition of partitions respec-
tively as follows:
(0) ∀S ∈ C (∅ ̸= S ⊆ A);
(1) ∀x ∈ A ∃S ∈ C (x ∈ S);
(2) ∀S1 , S2 ∈ C (S1 ∩ S2 ̸= ∅ ⇒ S1 = S2 ).
Here are two alternative ways to put this definition in words:
• C is a set of nonempty subsets S ⊆ A such that every element of A is in exactly one
S ∈ C;
• C is a set of mutually disjoint nonempty subsets of A whose union is A.
Example 6.3.3. One partition of the set A = {1, 2, 3} is {{1}, {2, 3}}. The others are

{{1}, {2}, {3}}, {{2}, {1, 3}}, {{3}, {1, 2}}, {{1, 2, 3}}.

Example 6.3.4. One partition of Z is

{{2k : k ∈ Z}, {2k + 1 : k ∈ Z}}.

Lemma 6.3.5. Let ∼ be an equivalence relation on a set A.


(1) x ∈ [x] for all x ∈ A.
(2) Any equivalence class is nonempty.

Proof. (1) Let x ∈ A. Then x ∼ x by reflexivity. So x ∈ [x] by the definition of [x].


(2) Any equivalence class is of the form [x] for some x ∈ A, and so it must be nonempty
by (1).

Lemma 6.3.6. Let ∼ be an equivalence relation on a set A. For all x, y ∈ A, if [x] ∩ [y] ̸= ∅,
then [x] = [y].

Proof. Assume [x] ∩ [y] ̸= ∅. Say, we have w ∈ [x] ∩ [y]. This means x ∼ w and y ∼ w by
the definition of [x] and [y].
To show [x] = [y], we need to prove both [x] ⊆ [y] and [y] ⊆ [x]. We will concentrate on
the former; the latter is similar.
Take z ∈ [x]. Then x ∼ z by the definition of [x]. By symmetry, we know from the first
paragraph that w ∼ x. Altogether we have y ∼ w ∼ x ∼ z. So transitivity tells us y ∼ z.
Thus z ∈ [y] by the definition of [y].

54
Question 6.3.7. Consider an equivalence relation. Is it true that if x is an element of an  6e
equivalence class S, then S = [x]?

Definition 6.3.8. Let A be a set and ∼ be an equivalence relation on A. Denote by A/∼


the set of all equivalence classes with respect to ∼, i.e.,

A/∼ = {[x]∼ : x ∈ A}.

We may read A/∼ as “the quotient of A by ∼”.

Example 6.3.9. Let A be a set. Then from Example 6.2.2 we know A/= is equal to
{{x} : x ∈ A}.

Example 6.3.10. If R is the equivalence relation on the set A = {a, b, c} represented by


the arrow diagram in Example 6.1.14, then from Example 6.2.3 we know
 
A/∼ = {[a], [b], [c]} = {a}, {b, c}, {b, c} = {a}, {b, c} .

Theorem 6.3.11. Let ∼ be an equivalence relation on a set A. Then A/∼ is a partition


of A.

Proof. Conditions (0) and (1) in the definition of partitions are guaranteed by the definition
of equivalence classes and Lemma 6.3.5. Condition (2) is given by Lemma 6.3.6.

6.4 Partial orders


Definition 6.4.1. Let A be a set and R be a relation on A.
(1) R is antisymmetric if ∀x, y ∈ A (x R y ∧ y R x ⇒ x = y).

(2) R is a (non-strict) partial order if R is reflexive, antisymmetric, and transitive.


(3) Suppose R is a partial order. Let x, y ∈ A. Then x, y are comparable (under R) if

xRy or y R x.

(4) R is a (non-strict) total order or a (non-strict) linear order if R is a partial order and
every pair of elements is comparable, i.e.,

∀x, y ∈ A (x R y ∨ y R x).

Note 6.4.2. A total order is always a partial order.


Example 6.4.3. Let R denote the non-strict less-than relation on Z, i.e., for all x, y ∈ Z,

xRy ⇔ x ⩽ y.

Then R is antisymmetric. In fact, it is a total order.


Example 6.4.4. Let R0 denote the subset relation on a set U of sets, i.e., for all x, y ∈ U ,

x R0 y ⇔ x ⊆ y.

Then R0 is antisymmetric. It is always a partial order, but it may not be a total order.

55
Example 6.4.5. Let R1 denote the divisibility relation on Z, i.e., for all x, y ∈ Z,

x R1 y ⇔ x | y.

Is R1 antisymmetric? Is R1 a partial order? Is R1 a total order?  6f

Example 6.4.6. Let R2 denote the divisibility relation on Z+ , i.e., for all x, y ∈ Z+ ,

x R2 y ⇔ x | y.

Is R2 antisymmetric? Is R2 a partial order? Is R2 a total order?  6g

Definition 6.4.7. Let R be a (non-strict) partial order on a set A. A smallest element of A


(with respect to the partial order R) is an element m ∈ A such that m R x for all x ∈ A.

Example 6.4.8. (1) S = {x ∈ Z⩾0 : 0 < x < 5} has smallest element 1.

(2) S ♯ = {x ∈ Q⩾0 : 0 < x < 5} has no smallest element because if x ∈ S ♯ , then x/2 ∈ S ♯
and x/2 < x.

Theorem 6.4.9 (Well-Ordering Principle). Let b ∈ Z and S ⊆ Z⩾b . If S ̸= ∅, then S has a


smallest element.

Proof. We prove the contrapositive. Assume that S has no smallest element. As S ⊆ Z⩾b ,
it suffices to show that n ̸∈ S for all n ∈ Z⩾b . We prove this by Strong MI on n. Let P (n)
be the predicate “n ̸∈ S” over Z⩾b .
(Base step) If b ∈ S, then b is the smallest element of S because S ⊆ Z⩾b , which contradicts
our assumption. So b ̸∈ S.
(Induction step) Let k ∈ Z⩾b such that P (b), P (b + 1), . . . , P (k) are true, i.e., that b, b +
1, . . . , k ̸∈ S. If k + 1 ∈ S, then k + 1 is the smallest element of S because S ⊆ Z⩾b ,
which contradicts our assumption. So k + 1 ̸∈ S. This means P (k + 1) is true.
Hence ∀n ∈ Z⩾b P (n) is true by Strong MI.
Exercise 6.4.10 (extra). The base step and the induction step in our proof of the Well-  6h
Ordering Principle above look very similar. Combine the two into one. (Hint: use Exer-
cise 3.2.25.)

Tutorial exercises
An asterisk (*) indicates a more challenging exercise.

6.1. Let A = {a, b, c, d, e}. Consider the following relation on A:

R = {(a, a), (a, b), (a, c), (b, a), (b, b), (b, c), (c, a), (c, b), (c, c), (d, d), (e, e)}.

(a) Draw an arrow diagram for R.


(b) Is R an equivalence relation? Briefly explain your answer. If R is an equivalence
relation, then also write down its equivalence classes in roster notation.
(c) Is R a partial order? Is R a total order? Briefly explain your answers.
6.2. For each of the relations defined below, determine whether it is

56
R = {(a, a), (a, b), (a, c), Here are the arrow diagrams of 8 of the
(b, a), (b, b), (b, c), binary relations on the set A = {a, b, c}.
(c, a), (c, b), (c, c)}
b Set inclusion ⊆ is a partial order on the set
consisting of these 8 relations. This is
a indicated by the lines between the arrow
diagrams.
R = {(a, a), (b, a), (b, b),
(b, c), (c, a), (c, b),
(c, c)}
reflexive
c ∧ symmetric b
∧ transitive
∧ ¬antisymmetric
a

R = {(a, a), (a, b), (b, a),


(b, b), (b, c), (c, b),
(c, c)}
reflexive
b c ∧ ¬symmetric
∧ transitive
∧ ¬antisymmetric
a

R = {(a, a), (b, a), (b, b),


(b, c), (c, b), (c, c)}
reflexive
c ∧ symmetric b
∧ ¬transitive
∧ ¬antisymmetric
a

R = {(b, a), (b, c), (c, b)}

reflexive
b c ∧ ¬symmetric
∧ ¬transitive
∧ ¬antisymmetric
a

¬reflexive
c ∧ ¬symmetric
∧ ¬transitive
∧ ¬antisymmetric

R = {(b, a)} R = {(b, c), (c, b)}

b b

a a

¬reflexive ¬reflexive
c ∧ ¬symmetric c ∧ symmetric
∧ transitive ∧ ¬transitive
∧ antisymmetric ∧ ¬antisymmetric

R = {}

¬reflexive
c ∧ symmetric
∧ transitive
∧ antisymmetric

Figure 6.2: A partial order on a set of relations

57
(i) reflexive, (ii) symmetric, (iii) antisymmetric, (iv) transitive.

Briefly explain your answers.


(a) Define R = {(x, y) ∈ Q2 : xy ⩾ 0}, considered as a relation on Q.
(b) Define the relation S on R2 by setting, for all (x1 , y1 ), (x2 , y2 ) ∈ R2 ,

(x1 , y1 ) S (x2 , y2 ) ⇔ x1 ⩽ x2 and y1 ⩽ y2 .

6.3. Define a relation R on R2 by setting, for all (x1 , y1 ), (x2 , y2 ) ∈ R2 ,

(x1 , y1 ) R (x2 , y2 ) ⇔ 3(x1 − x2 ) = y1 − y2 .

(a) Prove that R is an equivalence relation.


(b) Let (u, v) ∈ R2 . Describe the equivalence class [(u, v)] geometrically as a set of
points in the plane R2 .
(Here we are assuming some prior knowledge in coordinate geometry.)
(c) Prove that, for every (u, v) ∈ R2 , there exists c ∈ R such that (0, c) ∈ [(u, v)].
6.4. Let ∼ be an equivalence relation on a set A. Prove that for all x, y ∈ A,

x∼y ⇔ [x] = [y].

6.5. Consider the following proposition.


Every relation that is both symmetric and transitive must be reflexive.

(a) Someone tries to prove this proposition as follows.


Let R be a relation on a set A that is both symmetric and transitive. As
R is symmetric, we know x R y and y R x for all x, y ∈ A. So x R x for
all x ∈ A by transitivity. This shows the reflexivity of R.
What is wrong with this attempt?
(b) Give a counterexample to this proposition.

6.6. Prove or disprove each of the following propositions.


(a) Any relation that is symmetric cannot be antisymmetric.
(b) Any relation that is not symmetric must be antisymmetric.
6.7.∗ (Induction corner) The aim of this exercise is to prove that there is no closed walk
involving 2 or more vertices in the directed graph corresponding to a partial order.
Let R be a partial order on a set A. Prove by induction on n that, for every integer
n ⩾ 2, there exist no x1 , x2 , . . . , xn ∈ A satisfying x1 ̸= x2 and

x1 R x2 and x2 R x3 and ... and xn−1 R xn and xn R x1 .

Extra exercises
6.8. For each of the relations defined below, determine whether it is

(i) reflexive, (ii) symmetric, (iii) antisymmetric, (iv) transitive.

Briefly explain your answers.

58
(a) Define R = {(x, y) ∈ Q2 : xy > 0}, considered as a relation on Q.
(b) Define the relation S on Z by setting, for all x, y ∈ Z,

xSy ⇔ y = x + 1.

6.9. We saw in Exercise 6.1.10 how one can characterize transitivity in terms of relation
composition. In this exercise, we characterize symmetry in terms of relation inverse.
Let R be a relation on a set A. Prove that R is symmetric if and only if R−1 = R.

6.10. Consider again the congruence-mod-2 relation R from Tutorial Exercise 5.4, i.e., the
relation R on Z which satisfies

aRb ⇔ a − b is even

for all a, b ∈ Z.
(a) Prove that R is an equivalence relation.
(b) What are the equivalence classes with respect to R?

59
CS1231 Chapter 7

Functions

7.1 Basics
Definition 7.1.1. Let A, B be sets. A function or a map from A to B is a relation f from
A to B such that any element of A is f -related to a unique element of B, i.e.,

(F1) every element of A is f -related to at least one element of B, or in symbols,

∀x ∈ A ∃y ∈ B (x, y) ∈ f ;

(F2) every element of A is f -related to at most one element of B, or in symbols,



∀x ∈ A ∀y1 , y2 ∈ B (x, y1 ) ∈ f ∧ (x, y2 ) ∈ f ⇒ y1 = y2 .

We write f : A → B for “f is a function from A to B”. Here A is called the domain of f ,


and B is called the codomain of f .

Remark 7.1.2. The negations of (F1) and (F2) can be expressed respectively as
(¬F1) ∃x ∈ A ∀y ∈ B (x, y) ̸∈ f ; and

(¬F2) ∃x ∈ A ∃y1 , y2 ∈ B (x, y1 ) ∈ f ∧ (x, y2 ) ∈ f ∧ y1 ̸= y2 .

Example 7.1.3. Let A = {u, v, w} and B = {1, 2, 3, 4}.


(1) f = {(v, 1), (w, 2)} is not a function A → B because u ∈ A such that no y ∈ B makes
(u, y) ∈ f , violating (F1).
(2) g = {(u, 1), (v, 2), (v, 3), (w, 4)} is not a function A → B because v ∈ A and 2, 3 ∈ B
such that (v, 2), (v, 3) ∈ g but 2 ̸= 3, violating (F2).
(3) h = {(u, 1), (v, 1), (w, 4)} is a function A → B because both (F1) and (F2) are satisfied.
g h
u f 1 u 1 u 1
v 2 v 2 v 2
3 3 3
w 4 w 4 w 4

Example 7.1.4. (1) r = {(x, y) ∈ R⩾0 × R⩾0 : x = y 2 } is a function R⩾0 → R⩾0 √ because
for every x ∈ R⩾0 , there is a unique y ∈ R⩾0 such that (x, y) ∈ r, namely y = x.
(2) r1 = {(x, y) ∈ R × R⩾0 : x = y 2 } is not a function R → R⩾0 because −1 ∈ R that is
not equal to y 2 for any y ∈ R⩾0 , violating (F1).

60
(3) r2 = {(x, y) ∈ R⩾0 × R : x = y 2 } is not a function R⩾0 → R because 1 ∈ R⩾0 and
−1, 1 ∈ R such that 1 = (−1)2 and 1 = 12 but −1 ̸= 1, violating (F2).

y •
r1 r
−1 x
1
r2
x

Question 7.1.5. Which of the arrow diagrams below represent a function from the LHS set  7a
to the RHS set?

(a) (b) (c)

(d) (e) (f)

7.2 Images
Definition 7.2.1. Let f : A → B.
(1) If x ∈ A, then f (x) denotes the unique element y ∈ B such that (x, y) ∈ f . We call
f (x) the image of x under f .
(2) The range of f , denoted range(f ), is defined by

range(f ) = {f (x) : x ∈ A}.

Remark 7.2.2. It follows from the definition of images that if f : A → B and x ∈ A, then
for all y ∈ B,
(x, y) ∈ f ⇔ y = f (x).

Remark 7.2.3. (1) The range of a function is the set that contains all the outputs of the
function and nothing else, while the codomain is the set associated to the function as
part of its specification that contains all the outputs but maybe also other objects.
(2) For any function, the range is a subset of the codomain.
Example 7.2.4. The function r : R⩾0 → R⩾0 in Example 7.1.4(1) satisfies

∀x, y ∈ R⩾0 y = r(x) ⇔ x = y 2 .




Note that range(r) ⊇ R⩾0 , because for every y ∈ R⩾0 , there is x ∈ R⩾0 such that y = r(x),
namely x = y 2 . So range(r) = R⩾0 by Remark 7.2.3(2).

Definition 7.2.5. A Boolean function is a function {T, F}n → {T, F} where n ∈ Z+ .

61
Example 7.2.6. We can represent the compound expression p∨q, where p, q are propositional
variables, using the Boolean function d : {T, F}2 → {T, F} where, for all p0 , q0 ∈ {T, F},
d(p0 , q0 ) is the truth value that p∨q evaluates to when one substitutes propositions
of truth values p0 and q0 into the propositional variables p and q respectively.
For instance, we have d(T, T) = T and d(F, F) = F. Hence range(d) = {T, F} by Re-
mark 7.2.3(2).

Proposition 7.2.7. Let f, g : A → B. Then f = g if and only if f (x) = g(x) for all x ∈ A.

Proof. (⇒) Assume f = g. Let x ∈ A. Then


(x, f (x)) ∈ f by the ⇐ part of Remark 7.2.2.
∴ (x, f (x)) ∈ g as f = g.
∴ f (x) = g(x) by the ⇒ part of Remark 7.2.2.
(⇐) Assume f (x) = g(x) for all x ∈ A. For each x ∈ A and each y ∈ B,
(x, y) ∈ f ⇔ y = f (x) by Remark 7.2.2;
⇔ y = g(x) by our assumption;
⇔ (x, y) ∈ g by Remark 7.2.2.
So f = g.
Example 7.2.8. The descriptions of r and d in Examples 7.2.4 and 7.2.6 in terms of r(x)
and d(p, q) uniquely characterize these functions by Proposition 7.2.7, and can thus serve as
definitions of r and d.
Example 7.2.9. Let f : {0, 2} → Z and g : {0, 2} → Z defined by setting, for all x ∈ {0, 2},
f (x) = 2x and g(x) = x2 .
Then f = g by Proposition 7.2.7, because f (x) = g(x) for every x ∈ {0, 2}.
Example 7.2.10. Let f : Z → Z and g : Q → Q defined by
∀x ∈ Z (f (x) = x3 ) and ∀x ∈ Q (g(x) = x3 ).
Then f ̸= g because (1/2, 1/8) is an element of g but not of f .

7.3 Composition

Proposition 7.3.1. Let f : A → B and g : B → C. Then g ◦ f is a function A → C.


Moreover, for every x ∈ A,
(g ◦ f )(x) = g(f (x)).

Proof. (F1) Let x ∈ A. Use (F1) for f to find y ∈ B such that (x, y) ∈ f . Use (F1) for g
to find z ∈ C such that (y, z) ∈ g. Then (x, z) ∈ g ◦ f by the definition of g ◦ f .
(F2) Let x ∈ A and z1 , z2 ∈ C such that (x, z1 ), (x, z2 ) ∈ g ◦ f . Use the definition of g ◦ f
to find y1 , y2 ∈ B such that (x, y1 ), (x, y2 ) ∈ f and (y1 , z1 ), (y2 , z2 ) ∈ g. Then (F2) for f
implies y1 = y2 . So z1 = z2 as g satisfies (F2).
These show g ◦ f is a function A → C. Now, for every x ∈ A,

(x, f (x)) ∈ f and f (x), g(f (x)) ∈ g by the ⇐ part of Remark 7.2.2;
∴ (x, g(f (x))) ∈ g ◦ f by the definition of g ◦ f ;
∴ g(f (x)) = (g ◦ f )(x) by the ⇒ part of Remark 7.2.2.

62
Example 7.3.2. Let f, g : Z → Z such that for every x ∈ Z,

f (x) = 3x and g(x) = x + 1.

By Proposition 7.3.1, for every x ∈ Z,

(g ◦ f )(x) = g(f (x)) = g(3x) = 3x + 1 and (f ◦ g)(x) = f (g(x)) = f (x + 1) = 3(x + 1).

Note (g ◦ f )(0) = 1 ̸= 3 = (f ◦ g)(0). So g ◦ f ̸= f ◦ g by Proposition 7.2.7.

Definition 7.3.3. Let A be a set. Then the identity function on A, denoted idA , is the
function A → A which satisfies, for all x ∈ A,

idA (x) = x.

Example 7.3.4. Let f : A → B. Then f ◦ idA = f by Proposition 7.2.7, because Proposi-


tion 7.3.1 implies
• f ◦ idA is a function A → B; and
• (f ◦ idA )(x) = f (idA (x)) = f (x) for all x ∈ A.
Exercise 7.3.5. Prove that idB ◦ f = f for all functions f : A → B.  7b
Question 7.3.6. Which of the following define a function f : Z → Z that satisfies f ◦ f = f ?  7c
(1) f (x) = 1231 for all x ∈ Z.
(2) f (x) = x for all x ∈ Z.
(3) f (x) = −x for all x ∈ Z.
(4) f (x) = 3x + 1 for all x ∈ Z.
(5) f (x) = x2 for all x ∈ Z.

7.4 Inverse and bijectivity


Definition 7.4.1. Let f : A → B.
(1) f is surjective or onto if
∀y ∈ B ∃x ∈ A y = f (x). (F−1 1)
A surjection is a surjective function.
(2) f is injective or one-to-one if

∀x1 , x2 ∈ A (f (x1 ) = f (x2 ) ⇒ x1 = x2 ). (F−1 2)

An injection is an injective function.


(3) f is bijective if it is both surjective and injective. A bijection is a bijective function.

Remark 7.4.2. In view of Remark 7.2.2, one can formulate (F−1 1) and (F−1 2) for a general
relation f from A to B as follows:
(F−1 1) ∀y ∈ B ∃x ∈ A (x, y) ∈ f ;
(F−1 2) ∀x1 , x2 ∈ A ∀y ∈ B

(x1 , y) ∈ f ∧ (x2 , y) ∈ f ⇒ x1 = x2 .
By the definition of f −1 , these are equivalent respectively to (F1) and (F2) for f −1 , i.e.,

63
x

x
Figure 7.1: Surjectivity (left) and injectivity (right)

• ∀y ∈ B ∃x ∈ A (y, x) ∈ f −1 ; and
• ∀x1 , x2 ∈ A ∀y ∈ B (y, x1 ) ∈ f −1 ∧ (y, x2 ) ∈ f −1 ⇒ x1 = x2 .


So f −1 is a function B → A if and only if f satisfies the relational version of (F−1 1)


and (F−1 2). Similarly, the conditions (F1) and (F2) are equivalent to (F−1 1) and (F−1 2)
for f −1 .

Proposition 7.4.3. If f is a bijection A → B, then f −1 is a bijection B → A.

Proof. In view of the discussion in Remark 7.4.2, conditions (F1), (F2), (1), and (2) for f
are equivalent respectively to conditions (1), (2), (F1), and (F2) for f −1 .
Example 7.4.4. The function f : Q → Q, defined by setting f (x) = 3x + 1 for all x ∈ Q, is
surjective.
Proof. Take any y ∈ Q. Let x = (y − 1)/3. Then x ∈ Q and f (x) = 3x + 1 = y.
Remark 7.4.5. A function f : A → B is not surjective if and only if

∃y ∈ B ∀x ∈ A (y ̸= f (x)).

Example 7.4.6. Define g : Z → Z by setting g(x) = x2 for every x ∈ Z. Then g is not


surjective.
Proof. Note g(x) = x2 ⩾ 0 > −1 for all x ∈ Z. So g(x) ̸= −1 for all x ∈ Z, although
−1 ∈ Z.
Example 7.4.7. As in Example 7.4.4, define f : Q → Q by setting f (x) = 3x + 1 for all
x ∈ Q. Then f is injective.
Proof. Let x1 , x2 ∈ Q such that f (x1 ) = f (x2 ). Then 3x1 + 1 = 3x2 + 1. So x1 = x2 .
Remark 7.4.8. A function f : A → B is not injective if and only if

∃x1 , x2 ∈ A (f (x1 ) = f (x2 ) ∧ x1 ̸= x2 ).

Example 7.4.9. As in Example 7.4.6, define g : Z → Z by setting g(x) = x2 for every x ∈ Z.


Then g is not injective.
Proof. Note g(1) = 12 = 1 = (−1)2 = g(−1), although 1 ̸= −1.
Question 7.4.10. Amongst the arrow diagrams in Question 7.1.5 that represent a function,  7d
which ones represent injections, which ones represent surjections, and which ones represent
bijections?

Proposition 7.4.11. Let f : A → B and g : B → A. Then

g = f −1

⇔ ∀x ∈ A ∀y ∈ B g(y) = x ⇔ y = f (x) .

64
Proof.

g = f −1 (y, x) ∈ g ⇔ (y, x) ∈ f −1 as g, f −1 ⊆ B × A;

⇔ ∀y ∈ B ∀x ∈ A
by the definition of f −1 ;

⇔ ∀x ∈ A ∀y ∈ B (y, x) ∈ g ⇔ (x, y) ∈ f

⇔ ∀x ∈ A ∀y ∈ B g(y) = x ⇔ y = f (x) by Remark 7.2.2.

Example 7.4.12. As in Example 7.4.7, define f : Q → Q by setting f (x) = 3x + 1 for all


x ∈ Q. Note that for all x, y ∈ Q,

y = 3x + 1 ⇔ x = (y − 1)/3.

Let g : Q → Q such that g(y) = (y − 1)/3 for all y ∈ Q. The equivalence above implies

∀x, y ∈ Q y = f (x) ⇔ x = g(y) .

So Proposition 7.4.11 tells us g = f −1 .


Note 7.4.13. Unlike in Example 7.4.12, in general we are not guaranteed a description of
the inverse of a bijection f that is significantly different from the trivial description that it
is the inverse of f .

Proposition 7.4.14. Let f be a bijection A → B. Then f −1 ◦ f = idA and f ◦ f −1 = idB .

Proof. We know f −1 is a function by Proposition 7.4.3, because f is bijection.


For the first part, let x ∈ A. Define y = f (x). Then

(f −1 ◦ f )(x) = f −1 (f (x)) by Proposition 7.3.1;


−1
=f (y) by the definition of y;
=x by Proposition 7.4.11, as y = f (x);
= idA (x) by the definition of idA .

So f −1 ◦ f = idA by Proposition 7.2.7.


The proof of the second part is similar, and is left as an exercise.  7e

Tutorial exercises
7.1. Which of the following conditions are equivalent to the surjectivity of a function f : A →
B? For each positive answer, give a brief explanation. For each negative answer, give
a function f : {a, b} → {0, 1} that demonstrates the non-equivalence.

(a) For any x ∈ A, there is y ∈ B such that y = f (x).


(b) Some y ∈ B is equal to f (x) for some x ∈ A.
(c) All f (x)’s, where x ∈ A, are equal to the same y ∈ B.
(d) No y ∈ B is different from all the f (x)’s where x ∈ A.

7.2. Which of the following conditions are equivalent to the injectivity of a function f : A →
B? For each positive answer, give a brief explanation. For each negative answer, give
a function f : {a, b} → {0, 1} that demonstrates the non-equivalence.
(a) For all x1 , x2 ∈ A, whenever x1 = x2 , we have f (x1 ) = f (x2 ).
(b) For all x1 , x2 , ∈ A, whenever x1 ̸= x2 , we have f (x1 ) ̸= f (x2 ).
(c) There are no elements x1 , x2 ∈ A such that x1 ̸= x2 and f (x1 ) = f (x2 ).

65
(d) There are distinct x1 , x2 ∈ A that make f (x1 ) = f (x2 ).
7.3. For all A, B ⊆ Z, define

RA,B = {(x, y) ∈ A × B : y = x2 − 1}

considered as a relation from A to B.


(a) Let A = {−2, −1, 0, 1, 2} and B = {0, 1, 2, 3}. Is RA,B a function A → B? Briefly
explain your answer.
(b) Let A = {−2, −1, 0, 1, 2}. Give an example of B ⊆ {−4, −3, . . . , 3, 4} such that
RA,B is a surjection A → B.
(c) Let B = {0, 1, 2, 3}. Give an example of A ⊆ {−4, −3, . . . , 3, 4} such that RA,B is
an injection A → B.
7.4. Let f = {(n, x) ∈ Z2 : n = 2x or n = 2x + 1}, viewed as a relation from Z to Z.
(a) Prove that f is a function Z → Z.
(b) Is f surjective? Prove that your answer is correct.
(c) Is f injective? Prove that your answer is correct.
(d) Determine the range of f .
7.5. Define a Boolean function g : {T, F}3 → {T, F} by setting g(p0 , q0 , r0 ) to be the truth
value that the compound expression p ∨ q → ¬r evaluates to when one substitutes
propositions of truth values p0 , q0 and r0 into the propositional variables p, q and r
respectively, for all p0 , q0 , r0 ∈ {T, F}.
(a) Is g surjective? Prove that your answer is correct.
(b) Is g injective? Prove that your answer is correct.
(c) Give an example of a function f : {T, F} → {T, F}3 such that g ◦ f = id{T,F} .
7.6. We encountered several situations, e.g., in Proposition 7.4.14, where we can compose
one function with another to give an identity function. When we can compose one
function f with another function g to get an identity function, we can find out a lot of
information about f from g. This question gives one example of this phenomenon.
Let f : A → B and g : B → A. Prove that if f is surjective and g ◦ f = idA , then g is
injective.
7.7. (Induction corner) Someone attempts to prove that all people on the NUS campus have
the same birthday as follows.
Let P (n) be the sentence
if the NUS campus has exactly n people in it, then all these n people
have the same birthday.
(Base step) P (1) is true because if the NUS campus has exactly 1 person
in it, then clearly all people on the NUS campus have the same birthday.
(Induction step) Let k ∈ Z+ such that P (k) is true. Suppose the NUS
campus now has exactly k + 1 people in it. Pick two different people a, b
on the NUS campus. Ask a to leave the campus. Since there are k people
left on the NUS campus, by the induction hypothesis, all the remaining
people have the same birthday, including b. Tell a to come back to
campus, and then ask b to leave the campus. Since there are k people
left on the NUS campus, by the induction hypothesis, all the remaining
people have the same birthday, including a. The people who stayed on
the campus throughout have the same birthday as both a and b. So a
and b have the same birthday. This shows P (k + 1) is true.

66
Hence ∀n ∈ Z+ P (n) is true by MI.
What is wrong with this proof?

Extra exercises
7.8. Let f = {(x, y) ∈ Q2 : y = ±x} and g = {(x, y) ∈ Q2 : y(x2 + 1) = 1}, viewed as
relations from Q to Q. Is f a function Q → Q? Is g a function Q → Q?
7.9. In this exercise, we prove a strong converse to Proposition 7.4.3.
Let f : A → B. Prove that, if the relation f −1 is a function B → A, then f is bijective.

7.10. Let f be as defined in Tutorial Exercise 7.4. Define g = {(x, n) ∈ Z2 : n = 2x}, viewed
as a relation from Z to Z.
(a) Prove that g is a function Z → Z.
(b) Is g surjective? Prove that your answer is correct.
(c) Is g injective? Prove that your answer is correct.
(d) Prove that f ◦ g = idZ but g ◦ f ̸= idZ .
(e) Is g = f −1 ? Explain your answer.

67
CS1231 Chapter 8

Cardinality

8.1 Pigeonhole principles

surjection
injection

A B A B

Figure 8.1: Injections, surjections, and the number of elements in the domain and the
codomain

Theorem 8.1.1 (Pigeonhole Principle). Let A = {x1 , x2 , . . . , xn } and B = {y1 , y2 , . . . , ym },


where n, m ∈ N, the x’s are different, and the y’s are different. If there is an injection A → B,
then n ⩽ m.

xk+1 ym
xk × ..
.
.. yℓ
.
.. ..
. .
x2 y2
x1 f y1

Figure 8.2: Induction proofs for the Pigeonhole Principles

Proof (extra material). We prove this by induction on n.

(Base step) If n = 0, then m ⩾ 0 = n for all m ∈ N. So the theorem is true for n = 0.


(Induction step) Let k ∈ N such that the theorem is true for n = k. We want to prove
the theorem for n = k + 1. Consider A = {x1 , x2 , . . . , xk+1 } and B = {y1 , y2 , . . . , ym },
where m ∈ N, such that the x’s are different, and the y’s are different. Suppose we
have an injection f : A → B. Let yℓ = f (xk+1 ). By the injectivity of f , as the x’s are

68
all different, no i ∈ {1, 2, . . . , k} can make f (xi ) = f (xk+1 ) = yℓ . All such f (xi )’s must
appear in the list
y1 , y2 , . . . , yℓ−1 , yℓ+1 , . . . , ym .
Let ŷ1 , ŷ2 , . . . , ŷm−1 denote the elements of this list. Define fˆ: {x1 , x2 , . . . , xk } →
{ŷ1 , ŷ2 , . . . , ŷm−1 } by setting fˆ(xi ) = f (xi ) for each i ∈ {1, 2, . . . , k}. Then fˆ is injective
because if i, j ∈ {1, 2, . . . , k} such that fˆ(xi ) = fˆ(xj ), then f (xi ) = f (xj ) by the
definition of fˆ, and so the injectivity of f implies xi = xj . As the x’s are all different
and the ŷ’s are all different, the induction hypothesis tells us k ⩽ m − 1. Hence
k + 1 ⩽ m.

This completes the induction.

Theorem 8.1.2 (Dual Pigeonhole Principle). Let A = {x1 , x2 , . . . , xn } and B =


{y1 , y2 , . . . , ym }, where n, m ∈ N, the x’s are different, and the y’s are different. If there
is a surjection A → B, then n ⩾ m.

Proof. See Tutorial Exercise 8.6.

Theorem 8.1.3. Let A = {x1 , x2 , . . . , xn } and B = {y1 , y2 , . . . , ym }, where n, m ∈ N, the


x’s are different, and the y’s are different. Then n = m if and only if there is a bijection
A → B.

Proof. (⇒) Suppose n = m. Define f : A → B by setting f (xi ) = yi for each i ∈


{1, 2, . . . , n}. This definition is unambiguous because the x’s are different.
Surjectivity follows from the observation that for every yi ∈ B, we have xi ∈ A such that
f (xi ) = yi .
To show injectivity, suppose i, j ∈ {1, 2, . . . , n} such that f (xi ) = f (xj ). The definition
of f tells us f (xi ) = yi and f (xj ) = yj . Then yi = f (xi ) = f (xj ) = yj . So i = j because the
y’s are different. This implies xi = xj .
(⇐) This follows directly from Theorem 8.1.1 and Theorem 8.1.2.
Exercise 8.1.4. Prove the converse to Theorem 8.1.1. Prove also the converse to Theo-  8a
rem 8.1.2 when B ̸= ∅.

8.2 Same cardinality


Definition 8.2.1 (Cantor). A set A is said to have the same cardinality as a set B if there
is a bijection A → B.

Note 8.2.2. We defined what it means for a set to have the same cardinality as another set
without defining what the cardinality of a set is.
Example 8.2.3. (1) Let n ∈ N. Then {0, 1, . . . , n − 1} has the same cardinality as
{1, 2, . . . , n} because the function f : {0, 1, . . . , n − 1} → {1, 2, . . . , n} satisfying f (x) =
x + 1 for all x ∈ {0, 1, . . . , n − 1} is a bijection.
(2) N has the same cardinality as N \ {0} because the function g : N → N \ {0} satisfying
g(x) = x + 1 for all x ∈ N is a bijection.

(3) N has the same cardinality as N \ {1, 3, 5, . . . } because the function h : N → N \


{1, 3, 5, . . . } satisfying h(x) = 2x for all x ∈ N is a bijection.

69
0 1 2 3 4 ··· 0 1 2 ···

g h

1 2 3 4 5 ··· 0 2 4 ···

Figure 8.3: Removing 1 or half of the elements from N

Proposition 8.2.4. Let A, B, C be sets.


(1) A has the same cardinality as A. (reflexivity)
(2) If A has the same cardinality as B, then B has the same cardinality as A. (symmetry)

(3) If A has the same cardinality as B, and B has the same cardinality as C, then A has
the same cardinality as C. (transitivity)

Proof. See Tutorial Exercise 8.3.

Exercise 8.2.5. Prove that, if f is an injection A → B, then A has the same cardinality as  8b
range(f ).

Definition 8.2.6. A set A is finite if it has the same cardinality as {1, 2, . . . , n} for some
n ∈ N. In this case, we call n the cardinality or the size of A, and we denote it by |A|. A set
is infinite if it is not finite.

Exercise 8.2.7. Prove that no function N → {1, 2, . . . , n}, where n ∈ N, can be injective.  8c
Deduce that N is infinite.

Lemma 8.2.8. Let A and B be sets of the same cardinality. Then A is finite if and only if
B is finite.

Proof. See Tutorial Exercise 8.5.

Question 8.2.9. Which of the following is/are true for all sets A, B?  8d
(1) If there is a bijection A → B, then A has the same cardinality as B.
(2) If there is a surjection A → B that is not an injection, then A does not have the same
cardinality as B.

(3) If there is an injection A → B that is not a surjection, then A does not have the same
cardinality as B.
(4) If there is a function A → B that is neither a surjection nor an injection, then A does
not have the same cardinality as B.

Tutorial exercises
An asterisk (*) indicates a more challenging exercise.

70
8.1. In view of the Pigeonhole Principle, for (possibly infinite) sets A and B, one may define
“the cardinality of A is at most that of B” to mean the existence of an injection A → B.
One desirable property of this definition is transitivity, i.e., if A, B, C are sets such that
the cardinality of A is at most that of B and the cardinality of B is at most that of C,
then the cardinality of A is at most that of C. To prove this, one needs to find an
injection A → C given injections A → B and B → C. The aim of this exercise is to
show that we can get the required injection by composing together the given injections.
We also aim to establish the analogous result for surjections.
Let f : A → B and g : B → C. Prove the following propositions.
(a) If f and g are surjective, then so is g ◦ f .
(b) If f and g are injective, then so is g ◦ f .
(Hint: mimic the proof of Proposition 7.3.1.)
8.2. Here we consider the converses to the propositions proved in Exercise 8.1.

(a) Give an example of sets A, B, C and functions f : A → B and g : B → C such that


g ◦ f is surjective but f is not surjective.
(b) Give an example of sets A, B, C and functions f : A → B and g : B → C such that
g ◦ f is injective but g is not injective.
(c) Give an example of sets A, B, C and functions f : A → B and g : B → C such that
g ◦ f is bijective but both f and g are not bijective.

(Hint: some diagrams may help.)


8.3. Prove Proposition 8.2.4, i.e., the following propositions.
(a) (Reflexivity) Every set A has the same cardinality as itself.
(b) (Symmetry) For all sets A and B, if A has the same cardinality as B, then B has
the same cardinality as A.
(c) (Transitivity) For all sets A, B and C, if A has the same cardinality as B, and B
has the same cardinality as C, then A has the same cardinality as C.
8.4. Consider the equivalence relation R from Tutorial Exercise 6.3, i.e., the equivalence
relation R on R2 satisfying, for all (x1 , y1 ), (x2 , y2 ) ∈ R2 ,

(x1 , y1 ) R (x2 , y2 ) ⇔ 3(x1 − x2 ) = y1 − y2 .

Recall from Tutorial Exercise 6.3(b) that the equivalence classes have the form

[(u, v)] = {(x, y) ∈ R2 : y = 3x + (v − 3u)},

where (u, v) ∈ R2 . Prove that all these equivalence classes have the same cardinality.
(Hint: thinking geometrically may help.)
8.5. Prove Lemma 8.2.8, i.e., the following proposition.
Let A and B be sets of the same cardinality. Then A is finite if and only if
B is finite.
8.6.∗ (Induction corner) Recall from Theorem 8.1.2 that the Dual Pigeonhole Principle states
the following.
Let A = {x1 , x2 , . . . , xn } and B = {y1 , y2 , . . . , ym }, where n, m ∈ N, the x’s
are different, and the y’s are different. If there is a surjection A → B, then
n ⩾ m.

71
Someone attempts to prove this principle as follows.
We prove this by induction on n.
(Base step) Consider the theorem for n = 0. Let f be a surjection {} →
{y1 , y2 , . . . , ym }, where m ∈ N, such that the y’s are different. Suppose
m ⩾ 1. Consider y1 . The surjectivity of f gives x ∈ {} such that
f (x) = y1 . However, no x can be in {}. This is a contradiction. So
m = 0 = n.
(Induction step) Let k ∈ N such that the theorem is true for n = k. We
want to prove the theorem for n = k + 1. Let A = {x1 , x2 , . . . , xk+1 }
and B = {y1 , y2 , . . . , ym }, where m ∈ N, such that the x’s are different,
and the y’s are different. Suppose we have a surjection f : A → B. Let
yℓ = f (xk+1 ), so that no i ∈ {1, 2, . . . , k} makes f (xi ) = yℓ . Then all
such f (xi )’s must appear in the list

y1 , y2 , . . . , yℓ−1 , yℓ+1 , . . . , ym .

Let ŷ1 , ŷ2 , . . . , ŷm−1 denote the elements of this list. Define

fˆ: {x1 , x2 , . . . , xk } → {ŷ1 , ŷ2 , . . . , ŷm−1 }

by setting fˆ(xi ) = f (xi ) for each i ∈ {1, 2, . . . , k}. We claim that fˆ is


surjective. To prove this, consider any ŷ. It must equal yh where h ∈
{1, 2, . . . , m} \ {ℓ}. By the surjectivity of f , we have i ∈ {1, 2, . . . , k + 1}
such that yh = f (xi ). As ℓ ̸= h and the y’s are all different, we know
yℓ ̸= yh = f (xi ). Since yℓ = f (xk+1 ), we deduce that i ̸= k + 1. Hence
yh = f (xi ) = fˆ(xi ). As the x’s are all different and the ŷ’s are all
different, the induction hypothesis tells us k ⩾ m − 1. So k + 1 ⩾ m.
This completes the induction.

(a) What is wrong with this attempt?


(b) Turn this attempt into a correct proof.

Extra exercises
8.7. We demonstrated in Exercise 8.2 that the converses to the propositions proved in Exer-
cise 8.1 are false. However, some partial converses are true, as we show in this exercise.
Let f : A → B and g : B → C. Prove the following propositions.
(a) If g ◦ f is surjective, then g is surjective.
(b) If g ◦ f is injective, then f is injective.
8.8. In this exercise, we verify that any finite set has at most one cardinality according to
Definition 8.2.6, as one would expect.
Let A be a set, and m, n ∈ N. Prove that, if A has the same cardinality as both
{1, 2, . . . , m} and {1, 2, . . . , n}, then m = n.
8.9.∗ In this exercise, we consider the special case of the propositions in Question 8.2.9(2)
and (3) when the sets involved are finite.
Let A = {x1 , x2 , . . . , xn } and B = {y1 , y2 , . . . , ym }, where n, m ∈ N, the x’s are differ-
ent, and the y’s are different. Prove the following propositions.
(a) If there is a surjection f : A → B that is not an injection, then n > m.
(b) If there is an injection f : A → B that is not a surjection, then n < m.

72
CS1231 Chapter 9

Countability

9.1 Countable sets


Definition 9.1.1 (Cantor). A set is countable if it is finite or it has the same cardinality
as N. A set is uncountable if it is not countable.

.. .. ..
. . .
2 b2

1 b1

0 b0
bijection
N B

Figure 9.1: A countable infinite set B

Note 9.1.2. Some authors allow only infinite sets to be countable.


Example 9.1.3. (1) N is countable by Proposition 8.2.4(1).
(2) As shown in Example 8.2.3, both N \ {0} and N \ {1, 3, 5, . . . , } are countable.

Proposition 9.1.4. Z is countable.

Proof. Define f : Z → N by setting, for each x ∈ Z,


(
2x, if x ⩾ 0;
f (x) =
2(−x − 1) + 1, if x < 0.

This definition indeed assigns to each element x ∈ Z an element f (x) ∈ N because if x ⩾ 0,


then 2x ⩾ 0 as well; and if x < 0, then x ⩽ −1 as x ∈ Z, and so 2(−x − 1) + 1 ⩾
2(−(−1) − 1) + 1 = 1 > 0. It suffices to show that f is bijective.
To show surjectivity, pick any y ∈ N. Then Proposition 3.2.21 tells us that y is either
even or odd. If y is even, say y = 2x where x ∈ Z, then x = y/2 ⩾ 0, and so f (x) = 2x = y.
If y is odd, say y = 2x + 1 where x ∈ Z, then
y−1 0−1 1
x+1= +1⩾ + 1 = > 0,
2 2 2

73
.. .. ..
. . .
−3 5
−2 3
−1 1
.. .. ..
. . .
2 4
1 2
0 0
Z N

Figure 9.2: The countability of Z

and so f (−x − 1) = 2(−(−x − 1) − 1) + 1 = 2x + 1 = y. Thus some x ∈ Z makes f (x) = y


in all cases.
To show injectivity, pick x1 , x2 ∈ Z such that f (x1 ) = f (x2 ). If f (x1 ) is even, then
f (x1 ) = 2x1 and f (x2 ) = 2x2 by Proposition 3.2.17, and so x1 = x2 . If f (x1 ) is odd, then
f (x1 ) = 2(−x1 − 1) + 1 and f (x2 ) = 2(−x2 − 1) + 1 by Proposition 3.2.17, and so x1 = x2 .
Thus x1 = x2 in all cases.

Theorem 9.1.5 (Cantor 1877). N × N is countable.

Proof sketch.

.. .. .. .. .. .
. . . . . ..

(0, 4) (1, 4) (2, 4) (3, 4) (4, 4) ···

(0, 3) (1, 3) (2, 3) (3, 3) (4, 3) ···

(0, 2) (1, 2) (2, 2) (3, 2) (4, 2) ···

(0, 1) (1, 1) (2, 1) (3, 1) (4, 1) ···

(0, 0) (1, 0) (2, 0) (3, 0) (4, 0) ···

The function f : N → N × N such that f (0), f (1), f (2), . . . are respectively

(0, 0), (1, 0), (0, 1), (2, 0), (1, 1), (0, 2), (3, 0), (2, 1), (1, 2), (0, 3), (4, 0), (3, 1), (2, 2), (1, 3), . . .
| {z } | {z } | {z }
sum = 1 sum = 2 sum = 3
is a bijection. This shows N × N is countable.

Proposition 9.1.6. {0, 1}∗ is countable.

74
Proof sketch. Let f : N → {0, 1}∗ such that f (0), f (1), f (2), . . . are respectively

ε, 0, 1 , 00, 01, 10, 11, 000, 001, 010, 011, 100, 101, 110, 111, . . . ,
|{z} | {z } | {z }
length length length
1 2 3

where ε denotes the empty string. Then f is a bijection. This shows {0, 1}∗ is countable.

9.2 Countability

Lemma 9.2.1. Let A and B be sets of the same cardinality. Then A is countable if and
only if B is countable.

Exercise 9.2.2. Prove Lemma 9.2.1. (Hint: imitate the proof of Lemma 8.2.8.)  9a

..
. infinite

..
.
countable 2
1
0

Figure 9.3: The smallest cardinalities

Technique 9.2.3. To prove ∃x P (x), where P (x) is a sentence, produce an algorithmic


procedure that outputs an object z for which P (z) is true.

Justification. This is based on Note 2.2.5(4).

Proposition 9.2.4. Every infinite set B has a countable infinite subset.

Proof. Let B be an infinite set. Run the following procedure.


1. Initialize i = 0.
2. While B \ {g1 , g2 , . . . , gi } =
̸ ∅ do:
2.1. Pick any gi+1 ∈ B \ {g1 , g2 , . . . , gi }.
2.2. Increment i to i + 1.
Suppose this procedure stops. Then a run results in g1 , g2 , . . . , gℓ , where ℓ ∈ N. Define
g : {1, 2, . . . , ℓ} → B by setting g(i) = gi for all i ∈ {1, 2, . . . , ℓ}. Notice B \ {g1 , g2 , . . . , gℓ } =
∅ as the stopping condition is reached. This says any element of B is equal to some gi , thus
some g(i). So g is surjective. We know g is injective because each gi+1 ̸∈ {g1 , g2 , . . . , gi } by
line 2.1. As g is a bijection {1, 2, . . . , ℓ} → B, we deduce that B is finite. This contradicts
the condition that B is infinite.

75
So this procedure does not stop. Define A = {gi : i ∈ Z+ }, and g : N → A by setting
g(i) = gi+1 for each i ∈ N. Then g is surjective by construction. It is injective because each
gi+1 ̸∈ {g1 , g2 , . . . , gi } by line 2.1. As g is a bijection N → A, we deduce that A is countable.
With g, we know A has the same cardinality as N. So A is infinite by Lemma 8.2.8 and
Exercise 8.2.7.
Example 9.2.5. Knowing that R \ Q is infinite tells us R \ Q has a countable infinite subset
by Proposition 9.2.4.

Proposition 9.2.6. Let A, B be sets such that A ⊆ B.


(1) If B is finite, then A is finite.

(2) If B is countable, then A is countable.

.. .. .. .. .. ..
. . . . . .
4 f (4) 4 f (4)
3 f (3) 3
2 f (2) 2 f (2)
1 f (1) 1
0 f (0) 0 f (0)
f g
N B N A

Figure 9.4: Countability of any subset A of a countable set B

Proof sketch. One can prove part (1) in a way similar to how we handle part (2) below. So
we leave the proof of (1) as an exercise and concentrate on (2). Suppose B is countable. If  9b
B is finite, then (1) tells us that A must also be finite and thus countable. So let us suppose
B is infinite. As B is countable and infinite, there is a bijection N → B, say f . Run the
following procedure.
1. Initialize i = 0.
2. While A \ {g1 , g2 , . . . , gi } =
̸ ∅ do:
2.1. Let mi+1 be the smallest element in {m ∈ N : f (m) ∈ A\{g1 , g2 , . . . , gi }}.
2.2. Set gi+1 = f (mi+1 ).
2.3. Increment i to i + 1.
On the one hand, suppose we are at line 2.2 when this procedure is run. Then the loop
condition tells us A \ {g1 , g2 , . . . , gi } ̸= ∅. If ai ∈ A \ {g1 , g2 , . . . , gi }, then ai = f (m) for
some m ∈ N because f is a surjection N → B and A ⊆ B. This says {m ∈ N : f (m) ∈
A \ {g1 , g2 , . . . , gi }} =
̸ ∅. So mi+1 must exist by the Well-Ordering Principle.
On the other hand, by the choices of mi+1 and gi+1 on lines 2.2 and 2.1,
each gi+1 ∈ A \ {g1 , g2 , . . . , gi }. (∗)

Case 1: this procedure stops after finitely many steps. Then a run results in
m1 , m2 , . . . , mℓ and g1 , g2 , . . . , gℓ
where ℓ ∈ N. Define g : {1, 2, . . . , ℓ} → A by setting g(i) = gi for all i ∈ {1, 2, . . . , ℓ}.
Notice A\{g1 , g2 , . . . , gℓ } = ∅ as the stopping condition is reached. This says any element
of A is equal to some gi , thus some g(i). So g is surjective. We know g is injective by (∗).
As g is a bijection {1, 2, . . . , ℓ} → A, we deduce that A is finite and hence countable.

76
uncountable f uncountable

A injection range(f ) B

Figure 9.5: Injecting an uncountable set into another set

Case 2: this procedure does not stop. Then a run results in

m1 , m2 , m3 , . . . and g1 , g2 , g3 , . . . .

Define g : N → A by setting g(i) = gi+1 for all i ∈ N. As one can verify, this g is a bijection
N → A. So A is countable.

Explanation of why g is bijective in the proof above (extra material). We claim


that mi+1 < mi+2 for all i ∈ N. Let i ∈ N. Line 2.2 tells us gi+1 = f (mi+1 ) and gi+2 =
f (mi+2 ), but gi+1 ̸= gi+2 by (∗). So mi+1 ̸= mi+2 . Note that f (mi+2 ) = gi+2 ∈ A \
{g1 , g2 , . . . , gi+1 } ⊆ A \ {g1 , g2 , . . . , gi }. Thus mi+2 ∈ {m ∈ N : f (m) ∈ A \ {g1 , g2 , . . . , gi }}.
Since we chose mi+1 to be the smallest element of this set and mi+1 ̸= mi+2 , we deduce that
mi+1 < mi+2 , as claimed.
To show the surjectivity of g, assume we have y ∈ A such that g(i) ̸= y for any i ∈ N.
As f is a surjection N → B and A ⊆ B, we get n ∈ N making f (n) = y. The claim in the
previous paragraph tells us that 0 ⩽ m1 < m2 < · · · < mn+2 . So mn+2 ⩾ n + 1 > n. Also,
our assumption on y implies f (n) = y ∈ A \ {g(0), g(1), . . . , g(n)} = A \ {g1 , g2 , . . . , gn+1 }.
However, we chose mn+2 to be the smallest m ∈ N such that f (m) ∈ A \ {g1 , g2 , . . . , gn+1 }.
This contradiction shows the surjectivity of g.
We know g is injective by (∗). ■

Corollary 9.2.7. (1) A set B is infinite if there is an injection f from some infinite set A
to B.

(2) A set B is uncountable if there is an injection f from some uncountable set A to B.

Proof. The proofs of the two parts are similar. So we concentrate on (2) and leave the proof
of (1) as an exercise.  9c
As f is an injection A → B, Exercise 8.2.5 implies that A has the same cardinality
as range(f ). Since A is uncountable, Lemma 9.2.1 tells us range(f ) is also uncountable.
Recall from Remark 7.2.3(2) that range(f ) ⊆ B. Hence B is uncountable too by Proposi-
tion 9.2.6(2).
Example 9.2.8. The set of all programs is countable.
Proof. Every program is stored in a computer as a string over {0, 1}. So the set of all
programs is a subset of the set {0, 1}∗ of all strings over {0, 1}, which we know is count-
able from Proposition 9.1.6. So Proposition 9.2.6(2) tells us that the set of all programs is
countable.

9.3 Uncountable sets


Theorem 9.3.1 (Cantor 1891). No set A has the same cardinality as P(A).

77
0 1 2 3 4 ...
f (0) ∈
/ ∈ ∈
/ ∈
/ ∈
/ ...
f (1) ∈ ∈
/ ∈ ∈
/ ∈ ...
f (2) ∈
/ ∈ ∈ ∈
/ ∈ ...
f (3) ∈
/ ∈
/ ∈ ∈
/ ∈
/ ...
f (4) ∈ ∈
/ ∈ ∈ ∈
/ ...
.. .. .. .. .. .. ..
. . . . . . .

R ∈ ∈ ∈
/ ∈ ∈ ...

Figure 9.6: Illustration of Cantor’s diagonal argument

Proof. We consider here only the particular case when A = N. The general case is very
similar, and is left as an exercise.  9d
Given any function f : N → P(N), we will produce an element of P(N) that is not equal
to f (x) for any x ∈ N. This will show that there is no surjection f : N → P(N), and thus N
cannot have the same cardinality as P(N).
Let f : N → P(N). Define R = {x ∈ N : x ̸∈ f (x)}. Then R ∈ P(N) by the definition of
power sets. We claim that R ̸= f (x) for any x ∈ N. We prove this by contradiction. Suppose
we have a ∈ N such that R = f (a). From the definition of R,

∀x ∈ N x ∈ R ⇔ x ̸∈ f (x) . (†)

As R = f (a), applying (†) to x = a gives

a ∈ f (a) ⇔ a ̸∈ f (a). (‡)

Split into two cases.


• Case 1: assume a ∈ f (a). Then a ̸∈ f (a) by the ⇒ part of (‡). This contradicts our
assumption that a ∈ f (a).
• Case 2: assume a ̸∈ f (a). Then a ∈ f (a) by the ⇐ part of (‡). This contradicts our
assumption that a ̸∈ f (a).

In either case, we get a contradiction. This completes the proof of the claim and thus of the
theorem.

Corollary 9.3.2. Let A be a countable infinite set. Then P(A) is uncountable. Hence P(N)
is uncountable.

Proof. We consider here only the particular case when A = N. The general case is very
similar, and is left as an exercise.  9e
According to the definition of countability, we need to show that P(N) is infinite, and that
P(N) does not have the same cardinality as N. We already have the latter from Theorem 9.3.1.
For the former, let f : N → P(N) defined by setting f (n) = {n} for each n ∈ N. Then
f is injective because if n1 , n2 ∈ N such that f (n1 ) = f (n2 ), then {n1 } = {n2 }, and thus
n1 = n2 by the definition of set equality. Recall that N is infinite from Exercise 8.2.7. So
Corollary 9.2.7(1) tells us P(N) is infinite too, as required.

9.4 Non-computability
Assumption 9.4.1. Our programs have no time and memory limitation.

78
Corollary 9.4.2. There is a subset S of N that is not computed by any program, i.e., no
program can, when given any input n ∈ N,

• output T if n ∈ S; and
• output F if n ̸∈ S.

Proof. Suppose that every subset S ⊆ N is computed by a program. For each S ∈ P(N), let
f (S) be the smallest program that computes S. This defines a function f : P(N) → {0, 1}∗ ,
because each program has a unique representation by an element of {0, 1}∗ within a computer.
This function f is injective because if S1 , S2 ∈ P(N) such that f (S1 ) = f (S2 ), then S1 and S2
are computed by the same program, and thus S1 = S2 by the definition of set equality.
Recall from Corollary 9.3.2 that P(N) is uncountable. So Corollary 9.2.7(2) implies {0, 1}∗ is
uncountable as well. This contradicts the countability of {0, 1}∗ from Proposition 9.1.6.

Theorem 9.4.3 (Turing 1936, extra material). The set

H = {σ ∈ {0, 1}∗ : σ is a program that does not stop on the empty input}

is not computed by any program, i.e., no program can, when given any input σ ∈ {0, 1}∗ ,
• output T if σ ∈ H; and
• output F if σ ̸∈ H.

Proof. Suppose not. Use a program that computes H to devise a program R satisfying
 σ is a program that does 
∀σ ∈ {0, 1}∗ R stops on input σ ⇔ . (§)
not stop on input σ

Applying (§) to σ = R gives

R is a program that does


R stops on input R ⇔ (¶)
not stop on input R

Split into two cases.


• Case 1: assume R stops on input R. Then R does not stop on input R by the ⇒ part
of (¶). This contradicts our assumption that R stops on input R.
• Case 2: assume R does not stop on input R. Then R stops on input R by the ⇐ part
of (¶). This contradicts our assumption that R does not stop on input R.
In either case, we get a contradiction, as required.

Tutorial exercises
An asterisk (*) indicates a more challenging exercise.
9.1. It is often desirable for small sets to be closed under (binary) unions, i.e., the union of
two small sets should also be small. (Can you guess why?) The aim of this exercise is
to show that finite sets are a kind of small sets with this desirable property.
Let A and B be sets. Prove that, if A and B are finite, then A ∪ B is finite.
(Hint: start with the special case when A ∩ B = ∅. Then use Extra Exercise 4.9 to
generalize to all cases.)

79
9.2. The aim of this exercise is to show that countable sets are another kind of small sets
with the desirable property put forward in Exercise 9.1.
Let A and B be sets. Prove that, if A and B are countable, then A ∪ B is countable.
(Hint: as in Exercise 9.1, start with the special case when A ∩ B = ∅. Then use Extra
Exercise 4.9 to generalize to all cases.)
Sn
9.3. Recall the definition of i=0 Ai from Extra Exercise 4.11.
(Induction
Sn corner) Let A0 , A1 , A2 , . . . be countable sets. Prove by induction on n that
A
i=0 i is countable for every n ∈ N.
S∞
9.4.∗ Recall the definition of i=0 Ai from Extra Exercise 4.11.

(a) Someone claims that one can deduce directly from what S∞ we established in Exer-
cise 9.3 that, if A0 , A1 , A2 , . . . are countable sets, then i=0 Ai is countable. What
is wrong with this claim?
S∞
(b) Prove that, if A0 , A1 , A2 , . . . are countable sets, then i=0 Ai is countable.
S∞
(Hint: find an injection i=0 Ai → N × N.)

9.5. For each of the following propositions, determine whether it is true. Prove that your
answers are correct.

(a) If a set B has an uncountable subset A, then B is uncountable.


(b) If A is an uncountable set and B is a countable set, then A \ B is uncountable.
9.6. Corollary 9.3.2 states that the power set of a countable infinite set is uncountable. The
aim of this exercise is to show that this corollary remains true even when one omits the
word “countable” there.
Prove that the power set P(A) of any infinite set A is uncountable.

Extra exercises
9.7. According to our definition, there are two kinds of countable sets: finite sets, and
sets that have the same cardinality as N. Conceivably, this may lead to painful case-
splittings in proofs about countable sets. Fortunately, in many circumstances, one can
ignore the finite case via what we establish in this exercise.
Prove that, for every countable set A, there is a countable infinite set A∗ such that
A ⊆ A∗ .

9.8. We defined countability using (the notion of same-cardinality and thus) bijections. We
show in this exercise how one could have defined countability using injections instead.
Prove that a set A is countable if and only if there is an injection A → N.
9.9. We saw in Theorem 9.1.5 that N × N is countable. In this exercise, we generalize this
to the Cartesian product of any two countable sets, not only N.
Let A, B be countable sets. Use Theorem 9.1.5 to prove that A × B is countable.

80
CS1231 Chapter 10

Counting

10.1 Sums and differences


Proposition 10.1.1. Let A0 , A1 , A2 , . . . be finite sets. Then A0 ∪ A1 ∪ · · · ∪ An is finite for
all n ∈ N.

Proof. Proceed by induction on n as in Tutorial Exercise 9.3 using Tutorial Exercise 9.1.

Combinatorial interpretation of Proposition 10.1.1. If x is a variable that can only


take an element of one of finitely many finite sets, then there are finitely many ways to
substitute objects into x.

Y
A B X

Figure 10.1: Addition Rule and Difference Rule

Example 10.1.2. The sets {1, 2} and {3, 4, 5} are disjoint. Note that

|{1, 2} ∪ {3, 4, 5}| = |{1, 2, 3, 4, 5}| = 5 = 2 + 3 = |{1, 2}| + |{3, 4, 5}|.

Proposition 10.1.3 (Addition Rule). Let A and B be disjoint finite sets. Then |A ∪ B| =
|A| + |B|.

Proof. Proceed as in Tutorial Exercise 9.1.

Combinatorial interpretation of the Addition Rule. Let m, n ∈ N. Suppose that the


variable x can only take either one of m objects or one of n objects, and that these m objects
are different from the n objects here. Then there are exactly m+n ways to substitute objects
into x.

81
Example 10.1.4. Note that {1, 2} ⊆ {1, 2, 3, 4, 5}. Also
|{1, 2, 3, 4, 5} \ {1, 2}| = |{3, 4, 5}| = 3 = 5 − 2 = |{1, 2, 3, 4, 5}| − |{1, 2}|.

Corollary 10.1.5 (Difference Rule). Let X and Y be finite sets. Then Y \ X is finite, and
if X ⊆ Y , then |Y \ X| = |Y | − |X|.

Proof. First, note that Y \ X = {x ∈ Y : x ̸∈ X} ⊆ Y . So Y \ X is finite by Proposi-


tion 9.2.6(1) as Y is finite. Now, in view of Extra Exercise 4.9, we know Y \ X and X are
disjoint and (Y \ X) ∪ X = X ∪ Y . As X ⊆ Y , we also know from Tutorial Exercise 4.6 that
X ∪ Y = Y . Hence
|Y | = |(Y \ X) ∪ X| as (Y \ X) ∪ X = X ∪ Y = Y ;
= |Y \ X| + |X| by the Addition Rule, as Y \ X and X are disjoint.
∴ |Y \ X| = |Y | − |X|.

Combinatorial interpretation of the Difference Rule. Let m, n ∈ N. Suppose that


the variable x can only take one of m objects except n of them. Then there are exactly
m − n ways to substitute objects into x.

Remark 10.1.6. The Addition Rule becomes false if one drops the disjointness condition.
For example,
|{1, 2} ∪ {2, 3, 4}| = |{1, 2, 3, 4}| = 4 ̸= 5 = 2 + 3 = |{1, 2}| + |{2, 3, 4}|.

A B
B C

Figure 10.2: Inclusion–Exclusion Rule for two and three sets

Theorem 10.1.7 (Inclusion–Exclusion Rule for two sets). Let A, B be finite sets. Then

|A ∪ B| = |A| + |B| − |A ∩ B|.

Proof. Observe that A \ B = A \ (A ∩ B). (Exercise: prove this.) Thus  10a


|A ∪ B| = |(A \ B) ∪ B| by Extra Exercise 4.9;
= |A \ B| + |B| by the Addition Rule, as (A \ B) ∩ B = ∅;
= |A \ (A ∩ B)| + |B| by the observation above;
= |A| − |A ∩ B| + |B| by the Difference Rule, as A ∩ B ⊆ A.
Example 10.1.8. By the Inclusion–Exclusion Rule for two sets,
|{1, 2} ∪ {2, 3, 4}| = |{1, 2}| + |{2, 3, 4}| − |{1, 2} ∩ {2, 3, 4}|
= |{1, 2}| + |{2, 3, 4}| − |{2}|
= 2 + 3 − 1 = 4.

82
Combinatorial interpretation of the Inclusion–Exclusion Rule for two sets. Let
m, n ∈ N. Suppose that the variable x can only take either one of m objects or one of
n objects, and that the m objects and the n objects here have exactly k objects in common.
Then there are exactly m + n − k ways to substitute objects into x.

Corollary 10.1.9 (Inclusion–Exclusion Rule for three sets). Let A, B, C be finite sets. Then

|A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ B| − |B ∩ C| − |C ∩ A| + |A ∩ B ∩ C|.

Proof.

|A ∪ B ∪ C|
= |A| + |B ∪ C| − |A ∩ (B ∪ C)| by the Inclusion–Exclusion Rule for two sets;
= |A| + |B ∪ C| − |(A ∩ B) ∪ (A ∩ C)| by the Distributive Laws;
= |A| + |B| + |C| − |B ∩ C|
− |A ∩ B| − |A ∩ C| + |A ∩ B ∩ A ∩ C| by the Inclusion–Exclusion Rule for two sets;
= |A| + |B| + |C| − |A ∩ B|
− |B ∩ C| − |C ∩ A| + |A ∩ B ∩ C| by the set identity on idempotence.

Example 10.1.10. By the Inclusion–Exclusion Rule for three sets,

|{−1, 0} ∪ {0, 2, 3} ∪ {−1, 0, 1, 2}|


= |{−1, 0}| + |{0, 2, 3}| + |{−1, 0, 1, 2}| − |{−1, 0} ∩ {0, 2, 3}| − |{0, 2, 3} ∩ {−1, 0, 1, 2}|
− |{−1, 0, 1, 2} ∩ {−1, 0}| + |{−1, 0} ∩ {0, 2, 3} ∩ {−1, 0, 1, 2}|
= |{−1, 0}| + |{0, 2, 3}| + |{−1, 0, 1, 2}| − |{0}| − |{0, 2}| − |{−1, 0}| + |{0}|
= 2 + 3 + 4 − 1 − 2 − 2 + 1 = 5.

Exercise 10.1.11. There are 40 sets, of which 12 are countable and 31 are infinite. How  10b
many of them are both countable and infinite? Explain your answer.

10.2 Products and powers


Example 10.2.1. Let A = {a, b} and B = {1, 2, 3}. Then

|A × B| = |{(a, 1), (a, 2), (a, 3), (b, 1), (b, 2), (b, 3)}| = 6 = 2 × 3 = |A| × |B|.

1 (a, 1)
a 2 (a, 2)
3 (a, 3)

1 (b, 1)
b 2 (b, 2)
3 (b, 3)

Figure 10.3: The Cartesian product {a, b} × {1, 2, 3}

83
g1 (1) (f (1), g1 (1)) 1
g1 (2) (f (1), g1 (2)) 2
f (1) .. .. ..
. . .
g1 (n) (f (1), g1 (n)) n

g2 (1) (f (2), g2 (1)) n+1


g2 (2) (f (2), g2 (2)) n+2
f (2) .. .. ..
. . .
g2 (n) (f (2), g2 (n)) 2n

.. .. .. ..
. . . .

gm (1) (f (m), gm (1)) (m − 1)n + 1


gm (2) (f (m), gm (2)) (m − 1)n + 2
f (m) .. .. ..
. . .
gm (n) (f (m), gm (n)) mn

Figure 10.4: Proof of the General Multiplication Rule

Proposition 10.2.2 (General Multiplication Rule). Fix m, n ∈ N. Let A be a set of size m,


and for each x ∈ A, let Bx be a set of size n. Then {(x, y) : x ∈ A and y ∈ Bx } is finite and
has size mn.

Proof. Use our conditions on m and n to find bijections f : {1, 2, . . . , m} → A and gi : {1, 2, . . . , n} →
Bf (i) for each i ∈ {1, 2, . . . , m}. Then
 
h = (i − 1)n + j, (f (i), gi (j)) : i ∈ {1, 2, . . . , m} and j ∈ {1, 2, . . . , n}

is bijection {1, 2, . . . , mn} → {(x, y) : x ∈ A and y ∈ Bx }. This shows what we want.

Explanation of why h is a bijection in the proof above (extra material). Before


verifying bijectivity, let us check that h is indeed a function as claimed.

(F1) It suffices to prove that



∀u ∈ {1, 2, . . . , mn} ∃i ∈ {1, 2, . . . , m} ∃j ∈ {1, 2, . . . , n} u = (i − 1)n + j . (∗)

If m = 0 or n = 0, then mn = 0 and thus (∗) is vacuously true. So suppose m > 0 and n > 0.
We will proceed by induction on u.
(Base step) Note that 1 = (1 − 1)n + 1; so (∗) is true for u = 1.
(Induction step) Let v ∈ Z+ such that (∗) is true for u = v. We want to prove (∗)
for u = v + 1. If v + 1 > mn, then (∗) is vacuously true. So suppose v + 1 ⩽ mn, so that
v ⩽ mn−1 and thus v ∈ {1, 2, . . . , mn}. Use the induction hypothesis to find i ∈ {1, 2, . . . , m}
and j ∈ {1, 2, . . . , n} such that v = (i − 1)n + j. Then either i ⩽ m − 1 or j ⩽ n − 1, because
otherwise v = (i − 1)n + j = (m − 1)n + n = mn > mn − 1 ⩾ v, which is a contradiction.
Case 1: suppose j = n. Then i ⩽ m − 1. So

v + 1 = (i − 1)n + j + 1 = (i − 1)n + n + 1 = in + 1 = ((i + 1) − 1)n + 1,

84
where i + 1 ⩽ m.
Case 2: suppose j ⩽ n − 1. Then v + 1 = (i − 1)n + j + 1, where j + 1 ⩽ n.
Hence v + 1 = (i0 − 1)m + j0 for some i0 ∈ {1, 2, . . . , m} and j0 ∈ {1, 2, . . . , n}.
This completes the induction.

(F2) Let u ∈ {1, 2, . . . , mn} and i1 , i2 ∈ {1, 2, . . . , m} and j1 , j2 ∈ {1, 2, . . . , n} such that
(u, (f (i1 ), gi1 (j1 ))), (x, (f (i2 ), gi2 (j2 ))) ∈ h. Without loss of generality, assume i1 ⩾ i2 . Now
(i1 − 1)n + j1 = u = (i2 − 1)n + j2 according to the definition of h. As i1 ⩾ i2 and
j1 , j2 ∈ {1, 2, . . . , n}, this implies

j2 − j1 n−1
0 ⩽ i1 − i2 = ⩽ < 1.
n n
So i1 − i2 = 0 because i1 − i2 ∈ Z. Hence i1 = i2 , implying (i1 − 1)n + j1 = (i1 − 1)n + j2
and thus j1 = j2 . It follows that (f (i1 ), g(j1 )) = (f (i2 ), g(j2 )).

(Surjectivity) Take (x0 , y0 ) ∈ {(x, y) : x ∈ A and y ∈ Bx }. Then x0 ∈ A and y0 ∈ Bx0 .


Use the surjectivity of f and the gi ’s to find i0 ∈ {1, 2, . . . , n} and j0 ∈ {1, 2, . . . , m} such
that x0 = f (i0 ) and y0 = gi0 (j0 ). Then

1 = (1 − 1)n + 1 ⩽ (i0 − 1)n + j0 ⩽ (m − 1)n + n = mn


 
and h (i0 − 1)n + j0 = f (i0 ), gi0 (j0 ) = (x0 , y0 ).

(Injectivity) Take i1 , i2 ∈ {1, 2, . . . , m} and j1 , j2 ∈ {1, 2, . . . , m} such that


 
h (i1 − 1)n + j1 = h (i2 − 1)n + j2 .
 
In view of the definition of h, this means f (i1 ), gi1 (j1 ) = f (i2 ), gi2 (j2 ) Thus f (i1 ) = f (i2 )
and gi1 (j1 ) = gi2 (j2 ). The former implies i1 = i2 because f is injective. So the latter implies
j1 = j2 as gi1 is injective. ■

Combinatorial interpretation of the General Multiplication Rule. Let m, n ∈ N.


Suppose that in (x, y) the variable x can only take one of m objects, and possibly depending
on what x takes the variable y can only take one of n objects. Then there are exactly mn ways
to substitute objects into (x, y).

Corollary 10.2.3. Let n ∈ Z+ and m1 , m2 , . . . , mn ∈ N. Suppose that in (x1 , x2 , . . . , xn ),


• the variable x1 can only take one of m1 objects;

• possibly depending on what x1 takes, the variable x2 can only take one of m2 objects;
• possibly depending on what x1 , x2 take, the variable x3 can only take one of m3 objects;
• ...
• possibly depending on what x1 , x2 , . . . , xn−1 take, the variable xn can only take one of
mn objects.
Then there are exactly m1 m2 . . . mn ways to substitute objects into (x1 , x2 , . . . , xn ).

Proof. We proceed by induction on n.

85
(Base step) Clearly, if the variable x1 can only take one of m1 objects, then there are
exactly m1 ways to substitute objects into x1 .
(Induction step) Let k ∈ Z⩾2 such that the corollary is true for n = k. Suppose that
m1 , m2 , . . . , mk+1 ∈ N and in (x1 , x2 , . . . , xk+1 ),
• the variable x1 can only take one of m1 objects;
• possibly depending on what x1 takes, the variable x2 can only take one of m2 ob-
jects;
• possibly depending on what x1 , x2 take, the variable x3 can only take one of
m3 objects;
• ...
• possibly depending on what x1 , x2 , . . . , xk−1 take, the variable xk can only take
one of mk objects; and
• possibly depending on what x1 , x2 , . . . , xk take, the variable xk+1 can only take
one of mk+1 objects.
Then, by the induction hypothesis, there are m1 m2 . . . mk ways to substitute objects
into (x1 , x2 , . . . , xk ). It follows from the General Multiplication Rule that there are
m1 m2 . . . mk mk+1 ways to substitute objects into (x1 , x2 , . . . , xk , xk+1 ).
This completes the induction.

Corollary 10.2.4 (Multiplication Rule). Let A, B be finite sets and n ∈ Z⩾2 .

(1) A × B is finite and |A × B| = |A| × |B|.


n
(2) |An | = |A| .

Proof. (1) Apply the General Multiplication Rule with Bx = B for each x ∈ A.
(2) Applying part (1) repeatedly,
n
|An | = |A × A × · · · × A| = |A| × |A| × · · · × |A| = |A| .
| {z } | {z }
n-many A’s n-many |A|’s

Convention 10.2.5. Let A be a set and n ∈ N. Notationally, it is sometimes convenient to


identify an ordered n-tuple (a1 , a2 , . . . , an ) ∈ An with the string a1 a2 . . . an of length n. This
identification exploits the bijectivity of the function from An to the set of all strings over A
of length n mapping each (a1 , a2 , . . . , an ) ∈ An with a1 a2 . . . an .
Example 10.2.6. Let A = {1, 2, 3, 4, 5}. One can represent each subset S ⊆ A by the string
d1 d2 d3 d4 d5 over {0, 1} satisfying

i∈S ⇔ di = 1

for all i ∈ {1, 2, 3, 4, 5}. For instance,

{ } is represented by 00000;
{1, 3, 5} is represented by 10101;
{1,2, 4 } is represented by 11010;
{1,2,3,4,5} is represented by 11111.

As one can verify, this representation gives rise to a bijection P(A) → {0, 1}5 . So |P(A)| =
|{0, 1}5 | = 25 = 32 by Corollary 10.2.4(2).

86
Theorem 10.2.7. Let A be a finite set. Then P(A) is finite and |P(A)| = 2|A| .

Proof. Let n = |A| and A = {a1 , a2 , . . . , an }. As in Example 10.2.6, represent each subset
S ⊆ A by the string d1 d2 . . . dn over {0, 1} satisfying

ai ∈ S ⇔ di = 1

for all i ∈ {1, 2, . . . , n}. This representation gives rise to a bijection P(A) → {0, 1}n . So
|P(A)| = |{0, 1}n | = 2n by Corollary 10.2.4(2).

Combinatorial interpretation of Theorem 10.2.7. Let n ∈ N. Then the number of


ways to make n binary choices is 2n .

Remark 10.2.8. Like in the proof of Theorem 10.2.7, instead of counting the objects them-
selves, often it is more convenient to count suitably chosen representations of them instead.
Implicitly, each such representation is a bijection. Proofs of bijectivity are usually omit-
ted if they are straightforward and distracting. We will do the same. Nevertheless, the
representations themselves should be clearly formulated.

10.3 Permutations and combinations


Definition 10.3.1. Define 0! = 1 and (n + 1)! = (n + 1) × n! for all n ∈ N.

Remark 10.3.2. For every n ∈ N,

n! = n × (n − 1)! = n × (n − 1) × (n − 2)! = · · ·
= n × (n − 1) × · · · × 1 × 0! = n × (n − 1) × · · · × 1.

Definition 10.3.3. Let r, n ∈ N and Γ be a finite set.


(1) An r-permutation of Γ is a string of length r over Γ in which no symbol appears in two
different positions.
(2) Let P (n, r) denote the number of r-permutations of a set of size n.
(3) A permutation of Γ is a |Γ|-permutation of Γ.

Example 10.3.4. Let Γ = {E, I, L, N, S, T}.

(1) The 4-permutations of Γ include LNST, TELI, LINE, and SENT, but not any of SIT,
ABCD, SEEN, and NILET.
(2) The permutations of Γ include EILNST, TELSIN, LISTEN, and SILENT.
Remark 10.3.5. (1) One can view an r-permutation of a set Γ as a way to pick r elements
from Γ without replacement where order matters.
(2) One can view a permutation of a finite set Γ of size n as a way to arrange the n elements
of Γ into n positions.
(3) Some write n Pr or n Pr or Prn for P (n, r).

87
Theorem 10.3.6. For all r, n ∈ N,
n!

 , if r ⩽ n;
P (n, r) = (n − r)!
0, if r > n.

Proof. Fix a set Γ of size n.


Suppose there is some r-permutation of Γ, say a1 a2 . . . ar . As no symbol appears in
two different positions in an r-permutation, the function f : {1, 2, . . . , r} → Γ where each
f (i) = ai is an injection. So r = |{1, 2, . . . , r}| ⩽ |Γ| = n by the Pigeonhole Principle.
The paragraph above shows that, when r > n, there is no r-permutation of Γ, and thus
P (n, r) = 0. So let us concentrate on the case when r ⩽ n.
As no symbol appears in two different positions, the r-permutations are precisely those
x1 x2 . . . xr where
• x1 can only take one of the n elements of Γ, say a1 ;

• x2 can only take one of the n − 1 elements of Γ \ {a1 }, say a2 ;


• ...
• xr can only take one of the n − (r − 1) elements of Γ \ {a1 , a2 , . . . , ar−1 }, say ar .

So the General Multiplication Rule tells us that

P (n, r) = n × (n − 1) × · · · × (n − (r − 1))
n(n − 1) . . . (n − (r − 1))(n − r)(n − (r + 1)) . . . 1
=
(n − r)(n − (r + 1)) . . . 1
n!
= by Remark 10.3.2.
(n − r)!

Combinatorial interpretation of Theorem 10.3.6. Let r, n ∈ N.


n!
(1) If r ⩽ n, then there are exactly (n−r)! ways to pick r objects from n objects without
replacement where order matters.
(2) If r > n, then there is no way to pick r objects from n objects without replacement.

Corollary 10.3.7. Let Γ be a set of size n ∈ N. Then Γ has exactly n! permutations.

Proof. By Theorem 10.3.6, the number of permutations of Γ is


n! n! n!
P (n, n) = = = = n!.
(n − n)! 0! 1

Combinatorial interpretation of Corollary 10.3.7. Let n ∈ N. Then there are exactly


n! ways to arrange n objects into n positions.

Example 10.3.8. Let Γ = {E, I, L, N, S, T}. Note |Γ| = 6. So, according to Theorem 10.3.6
and Corollary 10.3.7,

88
6!
(1) the number of 4-permutations of Γ is P (6, 4) = (6−4)! = 6 × 5 × 4 × 3 = 360; and

(2) the number of permutations of Γ is 6! = 6 × 5 × 4 × 3 × 2 × 1 = 720.

Definition 10.3.9. Let Γ be a set and a1 a2 . . . an be a string over Γ. A permutation of


a1 a2 . . . an is a string over Γ of the form

af (1) af (2) . . . af (n)

where f is some bijection {1, 2, . . . , n} → {1, 2, . . . , n}.

Remark 10.3.10. (1) One can view a permutation of a string as a way to rearrange the
symbols in the string.
(2) Let n ∈ N and Γ be a set of size n, say Γ = {a1 , a2 , . . . , an }. Then the permutations of
the set Γ in the sense of Definition 10.3.3 are precisely the permutations of the string
a1 a2 . . . an in the sense of Definition 10.3.9.
Example 10.3.11. Here is a complete list of the permutations of the string EGG:

EGG, GEG, GGE.

To calculate (as opposed to count) the number of permutations of EGG, consider the set
Γ = {E, G1 , G2 }. Here is a complete list of the permutations of the set Γ:

EG1 G2 , G1 EG2 , G1 G2 E,
EG2 G1 , G2 EG1 , G2 G1 E.

Each permutation s of the string EGG corresponds to exactly 2! permutations of the set Γ
because one can arrange the 2 objects G1 , G2 into the 2 positions where G appears in s in
exactly 2! ways by (the combinatorial interpretation of) Corollary 10.3.7. Therefore, by the
General Multiplication Rule,
     
number of number of number of ways to
permutations = permutations × arrange G1 , G2 into .
of Γ of EGG 2 positions
 
number of
∴ 3! = permutations × 2!.
of EGG
3!
From this, we see that the number of permutations of EGG is 2! = 6/2 = 3.
Exercise 10.3.12. How many permutations of the string BICONDITIONAL are there?  10c
Explain your answer.

Definition 10.3.13. Let r, n ∈ N and A be a finite set.


(1) An r-combination of A is a subset of A of size r.

(2) Let nr denote the number of r-combinations of a set of size n. We read n


 
r as “n
choose r”.

Remark 10.3.14. (1) One can view an r-combination of a set A as a way to pick r ele-
ments from A without replacement where order does not matter.

(2) Some write C(n, r) or n Cr or n Cr or Crn for nr .




89
Theorem 10.3.15. For all r, n ∈ N,
n!

, if r ⩽ n;
  
n
= r! (n − r)!
r
0, if r > n.

Proof. Let A be a set of size n, say {a1 , a2 , . . . , an }.


Let S ⊆ A. Then S is finite by Proposition 9.2.6(1). Also, the function f : S → A where
each f (x) = x is an injection. So |S| ⩽ |A| by the Pigeonhole Principle.
n
 The paragraph above shows that, when r > n, there is no subset of A of size r, and thus
r = 0. So let us concentrate on the case when r ⩽ n.
As in the proof of Theorem 10.2.7, represent each subset S ⊆ A by the string d1 d2 . . . dn
over {0, 1} satisfying
ai ∈ S ⇔ di = 1
for all i ∈ {1, 2, . . . , n}. Under this representation, subsets of A of size r are represented
precisely by strings over {0, 1} of length n with exactly r-many 1’s and (n − r)-many 0’s,
i.e., by the permutations of the string
(n − r)-many 0’s
z }| {
11 . . . 1}00 . . . 0
| {z
r-many 1’s

As in Example 10.3.11, the number of such permutations is

number of permutations of
{11 , 12 , . . . , 1r , 01 , 02 , . . . , 0n−r } n!
   =
number of ways to arrange number of ways to arrange r! (n − r)!
11 , 12 , . . . , 1r into  × 01 , 02 , . . . , 0n−r into 
r positions n − r positions

by the General Multiplication Rule and Corollary 10.3.7.

Combinatorial interpretation of Theorem 10.3.15. Let r, n ∈ N.


n!
(1) If r ⩽ n, then there are exactly (n−r)! r! ways to pick r objects from n objects without
replacement where order does not matter.
(2) If r > n, then there is no way to pick r objects from n objects without replacement.

Technique 10.3.16 (counting argument). One way to prove k = ℓ, where k, ℓ ∈ N, is to


find two ways of counting the number of elements of the same finite set, the first of which
results in k and the second results in ℓ.

Tutorial exercises
An asterisk (*) indicates a more challenging exercise.
10.1. The Inclusion–Exclusion Rule tells us how one can calculate the size of the union of
finitely many finite sets from the sizes of the intersections between these sets. We saw
how this is done for two sets and for three sets in Theorem 10.1.7 and in Corollary 10.1.9.
State and prove an Inclusion–Exclusion Rule for four sets.

90
10.2. Fix m, n ∈ Z+ . Let A be a set of size m and B be a set of size n.
(a) How many relations are there from A to B?
(b) How many functions are there from A to B?
(c)∗ In the case when |B| = 3, how many surjections are there from A to B?
(d) How many injections are there from A to B?
(e) How many bijections are there from A to B?
Briefly explain your answers.
10.3. Pascal’s Formula states that: for all r, n ∈ Z+ with r ⩽ n,
     
n n n+1
+ = .
r r−1 r

(a) Prove Pascal’s Formula algebraically.


(b) Prove Pascal’s Formula using a counting argument.
10.4. Consider the following proposition.
       
0 1 n n+1
∀r, n ∈ N + + ··· + = .
r r r r+1

(a) (Induction corner) Prove the proposition above algebraically by induction.


(b) Prove the proposition above using a counting argument.

Extra exercises
10.5. Fix m ∈ Z+ . Let A be a set of size m.
(a) How many relations are there on A?
(b) How many reflexive relations are there on A?
(c) How many symmetric relations are there on A?
(d) How many antisymmetric relations are there on A?
Briefly explain your answers.

91
CS1231 Chapter 11

Graphs

11.1 Paths
Warning 11.1.1. There are several commonly used, conflicting sets of terminologies for
graphs. Always check the definitions being used when looking into the literature.

Definition 11.1.2. Let G be an undirected graph, where G = (V, E).


(1) Denote by V(G) and E(G) the set of all vertices and the set of all edges in G respectively,
i.e.,
V(G) = V and E(G) = E.

(2) When there is no risk of ambiguity, we may write an edge {x, y} as xy.

(3) The graph G is finite if V(G) is finite, else it is infinite.

Definition 11.1.3. Let G, H be undirected graphs,.


(1) We say that H is a subgraph of G, or G contains H (as a subgraph), if V(H) ⊆ V(G)
and E(H) ⊆ E(G).

(2) A proper subgraph of G is a subgraph H of G such that H ̸= G.

Example 11.1.4. Consider the graph G, where

V(G) = {b, d, h, k, m, s},


E(G) = {bd, bh, bs, ds, hk, hs, ks, mm, ss}.

Here is a drawing of G.
b d

s m

h k

The graphs G1 , G2 , where

V(G1 ) = {b, d, h, k, m, s}, V(G2 ) = {b, d, h, m, s},


E(G1 ) = {bd, bs, hk, hs}, E(G2 ) = {bd, bh, ds, hs, mm},

92
are subgraphs of G. Here are drawings of G1 and G2 respectively.

b d b d

s m h m

h k s

The graph G3 , G4 , where

V(G3 ) = {1, 2, 3, 4, 5, 6}, V(G4 ) = {b, d, h, m, s},


E(G3 ) = {12, 13, 24, 35}, E(G4 ) = {bd, bs, dh, hs, mm},

are not subgraphs of G because V(G3 ) ̸⊆ V(G) and E(G4 ) ̸⊆ E(G). Here are drawings of G3
and G4 respectively.

2 4 b d

1 6 s m

3 5 h

Definition 11.1.5. Let G be an undirected graph, and u, v be vertices in G. A path between


u and v in G is a subgraph of G of the form

{x0 , x1 , . . . , xℓ }, {x0 x1 , x1 x2 , . . . , xℓ−1 xℓ } ,

where the x’s are all different and ℓ ∈ N, satisfying u = x0 and v = xℓ . Here ℓ is called the
length of the path. When there is no risk of ambiguity, we may denote the subgraph above
by x0 x1 . . . xℓ .

Remark 11.1.6. (1) Informally speaking, a path links two vertices in a graph via a se-
quence of edges, each joined to the next, that has no repeated vertex.
(2) Some consider paths of infinite length. We do not.
Example 11.1.7. Consider the graph G from Example 5.3.8. Define

P = dbshk and Q = dshb.

Then P is a path of length 4 between d and k in G, and Q is a path of length 3 between b


and d in G. Here are drawings of P and Q respectively.

b d b d

s s

h k h

The graphs H1 and H2 , where

H1 = dbsshk and H2 = bshksd

are not paths in G because s is in three edges in H1 , and four edges in H2 . (Note that each
vertex in a path is in at most two edges in the path.) Here are drawings of H1 and H2

93
respectively.

b d b d

s s

h k h k

Remark 11.1.8. Consider again the graph G from Example 5.3.8.


(1) The subgraph ({s}, {}), which we may write as s, is a path of length 0 in G. It is
essentially the vertex s with no edge, not even a loop.
(2) The subgraph ({s, h}, {sh}), which we may write as sh, is a path of length 1 in G. It is
essentially the edge sh.

s s

Figure 11.1: A path of length 0 (left) and a path of length 1 (right)

Exercise 11.1.9. How many paths are there between 1 and 3 in the undirected graph G  11a
with the following drawing?
3 c

2 b

1 a

Briefly explain your answer.

Lemma 11.1.10. Let G be an undirected graph and u, v, w be vertices in G. Suppose there


are a path P between u and v in G, and a path Q between v and w in G. Then there is a
path between u and w in G.

u = x0
P

ys+1 ys
xt

... v = xk = y0
Q
w = yℓ ...

Figure 11.2: Combining paths

94
Proof. Let P = x0 x1 . . . xk and Q = y0 y1 . . . yℓ , so that k, ℓ ∈ N and

x0 = u, xk = v = y0 , w = yℓ .

As xk = y0 ∈ V(Q), we know some t ∈ {0, 1, . . . , k} satisfies xt ∈ V(Q). Let t be the smallest


element of {0, 1, . . . , k} such that xt ∈ V(Q). By the smallestness of t, none of x0 , x1 , . . . , xt−1
is in V(Q). So if s ∈ {0, 1, . . . , ℓ} such that xt = ys , then

x0 x1 . . . xt ys+1 ys+2 . . . yℓ

is a path between u and w in G.


Remark 11.1.11. In the proof of Lemma 11.1.10 above, the existence of the required t is
guaranteed by the Well-Ordering Principle. In more details, we know k is an element of

{t ∈ {0, 1, . . . , k} : xt ∈ V(Q)}.

This set is thus a nonempty subset of N, and hence must have a smallest element by the
Well-Ordering Principle. Similar applications of the Well-Ordering Principle can be found in
the proof of Theorem 11.2.5 below.

11.2 Cycles
Definition 11.2.1. Let G be an undirected graph.
(1) A cycle in G is a subgraph of G of the form

{x1 , x2 , . . . , xℓ }, {x1 x2 , x2 x3 , . . . , xℓ−1 xℓ , xℓ x1 } ,

where the x’s are all different and ℓ ∈ N⩾3 . Here ℓ is called the length of the cycle.
When there is no risk of ambiguity, we may denote the subgraph above by x1 x2 . . . xℓ x1 .
(2) An undirected graph is cyclic if it has a loop or a cycle; else it is acyclic.

Remark 11.2.2. (1) Informally speaking, a cycle in a graph is a sequence of at least three
edges, each joined to the next, and the last joined to the first, that has no repeated
vertex.
(2) By definition, a cycle has at least three vertices (and thus at least three edges). There-
fore, in no sense can a loop be a cycle.
Example 11.2.3. Consider the graph G from Example 5.3.8. Define the graphs C, D by

C = shks and D = sdbhs.

Then C is a cycle of length 3 in G, and D is a cycle of length 4 in G. Here are drawings of


C and D respectively.

b d

s s

h k h

The graphs H3 and H4 , where

H3 = shs and H4 = bshksdb,

95
are not cycles in G because H3 has only two vertices, and s is in four different edges in H4 .
(Note that every cycle by definition has at least three vertices, and each vertex in a cycle is
in exactly two edges in the cycle.) Here are drawings of H3 and H4 respectively.

b d

s s

h h k

Example 11.2.4. (1) The graphs H1 and H2 from Example 11.1.7 are both cyclic because
the former has a loop {a} and the latter has a cycle C as defined in Example 11.2.3.
(2) The graph G1 from Example 11.1.4 and the graph Q from Example 11.1.7 are acyclic.

Theorem 11.2.5. An undirected graph with no loop is cyclic if and only if it has two vertices
between which there are two distinct paths.

yt
xr
xs
P
xr−1
u ... v
yr−1
Q
yr ...

Figure 11.3: Constructing a cycle from two paths between u and v

Proof. Let G be an undirected graph with no loop.


(⇒) Assume G is cyclic. According to the definition of cyclic graphs, as G has no loop,
it must have a cycle, say,
x1 x2 . . . xℓ x1 .
From this, we find two paths between x1 and xℓ :

x1 xℓ and x1 x2 . . . xℓ .

These two paths are distinct because the first one has two vertices and the second one has
at least three vertices as ℓ ⩾ 3.
(⇐) Let u, v ∈ V(G) with two distinct paths between them, say,

P = x0 x1 . . . xk and Q = y0 y1 . . . yℓ ,

where x0 = u = y0 and xk = v = yℓ . If the two paths are of different lengths, then let us use
the name Q for the longer of the two paths. This makes k ⩽ ℓ.
As P ̸= Q, we know xi ̸= yi for some i ∈ {0, 1, . . . , k}. Let r be the smallest element
of {0, 1, . . . , k} such that xr ̸= yr . Here r ̸= 0 because x0 = y0 . So the smallestness of r
tells us xr−1 = yr−1 . It follows that amongst xr−1 , yr−1 , xr , yr , only xr−1 and yr−1 are equal
because all the x’s are different and all the y’s are different.
Recall xk = yℓ . So some s ∈ {r, r + 1, . . . , k} makes xs ∈ {yr , yr+1 , . . . , yℓ }. Let s be the
smallest element of {r, r + 1, . . . , k} that makes xs ∈ {yr , yr+1 , . . . , yℓ }. By the smallestness
of s, none of xr , xr+1 , . . . , xs−1 is equal to any of yr , yr+1 , . . . , yℓ .

96
Let t ∈ {r, r + 1, . . . , ℓ} that makes xs = yt . As xr ̸= yr , either s ̸= r or t ̸= r. So

xr−1 xr . . . xs yt−1 yt−2 . . . yr yr−1

has at least three vertices, and thus is a cycle in G.

Explanation of why xi ̸= yi for some i ∈ {0, 1, . . . , k} in the proof above (extra


material).. Suppose not. Then xi = yi for all i ∈ {0, 1, . . . , k}. In particular, this tells us
yℓ = v = xk = yk . So k = ℓ as the y’s are all different. This implies P = Q, which contradicts
our condition that P and Q are distinct, as required. ■

11.3 Connectedness
Definition 11.3.1. An undirected graph is connected if there is a path between any two
vertices.

Example 11.3.2. (1) The graphs H1 , H2 from Example 11.1.7 are connected, as one can
verify exhaustively.
(2) The graphs G1 , G2 from Example 11.1.4 are not connected, because there is no path
between d and m in G1 and in G2 .
Exercise 11.3.3. Which of the following are drawings of connected graphs?  11b
(a) (b) (c) (d)

Definition 11.3.4. Let G be an undirected graph. A connected component of G is a maximal


connected subgraph of G, i.e., it is a connected subgraph H of G such that no connected
subgraph of G contains H as a proper subgraph.

Example 11.3.5. Consider the graph G from Example 11.1.4. The following are respectively
drawings of two connected components Hs and Hm of G.

b d

s m

h k

The graph G1 from Example 11.1.4 is not a connected component of G because it is not
connected. The graph D from Example 11.2.3 is not a connected component of G because it
is a subgraph of the connected subgraph Hs of G above with two fewer edges ss and bh.

Proposition 11.3.6. Let G be an undirected graph. Then every vertex v in G is in some


connected component of G.

Proof. Define the subgraph H of G by setting

V(H) = {x ∈ V(G) : there is a path between v and x in G} and


E(H) = {xy ∈ E(G) : x, y ∈ V(H)}.

97
We know v ∈ V(H) because ({v}, {}) is a path between v and v. To finish the proof, we
show that H is a connected component of G.
For connectedness, let a, b ∈ V(H). By Tutorial Exercise 11.6, in H, there is a path
between v and a, and there is a path between v and b. Lemma 11.1.10 then gives us a path
between a and b in H.
Let H + be a connected subgraph of G contains H as a subgraph. We want to show
H = H. The definition of subgraphs tells us already V(H) ⊆ V(H + ) and E(H) ⊆ E(H + ).
+

So it remains to show V(H + ) ⊆ V(H) and E(H + ) ⊆ E(H).


Take any x ∈ V(H + ). As v ∈ V(H) ⊆ V(H + ) and H + is connected, there is a path
between v and x in H + , hence in G. So x ∈ V(H) by the definition of V(H).
Take any xy ∈ E(H + ). Then x, y ∈ V(H + ) ⊆ V(H) by the previous paragraph. As
xy ∈ E(H + ) ⊆ E(G), the definition of E(H) tells us xy ∈ E(H).

Theorem 11.3.7. Let u, v be vertices in an undirected graph G. Then there is a path


between u and v in G if and only if there is a connected component of G that has both u
and v in it.

a Q2
Hu b

Q1

u v

Figure 11.4: A connected component plus a path

Proof. (⇒) Assume there is a path between u and v in G, say,


P = x0 x1 . . . xℓ ,
where u = x0 and v = xℓ . Use Proposition 11.3.6 to finda connected component Hu of G
that has u in it. Define H = V(Hu ) ∪ V(P ), E(Hu ) ∪ E(P ) . We claim that H is a connected
subgraph of G. From this, we will deduce H = Hu using the maximality of the connected
component Hu ; thus v ∈ V(P ) ⊆ V(H) = V(Hu ).
Take a, b ∈ V(H). As V(H) = V(Hu ) ∪ V(P ), we have three cases.
Case 1: suppose a, b ∈ V(Hu ). As Hu is connected, there is a path between a and b in Hu ,
hence in H.
Case 2: suppose a, b ∈ V(P ). Say a = xr and b = xs , where r ⩽ s. Then a path between
a and b in H is xr xr+1 . . . xs .
Case 3: suppose one of a, b is in Hu and another is in P . Say a ∈ V(Hu ) and b ∈
V(P ). On the one hand, as Hu is connected, and a, u ∈ V(Hu ), one can find a path,
say Q1 , between a and u in Hu , hence in H. On the other hand, if b = xt where
t ∈ {0, 1, . . . , ℓ}, then Q2 = x0 x1 . . . xt a path between u and b in H. Combining Q1
and Q2 using Lemma 11.1.10, we get a path between a and b in H.

98
(⇐) Assume there is a connected component, say H, of G that has both u and v in it.
As H is connected, there is a path between u and v in H, hence in G.

Tutorial exercises
An asterisk (*) indicates a more challenging exercise.
11.1. Let us look into the notion of complete graphs. Fix n ∈ N.
Definition. A complete graph on n vertices, denoted Kn , is an undirected graph, with
exactly n vertices and with no loop, in which there is an edge between any pair of
distinct vertices.

(a) Draw K1 , K2 , K3 , and K4 . There is no need to label the vertices in your drawings.
(b) How many edges are there in Kn ? Explain your answer briefly.

11.2. Consider the undirected graphs G with V(G) = {a, b, c}.

(a) How many such graphs are there?


(b) How many of them have no loop?
(c) How many of them have a cycle?
(d) How many of them are cyclic?

Briefly explain your answers.


11.3. Two graphs of the same shape are considered unequal if their vertices are labelled
differently. This is sometimes undesirable. Sometimes we want to consider two graphs
as the same if (and only if) they are equal after a relabelling of the vertices. This notion
of sameness is called isomorphism in mathematics.

Definition. An isomorphism from an undirected graph G1 to an undirected graph G2


is a bijection f : V(G1 ) → V(G2 ) such that for all x, y ∈ V(G1 ),

{x, y} ∈ E(G1 ) ⇔ {f (x), f (y)} ∈ E(G2 ).

An undirected graph G1 is said to be isomorphic to an undirected graph G2 if there is


an isomorphism from G1 to G2 .
Example. The following are drawings of isomorphic graphs:

1 2 3 1

4 3 2 4

One isomorphism from the left graph to the right graph is the function f : {1, 2, 3, 4} →
{1, 2, 3, 4} satisfying

f (1) = 3, f (2) = 1, f (3) = 4, f (4) = 2.

It can be verified as in Tutorial Exercise 8.3 that the isomorphism relation on a set of
graphs is an equivalence relation.

99
(a) Which of the graphs drawn below are isomorphic? Which are not isomorphic?

1 2 1 2 1 2 3 2
6 7 6 7 5 6 4 1

8 3 8 3 8 7 5 8
5 4 5 4 4 3 6 7

(i) (ii) (iii) (iv)

Briefly explain your answer.


(b) Let n ∈ {2, 3, 4}. How many undirected graphs are there with exactly n vertices
and with no loop if we count isomorphic graphs as one?

11.4. The aim of this exercise is to investigate in what sense the connected components form
a partition of an undirected graph.
(a) Is it true that, for all undirected graphs G with at least one vertex, the set {V(H) :
H is a connected component of G} is a partition of V(G)?
(b) Is it true that, for all undirected graphs G with at least one edge, the set {E(H) :
H is a connected component of G} is a partition of E(G)?
Prove that your answers are correct.
11.5. In this exercise, we look into the relationship between an undirected graph with no loop
and its complement, in the sense defined below.
Definition. The complement of an undirected graph G with no loop, denoted G, is the
undirected graph with no loop defined by V(G) = V(G) and, for all distinct x, y ∈ V(G),

xy ∈ E(G) ⇔ xy ̸∈ E(G).

(a) Consider the graph whose drawing is as follows.

3 2

4 1

5 6

Draw the complement of this graph.



(b) Prove that, for all undirected graphs G with at least one vertex but with no loop,
either G is connected or G is connected.

11.6. The aim of this exercise is to fill a small gap in the proof of Proposition 11.3.6: when
showing connectedness there, it is clear that we get the desired paths in the bigger
graph, but it is less clear why we get the same in the subgraph. Here we analyze the
situation by splitting the subgraph into layers.
(Induction corner) Fix an undirected graph G and v ∈ V(G). For each n ∈ N, define a
subgraph Hn of G by setting

V(Hn ) = {x ∈ V(G) : there is a path of length at most n between v and x in G}, and
E(Hn ) = {xy ∈ E(G) : x, y ∈ V(Hn )}.

Prove by induction that, for every n ∈ N and every x ∈ V(Hn ), there is a path between
v and x in Hn .

100
Extra exercises
11.7. We verify in this exercise that a connected component of an undirected graph must
inherit all the possible edges from that graph.
Let G be an undirected graph, and H be a connected component of G. Prove that

E(H) = {xy ∈ E(G) : x, y ∈ V(H)}.

11.8. Intuitively, undirected graphs that have many edges relative to the number of vertices
must be connected. In this exercise, we investigate what “many” may mean here.

(a)∗ Let n ∈ N and G be an undirected graph with exactly n vertices and with no loop.
Prove that, if |E(G)| > n−1

2 , then G is connected.
(b) How many connected undirected graphs are there with exactly 4 vertices and with
no loop in which the number of edges is at most 4−1

2 if we count isomorphic
graphs as one?

101
CS1231 Chapter 12

Trees

12.1 Characterizations
Definition 12.1.1. A tree is a connected acyclic undirected graph.

Example 12.1.2. The following are drawings of trees.

b d b d

s m s m

h k h k

One can redraw these respectively as follows.

s s

h k b d k b

m h m d

Proposition 12.1.3. An undirected graph with no loop is a tree if and only if between any
two vertices there is exactly one path in the graph.

Proof. Being connected is by definition equivalent to having at least one path between
any two vertices. For an undirected graph with no loop, being acyclic is by Theorem 11.2.5
equivalent to having at most one path between any two vertices. The proposition then follows
from the definition of trees.

Theorem 12.1.4. A connected undirected graph G is a tree if and only if removing any
edge disconnects G, i.e., for every e ∈ E(G), the graph (V(G), E(G) \ {e}) is not connected.

Proof. (⇒) Suppose G is a tree. Take any uv ∈ E(G). Being acyclic, we know G has no
loop. So u ̸= v, and thus uv is a path between u and v in G. In view of Proposition 12.1.3,
this is the only path between u and v in G. Hence in (V(G), E(G) \ {uv}) there is no path
between u and v. This shows (V(G), E(G) \ {uv}) is not connected.
(⇐) We prove this by contraposition. Suppose G is not a tree. As G is connected, we
deduce that G must be cyclic. If G has a loop, say uu ∈ E(G), then (V(G), E(G) \ {uu})

102
x1
P ×
a
xk
b

Figure 12.1: Removing an edge from a cycle

remains connected because by definition no path can have a loop. So suppose G has a cycle,
say x1 x2 . . . xk x1 . We show that (V(G), E(G) \ {x1 xk }) remains connected; this will imply
what we want.
Take any a, b ∈ V(G). We want a path between a and b in (V(G), E(G) \ {x1 xk }). Use
the connectedness of G to find a path P = y0 y1 . . . yℓ in G where y0 = a and yℓ = b.

Case 1: suppose x1 xk ̸∈ E(P ). Then P is a path between a and b in (V(G), E(G)\{x1 xk }).
Case 2: suppose x1 xk ∈ E(P ). Swapping a and b if needed, say x1 = yr and xk = yr+1 .
Now in (V(G), E(G) \ {x1 xk }),
• between a and yr there is a path y0 y1 . . . yr ;
• between yr and yr+1 there is a path x1 x2 . . . xk ;
• between yr+1 and b there is a path yr+1 yr+2 . . . yℓ .
So two applications of Lemma 11.1.10 give us a path between a and b in (V(G), E(G) \
{x1 xk }).

Exercise 12.1.5. Which proof technique(s) is/are used in our proof of Theorem 12.1.4?  12a

Theorem 12.1.6. Let G be a finite tree with at least one vertex. Then |E(G)| = |V(G)| − 1.

Proof. We proceed by strong induction on the number of vertices in G.

(Base step) Let G be a tree with exactly one vertex. Note that G cannot have a loop
because this would make G cyclic. So G cannot have any edge. Thus |E(G)| = 0 =
1 − 1 = |V(G)| − 1.
(Induction step) Let k ∈ Z+ such that the equation holds for all trees with at most
k vertices. Consider a tree G with exactly k + 1 vertices. As k ⩾ 1, we know G has
at least 1 + 1 = 2 vertices. Being a tree, the graph G must be connected. So G must
have an edge, say uv, where u ̸= v. Define Guv = (V(G), E(G) \ {uv}). Then Guv is
not connected by Theorem 12.1.4.
Apply Proposition 11.3.6 to find connected components Hu , Hv of Guv with u ∈ V(Hu )
and v ∈ V(Hv ). These two connected components are distinct, and they are the only
connected components of Guv .
On the one hand, by the definition of connected components, we know Hu , Hv are
connected. On the other hand, both Hu , Hv are subgraphs of Guv and thus of G. As G
is acyclic, both Hu and Hv must also be acyclic. Putting these together, we conclude
that Hu and Hv are both trees. Since Hu ̸= Hv , we know v ̸∈ V(Hu ) and u ̸∈ V(Hv )
by Tutorial Exercise 11.4(a). Thus, by the Difference Rule,

|V(Hu )| ⩽ |V(G) \ {v}| = |V(G)| − |{v}| = (k + 1) − 1 = k,

103
and similarly |V(Hv )| ⩽ k. Hence the induction hypothesis tells us |E(Hu )| = |V(Hu )|−
1 and |E(Hv )| = |V(Hv )| − 1. Therefore, by the Addition Rule,

|E(G)| = |E(Hu )| + |{uv}| + |E(Hv )|


 
= |V(Hu )| − 1 + 1 + |V(Hv )| − 1 = |V(G)| − 1.

This completes the induction.

Hu u v Hv

mu vertices mv vertices
mu − 1 edges mv − 1 edges

mu + mv vertices
mu + mv − 1 edges

Figure 12.2: Induction step in the proof of Theorem 12.1.6

Exercise 12.1.7. Which proof technique(s) is/are used in our proof of Theorem 12.1.6?  12b

Explanation of why G has an edge uv with u ̸= v in the proof above (extra


material). We know G has at least two vertices. Between these two distinct vertices, there
is a path by connectedness. To connect two distinct vertices, this path must have at least
one edge uv where u ̸= v. ■

Explanation of why Hu ̸= Hv in the proof above (extra material). As u ̸= v, we


know uv is a path between u and v in G. In view of Proposition 12.1.3, this is the only path
between u and v in G because G is a tree. Hence in Guv there is no path between u and v.
So Hu ̸= Hv by Theorem 11.3.7. ■

Explanation of why Hu , Hv are the only connected components of Guv in the proof
above (extra material). Take any connected component H of Guv . As Guv has at least
two vertices, namely u, v, we know from Tutorial Exercise 11.4(a) that V(H) ̸= ∅. Pick
a ∈ V(H). Use the connectedness of G to find a path P = x0 x1 . . . xℓ in G where x0 = a and
xℓ = v.
Case 1: suppose uv ̸∈ E(P ). Then P is a path between a and v in Guv . So there is some
connected component, say Ha,v , with both a and v in it by Theorem 11.3.7. In view of
Tutorial Exercise 11.4(a), we must have H = Ha,v = Hv because a ∈ V(H) ∩ V(Ha,v )
and v ∈ V(Ha,v ) ∩ V(Hv ).
Case 2: suppose uv ∈ E(P ). Then u = xℓ−1 because v = xℓ . So x0 x1 . . . xℓ−1 is a path
between a and u in Guv . As in the previous case, Theorem 11.3.7 then gives some
connected component, say Ha,u , with both a and u in it. In view of Tutorial Ex-
ercise 11.4(a), we must have H = Ha,u = Hu because a ∈ V(H) ∩ V(Ha,u ) and
u ∈ V(Ha,u ) ∩ V(Hu ).

104
Thus H = Hu or H = Hv in all cases. ■

Theorem 12.1.8. Let G be a connected cyclic finite undirected graph. Then |E(G)| ⩾
|V(G)|.

Proof. Let G be a connected cyclic finite undirected graph. Then the definition of cyclicity
tells us that G contains either a loop or a cycle. Run the following procedure.
1. If G has a loop, then set H0 = ({u}, {uu}) where uu ∈ E(G); else set H0 to be any
cycle in G.
// Note that |V(H0 )| = |E(H0 )| ⩾ 1 in either case.
2. Initialize i = 0.
3. While V(G) \ V(Hi ) ̸= ∅ do:

3.1. Use the connectedness of G to find a path Pi = xi0 xi1 . . . xiℓi in G where xi0 ̸∈ V(Hi )
and xiℓi ∈ V(Hi ).
// Note that this implies ℓi ⩾ 1.
3.2. Set ri to be the smallest element of {1, 2, . . . , ℓi } such that xiri ∈ V(Hi ).
// Such ri exists by the Well-Ordering Principle because ℓi ∈ {1, 2, . . . , ℓi } and
xiℓi ∈ V(Hi ).

3.3. Set Hi+1 = V(Hi ) ∪ {xiri −1 }, E(Hi ) ∪ {xiri −1 xiri } .
// Note that xiri −1 ̸∈ V(Hi ) by the smallestness of ri . So |V(Hi+1 )| = |V(Hi )| +
1 = |E(Hi )| + 1 = |E(Hi+1 )|.
3.4. Increment i to i + 1.

This procedure must stop after finitely many steps because G is finite. Then a run results
in H0 , H1 , . . . , Hk where k ∈ N. Notice V(Hk ) = V(G) as the stopping condition is reached.
So, as each Hi is a subgraph of G,

|E(G)| ⩾ |E(Hk )| = |V(Hk )| = |V(G)|.

b b d b d b d b d
s → s → s → s m → s m

h h h k h k h k
#vertices = 3 #vertices = 4 #vertices = 5 #vertices = 6 #vertices = 6
#edges = 3 #edges = 4 #edges = 5 #edges = 6 #edges ⩾ 6

Figure 12.3: A run of the procedure in the proof of Theorem 12.1.8 from a cycle

Exercise 12.1.9. Which proof technique(s) is/are used in our proof of Theorem 12.1.8?  12c

105
b b b
m → m → s m → s m

h
#vertices = 1 #vertices = 2 #vertices = 3 #vertices = 4
#edges = 1 #edges = 2 #edges = 3 #edges = 4

b d b d b d
→ s m → s m → s m

h h k h k
#vertices = 5 #vertices = 6 #vertices = 6
#edges = 5 #edges = 6 #edges ⩾ 6

Figure 12.4: A run of the procedure in the proof of Theorem 12.1.8 from a loop

Corollary 12.1.10. The following are equivalent for all finite undirected graphs G with at
least one vertex.

(i) G is a tree, i.e., it is connected and acyclic.


(ii) G has no loop, and between any two vertices there is exactly one path in G.
(iii) G is connected, and removing any edge disconnects G.

(iv) G is connected and |E(G)| = |V(G)| − 1.


(v) G is acyclic, and adding any new edge makes G cyclic.
(vi) G is acyclic and |E(G)| = |V(G)| − 1.

Proof. The equivalence of (i) and (ii) is Proposition 12.1.3. The equivalence of (i) and (iii)
is Theorem 12.1.4. The equivalence of (i) and (iv) follows from Theorem 12.1.6 and Theo-
rem 12.1.8. In a similar way, the equivalence of (i) and (vi) follows from Theorem 12.1.6 and
Tutorial Exercise 12.4. The equivalence of (i) and (v) is Tutorial Exercise 12.3.

12.2 Roots
Definition 12.2.1. A rooted tree is a tree with a distinguished vertex called the root. In a
finite rooted tree,
(1) the height is the length of a longest path between the root and some vertex;

(2) every vertex y except the root has a parent, which is defined to be the vertex x such
that the edge xy is in the path (unique by Proposition 12.1.3) between y and the root;
(3) a vertex y is said to be a child of a vertex x if x is the parent of y;
(4) a terminal vertex or a leaf is a vertex with no child;

(5) an internal vertex or a parent is a vertex that is not terminal.

Example 12.2.2. Here are drawings of the left tree in Example 12.1.2 with different choices

106
of roots drawn at the top.

s m b

h k b d b s m

m s h k d

h k d

h k d

s s s

k d b d h b h k b

m m m
In the first tree where s is the root,
(1) s is a parent of h, k, b, d but not of m;

(2) h, k, b, d are children of s, but m is not.

– root

height 2 – internal vertex

– terminal vertex

Figure 12.5: Illustrations of some terms for rooted trees

Proposition 12.2.3. Let T be a finite rooted tree of height h in which every vertex has at
most two children. Then T has at most 2h terminal vertices.

Figure 12.6: Counting terminal vertices in a rooted tree

Proof. As there is a unique path between the root and any terminal vertex in view of
Proposition 12.1.3, we may equivalently count the paths x0 x1 . . . xℓ where x0 is the root and
xℓ is a terminal vertex. By the definition of heights, such ℓ ⩽ h. For each i ∈ {1, 2, . . . , h}
such that x1 , x2 , . . . , xi−1 are chosen,

• if xi−1 has no child, then xi−1 is already a terminal vertex, and thus there is no xi ;
• if xi−1 has a child, then xi−1 has one or two children by assumption, and xi must be
one of these children.

107
Here, if xi−1 has a child, then there must be an xi , because otherwise xℓ = xi−1 , which is
not a terminal vertex. Therefore, by Corollary 10.2.3, there are at most

2 × 2 × · · · × 2 = 2h
| {z }
h-many 2’s

such paths.
Exercise 12.2.4. Which proof technique(s) is/are used in our proof of Proposition 12.2.3?  12d

Theorem 12.2.5. Let T be a finite rooted tree in which every internal vertex has exactly
two children. If T has exactly t terminal vertices, then T has exactly t − 1 internal vertices
and thus exactly 2t − 1 vertices in total.

−1

−1 −1

−1 +1 −1 −1

−1 −1 +1 −1 +1 +1

+1 +1 +1 +1 +1 +1

Figure 12.7: Internal versus terminal vertices

Proof. Denote by i the number of internal vertices in T . By definition, every vertex is either
internal or terminal, but not both. So T has exactly i + t vertices by the Addition Rule. We
count in two different ways the number of elements in

{(x, y) ∈ V(G)2 : y is a child of x in T }.

• The variable x can only take one of i internal vertices, and then the variable y can only
take one of the two children the internal vertex chosen. So there are exactly 2i ways to
substitute objects into (x, y) by the General Multiplication Rule.
• The variable y can only take one of i + t vertices in T , except the root, and then the
variable x can only take the parent of this vertex. So there are exactly i + t − 1 ways
to substitute objects into (x, y) by the General Multiplication Rule.
It follows that 2i = i + t − 1. Hence i = t − 1.
Exercise 12.2.6. Which proof technique(s) is/are used in our proof of Theorem 12.2.5?  12e

Tutorial exercises
An asterisk (*) indicates a more challenging exercise.
12.1. Consider the graph G where

V(G) = {1, 2, 3, 4, 5, 6, 7, 8, 9};


E(G) = {12, 23, 45, 67, 68, 78, 89}.

(a) Draw G.

108
(b) Draw all subgraphs of G that is a tree and contains the vertex 7. Put the vertex 7
at the top of your drawings.
(c) Calculate the number of graphs that have the same vertices as G and are isomor-
phic to G. Briefly explain your calculations.
12.2. Recall the definition of isomorphism for graphs from Tutorial Exercise 11.3. Let T1 , T2
be trees with roots r1 , r2 respectively. These two rooted tree are isomorphic if there is
an isomorphism f from T1 to T2 such that f (r1 ) = r2 .
Let n ∈ {1, 2, 3, 4}.
(a) How many trees are there whose vertices are precisely 1, 2, . . . , n?
(b) How many trees are there with n vertices if we count isomorphic trees as one?
(c) How many rooted trees are there with n vertices if we count isomorphic rooted
trees as one?
Justify your answers.
12.3. The aim of this exercise is to show that trees are precisely the acyclic graphs with a
maximal set of edges.
Prove that an acyclic undirected graph G is a tree if and only if adding any new edge
makes G cyclic, i.e., for all u, v ∈ V(G), if uv ̸∈ E(G), then (V(G), E(G) ∪ {uv}) is
cyclic.
12.4. We proved Theorem 12.1.8 that |E(G)| > |V(G)| − 1 for all connected cyclic finite
undirected graphs G. In this exercise, we prove that the opposite inequality holds for
all unconnected acyclic finite undirected graphs.
Let G be an unconnected acyclic finite undirected graph. Prove that

|E(G)| < |V(G)| − 1.

12.5. Is it true that, for all finite undirected graphs G, if |E(G)| ⩾ |V(G)| − 1, then G is
connected? Prove that your answer is correct.
12.6. Is it true that, for all finite undirected graphs G, if |E(G)| ⩽ |V(G)| − 1, then G is
acyclic? Prove that your answer is correct.
12.7. (Induction corner) Using induction, prove Theorem 12.2.5, i.e.,
Let T be a finite rooted tree in which every internal vertex has exactly two
children. If T has exactly t terminal vertices, then T has exactly t−1 internal
vertices.

Extra exercises
12.8. In this exercise, we look into the notion of spanning trees.
Definition. Let G be an undirected graph. A spanning tree of G is a subgraph T of G
such that T is a tree and V(T ) = V(G).

(a) Draw all spanning trees of the graph drawn below.

2
3
1
4
5

109
(b) Let G be a finite tree. Prove that G has exactly one spanning tree.
(c)∗ Let G be a finite undirected graph with no loop. Prove that, if G has exactly one
spanning tree, then G is a tree.

12.9. Let T be a finite tree with at least two vertices. Prove that T has at least two vertices
that are each in exactly one edge.
(Hint: Consider the end-points of a path of maximum length in T . Why does such a
path exist?)

110
Solutions to selected exercises

 1a, page 4
Consider a vacuously true condition proposition, say p → q. By the definition of vacuously
true, the hypothesis p is false. In particular, it is not the case that p is true and q is false.
So the conditional proposition p → q is true by the definition of →.

 1b, page 4
In the notation of Definition 1.3.8, we have p = (a  ∧ b) and q = (c ∨ d) here. So the
converse is (c ∨ d) → (a ∧ b), the inverse is ¬(a ∧ b) → ¬(c ∨ d) , and the contrapositive
is ¬(c ∨ d) → ¬(a ∧ b) .

 1c, page 5
If a proposition is true, then it cannot be false because by definition no proposition can be
both true and false.
If a proposition is not false, then it must be true because by definition no proposition can
be neither true nor false.

 1d, page 6
According to Convention 1.4.3, the compound expression ¬p → ¬q stands for (¬p) → (¬q).
• ¬p evaluates to F according to the definition of ¬.
• ¬q evaluates to T according to definition of ¬.
• ¬p → ¬q evaluates to T according to the definition of →.

In summary,
¬p → ¬q
T F
F T
T

 1e, page 6
(1) P and P evaluate to the same truth value under any substitution of propositions into
the propositional variables.
(2) If P and Q evaluate to the same truth value under any substitution of propositions into
the propositional variables, then so do Q and P .
(3) If P and Q evaluate to the same truth value under any substitution of propositions into
the propositional variables, and Q and R evaluate to the same truth value under any
substitution of propositions into the propositional variables, then so do P and R.

sol.1
 1f, page 8
No, as the following truth table shows.
p q r p∧q (p ∧ q) ∨ r q∨r p ∧ (q ∨ r)
T T T T T T T
T T F T T T T
T F T F T T T
T F F F F F F
F T T F T T F
F T F F F T F
F F T F T T F
F F F F F F F
Actually, to justify a “no” answer, it suffices to give one row of this truth table in which the
columns for (p ∧ q) ∨ r and p ∧ (q ∨ r) are different.

 1g, page 8
One can prove the Associativity, the Commutativity, the Identity, and the Annihilator parts
of Theorem 1.4.20 using the truth tables below.
p q r p∨q (p ∨ q) ∨ r q∨r p ∨ (q ∨ r)
T T T T T T T
T T F T T T T
T F T T T T T
T F F T T F T
F T T T T T T
F T F T T T T
F F T F T T T
F F F F F F F
p q r p∧q (p ∧ q) ∧ r q∧r p ∧ (q ∧ r)
T T T T T T T
T T F T F F F
T F T F F F F
T F F F F F F
F T T F F T F
F T F F F F F
F F T F F F F
F F F F F F F
p q p∨q q∨p p∧q q∧p p t c p∨c p∧t p∨t p∧c
T T T T T T T T F T T T F
T F T T F F F T F F F T F
F T T T F F
F F F F F F
Alternatively, one can prove the associativity of ∧ from that of ∨ as follows:
(p ∧ q) ∧ r ≡ (¬¬p ∧ ¬¬q) ∧ ¬¬r by the Double Negative Law;
≡ ¬(¬p ∨ ¬q) ∧ ¬¬r by De Morgan’s Laws;

≡ ¬ (¬p ∨ ¬q) ∨ ¬r by De Morgan’s Laws;

≡ ¬ ¬p ∨ (¬q ∨ ¬r) by the associativity of ∨;
≡ ¬¬p ∧ ¬(¬q ∨ ¬r) by De Morgan’s Laws;
≡ ¬¬p ∧ (¬¬q ∧ ¬¬r) by De Morgan’s Laws;
≡ p ∧ (q ∧ r) by the Double Negative Law.

sol.2
One can also prove the commutativity of ∧ from that of ∨ as follows:

p ∧ q ≡ ¬¬p ∧ ¬¬q by the Double Negative Law;


≡ ¬(¬p ∨ ¬q) by De Morgan’s Laws;
≡ ¬(¬q ∨ ¬p) by the commutativity of ∨;
≡ ¬¬q ∧ ¬¬p by De Morgan’s Laws;
≡q∧p by the Double Negative Law.

 2a, page 15
(1) False: note that ∀x ∈ Z ¬(x > 0 ∧ x < 1) is true, but ∀x ∈ R ¬(x > 0 ∧ x < 1) is false.
(2) True, because every integer is a real number.
(3) True, because every integer is a real number.
(4) False: note that ∃x ∈ R (x > 0 ∧ x < 1) is true, but ∃x ∈ R (x > 0 ∧ x < 1) is false.

There are many other counterexamples for (1) and (4).

 2b, page 16
(3) Note that the following are true.

¬∀x ∈ D P (x) ↔ ¬∀x x ∈ D → P (x) by Definition 2.2.1(5).
¬∀x x ∈ D → P (x) ↔ ∃x ¬ x ∈ D → P (x) by part (1).
∃x ¬ x ∈ D → P (x) ↔ ∃x x ∈ D ∧ ¬P (x) by Example 1.4.23.
∃x x ∈ D ∧ ¬P (x) ↔ ∃x ∈ D ¬P (x) by Definition 2.2.4(5).

From these, we deduce that ¬∀x ∈ D P (x) is true if and only if ∃x ∈ D ¬P (x) is true.

(4) Note that the following are true.



¬∃x ∈ D P (x) ↔ ¬∃x x ∈ D ∧ P (x) by Definition 2.2.4(5).
¬∃x x ∈ D ∧ P (x) ↔ ∀x ¬ x ∈ D ∧ P (x)  by part (2).
∀x ¬ x ∈ D ∧ P (x) ↔ ∀x ¬(x ∈ D) ∨ ¬P (x)
 by De Morgan’s Laws.
∀x ¬(x ∈ D) ∨ ¬P (x) ↔ ∀x x ∈ D → ¬P (x) by the Implication part of Theorem 1.4.20.
∀x x ∈ D → ¬P (x) ↔ ∀x ∈ D ¬P (x) by Definition 2.2.1(5).

From these, we deduce that ¬∃x ∈ D P (x) is true if and only if ∀x ∈ D ¬P (x) is true.

 2c, page 19
(3) We have the following equivalences by Theorem 2.3.1.

¬∃x ∃y Q(x, y) ↔ ∀x ¬∃y Q(x, y).


∀x ¬∃y Q(x, y) ↔ ∀x ∀y ¬Q(x, y).

From these, we deduce that ¬∃x ∃y Q(x, y) is true if and only if ∀x ∀y ¬Q(x, y) is true.

(4) We have the following equivalences by Theorem 2.3.1.

¬∃x ∀y Q(x, y) ↔ ∀x ¬∀y Q(x, y).


∀x ¬∀y Q(x, y) ↔ ∀x ∃y ¬Q(x, y).

From these, we deduce that ¬∃x ∀y Q(x, y) is true if and only if ∀x ∃y ¬Q(x, y) is
true.

sol.3
 2d, page 20
(1) • This reads “there exists x in D such that, for every y in E, xy = 0”.
• Alternatively, one can express this as “there is an element x of D which, when
multiplied to any element y of E, gives a product of 0”.
• This is true because if we choose the element 0 of D, then no matter which element
y of E we multiply it to, we get a product of 0.
(2) • This reads “for every y in E, there is x in D such that xy = 0”.
• Alternatively, one can express this as “no matter which element y of E is given,
one can always multiply it to an element x of D to get 0”.
• This is true because no matter which element y of E is given, we can always
multiply it to the element 0 of D to get 0.
(3) • This reads “there exists x in D such that, for every y in E, xy < 0”.
• Alternatively, one can express this as “there is an element x of D which, when
multiplied to any element y of E, gives a negative product”.
• This is false because no element x of D, when multiplied to any element y of E,
always gives a negative product: let us consider all the elements of D one by one.
– For the element −1 of D, when we multiply it to the element −1 of E, we get
a non-negative product.
– For the elements 0 and 1 of D, when we multiply them to the element 1 of E,
we get non-negative products.
There are other counterexamples.
(4) • This reads “for every y in E, there exists x in D such that xy < 0”.
• Alternatively, one can express this as “one can make any element y of E negative
by multiplying it to some element x of D.”
• This is true, as one can verify exhaustively for each element of E.
– For the elements 1 and 2 of E, one can multiply them to the element −1 of D
to make a negative product.
– For the elements −1 and −2 of E, one can multiply them to the element 1
of D to make a negative product.
(5) • This reads “there exist x1 , x2 in D such that x1 + x2 = 2”.
• Alternatively, one can express this as “there are two (possibly equal) elements x1 ,
x2 of D whose sum is 2”.
• This is true because 1 is an element of D and 1 + 1 = 2.
(6) • In view of Theorem 2.4.9(1), its negation ¬∀y1 , y2 ∈ E y1 = y2 is equivalent to
∃y1 , y2 ∈ E y1 ̸= y2 .
• This negation reads “there exist y1 , y2 in E such that y1 ̸= y2 ”.
• Alternatively, one can express this negation as “there are two different elements
y1 , y2 of E”.
• This negation is true: for example, the numbers 1 and 2 are different elements
of E.
• So the given proposition is false, because its negation is true.

 3a, page 24
No. In the case when p is a false proposition and q is a true proposition, we have both p → q
and ¬p true, but ¬q is false.

sol.4
 3b, page 27
(1) Suppose n is even. Use the definition of even integers to find an integer x such that
n = 2x. Then −n = −2x = 2(−x) where −x is an integer. So −n is even.
(2) Suppose n is odd. Use the definition of odd integers to find an integer x such that
n = 2x + 1. Then −n = −(2x + 1) = 2(−x − 1) + 1 where −x − 1 is an integer. So n is
odd.

 3c, page 28
(1) We deduced n is odd from the assumption that n is not even. This uses Proposi-
tion 3.2.17.
(2) We deduced n2 is not even from our knowledge that n2 is odd. This uses Proposi-
tion 3.2.21.

 3d, page 28
Proof. We show that ∀x ∈ Z 2x ̸= 1. Take any z ∈ Z. By trichotomy, we have z > 0 or
z = 0 or z < 0.
Case 1: suppose z > 0. Then z ∈ N. So

z⩾1 by the discreteness of N;


∴ 2z ⩾ 2 × 1 = 2 > 1
∴ 2z ̸= 1 by the irreflexivity of <.

Case 2: suppose z ⩽ 0. Then 2z ⩽ 2 × 0 = 0 < 1. So 2z ̸= 1 by the irreflexivity of <.

 3e, page 30
Let us read the two steps in Strong MI as follows.
(base step) show that P (i) is true for each integer i satisfying b ⩽ i ⩽ c;
(induction step) for each integer k ⩾ c, use the hypothesis that P (i) is true for each
integer i satisfying b ⩽ i ⩽ k to show that P (k + 1) is also true.
Consider the case when c = b − 1.
• For the base step, there is nothing to prove, because no integer i satisfies b ⩽ i ⩽ c =
b − 1.

• Consider the induction step when k = c. The hypothesis we can use is P (i) is true for
each integer i satisfying b ⩽ i ⩽ c = b − 1. However, there is no such i. So there is no
hypothesis one can use to show P (b). In other words, one simply needs to show that
P (b) is true here (without assuming anything).
• In the induction step when k = c + 1, one needs to show P (b) → P (b + 1).

• In the induction step when k = c + 2, one needs to show P (b) ∧ P (b + 1) → P (b + 2).


• Etc.
We deduce that P (b), P (b + 1), P (b + 2), . . . are all true by a series of modus ponens.

sol.5
 3f, page 31
Proof. Note that 2a1 −a2 b1 = b2 . As b2 is odd, it cannot be even by Proposition 3.2.17. So
a1 ⩽ a2 . Similarly, we know b1 = 2a2 −a1 b2 . As b2 is odd, it cannot be even by Proposi-
tion 3.2.17. So a2 ⩽ a1 . Combining the two inequalities, we have a1 = a2 . As 2a1 = 2a2 ̸= 0,
we deduce from 2a1 b1 = 2a2 b2 that b1 = b2 .

 4a, page 34
(1) We want to prove that E = Z+ , where E = {x + 1 : x ∈ Z⩾0 }.

Proof. (⇒) Let z ∈ E. Use the definition of E to find x ∈ Z⩾0 such that x + 1 = z.
Then x ∈ Z and x ⩾ 0 by the definition of Z⩾0 . As x ∈ Z, we know x + 1 ∈ Z because
Z is closed under +. As x ⩾ 0, we know x + 1 ⩾ 0 + 1 = 1 > 0. So z = x + 1 ∈ Z+ by
the definition of Z+ .
(⇐) Let z ∈ Z+ . Then z ∈ Z and z > 0. Define x = z − 1. As z ∈ Z, we know x ∈ Z
because Z is closed under −. As z > 0, we know x = z − 1 > 0 − 1 = −1, and thus
x ⩾ 0 as x ∈ Z. So x ∈ Z⩾0 by the definition of Z⩾0 . Hence the definition of E tells us
z = x + 1 ∈ E.

(2) We want to prove that F = Z, where F = {x − y : x, y ∈ Z⩾0 }.

Proof. (⇒) Let z ∈ F . Use the definition of F to find x, y ∈ Z⩾0 such that x − y = z.
Then x, y ∈ Z by the definition of Z⩾0 . So z = x − y ∈ Z as Z is closed under −.
(⇐) Let z ∈ Z.
• Case 1: suppose z ⩾ 0. Let x = z and y = 0. Then x, y ∈ Z⩾0 . So z = z − 0 =
x − y ∈ F by the definition of F .
• Case 2: suppose z < 0. Let x = 0 and y = −z. Then x, y ∈ Z⩾0 as z < 0. So
z = 0 − (−z) = x − y ∈ F by the definition of F .
So z ∈ F in all the cases.

 4b, page 35
• {1} ∈ C but {1} ̸⊆ C;

• {2} ̸∈ C but {2} ⊆ C;


• {3} ∈ C and {3} ⊆ C; and
• {4} ̸∈ C and {4} ̸⊆ C.

 4c, page 38
Let z ∈ A. In particular, we know z ∈ A or z ∈ B. So z ∈ A ∪ B by the definition of ∪.

 4d, page 39
Assume A ⊆ B and A ⊆ C. Take any z ∈ A. Then z ∈ B and z ∈ C as A ⊆ B and A ⊆ C
by assumption. So z ∈ B ∩ C by the definition of ∩. As the choice of z in A was arbitrary,
this shows A ⊆ B ∩ C.

sol.6
 4e, page 39

B B

A A
C C

(A \ B) ∪ (B \ C) A\C

No. For a counterexample, let A = C = ∅ and B = {1}. Then

(A \ B) ∪ (B \ C) = ∅ ∪ {1} = {1} =
̸ ∅ = A \ C.

 4f, page 39
Ideas. (1) The set of all sets?
( )
n o
(2) {. . . . . . } ?

 4g, page 39
Maybe, but is it better?

Proof. Take any set R. Split into two cases.


• Case 1: assume R ∈ R. Then ¬(R ̸∈ R). So ¬(R ∈ R ⇒ R ̸∈ R). Hence

∃x ¬(x ∈ R ⇔ x ̸∈ x).

• Case 2: assume R ̸∈ R. Then ¬(R ∈ R). So ¬(R ̸∈ R ⇒ R ∈ R). Hence

∃x ¬(x ∈ R ⇔ x ̸∈ x).

In either case, we showed ¬∀x (x ∈ R ⇔ x ̸∈ x). So the proof is finished.

 5a, page 44
Let P (n) be the predicate

For all ordered n-tuples (x1 , x2 , . . . , xn ) and (y1 , y2 , . . . , yn ),

(x1 , x2 , . . . , xn ) = (y1 , y2 , . . . , yn ) ⇔ x1 = y1 and x2 = y2 and . . . and xn = yn .

over Z⩾2 .

(Base step) P (2) is true by the definition of ordered pairs.


(Induction step) Let k ∈ Z⩾2 such that P (k) is true, i.e., all ordered k-tuples (x1 , x2 , . . . , xk )
and (y1 , y2 , . . . , yk ),

(x1 , x2 , . . . , xk ) = (y1 , y2 , . . . , yk ) ⇔ x1 = y1 and x2 = y2 and . . . and xk = yk .

sol.7
For all (k + 1)-tuples (x1 , x2 , . . . , xk+1 ) and (y1 , y2 , . . . , yk+1 ),

(x1 , x2 , . . . , xk , xk+1 ) = (y1 , y2 , . . . , yk , yk+1 )


 
⇔ (x1 , x2 , . . . , xk ), xk+1 = (y1 , y2 , . . . , yk ), yk+1 by Definition 5.1.10(2);
⇔ (x1 , x2 , . . . , xk ) = (y1 , y2 , . . . , yk ) and xk+1 = yk+1 by Definition 5.1.1;
⇔ x1 = y1 and x2 = y2 and . . . and xk = yk and xk+1 = yk+1
by the induction hypothesis.

This shows P (k + 1) is true.


Hence ∀n ∈ Z⩾2 P (n) is true by MI.

 5b, page 46
2 2 2 2 2 2

1 1 1 1 1 1

0 0 0 0 0 0
S R R S
2 2 2 2

1 1 1 1

0 0 0 0
R◦S S◦R

No. For instance, we have (2, 2) ∈ R ◦ S because (2, 0) ∈ S and (0, 2) ∈ R, but (2, 2) ̸∈
S ◦ R because no y ∈ A makes (2, y) ∈ R and (y, 2) ∈ S. (There are exactly three other
counterexamples.)

 6a, page 52
• R is reflexive as x ⩽ x for all x ∈ Q;
• R is not symmetric as 0 ⩽ 1 but 1 ̸⩽ 0, for example;
• R is transitive as x ⩽ y and y ⩽ z imply x ⩽ z for all x, y, z ∈ Q.

 6b, page 52
• R′ is not reflexive as 0 ̸< 0, for example;
• R′ is not symmetric as 0 < 1 but 1 ̸< 0, for example;
• R′ is transitive as x < y and y < z imply x < z for all x, y, z ∈ Q.

 6c, page 52
The arrow diagram below represents the relation R in the exercise:

sol.8
This relation is not reflexive because 2 ̸R 2. It is not symmetric because 3 R 2 but 2 ̸R 3. It
is not transitive because 2 R 1 and 1 R 2 but 2 ̸R 2.

 6d, page 52
Proof. (⇒) Assume R is transitive. Let (x, z) ∈ R ◦ R. Use the definition of R ◦ R to find
y ∈ A such that (x, y) ∈ R and (y, z) ∈ R. This means x R y and y R z. So x R z by the
transitivity of R. Hence (x, z) ∈ R.
(⇐) Assume R◦R ⊆ R. Let x, y, z ∈ A such that x R y and y R z. This means (x, y) ∈ R
and (y, z) ∈ R. So (x, z) ∈ R ◦ R by the definition of R ◦ R. Our assumption then implies
(x, z) ∈ R. Hence x R z.

 6e, page 54
Yes, as shown below.
Proof. We know x ∈ [x] by Lemma 6.3.5(1). So x ∈ S ∩ [x] by the hypothesis. This implies
S ∩ [x] ̸= ∅. Hence S = [x] by Lemma 6.3.6.

 6f, page 55
The divisibility relation on Z is not antisymmetric because 1 | −1 and −1 | 1, but 1 ̸= −1.

 6g, page 56
The divisibility relation on Z+ is antisymmetric, as shown below. So it is a partial order by
Example 6.1.8. It is not total because 2 ∤ 3 and 3 ∤ 2.
Proof of antisymmetry. Let us first show that if a, b ∈ Z+ such that a | b, then a ⩽ b.
Let a, b ∈ Z+ such that a | b. Then the definition of divisibility gives k ∈ Z such that b = ak.
Note k = b/a > 0 as both a and b are positive. Since k ∈ Z, this implies k ⩾ 1. Thus
b = ak ⩾ a × 1 = a, as required.
Now let a, b ∈ Z+ such that a | b and b | a. Then the previous paragraph tells us a ⩽ b
and b ⩽ a. So a = b.

 6h, page 56
We use the version of Strong MI with c = b − 1 given by Exercise 3.2.25.
Proof. Let P (n) be the predicate “n ̸∈ S” over Z⩾b .
(Induction step) Let k ∈ Z⩾b−1 such that P (b), P (b + 1), . . . , P (k) are true, i.e., that
b, b + 1, . . . , k ̸∈ S. If k + 1 ∈ S, then k + 1 is the smallest element of S because
S ⊆ Z⩾b , which contradicts our assumption. So k + 1 ̸∈ S. This means P (k + 1) is
true.
Hence ∀n ∈ Z⩾b P (n) is true by Strong MI.

 7a, page 61
Only (b), (c), (d) and (f) represent functions.

 7b, page 63
Proposition 7.3.1 implies
• idB ◦ f is a function A → B; and
• (idB ◦ f )(x) = idB (f (x)) = f (x) for all x ∈ A.
So idB ◦ f = f by Proposition 7.2.7.

sol.9
 7c, page 63
(1) Yes, because (f ◦ f )(x) = f (f (x)) = f (1231) = 1231 = f (x) for all x ∈ Z in this case.
(2) Yes, because (f ◦ f )(x) = f (f (x)) = f (x) for all x ∈ Z in this case.
(3) No, because (f ◦ f )(1) = f (f (1)) = f (−1) = 1 ̸= −1 = f (1) in this case.
(4) No, because (f ◦ f )(0) = f (f (0)) = f (1) = 4 ̸= 1 = f (0) in this case.

(5) No, because (f ◦ f )(2) = f (f (2)) = f (4) = 16 ̸= 4 = f (2) in this case.

 7d, page 64
(b) is a surjection but not an injection; (c) is neither a surjection nor an injection; (d) is an
injection but not a surjection; and (f) is both an injection and a surjection. Thus only the
last one is a bijection.

 7e, page 65
Proof. Let y ∈ B. Define x = f −1 (y). Then

(f ◦ f −1 )(y) = f (f −1 (y)) by Proposition 7.3.1;


= f (x) by the definition of x;
=y by Proposition 7.4.11, as f −1 (y) = x;
= idB (y) by the definition of idB .

So f ◦ f −1 = idB by Proposition 7.2.7.

 8a, page 69
Proof of the converse to the Pigeonhole Principle. Suppose n ⩽ m. Define f : A →
B by setting f (xi ) = yi for each i ∈ {1, 2, . . . , n}. This definition is unambiguous because the
x’s are different. To show injectivity, suppose i, j ∈ {1, 2, . . . , n} such that f (xi ) = f (xj ).
The definition of f tells us f (xi ) = yi and f (xj ) = yj . Then yi = f (xi ) = f (xj ) = yj . So
i = j because the y’s are different. This implies xi = xj .

Proof of a partial converse to the Dual Pigeonhole Principle. Suppose n ⩾ m > 0.


Define f : A → B by setting, for each i ∈ {1, 2, . . . , n},
(
yi , if i ⩽ m;
f (xi ) =
ym , otherwise.

This definition is unambiguous because the x’s are different. It is surjective because given
any yi ∈ B, we have xi ∈ A such that f (xi ) = yi .

Proof. (1) Suppose f and g are surjective. Let z ∈ C. Use the surjectivity of g to find
y ∈ B such that z = g(y). Then use the surjectivity of f to find x ∈ A such that
y = f (x). Now z = g(y) = g(f (x)) = (g ◦ f )(x) by Proposition 7.3.1, as required.
(2) Suppose f and g are injective. Let x1 , x2 ∈ A such that (g ◦ f )(x1 ) = (g ◦ f )(x2 ).
Then g(f (x1 )) = g(f (x2 )) by Proposition 7.3.1. The injectivity of g then implies
f (x1 ) = f (x2 ). So the injectivity of f tells us x1 = x2 , as required.

sol.10
 8b, page 70
Proof. To show that A has the same cardinality as range(f ), it suffices to find a bijection
A → range(f ). We use the function f0 : A → range(f ) defined by setting f0 (x) = f (x) for
each x ∈ A.

(Well-defined) Let us first check that the definition of f0 given indeed assigns every element
of A exactly one element of range(f ), as required by the definition of functions. Take
any x0 ∈ A. As x0 ∈ A and f is a function with domain A, there is exactly one object
that is equal to f (x0 ). So we only need to check that this object is indeed an element
of the codomain of f0 , i.e., range(f ). Recall range(f ) = {f (x) : x ∈ A} by definition.
As x0 ∈ A, we see that f (x0 ) ∈ range(f ), as required.
(Surjective) Take any y ∈ range(f ). Use the definition of range(f ) to find x ∈ A such that
y = f (x). Then y = f (x) = f0 (x) by the definition of f0 .
(Injective) Let x1 , x2 ∈ A such that f0 (x1 ) = f0 (x2 ). Then the definition of f0 tells us
f (x1 ) = f (x2 ). So x1 = x2 as f is injective.

Additional comment. Sometimes when one defines a function, it is not immediately clear
that the definition given indeed defines a function, i.e., that it defines an object satisfying
the definition of functions. In such cases, a proof should be provided. In many other cases,
it is clear that the definition given really defines a function, and so no additional explanation
is needed.

 8c, page 70
Proof. Let n ∈ N and f : N → {1, 2, . . . , n}. Define fn : {1, 2, . . . , n + 1} → {1, 2, . . . , n} by
setting fn (x) = f (x) for all x ∈ {1, 2, . . . , n + 1}. Then fn is not injective by the Pigeonhole
Principle. Let x1 , x2 ∈ {1, 2, . . . , n + 1} such that x1 ̸= x2 but fn (x1 ) = fn (x2 ). Then
f (x1 ) = f (x2 ) by the definition of fn . This show f is not injective.
The paragraph above shows, in particular, that there is no bijection N → {1, 2, . . . , n},
for any n ∈ N. So N is infinite.

 8d, page 70
(1) True. This follows directly from Definition 8.2.1.

(2) False. The f : N → N satisfying f (0) = 0 and f (x+1) = x for each x ∈ N is a surjection
that is not an injection, but N has the same cardinality as N.
(3) False. The f : N → N satisfying f (x) = x + 1 for each x ∈ N is an injection that is not
a surjection, but N has the same cardinality as N.

(4) False. The function f : {0, 1} → {0, 1} satisfying f (0) = 0 = f (1) is neither a surjection
nor an injection, but {0, 1} has the same cardinality as {0, 1}.

 9a, page 75
Proof. By symmetry, it suffices to show only one direction. Suppose A is countable. If A is
finite, then B is also finite by Lemma 8.2.8; thus B is countable and we are done. So suppose
A is infinite. Then A has the same cardinality as N by the definition of countability. Then
the symmetry and the transitivity of same-cardinality tell us B has the same cardinality of N.
So B is countable.

sol.11
 9b, page 76
Proof sketch. Suppose B is finite. Use the finiteness of B to find n ∈ N and a bijection
f : {1, 2, . . . , n} → B. Run the following procedure.
1. Initialize i = 0.
2. While A \ {g1 , g2 , . . . , gi } =
̸ ∅ do:
2.1. Let mi+1 be the smallest element in

m ∈ {1, 2, . . . , n} : f (m) ∈ A \ {g1 , g2 , . . . , gi } .

2.2. Set gi+1 = f (mi+1 ).


2.3. Increment i to i + 1.
On the one hand, suppose we are at line 2.2 when this procedure is run. Then the loop
condition tells us A \ {g1 , g2 , . . . , gi } =
̸ ∅. If ai ∈ A \ {g1 , g2 , . . . , gi }, then ai = f (m)
for some m ∈ {1, 2, . . . , n} because f is a surjection {1, 2, . . . , n} → B and A ⊆ B. This
says {m ∈ {1, 2, . . . , n} : f (m) ∈ A \ {g1 , g2 , . . . , gi }} =
̸ ∅. So mi+1 must exist by the
Well-Ordering Principle.
On the other hand, by the choices of mi+1 and gi+1 on lines 2.2 and 2.1,

each gi+1 ∈ A \ {g1 , g2 , . . . , gi }. (∗)

Case 1: this procedure stops after finitely many steps. Then a run results in

m1 , m2 , . . . , mℓ and g1 , g2 , . . . , gℓ

where ℓ ∈ N. Define g : {1, 2, . . . , ℓ} → A by setting g(i) = gi for all i ∈ {1, 2, . . . , ℓ}.


Notice A\{g1 , g2 , . . . , gℓ } = ∅ as the stopping condition is reached. This says any element
of A is equal to some gi , thus some g(i). So g is surjective. We know g is injective by (∗).
As g is a bijection {1, 2, . . . , ℓ} → A, we deduce that A is finite.

Case 2: this procedure does not stop. Then a run results in

m1 , m2 , m3 , . . . and g1 , g2 , g3 , . . . .

Define g : N → A by setting g(i) = gi+1 for all i ∈ N. As one can verify, this g is a bijection
N → A. Recall that f is a bijection {1, 2, . . . , n} → B. So Proposition 7.4.3 tells us f −1 is a
bijection B → {1, 2, . . . , n}. Define h : N → {1, 2, . . . , n} by setting h(i) = f −1 (g(i)) for all
i ∈ N. This h is injective because, if i, j ∈ N such that h(i) = h(j), then

f −1 (g(i)) = f −1 (g(j)) by the definition of h.


∴ g(i) = g(j) as f −1 is injective.
∴ i=j as g is injective.

This contradicts Exercise 8.2.7. Therefore, this case is not possible.

 9c, page 77
Proof. As f is an injection A → B, Exercise 8.2.5 implies that A has the same cardinality
as range(f ). Since A is infinite, Lemma 8.2.8 tells us range(f ) is also infinite. Recall from
Remark 7.2.3(2) that range(f ) ⊆ B. Hence B is infinite too by Proposition 9.2.6(1).

sol.12
 9d, page 77
Given any function f : A → P(A), we will produce an element of P(A) that is not equal to
f (x) for any x ∈ A. This will show that there is no surjection f : A → P(A), and thus A
cannot have the same cardinality as P(A).
Let f : A → P(A). Define R = {x ∈ A : x ̸∈ f (x)}. Then R ∈ P(A) by the definition of
power sets. We claim that R ̸= f (x) for any x ∈ A. We prove this by contradiction. Suppose
we have a ∈ A such that R = f (a). From the definition of R,

∀x ∈ A x ∈ R ⇔ x ̸∈ f (x) . (†)
As R = f (a), applying (†) to x = a gives
a ∈ f (a) ⇔ a ̸∈ f (a). (‡)
Split into two cases.
• Case 1: assume a ∈ f (a). Then a ̸∈ f (a) by the ⇒ part of (‡). This contradicts our
assumption that a ∈ f (a).
• Case 2: assume a ̸∈ f (a). Then a ∈ f (a) by the ⇐ part of (‡). This contradicts our
assumption that a ̸∈ f (a).
In either case, we get a contradiction. This completes the proof of the claim and thus of the
remark.

 9e, page 78
According to the definition of countability, we need to show that P(A) is infinite, and that
P(A) does not have the same cardinality as N.
Let f : A → P(A) defined by setting f (a) = {a} for each a ∈ A. Then f is injective
because if a1 , a2 ∈ A such that f (a1 ) = f (a2 ), then {a1 } = {a2 }, and thus a1 = a2 by the
definition of set equality. As A is infinite, Corollary 9.2.7(1) tells us that P(A) is infinite too.
As A is countable and infinite, it must have the same cardinality as N by the definition of
countability. However, Theorem 9.3.1 tells us A does not have the same cardinality as P(A).
Thus P(A) cannot have the same cardinality as N by Proposition 8.2.4.

 10a, page 82
(⊆) Let x ∈ A \ B. Then x ∈ A and x ̸∈ B by the definition of \. The latter implies x ̸∈ A
or x ̸∈ B. So it is not the case that x is both in A and in B by De Morgan’s Laws. Thus the
definition of ∩ tells us x ̸∈ A ∩ B. As x ∈ A, we deduce that x ∈ A \ (A ∩ B) according to
the definition of \.
(⊇) Let x ∈ A \ (A ∩ B). Then x ∈ A and x ̸∈ A ∩ B by the definition of \. In view of
the definition of ∩, the latter implies that it is not the case that x is both in A and in B. So
either x ̸∈ A or x ̸∈ B by De Morgan’s Laws. As x ∈ A, we deduce that x ̸∈ B. So x ∈ A \ B
by the definition of \.

 10b, page 83
Let C be the set of all countable sets and I be the set of all infinite sets here. Note that
all sets are either countable or infinite because finite sets are by definition countable. So
|C ∪ I| = 40. Also, by the Inclusion–Exclusion Rule,
|C ∪ I| = |C| + |I| − |C ∩ I|
= 12 + 31 − |C ∩ I|.
Hence, the number of sets that are both countable and infinite here is
|C ∩ I| = 12 + 31 − |C ∪ I| = 12 + 31 − 40 = 3.

sol.13
 10c, page 89
Define Γ = {B, I1 , C, O1 , N1 , D, I2 , T, I3 , O2 , N2 , A, L}. In view of the General Multiplication
Rule,
     
    number of number of number of
number of number of ways to

 ways to
 
 ways to 
  
permutations = permutations of  × arrange  × arrange  × arrange  .
     
of Γ BICONDITIONAL I1 , I2 , I3 into O1 , O2 into N1 , N2 into
3 positions 2 positions 2 positions
 
number of
∴ 13! = permutations of  × 3! × 2! × 2! by Corollary 10.3.7.
BICONDITIONAL
13!
From this, we see that the number of permutations of BICONDITIONAL is 3! 2! 2! = 13!/24.

 11a, page 94
Note that, in G, there is no edge between the left vertices, and there is no edge between the
right vertices. So vertices in a path in G must alternate between the left vertices and the
right vertices. As 1 and 3 are both on the left, the length of the path between 1 and 3 must
be even, and so be at least 2. So such a path must have length 2 or 4 because there are only
6 vertices in the graph, and paths cannot “use” the same vertex twice or more.

Case 1: consider those paths between 1 and 3 of length 2. There are 3 choices for
the remaining vertex from {a, b, c}. So there are exactly 3 such paths.
Case 2: consider those paths between 1 and 3 of length 4. Such a path contains one
more left vertex and two more right vertices. This left vertex must be 2 because this
is the only remaining vertex on the left. For the two right vertices, they can be any
two distinct ones from {a, b, c}, and order matters for these two vertices. So there are
P (3, 2) = 3 × 2 = 6 such paths.
In total, there are exactly 3 + 6 = 9 paths between 1 and 3 in G.

 11b, page 97
As one can verify exhaustively, (a) and (b) are drawings of connected graphs. It is clear that
(d) is a drawing of graph that is not connected. That (c) is a drawing of a graph that is not
connected can be more easily seen by redrawing the same graph as follows:

 12a, page 103


• By splitting into a ⇒ part and a ⇐ part, we used Technique 3.2.9 to prove a bicondi-
tional proposition.

• We used Technique 3.2.3 to prove the ⇒ part.


• The ⇐ part is proved using contraposition, i.e., Technique 3.2.7.
• In the ⇐ part, to prove that there is an edge e in G such that (V(G), E(G) \ {e})
remains connected, we produced a witness e; this is Technique 3.2.1.

sol.14
• In the ⇐ part, we split into two cases: one when x1 xk ̸∈ E(P ), the other when x1 xk ∈
E(P ); this uses Technique 3.2.11.
• Etc.

 12b, page 104


• We used Strong MI, i.e., Technique 3.2.23.

• In the base step, we used a proof by contradiction, i.e., Technique 3.2.16, to show that
G does not have a loop.
• Etc.

 12c, page 105


• We used an algorithmic proof, i.e., Technique 9.2.3, to produce a subgraph Hk of G
|V(G)| = |V(Hk )| = |E(Hk )|.
• Etc.

 12d, page 108


• We used a counting argument here, i.e., Technique 10.3.16.
• Etc.

 12e, page 108


• We used a counting argument here, i.e., Technique 10.3.16.
• Etc.

sol.15
Tutorial solutions for Chapter 1

Sometimes there are other correct answers.


1.1. All of these are true, except the proposition in (c), which is false.

(a) p∧q → r (b) p ↔ q ∨ ¬r (c) p ∧ q ∨ (¬ r → p)
F F T F F T F F T F
F F F ?
T F F
T

(d) Treating p, q, r as propositional variables,



q ∨ r ∨ (¬p ↔ q) ∧ (q ∨ r) ≡ q ∨ r

by the absorption logical identities. Since r is a true proposition, the given propo-
sition is also true.

1.2. (a) t ↔ c ∧ a.
(b) t → a.
(c) t → c.

1.3. (a) (i) p q r q∨r p ∧ (q ∨ r) p∧q p∧r (p ∧ q) ∨ (p ∧ r)


T T T T T T T T
T T F T T T F T
T F T T T F T T
T F F F F F F F
F T T T F F F F
F T F T F F F F
F F T T F F F F
F F F F F F F F
(ii) p p∧p
T T
F F
(iii) p q p∨q p ∧ (p ∨ q)
T T T T
T F T T
F T T F
F F F F
(iv) t c ¬t
T F F

tutsol.1
(b) (i) p ∨ (q ∧ r) ≡ ¬¬p ∨ (¬¬q ∧ ¬¬r) by the Double Negative Law;
≡ ¬¬p ∨ ¬(¬q ∨ ¬r) by De Morgan’s Laws;

≡ ¬ ¬p ∧ (¬q ∨ ¬r) by De Morgan’s Laws;

≡ ¬ (¬p ∧ ¬q) ∨ (¬p ∧ ¬r) by (a)(i);

≡ ¬ ¬(p ∨ q) ∨ ¬(p ∨ r) by De Morgan’s Laws;

≡ ¬¬ (p ∨ q) ∧ (p ∨ r) by De Morgan’s Laws;
≡ (p ∨ q) ∧ (p ∨ r) by the Double Negative Law.
Alternatively,

¬ p ∨ (q ∧ r) ≡ ¬p ∧ ¬(q ∧ r) by De Morgan’s Laws;
≡ ¬p ∧ (¬q ∨ ¬r) by De Morgan’s Laws;
≡ (¬p ∧ ¬q) ∨ (¬p ∧ ¬r) by (a)(i);
≡ ¬(p ∨ q) ∨ ¬(p ∨ r) by De Morgan’s Laws;

≡ ¬ (p ∨ q) ∧ (p ∨ r) by De Morgan’s Laws.
Thus p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r).
(ii) p ∨ p ≡ ¬¬p ∨ ¬¬p by the Double Negative Law;
≡ ¬(¬p ∧ ¬p) by De Morgan’s Laws;
𠪪p by (a)(ii);
≡p by the Double Negative Law.
Alternatively,
¬(p ∨ p) ≡ ¬p ∧ ¬p by the Double Negative Law;
≡ ¬p by (a)(ii).
Thus p ∨ p ≡ p.
(iii) p ∨ (p ∧ q) ≡ (p ∨ p) ∧ (p ∨ q) by (b)(i);
≡ p ∧ (p ∨ q) by (b)(ii);
≡p by (a)(iii).
(iv) ¬c ≡ ¬¬t by (a)(iv);
≡t by the Double Negative Law.
Additional explanations. Let us provide a slightly more intuitive explanation of why
the Absorption Laws are true. Fix a substitution of propositions into the propositional
variables p and q.
Consider the identity p ∨ (p ∧ q) ≡ p; the argument for the other Absorption Law is
similar. We split into two cases.
• Case 1: suppose p evaluates to T. Then p ∨ (p ∧ q) evaluates to T too by the
definition of ∨.
• Case 2: suppose p evaluates to F. Then p ∧ q evaluates to F by the definition of ∧.
In view of the definition of ∨, we conclude that p ∨ (p ∧ q) evaluates to F.
In all cases, the LHS and the RHS evaluate to the same truth value. So the equivalence
holds.
1.4. Let us use a truth table:
p q p↔q p→q q→p (p → q) ∧ (q → p)
T T T T T T
T F F F T F
F T F T F F
F F T T T T

tutsol.2
As the column for p ↔ q is exactly the same as the column for (p → q) ∧ (q → p), the
two compound expressions are equivalent.
Alternative solution. According to our definition of ↔ in Definition 1.3.11, under a
substitution of propositions into the propositional variables p and q, we know p ↔ q
evaluates to true if and only if p and q evaluate to the same truth value. As propositions
by definition have exactly one truth value amongst “true” and “false”, the latter in turn
is equivalent to p and q both evaluating to true or both evaluating to false. This means
the compound expression (p ∧ q) ∨ (¬p ∧ ¬q) evaluates to true under this substitution.
All these show that p ↔ q ≡ (p ∧ q) ∨ (¬p ∧ ¬q). Hence

p↔q
≡ (p ∧ q) ∨ (¬p ∧ ¬q) by the above;

≡ (p ∧ q) ∨ ¬p) ∧ (p ∧ q) ∨ ¬q) by the Distributive Laws;
 
≡ (p ∨ ¬p) ∧ (q ∨ ¬p) ∧ (p ∨ ¬q) ∧ (q ∨ ¬q) by the Distributive Laws;
 
≡ T ∧ (q ∨ ¬p) ∧ (p ∨ ¬q) ∧ t by the logical identities on negation;
≡ (q ∨ ¬p) ∧ (p ∨ ¬q) as t is an identity for ∧;
≡ (p → q) ∧ (q → p) by the logical identity on the implication.

Here t denotes a tautology.

1.5. Let t be a tautology.

(p → q) ∧ (q → r) → (p → r)

≡ ¬ (¬p ∨ q) ∧ (¬q ∨ r) ∨ (¬p ∨ r) by the logical identity on the implication;
≡ ¬(¬p ∨ q) ∨ ¬(¬q ∨ r) ∨ ¬p ∨ r by De Morgan’s Laws;
≡ (p ∧ ¬q) ∨ ¬p ∨ (q ∧ ¬r) ∨ r by De Morgan’s Laws;
 
≡ (p ∨ ¬p) ∧ (¬q ∨ ¬p) ∨ (q ∨ r) ∧ (¬r ∨ r) by the Distributive Laws;
 
≡ t ∧ (¬q ∨ ¬p) ∨ (q ∨ r) ∧ t by the logical identities on negation;
≡ ¬q ∨ ¬p ∨ q ∨ r as t is the identity for ∧;
≡ t ∨ ¬p ∨ r by the logical identities on negation;
≡t as t is annihilating with respect to ∨.

Alternatively, one can use the following truth table:

p q r p→q q→r (p → q) ∧ (q → r) p→r (p → q) ∧ (q → r) → (p → r)


T T T T T T T T
T T F T F F F T
T F T F T F T T
T F F F T F F T
F T T T T T T T
F T F T F F T T
F F T T T T T T
F F F T T T T T

1.6. No. Let us substitute a false proposition into p and a true proposition into q. Then
p → q evaluates to T, while q → p evaluates to F. So (p → q) → (q → p) evaluates to
F. This shows the compound expression given is not a tautology. (There is no other
substitution under which this expression evaluates to F.)

Additional comments. To determine whether the given expression is a tautology,


one may want to draw a complete truth table. However, to prove that this expression

tutsol.3
is not a tautology, it suffices to identify one row of the truth table in which it evaluates
to F. This is essentially what the solution above is doing.
One may use the logical identities to show that the expression given is equivalent to
p ∨ ¬q. While p ∨ ¬q does not look like a tautology, this does not logically imply it is
not a tautology: we need to demonstrate a way to substitute propositions into p and q
which makes p ∨ ¬q evaluate to F; cf. Note 1.4.24. One may find it easier to come
up with such a substitution for the equivalent expression p ∨ ¬q than for the original
expression.

1.7. By the definition of tautologies, the compound expression P ↔ Q is a tautology means


P ↔ Q evaluates to true no matter what propositions we substitute into its proposi-
tional variables. According to the definition of ↔, this in turn means P and Q evaluate
to the same truth value no matter what propositions we substitute into their proposi-
tional variables. This is exactly what the definition of P ≡ Q says.

Extra exercises
1.8. These are not equivalent. (Note that, since we are given two compound expressions,
we are referring to equivalence in the sense of Definition 1.4.7 here.)
Let us substitute a false proposition into p and r, and a true proposition into q. Then
p ∧ q → r evaluates to T, while (p → r) ∧ (q → r) evaluates to F. So the two compound
expressions are not equivalent.
1.9. (a) p q r p ∨ q p → r q → r (p ∨ q) ∧ (p → r) ∧ (q → r) (p ∨ q) ∧ (p → r) ∧ (q → r) → r
T T T T T T T T
T T F T F F F T
T F T T T T T T
T F F T F T F T
F T T T T T T T
F T F T T F F T
F F T F T T F T
F F F F T T F T
Since the column for (p ∨ q) ∧ (p → r) ∧ (q → r) → r consists entirely of T’s, we
see that (p ∨ q) ∧ (p → r) ∧ (q → r) → r is a tautology.
Alternatively, one can use the logical identities as follows.

(p ∨ q) ∧ (p → r) ∧ (q → r) → r
≡ (p ∨ q) ∧ (¬p ∨ r) ∧ (¬q ∨ r) → r by the logical identity on implication;

≡ (p ∨ q) ∧ (¬p ∧ ¬q) ∨ r) → r by the Distributive Law;

≡ (p ∨ q) ∧ ¬(p ∨ q) ∨ r) → r by De Morgan’s Laws;
 
≡ (p ∨ q) ∧ ¬(p ∨ q) ∨ (p ∨ q) ∧ r → r by the Distributive Law;

≡ (p ∨ q) ∧ r → r by the logical identities on negation and identities;

≡ ¬ (p ∨ q) ∧ r ∨ r by the logical identity on implication;

≡ ¬(p ∨ q) ∨ ¬r ∨ r by De Morgan’s Laws;
≡ ¬(p ∨ q) ∨ (¬r ∨ r) by the Associative Laws;
≡t by the logical identities on negation and identities,

where t is a tautology.
(b) p c ¬p ¬p → c (¬p → c) → p
T F F T T
F F T F T

tutsol.4
Since the column for (¬p → c) → p consists entirely of T’s, we see that (¬p →
c) → p is a tautology.
Alternatively, we may use the logical identities as follows:

(¬p → c) → p ≡ ¬(p ∨ c) ∨ p by the logical identity on implication;


≡ ¬p ∨ p by the logical identities on negation and identities;
≡t by the logical identity on negation,

where t is a tautology.
1.10. Suppose P ≡ Q.
Consider any substitution of propositions into the propositional variables in P and Q.
We split into two cases.
• Suppose P evaluates to T under this substitution. Then Q evaluates to T too
because P ≡ Q. So both ¬P and ¬Q evaluate to F according to the definition
of ¬.
• Suppose P evaluates to F under this substitution. Then Q evaluates to F too
because P ≡ Q. So both ¬P and ¬Q evaluate to T according to the definition
of ¬.
Thus ¬P and ¬Q evaluate to the same truth value in all cases.
Since this is true regardless of which substitution we pick, we conclude that ¬P ≡ ¬Q.

tutsol.5
Tutorial solutions for Chapter 2

Sometimes there are other correct answers.


2.1. (a) ∀x ∈ A x R x.
(b) ∀x, y ∈ A (x R y → y R x).
The answer ∀x, y ∈ A (x R y ∧ y R x) is not correct; see Example 2.2.10(1).
(c) ¬∃x, y ∈ A (x ̸= y ∧ x R y ∧ y R x).
Another acceptable answer is ∀x, y ∈ A ¬(x ̸= y ∧ x R y ∧ y R x), but this
resembles the given sentence less.
2.2. One can rewrite this English sentence symbolically as

∀x, y ∈ A (x R y ∧ y R x → x = y).

This is equivalent to

∀x, y ∈ A ¬(x R y ∧ y R x) ∨ x = y

by the logical identity on implication. In view of De Morgan’s Laws, this in turn is


equivalent to 
∀x, y ∈ A ¬ (x R y ∧ y R x) ∧ x ̸= y
and thus, via Theorem 2.3.1, to

¬∃x, y ∈ A (x ̸= y ∧ x R y ∧ y R x),

which is what we gave for Exercise 2.1(c).


2.3. (a) ¬∃x ∈ N ∀y ∈ N (x ⩾ y).
Another acceptable answer is ∀x ∈ N ∃y ∈ N (y > x), but this resembles the
given sentence less.

(b) ∀x, y ∈ Q x ̸= y → ∃z ∈ Q (x < z ∧ z < y) ∨ (y < z ∧ z < x) .
Another acceptable answer is

∀x, y ∈ Q ∃z ∈ Q (x ̸= y → (x < z ∧ z < y) ∨ (y < z ∧ z < x)),

but this resembles the given sentence less. Yet less preferable but still acceptable
answers include

∀x, y ∈ Q x < y → ∃z ∈ Q (x < z ∧ z < y) and

∀x, y ∈ Q ∃z ∈ Q x < y → x < z ∧ z < y .

One may write x < z < y for x < z ∧ z < y.


2.4. (a) • By Theorem 2.4.9, the negation is equivalent to

∃x ∈ R ∀y ∈ R ¬(y = x2 ),

or simply ∃x ∈ R ∀y ∈ R y ̸= x2 .

tutsol.6
• The original proposition says any real number has a real square.
• This is true.
(b) • By Theorem 2.4.9, the negation is equivalent to

∃y ∈ R ∀x ∈ R ¬(y = x2 ),

or simply ∃y ∈ R ∀x ∈ R y ̸= x2 .
• This negation says some real number is not the square of any real number.
• The negated proposition is true: for instance, the real number −1 is not the
square of any real number.
• The original proposition is false, because its negation is true.
(c) • By Theorem 2.4.9, the negation is equivalent to

∃x1 , x2 , y1 , y2 ∈ R ¬(y1 = x1 2 ∧ y2 = x2 2 ∧ x1 ̸= x2 → y1 ̸= y2 ).

In view of Example 1.4.23, this is in turn equivalent to

∃x1 , x2 , y1 , y2 ∈ R (y1 = x1 2 ∧ y2 = x2 2 ∧ x1 ̸= x2 ∧ ¬(y1 ̸= y2 )),

or simply ∃x1 , x2 , y1 , y2 ∈ R (y1 = x1 2 ∧ y2 = x2 2 ∧ x1 ̸= x2 ∧ y1 = y2 ).


• The negated proposition says there are distinct real numbers who squares are
equal.
• This is true: for instance, the real numbers 1 and −1 are not equal, but their
squares are equal.
• The original proposition is false, because its negation is true.
(d) • By Theorem 2.4.9, the negation is equivalent to

∃x1 , x2 , y1 , y2 ∈ R ¬(y1 = x1 2 ∧ y2 = x2 2 ∧ y1 ̸= y2 → x1 ̸= x2 ).

In view of Example 1.4.23, this is in turn equivalent to

∃x1 , x2 , y1 , y2 ∈ R (y1 = x1 2 ∧ y2 = x2 2 ∧ y1 ̸= y2 ∧ ¬(x1 ̸= x2 ))

or simply ∃x1 , x2 , y1 , y2 ∈ R (y1 = x1 2 ∧ y2 = x2 2 ∧ y1 ̸= y2 ∧ x1 = x2 ).


• The original proposition says that if the squares of two real numbers are
different, then these two real numbers must be different too.
• To put this contrapositively, this says if two real numbers are equal, then their
squares are also equal.
• This is true.
• So by Theorem 1.4.12(1), the given proposition is true as well.
(e) • By Theorem 2.4.9, the negation is equivalent to

∃x ∈ R ¬ (∃y ∈ R y = x2 ) → x ⩾ 0 .


In view of Example 1.4.23, this is in turn equivalent to

(∃y ∈ R y = x2 ) ∧ ¬(x ⩾ 0) ,

∃x ∈ R

or simply ∃x ∈ R (∃y ∈ R y = x2 ) ∧ x < 0 .
• The negated proposition says there is a real number that has a real square
but is negative.
• This is true: for instance, the real number −1 has a real square 1 but it is
negative.
• The original proposition is false, because its negation is true.

tutsol.7
(f) • By Theorem 2.3.1, the negation is equivalent to

∃y ∈ R ¬ (∃x ∈ R y = x2 ) → y ⩾ 0 .


In view of Example 1.4.23, this is in turn equivalent to

(∃x ∈ R y = x2 ) ∧ ¬(y ⩾ 0) ,

∃y ∈ R

or simply ∃y ∈ R (∃x ∈ R y = x2 ) ∧ y < 0 .
• The original proposition says any real number that is the square of some real
number must be non-negative.
• This is true.
Additional information. Consider the proposition

∀x ∈ R ∃y ∈ R (y = x2 → x ⩾ 0).

It says that for every real number x, there is a real number y such that if y = x2 ,
then x ⩾ 0. This is true: no matter which real number x is, one can set y to be
the real number −1 such that y = x2 is false and thus the conditional proposition
y = x2 → x ⩾ 0 is vacuously true. In particular, this proposition is not equivalent to
that in (e).

Extra exercises

2.5. ∀d, n ∈ Z Divides(d, n) ↔ ∃k ∈ Z (n = dk) .
The proposition ∀d, n ∈ Z ∃k ∈ Z (Divides(d, n) ↔ n = dk) is not a correct answer.
To see this, let us replace Divides(d, n) by “d + n ̸= d + n”.
• The first proposition becomes false because 2 and 6 are integers where 2+6 ̸= 2+6
is false, but for some integer k, namely k = 3, we have 6 = 2 × k.
• The second proposition remains true because, given any integers d and n, one can
choose k to be the integer n + 1 such that d + n ̸= d + n and n = dk are both false.
Hence the two propositions do not “mean” the same.
2.6. (a) • By Theorem 2.4.9, the negation is equivalent to

∃x ∈ D ∀y ∈ E ¬(y < x)

or simply ∃x ∈ D ∀y ∈ E y ⩾ x.
• The original proposition says every element x of D is strictly bigger than some
element y of E.
• This is true: no matter what x is, we can choose y = 0 to guarantee y < x.
(b) • By Theorem 2.4.9, the negation is equivalent to

∀y ∈ E ∃x ∈ D ¬(y < x)

or simply ∀y ∈ E ∃x ∈ D y ⩾ x.
• The original proposition says some element y of E is strictly less than all the
elements x of D.
• This is true: take y = 0 so that, no matter what x is, we must have y < x.
(c) • By Theorem 2.4.9, the negation is equivalent to

∃x ∈ D ∀y ∈ E ¬(y + 1 = x)

or simply ∃x ∈ D ∀y ∈ E y + 1 ̸= x.

tutsol.8
• This negation says some element x of D is not equal to any element y of E
plus 1.
• This is true: the element 13 of D is not equal to any element of E plus 1.
• Thus the original proposition is false, because its negation is true.
(d) • By Theorem 2.3.1, the negation is equivalent to

∃x ∈ D ¬ x < 6 → ∃y ∈ E (y + 1 = x) .

In view of Example 1.4.23, this is equivalent to



∃x ∈ D x < 6 ∧ ¬∃y ∈ E (y + 1 = x) .

This is in turn equivalent to



∃x ∈ D x < 6 ∧ ∀y ∈ E ¬(y + 1 = x)

by Theorem 2.3.1, or simply ∃x ∈ D x < 6 ∧ ∀y ∈ E (y + 1 ̸= x) .
• The original proposition says every element x of D that is strictly less than 6
is equal to some element y of E plus 1.
• This is true: the only elements of D that are strictly less than 6 are 1, 3,
and 5; if x is equal of 1, 3, or 5, then we can take y to be 0, 2, or 4 respectively
such that y + 1 = x.

tutsol.9
Tutorial solutions for Chapter 3

Sometimes there are other correct answers.


3.1. One can rewrite the proposition to be proved symbolically as

∀x ∈ R x2 ⩾ 0.

To prove this by contradiction (i.e., using Technique 3.2.16), one starts with the nega-
tion, which is equivalent to
∃x ∈ R x2 < 0
by Theorem 2.3.1. However, the author started instead with

∀x ∈ R x2 < 0.

This is not justified.


Moral 1. Proofs of true propositions need not be correct.

Moral 2. Negate propositions carefully when proving by contradiction.

3.2. (a) The argument given proves ∀x ∈ R (x2 + 9 = 6x → x = 3). However, what we
want to prove is ∃x ∈ R (x2 + 9 = 6x). The author did not explain how one can
derive what we want to prove from what is proved.
The situation is different if the author proves ∀x ∈ R (x = 3 → x2 + 9 = 6x)
instead, because instantiating x to 3 here (in the sense of Example 3.1.13) imme-
diately gives a real number x satisfying x2 + 9 = 6x, namely 3.
(b) Note that 3 is real number and 32 + 9 = 18 = 6 × 3.
Moral. Do not mix up a conditional proposition and its converse: as shown in Theo-
rem 1.4.12(3), the two may not be equivalent.
Additional information. Strictly speaking, proofs do not need to contain information
about how one came up with them. However, sometimes authors still include this
information because this can be useful to the reader.

3.3. Proof. ((a) → (b)) Assume (a) is true. Pick elements z and w of A. As P (x, y) is a
predicate on A, the sentence P (z, w) is a proposition. So it is either true or false.
Case 1: suppose P (z, w) is true. Then P (w, z) is also true by (a).
Case 2: suppose P (z, w) is false. If P (w, z) is true, then P (z, w) is also true by (a),
which contradicts our supposition. So P (w, z) is false.
Hence P (z, w) and P (w, z) are either both true or both false in all cases. As the choice
of the elements z and w from A was arbitrary, we have shown (b).
((b) → (a)) Assume (b) is true. Pick elements z and w of A. Then P (z, w) and P (w, z)
are either both true or both false by (b).

tutsol.10
Case 1: suppose P (z, w) and P (w, z) are both true. Then P (z, w) → P (w, z) is
true by the definition of →.
Case 2: suppose P (z, w) and P (w, z) are both false. Then P (z, w) → P (w, z) is
(vacuously) true by the definition of →.

Hence P (z, w) → P (w, z) is true in all cases. As the choice of the elements z and w
from A was arbitrary, we have shown (a).

• To prove (a) ↔ (b), we split into (a) → (b) and (b) → (a) according to Tech-
nique 3.2.9.
• To each of the two directions, we split into two cases according to Technique 3.2.11.
• We applied universal instantiation and modus ponens from Example 3.1.11 and
Example 3.1.13 in Case 1 of (a) → (b).
• We used a subproof by contradiction (i.e., Technique 3.2.16) in Case 2 of (a) → (b).
Alternative proof of (b) → (a). Assume (b) is true. Pick elements z and w of A
such that P (z, w) is true. Then P (z, w) and P (w, z) are either both true or both false
by (b). Since P (z, w) is true, it cannot be the case that P (z, w) and P (w, z) are both
false. So they must be both true. In particular, this says P (w, z) is true. As the choice
of the elements z and w from A satisfying P (z, w) was arbitrary, we have shown (a).
Moral. One can instantiate a universal proposition (in the sense of Example 3.1.13)
in more than one way.
Additional remark. The sentence “As the choice of . . . was arbitrary, . . . ” is some-
times omitted in proofs, as this should be clear to the (experienced) reader.

Extra exercises
3.4. The argument considers only three real numbers: −1, 0, and 1. It does not explain
why x2 − 6x + 7 > 0 is true for other real numbers, for example, for x = 2.

3.5. Suppose the proposition is not true. Let m, n, k be integers such that m2 +n2 = k 2 , but
m and n are both odd. Use Proposition 3.2.27 to find an integer a making m2 + n2 =
4a + 2. This tells us k 2 = m2 + n2 = 4a + 2 = 2(2a + 1), where 2a + 1 is an integer. So
k 2 is even by the definition of even integers. Thus, in view Proposition 3.2.8 we know
k is even. Use the definition of even integers to find an integer x such that k = 2x.
Then 4a + 2 = m2 + n2 = k 2 = (2x)2 = 4x2 . Hence

4x2 − 4a 4a + 2 − 4a 1
x2 − a = = = ,
4 4 2
which is not an integer. However, we know that x2 − a is an integer because x and a
are. This is a contradiction. Therefore, the proposition must be true.

tutsol.11
Tutorial solutions for Chapter 4

Sometimes there are other correct answers.


4.1. (a) False. (The empty set ∅ is by definition a set with no element. In particular, the
empty set ∅ cannot be its element.)
(b) True. (The empty set ∅ is a subset of any set by Proposition 4.2.7. In particular,
it is a subset of itself.)
(c) True. (According to the definition of roster notation, the set {∅} contains exactly
one element ∅.)
(d) True. (The empty set ∅ is a subset of any set by Proposition 4.2.7. In particular,
it is a subset of {∅}.)
(e) False. (The empty set ∅ is an element of {∅, 1}, but it is not an element of {1}.)
(f) False. (According to the definition of roster notation, the set {{1, 2}, {2, 3}, 4}
contains exactly 3 elements: the set {1, 2}, the set {2, 3}, and the number 4; none
of these is equal to 1.)
(g) True. (The set {1, 2} contains exactly 2 elements: the number 1 and the number 2;
both of these are elements of {3, 2, 1}.)
(h) True. (The set {3, 3, 2} contains exactly 2 elements: the number 3 and the
number 2; both of these are elements of {3, 2, 1}. However, the number 1 is an
element of {3, 2, 1} but not an element of {3, 3, 2}.)
4.2. Yes, as shown below.
(⊆) Let a ∈ A. Use the definition of A to find n ∈ Z such that a = 2n + 1. Then
a = 2(n + 1) − 1. As n ∈ Z, we know n + 1 ∈ Z. So a ∈ B by the definition of B.
(⊇) Let b ∈ B. Use the definition of B to find n ∈ Z such that a = 2n − 1. Then
b = 2(n − 1) + 1. As n ∈ Z, we know n − 1 ∈ Z. So b ∈ A by the definition of A.
Hence A = B by the definition of set equality.
4.3. P(P(∅)) = {∅, {∅}}.

Explanations. We know ∅ is a subset of ∅ by Proposition 4.2.7. If A is a nonempty


set, then A has an element and thus A cannot be a subset of ∅ which by definition has
no element. So the only subset of ∅ is ∅. This tells us P(∅) = {∅}.
Now {∅} has exactly 1 element, namely the empty set ∅. In constructing a subset
of {∅}, one can choose to take this element of {∅} or not, giving two results ∅ and {∅}.
No other set can be a subset of {∅}. So

P(P(∅)) = P({∅}) = {∅, {∅}}.

4.4. (a) {6, 8, 10, 12}.


Explanation. The elements of this set are exactly the elements of U that are
even.

tutsol.12
(b) {−7, −6, −5, . . . , 7}.
Explanation.
{m − n : m, n ∈ U }
= {5 − 5, 5 − 6, . . . , 5 − 12, 6 − 5, 6 − 6, . . . , 6 − 12, . . . , 12 − 5, 12 − 6, . . . , 12 − 12}
= {0, −1, . . . , −7, 1, 0, . . . , −6, . . . , 7, 6, . . . , 0}
= {−7, −6, −5, . . . , 7}.
(c) {−5, −4, −3, −2, −1, 0}.
Explanation. The elements of this set are exactly the integers n for which −5 ⩽
n ⩽ 5 is true but 1 ⩽ n ⩽ 10 is false.
(d) {6, 8, 10, 12}.
Explanation. {5, 7, 9} ∪ {9, 11} = {5, 7, 9, 11} = {6, 8, 10, 12}, in a context where
U is the universal set.
4.5. (a) A \ B = {1, 9} and B \ A = {2, 6, 8, 10, 12, 14}. So A △ B = {1, 2, 6, 8, 9, 10, 12, 14}.
(b) Compare the following truth tables.
z ∈A z ∈B z ∈A\B z ∈B\A z ∈A△B
T T F F F
T F T F T
F T F T T
F F F F F
z ∈ A z ∈ B z ∈ A ∪ B z ∈ A ∩ B z ∈ (A ∪ B) \ (A ∩ B)
T T T T F
T F T F T
F T T F T
F F F F F
Since the last columns of the two tables are the same, we conclude that A △ B =
(A ∪ B) \ (A ∩ B).

Alternatively, one may use the set identities in the context where we have a uni-
versal set U .

A△B
= (A \ B) ∪ (B \ A) by the definition of △;
= (A ∩ B) ∪ (B ∩ A) by the set identity on set difference;
 
= (A ∩ B) ∪ B ∩ (A ∩ B) ∪ A by distributivity;
= (A ∪ B) ∩ (B ∪ B) ∩ (A ∪ A) ∩ (B ∪ A) by distributivity;
= (A ∪ B) ∩ U ∩ U ∩ (B ∪ A) by the set identity on complement;
= (A ∪ B) ∩ U ∩ U ∩ (B ∩ A) by De Morgan’s Laws;
= (A ∪ B) ∩ (B ∩ A) as U is the identity for ∩;
= (A ∪ B) ∩ (A ∩ B) as ∩ is commutative;
= (A ∪ B) \ (A ∩ B) by the set identity on set difference.

tutsol.13
Another way to proceed in propositional logic as follows: for every object z,

z ∈A△B
⇔ z ∈ (A \ B) ∪ (B \ A) by the definition of △;
⇔ (z ∈ A ∧ z ̸∈ B) ∨ (z ∈ B ∧ z ∈
̸ A) by the definition of ∪, ∩, \;
 
⇔ (z ∈ A ∧ z ̸∈ B) ∨ z ∈ B ∧ (z ∈ A ∧ z ̸∈ B) ∨ z ̸∈ A
by distributivity;
⇔ (z ∈ A ∨ z ∈ B) ∧ (z ̸∈ B ∨ z ∈ B) ∧ (z ∈ A ∨ z ̸∈ A) ∧ (z ̸∈ B ∨ z ̸∈ A)
by distributivity;
⇔ (z ∈ A ∨ z ∈ B) ∧ (z ̸∈ B ∨ z ̸∈ A) by the logical identities
on negation and identities;
⇔ (z ∈ A ∨ z ∈ B) ∧ ¬(z ∈ B ∧ z ∈ A) by De Morgan’s Laws;
⇔ z ∈ (A ∪ B) \ (B ∩ A) by the definition of ∪, ∩, \.

4.6. (⇒) Assume A ⊆ B. We want to show A ∪ B = B. We already know B ⊆ A ∪ B from


Example 4.3.9(2). So it remains to show A ∪ B ∪ B.
Take z ∈ A ∪ B. Then z ∈ A or z ∈ B by the definition of ∪.
• If z ∈ A, then z ∈ B by our assumption that A ⊆ B.
• If z ∈ B, then of course z ∈ B.
So z ∈ B in all cases, as required.
(⇐) Assume A ∪ B = B. We want to show A ⊆ B. Take any z ∈ A. This implies
z ∈ A ∪ B in view of Example 4.3.9(2). Thus z ∈ B since A ∪ B = B by assumption,
as required.
Alternative proof for ⇐. Assume A ∪ B = B. Then Example 4.3.9(1) tells us
A ⊆ A ∪ B = B.

4.7. • P1 (A, C1 ) is false because 9 ∈ A that is not in any S ∈ C1 .


• P2 (A, C1 ) is true because no distinct elements S1 , S2 ∈ C1 have a nonempty
intersection, as one can verify exhaustively.
• P1 (A, C2 ) is true because every x ∈ A is in some S ∈ C2 , as one can verify
exhaustively.
• P2 (A, C2 ) is false because {6, 7, 8} and {8, 9} are distinct elements of C2 that have
a nonempty intersection {8}.
Additional comment. Note that P2 (A, C ) is equivalent to

∀x ∈ A ∀S1 , S2 ∈ C (x ∈ S1 ∧ x ∈ S2 ⇒ S1 = S2 ).

So the conjunction of P1 (A, C ) and P2 (A, C ) can be expressed as

∀x ∈ A ∃!S ∈ C x ∈ S.

4.8. Fix sets A0 , A1 , A2 , . . . . Let P (n) be the predicate “A0 ∪ A1 ∪ . . . An = A0 ∩ A1 ∩ · · · ∩


An ” over Z+ .
(Base step) P (1) is true because A0 ∪ A1 = A0 ∩ A1 by De Morgan’s Laws.

tutsol.14
(Induction step) Let k ∈ Z+ such that P (k) is true, i.e., that A0 ∪ A1 ∪ · · · ∪ Ak =
A0 ∩ A1 ∩ · · · ∩ Ak . Then

A0 ∪ A1 ∪ · · · ∪ Ak ∪ Ak+1
= A0 ∪ A1 ∪ · · · ∪ Ak ∩ Ak+1 by De Morgan’s Laws;
= A0 ∩ A1 ∩ · · · ∩ Ak ∩ Ak+1 by the induction hypothesis.

This shows P (k + 1) is true.


Hence ∀n ∈ Z+ P (n) is true by MI.

Alternative solution. Let P (n) be the predicate

A0 ∪ A1 ∪ . . . An = A0 ∩ A1 ∩ · · · ∩ An for all sets A0 , A1 , . . . , An

over Z+ .

(Base step) P (1) is true because A0 ∪ A1 = A0 ∩ A1 by De Morgan’s Laws.


(Induction step) Let k ∈ Z+ such that P (k) is true, i.e., that A0 ∪ A1 ∪ · · · ∪ Ak =
A0 ∩ A1 ∩ · · · ∩ Ak for all sets A0 , A1 , . . . , Ak . For all sets B0 , B1 , . . . , Bk+1 ,

B0 ∪ B1 ∪ · · · ∪ Bk ∪ Bk+1
= B0 ∩ B1 ∩ · · · ∩ Bk ∪ Bk+1 by the induction hypothesis;
= B0 ∩ B1 ∩ · · · ∩ Bk ∩ Bk+1 by De Morgan’s Laws.

This shows P (k + 1) is true.

Hence ∀n ∈ Z+ P (n) is true by MI.


Additional comment. In the first proof above, it does not matter much whether we
put the universal quantifier for A0 , A1 , A2 , . . . into P (n) or not. This is not true in the
alternative proof.

Extra exercises
4.9. If x ∈ A0 ∩ B0 = (A \ B) ∩ B, then x ∈ A \ B and x ∈ B by the definition of ∩, and so
x ̸∈ B and x ∈ B, which is not possible. Therefore, the set A0 ∩ B0 cannot have any
element, and hence it must be equal to ∅ by Theorem 4.1.18.
We know A0 ∪ B0 = A ∪ B because for every object z,

z ∈ A0 ∪ B 0
⇔ z ∈ (A \ B) ∪ B by the definitions of A0 and B0 ;
⇔ (z ∈ A ∧ z ̸∈ B) ∨ z ∈ B by the definition of \ and ∪;
⇔ (z ∈ A ∨ z ∈ B) ∧ (z ̸∈ B ∨ z ∈ B) by the Distributive Laws;
⇔ z ∈A∨z ∈B by the logical identities on negation and identities;
⇔ z ∈A∪B by the definition of ∪.

Additional comment. If we are in a context with a universal set U , then we can

tutsol.15
proceed alternatively as follows:
A0 ∩ B0 = (A \ B) ∩ B by the definition of A0 and B0 ;
= (A ∩ B) ∩ B by the set identity on set difference;
=A∩∅ by the set identity on the complement;
=∅ as ∅ is an identity for ∩;
A0 ∪ B0 = (A \ B) ∪ B by the definition of A0 and B0 ;
= (A ∩ B) ∪ B by the set identity on set difference;
= (A ∪ B) ∩ (B ∪ B) by the Distributive Laws;
= (A ∪ B) ∪ U by the set identities on the complements;
=A∪B as U is an identity for ∪.

4.10. (⇒) Assume A ⊆ B. We want to show A ∩ B = A. We already know A ∩ B ⊆ A from


Example 4.3.9(1). So it remains to show A ∩ B ⊇ A.
Take z ∈ A. Then z ∈ B by our assumption that A ⊆ B. So z ∈ A∩B by the definition
of ∩, as required.
(⇐) Assume A ∩ B = A. We want to show A ⊆ B. Take any z ∈ A. This implies
z ∈ A ∩ B as A ∩ B = A by assumption. Recall from Example 4.3.9(1) that A ∩ B ⊆ B.
So z ∈ B, as required.
Alternative proof for ⇐. Assume A ∩ B = A. Then A = A ∩ B ⊆ B by Exam-
ple 4.3.9(1).
Another alternative proof. In view of Tutorial Exercise 4.6, it suffices to show that
A ∪ B = B if and only if A ∩ B = A.
(⇒) Assume A ∪ B = B. Then
A ∩ B = A ∩ (A ∪ B) by assumption;
=A by the Absorption Law.

(⇐) Assume A ∩ B = A. Then


A ∪ B = (A ∩ B) ∪ B by assumption;
=B by the Absorption Law.
Tn
4.11. • i=0 Ai = {1} = A0 .
Explanation. Note that A0 ⊆ A1 ⊆ · · · ⊆ An . So
n
\ n
\
Ai = A0 ∩ A1 ∩ A2 ∩ A3 ∩ · · · ∩ An by the definition of Ai ;
i=0 i=0
= A0 ∩ A2 ∩ A3 ∩ · · · ∩ An by Extra Exercise 4.10, as A0 ⊆ A1 ;
= A0 ∩ A3 ∩ · · · ∩ An by Extra Exercise 4.10, as A0 ⊆ A2 ;
= A0 ∩ · · · ∩ An by Extra Exercise 4.10, as A0 ⊆ A3 ;
= · · · = A0 ∩ An
= A0 by Extra Exercise 4.10, as A0 ⊆ An .
T∞
• i=0 Ai = {1} = A0 .
T∞
Explanation.
T∞ (⊆) Let z ∈ i=0 Ai . Then z ∈ Ai for each i ∈ N by the definition
of i=0 Ai . In particular, we know z ∈ A0 .
T∞ of Ai , for every i ∈ N. This
(⊇) Note that every element of A0 is an element
means
T∞ every element of
T∞ A 0 is an element of i=0 Ai according to the definition
of i=0 Ai . So A0 ⊆ i=0 Ai .

tutsol.16
Sn
• i=0 Ai = {x ∈ Q : 1
n+1 ⩽ x ⩽ n + 1} = An .
Explanation. Note that A0 ⊆ A1 ⊆ · · · ⊆ An . So
n
[ n
[
Ai = A0 ∪ A1 ∪ A2 ∪ A3 ∪ · · · ∪ An by the definition of Ai ;
i=0 i=0
= A1 ∪ A2 ∪ A3 ∪ · · · ∪ An by Extra Exercise 4.6, as A0 ⊆ A1 ;
= A2 ∪ A3 ∪ · · · ∪ An by Extra Exercise 4.6, as A0 ⊆ A2 ;
= A3 ∪ · · · ∪ An by Extra Exercise 4.6, as A0 ⊆ A3 ;
= · · · = An−1 ∪ An
= An by Extra Exercise 4.6, as A0 ⊆ An .
S∞
• i=0 Ai = {x ∈ Q : x > 0}.
S∞ S∞
Explanation. (⊆) Let z ∈ i=0 Ai . Use the definition of i=0 Ai to find i ∈ N
1
such that z ∈ Ai . According to the definition of Ai , this means i+1 ⩽ z ⩽ i + 1.
1
Thus z ⩾ i+1 > 0 as i + 1 ⩾ 0 + 1 > 0. So z ∈ {x ∈ Q : x > 0}.
(⊇) Let z ∈ {x ∈ Q : x > 0}. Then x > 0. Use the Archimedean property of R
to find j ∈ N such that j > z − 1 and j > z1 − 1. Now j+1 1
⩽ z ⩽ j + 1, and thus
S∞
z ∈ Aj . This implies z ∈ i=0 Ai .
Note. Our definition of the Ai ’s does not cover the A∞ case: if we try to substitute
1
∞ into i, then we face expressions such as ∞+1 and ∞ + 1, which do not have
commonly accepted meanings.
Moral. It is possible that an infinite intersection or union reaches its true value only
after infinitely many steps; thus no finite number of steps suffices to reveal the true
answer in general. There is a gap between “arbitrarily large finite” and “infinite”.

tutsol.17
Tutorial solutions for Chapter 5

Sometimes there are other correct answers.


5.1. (a) M × G = {(MA1100, A), (MA1100, B), (MA1100, C),
(CS1231, A), (CS1231, B), (CS1231, C)}.
(b) M × G × S = {(MA1100, A, +), (MA1100, A, −),
(MA1100, B, +), (MA1100, B, −),
(MA1100, C, +), (MA1100, C, −),
(CS1231, A, +), (CS1231, A, −),
(CS1231, B, +), (CS1231, B, −),
(CS1231, C, +), (CS1231, C, −)}.
(c) P(P(∅)) × S = {∅, {∅}} × S by Tutorial Exercise 4.3;
= {(∅, +), (∅, −), ({∅}, +), ({∅}, −)}.

SN SM
5.2. (a) 001R Gates 001R CS3234
012B Brin 012B MA2001
062E Bezos 062E MU2109
126N Ma 126N PC2130
254E Zuckerberg 254E PL3101

−1
SM ◦ (SN )
Gates CS3234
Brin MA2001
Bezos MU2109
Ma PC2130
Zuckerberg PL3101

−1
(b) x SM ◦ (SN ) y says

“x is (the name of) a student who is enrolled in the module y”.

tutsol.18
5.3. R S
4 1 1 7
3 5
0 0
2 3
1 −1 −1 2

A B B C

S◦R
4 7
3 5
2 3
1 2

A C

S −1 R−1
7 1 1 4
5 3
0 0
3 2
2 −1 −1 1

C B B A

R−1 ◦ S −1
7 4
5 3
3 2
2 1

C A
Extra information.

R = {(1, 0), (2, −1), (2, 0), (2, 1), (3, 0), (4, −1), (4, 0), (4, 1)}.
S = {(−1, 2), (−1, 3), (−1, 5), (−1, 7), (1, 2), (1, 3), (1, 5), (1, 7)}.
S ◦ R = {(2, 2), (2, 3), (2, 5), (2, 7), (4, 2), (4, 3), (4, 5), (4, 7)}.
R−1 = {(0, 1), (−1, 2), (0, 2), (1, 2), (0, 3), (−1, 4), (0, 4), (1, 4)}.
S −1 = {(2, −1), (3, −1), (5, −1), (7, −1), (2, 1), (3, 1), (5, 1), (7, 1)}.
R−1 ◦ S −1 = {(2, 2), (3, 2), (5, 2), (7, 2), (2, 4), (3, 4), (5, 4), (7, 4)} = (S ◦ R)−1 .

5.4. (a) (⊆) Let (a, b) ∈ R−1 . Then (b, a) ∈ R by the definition of R−1 . In view of the
definition of R, this means b − a is even. Use the definition of even integers to
find x ∈ Z such that b − a = 2x. Then a − b = 2(−x) where −x ∈ Z. So a − b
is even by the definition of even integers. According to the definition of R, this
means a R b. Thus (a, b) ∈ R.
(⊇) Let (a, b) ∈ R. Then a − b is even by the definition of R. Use the definition
of even integers to find x ∈ Z such that a − b = 2x. Then b − a = 2(−x) where
−x ∈ Z. So b − a is even by the definition of even integers. According to the
definition of R, this means b R a. Thus (a, b) ∈ R−1 by the definition of R−1 .

tutsol.19
Additional comments. Note that what we need to show here is essentially
∀a, b ∈ Z (a, b) ∈ R−1 ↔ (a, b) ∈ R .


In view of the definition of R−1 , this is equivalent to



∀a, b ∈ Z (b, a) ∈ R ↔ (a, b) ∈ R .
From the initial explanation in the alternative solution to Tutorial Exercise 1.4,
we know that this is in turn equivalent to
 
∀a, b ∈ Z (b, a) ∈ R ∧ (a, b) ∈ R ∨ (b, a) ̸∈ R ∧ (a, b) ̸∈ R .
Therefore, applying Tutorial Exercise 3.3 to the predicate P (x, y) = “(x, y) ∈ R”,
we see that for this question it suffices to show
∀a, b ∈ Z (a, b) ∈ R−1 → (a, b) ∈ R .


As mentioned in Tutorial Exercise 3.3, all these are related to the symmetry of
the relation R, a notion to be introduced in Chapter 6.
(b) (⊆) Let (a, c) ∈ R ◦ R. Use the definition of R ◦ R to find b ∈ Z such that
(a, b), (b, c) ∈ R. In view of the definition of R, this means both a − b and b − c are
even. Apply the definition of even integers to find x, y ∈ Z such that a − b = 2x
and b − c = 2y. Then a − c = (a − b) + (b − c) = 2x + 2y = 2(x + y), where
x + y ∈ Z. So a − c is even. According to the definition of R, this means a R c.
Thus (a, c) ∈ R.
(⊇) Let (a, b) ∈ R. Note that b − b = 0 = 2 × 0, which is even. So (b, b) ∈ R
by the definition of R. As (a, b), (b, b) ∈ R, we deduce that (a, b) ∈ R ◦ R by the
definition of R ◦ R.
5.5. By the definition of relation composition, both T ◦ (S ◦ R) and (T ◦ S) ◦ R are relations
from A to D, i.e., they are both subsets of A × D. So it suffices show that (w, z) ∈
T ◦ (S ◦ R) if and only if (w, z) ∈ (T ◦ S) ◦ R for all (w, z) ∈ A × D.
(⇒) Let (a, d) ∈ T ◦ (S ◦ R). Apply the definition of ◦ to find c ∈ C such that
(a, c) ∈ S ◦ R and (c, d) ∈ T . Applying the definition of ◦ again, we get b ∈ B such
that (a, b) ∈ R and (b, c) ∈ S. With c ∈ C satisfying (b, c) ∈ S and (c, d) ∈ T , we know
(b, d) ∈ T ◦ S by the definition of ◦. With b ∈ B satisfying (a, b) ∈ R and (b, d) ∈ T ◦ S,
the definition of ◦ tells us (a, d) ∈ (T ◦ S) ◦ R.
(⇐) Let (a, d) ∈ (T ◦ S) ◦ R. Apply the definition of ◦ to find b ∈ B such that (a, b) ∈ R
and (b, d) ∈ (T ◦S). Applying the definition of ◦ again, we get c ∈ C such that (b, c) ∈ S
and (c, d) ∈ T . With b ∈ B satisfying (a, b) ∈ R and (b, c) ∈ S, we know (a, c) ∈ S ◦ R
by the definition of ◦. With c ∈ C satisfying (a, c) ∈ S ◦ R and (c, d) ∈ T , the definition
of ◦ tells us (a, d) ∈ T ◦ (S ◦ R).
Alternative proof. By the definition of relation composition, both T ◦ (S ◦ R) and
(T ◦ S) ◦ R are relations from A to D, i.e., they are both subsets of A × D. So it suffices
show that (w, z) ∈ T ◦ (S ◦ R) if and only if (w, z) ∈ (T ◦ S) ◦ R for all (w, z) ∈ A × D.
Given any (w, z) ∈ A × D, by the definition of ◦,
(w, z) ∈ T ◦ (S ◦ R)
⇔ (w, y) ∈ S ◦ R and (y, z) ∈ T for some y ∈ C
⇔ (w, x) ∈ R and (x, y) ∈ S for some x ∈ B and (y, z) ∈ T for some y ∈ C
⇔ (w, x) ∈ R and (x, y) ∈ S and (y, z) ∈ T for some x ∈ B and y ∈ C
⇔ (w, x) ∈ R and (x, y) ∈ S and (y, z) ∈ T for some y ∈ C and x ∈ B
⇔ (w, x) ∈ R and (x, z) ∈ T ◦ S for some x ∈ B
⇔ (w, z) ∈ (T ◦ S) ◦ R.

tutsol.20
Additional comment. One can extract an explanation of the highlighted step above
from the first proof.

5.6. V = {a, b, c, d, e}, D = {(b, b), (b, c), (c, a), (c, d), (d, b), (d, c), (e, d), (e, e)}.
W = {1, 2, 3, 4, 5, 6}, E = {{3, 3}, {4, 4}, {6, 6}, {1, 3}, {1, 5}, {2, 5}, {3, 5}, {3, 4}}.
Additional explanations. The edges in the left drawing have directions. So it is the
drawing of the directed graph (V, D). Since (V, D) is a directed graph, the elements
of D are ordered pairs.
The edges in the right drawing have no direction. So it is the drawing of the undirected
graph (W, E). Since (W, E) is an undirected graph, the elements of E are sets.

5.7. Let P (n) be the predicate


if one square is removed from a 2n × 2n checkerboard, then the remaining
squares can be covered by L-trominos
over Z+ .
(Base step) P (1) is true because such a board itself is an L-tromino.
(Induction step) Let k ∈ Z+ such that P (k) is true. Let B be
2k
a 2k+1 × 2k+1 checkerboard with one square removed. Divide B
into four 2k × 2k quadrants. Let Q be the quadrant containing
the removed square. Remove one L-tromino from the centre of B Q
in a way such that each quadrant other than Q has one square 2k+1
removed. We are left with four 2k × 2k checkerboards, each with
one square removed. By the induction hypothesis, each quad-
rant can be covered by L-trominos. Hence B can be covered by
L-trominos. This shows P (k + 1) is true. B
Hence ∀n ∈ Z+ P (n) is true by MI.

Extra exercises
5.8. (a) R = {(a, 1), (a, 2), (b, 4), (c, 1), (c, 2), (c, 4), (d, 5), (e, 3)}.
−1
R = {(1, a), (2, a), (4, b), (1, c), (2, c), (4, c), (5, d), (3, e)}.
−1
R ◦ R = {(a, a), (a, c), (b, b), (b, c), (c, a), (c, b), (c, c), (d, d), (e, e)}.
R ◦ R−1 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (2, 4), (3, 3), (4, 1), (4, 2), (4, 4), (5, 5)}.

(b) R−1 ◦ R: a R ◦ R−1 : 1

b c 2 3

d e 4 5

Additional remark. We are asked for drawings of directed graphs here. So we


refer to Definition 5.3.5(5), and thus Definition 5.3.3.
5.9. By the definition of relation inverse, we know R−1 is a relation from B to A, and thus
(R−1 )−1 is a relation from A to B. Given any (x, y) ∈ A × B,

(x, y) ∈ (R−1 )−1 ⇔ (y, x) ∈ R−1 by the definition of (R−1 )−1 ;


⇔ (x, y) ∈ R by the definition of R−1 .

tutsol.21
Alternative proof. By the definition of relation inverse, we know R−1 is a relation
from B to A. So

(R−1 )−1 = {(x, y) ∈ A × B : (y, x) ∈ R−1 } by the definition of (R−1 )−1 ;


= {(x, y) ∈ A × B : (x, y) ∈ R} by the definition of R−1 ;
= R.

tutsol.22
Tutorial solutions for Chapter 6

Sometimes there are other correct answers.


6.1. (a)
a d

b e

(b) Yes, this R is an equivalence relation: as one can verify exhaustively, it is


reflexive, symmetric, and transitive.
The equivalence classes are {a, b, c} and {d} and {e}.
(c) No, this R is not a partial order. It is not antisymmetric because, for example,
we have (a, b) ∈ R and (b, a) ∈ R, but a ̸= b. As R is not antisymmetric, it cannot
be a partial order.
No, this R is not a total order, because it is not even a partial order.
Moral. It is often helpful to draw a diagram.

6.2. (a) R is reflexive because xx = x2 ⩾ 0 for all x ∈ Q.


R is symmetric because xy ⩾ 0 implies yx ⩾ 0 for all x, y ∈ Q.
R is not antisymmetric because 1 × 2 ⩾ 0 and 2 × 1 ⩾ 0 but 1 ̸= 2, for instance.
R is not transitive because 1 × 0 ⩾ 0 and 0 × (−1) ⩾ 0 but 1 × (−1) = −1 < 0,
for instance.
(b) y (x2 , y2 )

(x1 , y1 ) x

S is reflexive because x ⩽ x and y ⩽ y for all (x, y) ∈ R2 .


S is not symmetric because (1, 1) S (2, 2) but (2, 2) ̸S (1, 1), for instance.
S is antisymmetric. To see this, let (x1 , y1 ), (x2 , y2 ) ∈ R2 such that (x1 , y1 ) S
(x2 , y2 ) and (x2 , y2 ) S (x1 , y1 ). The former implies x1 ⩽ x2 and y2 ⩽ y2 , while
the latter implies x2 ⩽ x1 and y2 ⩽ y1 . Thus x1 = x2 and y1 = y2 . Hence
(x1 , y1 ) = (x2 , y2 ).
S is transitive. To see this, let (x1 , y1 ), (x2 , y2 ), (x3 , y3 ) ∈ R2 such that (x1 , y1 ) S
(x2 , y2 ) and (x2 , y2 ) S (x3 , y3 ). These imply x1 ⩽ x2 ⩽ x3 and y1 ⩽ y2 ⩽ y3 . Thus
x1 ⩽ x3 and y1 ⩽ y3 . Hence (x1 , y1 ) S (x3 , y3 ).

tutsol.23
6.3. y (x2 , y2 )


(x1 , y1 )
x

(a) (Reflexivity) Let (x, y) ∈ R2 . Then 3(x−x) = 3×0 = 0 = y−y. So (x, y) R (x, y).
(Symmetry) Let (x1 , y1 ), (x2 , y2 ) ∈ R2 such that (x1 , y1 ) R (x2 , y2 ). In view of
the definition of R, this means 3(x1 − x2 ) = y1 − y2 . Thus 3(x2 − x1 ) = y2 − y1 .
So (x2 , y2 ) R (x1 , y1 ) by the definition of R.
(Transitivity) Let (x1 , y1 ), (x2 , y2 ), (x3 , y3 ) ∈ R2 such that (x1 , y1 ) R (x2 , y2 ) and
(x2 , y2 ) R (x3 , y3 ). In view of the definition of R, this means 3(x1 − x2 ) = y1 − y2
and 3(x2 − x3 ) = y2 − y3 . Thus

3(x1 − x3 ) = 3(x1 − x2 ) + 3(x2 − x3 ) = (y1 − y2 ) + (y2 − y3 ) = y1 − y3 .

So (x1 , y1 ) R (x3 , y3 ) by the definition of R.


As R is reflexive, symmetric and transitive, it is an equivalence relation.
(b) [(u, v)] is the straight line with slope 3 passing through the point (u, v) in the
plane R2 .
Explanations.

[(u, v)] = {(x, y) ∈ R2 : (u, v) R (x, y)} by the definition of [(u, v)];
2
= {(x, y) ∈ R : 3(u − x) = v − y} by the definition of R;
2
= {(x, y) ∈ R : y = 3x + (v − 3u)}.

From this, we see that [(u, v)] is a straight line with slope 3. We know (u, v) ∈
[(u, v)] by Lemma 6.3.5(1).

y
y = 3x + (v − 3u)

(u, v)

(0, c)
x

(c) Let (u, v) ∈ R2 . Define c = v − 3u. Then v − c = v − (v − 3u) = 3u = 3(u − 0). So


the definition of R tells us (u, v) R (0, c). Hence (0, c) ∈ [(u, v)] by the definition
of [(u, v)].
How one may find this c. Unravelling the definitions, we see that we want
c ∈ R such that (u, v) R (0, c). This means 3(u − 0) = v − c. Solving gives
c = v − 3u. What we showed here is that the only c ∈ R that can possibly make
(0, c) ∈ [(u, v)] is v − 3u. As verified above, this choice of c actually works.
Additional comment. We do not need to explain how we found our c in a proof
that such a c exists.

tutsol.24
6.4. (⇒) Suppose x ∼ y. We want to show [x] = [y].
([x] ⊆ [y]) Take z ∈ [x]. This means x ∼ z by the definition of [x]. As x ∼ y, the
symmetry of ∼ tells us y ∼ x. In view of the transitivity of ∼, having both y ∼ x and
x ∼ z implies y ∼ z. So z ∈ [y] by the definition of [y].
([y] ⊆ [x]) This is essentially the same as the proof of the converse, except that we
interchange x and y. Take z ∈ [y]. This means y ∼ z by the definition of [y]. In view
of the transitivity of ∼, having both x ∼ y and y ∼ z implies x ∼ z. So z ∈ [x] by the
definition of [x].
(⇐) Suppose [x] = [y]. Note y ∼ y by the reflexivity of ∼. So the definition of [y] tells
us y ∈ [y] = [x]. So x ∼ y by the definition of [x].
Alternative proof using Lemma 6.3.5 and Lemma 6.3.6. (⇒) Suppose x ∼ y.
Then y ∈ [x] by the definition of [x]. We also know y ∈ [y] by Lemma 6.3.5(1). These
tell us y ∈ [x] ∩ [y] and thus [x] ∩ [y] ̸= ∅. Hence [x] = [y] by Lemma 6.3.6.
(⇐) Suppose [x] = [y]. Then Lemma 6.3.5(1) implies y ∈ [y] = [x]. So x ∼ y by the
definition of [x].

6.5. (a) The symmetry of a relation R on A states that ∀x, y ∈ A (x R y ⇒ y R x). The
attempt claims that this implies ∀x, y ∈ A (x R y ∧ y R x). This is not justified
(and actually not true).
(b) One counterexample is the relation R = {(0, 0)} on the set A = {0, 1}.
Explanation. The given proposition can be written semi-symbolically as

∀set A ∀relation R on A Sym(A, R) ∧ Tran(A, R) → Refl(A, R) ,

where Sym(A, R) stands for “R is a symmetric relation on A”, etc. So a coun-


terexample consists of a set A and a relation R on A which makes the conditional
proposition
Sym(A, R) ∧ Tran(A, R) → Refl(A, R)
false. According to Example 1.4.23, the negation of this conditional proposition is

Sym(A, R) ∧ Tran(A, R) ∧ ¬Refl(A, R).

The relation given above satisfies this: it is symmetric and transitive, as one can
verify exhaustively, but it is not reflexive because 1 ∈ A but (1, 1) ̸∈ R.
Moral. The compound expressions p → q and p ∧ q, where p, q are propositional
variables, are not equivalent, as one can verify using a truth table.

6.6. (a) This proposition is false. One counterexample is the relation R= {(0, 0), (1, 1)}
on the set A = {0, 1}. It is both symmetric and antisymmetric, as one can verify
exhaustively.
(b) This proposition is also false. One counterexample is the divisibility relation on Z
from Example 6.1.8 and Example 6.4.5.
Moral. Antisymmetry is not the negation of symmetry. In fact, it is neither a necessary
nor a sufficient condition for the negation of symmetry.

6.7. Let P (n) be the predicate


there exist no x1 , x2 , . . . , xn ∈ A satisfying x1 ̸= x2 and

x1 R x2 and x2 R x3 and ... and xn−1 R xn and xn R x1

over Z⩾2 .

tutsol.25
(Base step) The antisymmetry of R tells us there exist no x1 , x2 ∈ A satisfying
x1 ̸= x2 and x1 R x2 and x2 R x1 . So P (2) is true.
(Induction step) Let k ∈ Z⩾2 such that P (k) is true, i.e., there exist no x1 , x2 , . . . , xk ∈
A satisfying x1 ̸= x2 and

x1 R x2 and x2 R x3 and ... and xk−1 R xk and xk R x1 .

Suppose P (k + 1) is false. This gives x1 , x2 , . . . , xk , xk+1 ∈ A satisfying x1 ̸= x2


and

x1 R x 2 and x2 R x3 and ... and xk−1 R xk and xk R xk+1 and xk+1 R x1 .

In view of the transitivity of R, the last two conditions imply xk R x1 . This,


together with the rest of the conditions above, contradict the induction hypothesis.
So P (k + 1) is true.
Hence ∀n ∈ Z⩾2 P (n) is true by MI.

Extra exercises
6.8. (a) R is not reflexive because 0 × 0 = 0 ⩽ 0.
R is symmetric because xy > 0 implies yx > for all x, y ∈ Q.
R is not antisymmetric because 1 × 2 > 0 and 2 × 1 > but 1 ̸= 2, for instance.
R is transitive. To see this, suppose x, y, z ∈ Q such that xy > 0 And yz > 0.
As xy > 0, either x, y are both positive, or x, y are both negative.
• Suppose x > 0 and y > 0. Then z > 0 too as yz > 0. It follows that xz > 0.
• Suppose x < 0 and y < 0. Then z < 0 too as yz > 0. It follows that xz > 0.
(b) S is not reflexive because x ̸= x + 1 for all x ∈ Z.
S is not symmetric because y = x + 1 implies x = y − 1 ̸= y + 1 for all x, y ∈ Z.
S is antisymmetric vacuously because if y = x + 1 and x = y + 1, then x =
y + 1 = (x + 1) + 1 = x + 2 ̸= x, which is a contradiction.
S is not transitive because if y = x + 1 and z = y + 1, then z = (x + 1) + 1 =
x + 2 ̸= x + 1.
6.9. R = R−1
∀(x, y) ∈ A2 (x, y) ∈ R ⇔ (x, y) ∈ R−1 as R, R−1 ⊆ A2 ;


∀(x, y) ∈ A2 by the definition of R−1 ;

⇔ (x, y) ∈ R ⇔ (y, x) ∈ R
∀(x, y) ∈ A2

⇔ (x, y) ∈ R ⇒ (y, x) ∈ R by Exercise 3.3;
⇔ R is symmetric by the definition of symmetry.

6.10. (a) (Reflexivity) Let a ∈ Z. Note that a − a = 0 = 2 × 0, where 0 ∈ Z. So a − a is


even, and thus a R a by the definition of R.
(Symmetry) Let a, b ∈ Z such that a R b. Then a − b is even by the definition
of R. Use the definition of even integers to find x ∈ Z such that a − b = 2x. Then
b − a = 2(−x), where −x ∈ Z. So b − a is even, and thus b R a by the definition
of R.
(Alternative proof of symmetry) Let a, b ∈ Z such that a R b. Then a − b is even
by the definition of R. So Exercise 3.2.6(1) implies b − a = −(a − b) is also even.
Thus b R a by the definition of R.
(Yet another proof of symmetry) We know R−1 = R from Tutorial Exercise 5.4(a)
So R is symmetric by Tutorial Exercise 6.9.

tutsol.26
(Transitivity) Let a, b, c ∈ Z such that a R b and b R c. Then a − b and b − c are
both even by the definition of R. Use the definition of even integers to find x, y ∈ Z
such that a−b = 2x and b−c = 2y. Then a−c = (a−b)+(b−c) = 2x+2y = 2(x+y),
where x + y ∈ Z. So a − c is even, and thus a R c by the definition of R.
(Alternative proof of transitivity) We know R ◦ R = R ⊆ R from Tutorial Exer-
cise 5.4(b) and Remark 4.2.4(3). So R is transitive by Exercise 6.1.10.
As R is reflexive, symmetric, and transitive, it is an equivalence relation.
(b) [0] = {. . . , −4, −2, 0, 2, 4, . . . } = [2] = [−2] = [4] = [−4] = · · ·
[1] = {. . . , −3, −1, 1, 3, 5, . . . } = [−1] = [3] = [−3] = [5] = · · ·

tutsol.27
Tutorial solutions for Chapter 7

Sometimes there are other correct answers.


7.1. (a) No. One can write this condition symbolically as ∀x ∈ A ∃y ∈ B y = f (x).
The function f : {a, b} → {0, 1} satisfying f (a) = 0 = f (b) is not surjective but it
satisfies the condition there.
(b) No. One can write this condition symbolically as ∃y ∈ B ∃x ∈ A y = f (x).
The function f : {a, b} → {0, 1} satisfying f (a) = 0 = f (b) is not surjective but it
satisfies the condition there.
(c) No. One can write this condition symbolically as ∃y ∈ B ∀x ∈ A y = f (x).
The function f : {a, b} → {0, 1} satisfying f (a) = 0 = f (b) is not surjective but it
satisfies the condition there.
(d) Yes. One can write this condition symbolically as ¬∃y ∈ B ∀x ∈ A y ̸= f (x).
This is equivalent to the surjectivity of f by Theorem 2.4.9.
Moral. Sometimes it is easier to see the logical structure of a proposition when it is
written symbolically.

7.2. (a) No. One can write this symbolically as ∀x1 , x2 ∈ A x1 = x2 → f (x1 ) = f (x2 ) .
The function f : {a, b} → {0, 1} satisfying f (a) = 0 = f (b) is not injective but it
satisfies the condition there.

(b) Yes. One can write this symbolically as ∀x1 , x2 ∈ A x1 ̸= x2 → f (x1 ) ̸= f (x2 ) .
This is equivalent to the injectivity of f because any conditional proposition is
equivalent to its contrapositive.

(c) Yes. One can write this symbolically as ¬∃x1 , x2 ∈ A x1 ̸= x2 ∧ f (x1 ) = f (x2 ) .
This is equivalent to the injectivity of f by Theorem 2.4.9 and Example 1.4.23.

(d) No. One can write this symbolically as ∃x1 , x2 ∈ A x1 ̸= x2 ∧ f (x1 ) = f (x2 ) .
The function f : {a, b} → {0, 1} satisfying f (a) = 0 = f (b) is not injective but it
satisfies the condition there.
Moral. Sometimes it is easier to see the logical structure of a proposition when it is
written symbolically.

7.3. (a) No, because 0 is not related to any element of B, violating (F1).

A RA,B 3
2 2
1 1
0 0
−1 B
−2

tutsol.28
(b) Let B = {−1, 0, 3}. There is no other choice.

A RA,B 3
2
1
0 0
−1 −1
−2 B

(c) Say A = {1, 2}. There are exactly 8 other examples.

RA,B 3
2 2
1 1
A 0
B

Extra information. y

Moral. The same equation can define different relations: some are functions, some are
not; some are surjective, some are not; some are injective, some are not.

7.4. (a) (F1) Let n ∈ Z. Then n is either even or odd by Proposition 3.2.21. If n is even,
then the definition of even integers gives x ∈ Z such that n = 2x. If n is odd, then
the definition of odd integers gives x ∈ Z such that n = 2x + 1. In all cases, we
get x ∈ Z such that n = 2x or n = 2x + 1, i.e., such that (n, x) ∈ f .
(F2) Let n, x1 , x2 ∈ Z such that (n, x1 ), (n, x2 ) ∈ f . Recall that n is either even
or odd by Proposition 3.2.21.
Consider the case when n is even. As (n, x1 ) ∈ f , the definition of f tells us
n = 2x1 or n = 2x1 + 1. The latter cannot be true because it implies n is odd,
and no integer is both even and odd by Proposition 3.2.17. So it must be the case
that n = 2x1 . Similarly, as (n, x2 ) ∈ f , we derive that n = 2x2 . Combining the
two, we have 2x1 = n = 2x2 . Thus x1 = x2 .
Consider the case when n is odd. As (n, x1 ) ∈ f , the definition of f tells us
n = 2x1 or n = 2x1 + 1. The former cannot be true because it implies n is even,
and no integer is both even and odd by Proposition 3.2.17. So it must be the case
that n = 2x1 + 1. Similarly, as (n, x2 ) ∈ f , we derive that n = 2x2 + 1. Combining
the two, we have 2x1 + 1 = n = 2x2 + 1. It follows that x1 = x2 .
(b) This f is surjective, as shown below.
Let x ∈ Z. Define n = 2x. Then (n, x) ∈ f by the definition of f .
(c) This f is not injective, as shown below.
Note that 0 = 2 × 0 and 1 = 2 × 0 + 1. So (0, 0), (1, 0) ∈ f by the definition of f ,
but 0 ̸= 1.
(d) The range of f is Z.

tutsol.29
Additional explanation. Note that the codomain of f is Z. So we know
range(f ) ⊆ Z by Remark 7.2.3(2). Conversely, by (b), for every x ∈ Z, there exists
n ∈ Z such that f (n) = x. This shows Z ⊆ range(f ). Hence range(f ) = Z.
Additional comment. Here f (n) is the quotient when n is divided by 2, or equiva-
lently f (n) = ⌊n/2⌋, for each n ∈ Z.

7.5. (a) This g is surjective, as shown below.


Note that g(T, T, F) = T and g(T, T, T) = F. So for every y ∈ {T, F}, there exists
(p0 , q0 , r0 ) ∈ {T, F}3 such that g(p0 , q0 , r0 ) = y.
(b) This g is not injective, as shown below.
Note that g(T, T, T) = F = g(T, F, T), where (T, T, T) ̸= (T, F, T).
(c) The function f : {T, F} → {T, F}3 that satisfies f (T) = (T, T, F) and f (F) =
(T, T, T) has the required property.
Additional information.
p q r p∨q ¬r p ∨ q → ¬r
T T T T F F
T T F T T T
T F T T F F
T F F T T T
F T T T F F
F T F T T T
F F T F F T
F F F F T T

7.6. Assume f is surjective and g ◦ f = idA . Let y1 , y2 ∈ B such that g(y1 ) = g(y2 ).
Apply the surjectivity of f to find x1 , x2 ∈ A satisfying f (x1 ) = y1 and f (x2 ) = y2 .
Substituting these into g(y1 ) = g(y2 ) gives

g(f (x1 )) = g(f (x2 ))


∴ (g ◦ f )(x1 ) = (g ◦ f )(x2 ) by Proposition 7.3.1.
∴ idA (x1 ) = idA (x2 ) as g ◦ f = idA by assumption.
∴ x1 = x2 by the definition of idA .
∴ y1 = f (x1 ) = f (x2 ) = y2 by the choice of x1 , x2 .

7.7. The induction step breaks down when k = 1, as explained below.


When k = 1, the whole campus has only a and b in it, because it has exactly k + 1 = 2
people in it. So no person stayed on the campus throughout. Therefore, while it is
true that “the people who stayed on the campus throughout have the same birthday as
both a and b”, it is only true vacuously. In this case, one cannot deduce that a and b
have the same birthday.
Moral. In the induction step, one needs to carefully check that the proof of P (k + 1)
from P (k) works for all relevant k’s. Even the failure of one of them can make the
whole proof fail very badly.

Extra exercises
7.8. f is not a function Q → Q, while g is.
Additional explanations. • Recall that y = ±x stands for “y = x or y = −x”.
So 1 = ±1 and −1 = ±1. Thus (1, 1), (1, −1) ∈ f , where 1 ̸= −1. This shows that
f does not satisfy (F2).

tutsol.30
• g is the function Q → Q that satisfies
1
g(x) =
x2 +1
for all x ∈ Q.

7.9. Assume f −1 is a function B → A.


(Surjectivity) Let y ∈ B. Use (F1) for f −1 to find x ∈ A such that (y, x) ∈ f −1 . Then
(x, y) ∈ f by the definition of f −1 . So f (x) = y.
(Injectivity) Let x1 , x2 ∈ A such that f (x1 ) = f (x2 ). Define y = f (x1 ). Then y =
f (x2 ) too because f (x1 ) = f (x2 ). So (x1 , y) ∈ f and (x2 , y) ∈ f . These imply
(y, x1 ), (y, x2 ) ∈ f −1 via the definition of f −1 . Hence x1 = x2 as f −1 satisfies (F2).
7.10. (a) (F1) Let x ∈ Z. Then 2x ∈ Z. So (x, 2x) ∈ g.
(F2) For g, let x, n1 , n2 ∈ Z such that (x, n1 ), (x, n2 ) ∈ g. Then n1 = 2x and
n2 = 2x by the definition of g. So n1 = 2x = n2 .
(b) g is not surjective, as shown below.
Consider −1231 ∈ Z. It is odd by Example 3.1.3(2). So −1231 is not even by
Proposition 3.2.17. This means −1231 ̸= 2x for any x ∈ Z. Thus g(x) ̸= −1231
for any x ∈ Z according to the definition of g.
(c) g is injective, as shown below.
Let x1 , x2 ∈ Z such that g(x1 ) = g(x2 ). Then 2x1 = 2x2 by the definition of g.
So x1 = x2 .
(d) (⊆) Let (x, y) ∈ f ◦ g. Use the definition of f ◦ g to find n ∈ Z such that (x, n) ∈ g
and (n, y) ∈ f . In view of the definitions of g and f , the former means n = 2x,
while the latter means n = 2y or n = 2y + 1. As n = 2x, we know n is even. So n
is not odd by Proposition 3.2.17. Thus n ̸= 2y + 1. It follows that n = 2y, from
which we deduce 2y = n = 2x. Hence x = y. This implies (x, y) = (x, x) ∈ idZ .
(⊇) Let (x, y) ∈ idZ . Then x = x by the definition of id. In view of the definitions
of g and f , we know (x, 2x) ∈ g and (2x, x) ∈ f . So (x, y) = (x, x) ∈ f ◦ g.
It follows that f ◦ g = idZ .
Consider 1 ∈ Z. Since 1 = 2 × 0 + 1, we know f (1) = 0 from the definition of f . So
(g ◦ f )(1) = g(f (1)) = g(0) = 2 × 0 = 0 ̸= 1 = idZ (1). This shows g ◦ f ̸= idZ .
(e) No. Since 1 = 2×0+1, we know (1, 0) ∈ f from the definition of f . So (0, 1) ∈ f −1
by the definition of f −1 . However, we know (0, 1) ̸∈ g because 1 ̸= 2 × 0. So
g ̸= f −1 .
Alternative proof. We know from Tutorial Exercise 7.4 that f is not injective,
and thus not bijective. So Extra Exercise 7.9 tells us f −1 is not a function. Since
g is a function by (a), it must be the case that g ̸= f −1 .

tutsol.31
Tutorial solutions for Chapter 8

Sometimes there are other correct answers.


8.1. (a) Suppose f and g are surjective. Let z ∈ C. Use the surjectivity of g to find
y ∈ B such that z = g(y). Then use the surjectivity of f to find x ∈ A such
that y = f (x). Now z = g(y) = g(f (x)) = (g ◦ f )(x) by Proposition 7.3.1, as
required.
(b) Suppose f and g are injective. Let x1 , x2 ∈ A such that (g ◦ f )(x1 ) = (g ◦ f )(x2 ).
Then g(f (x1 )) = g(f (x2 )) by Proposition 7.3.1. The injectivity of g then implies
f (x1 ) = f (x2 ). So the injectivity of f tells us x1 = x2 , as required.
Additional comment. Let S be a relation from a set C to a set B and R be a relation
from the set B to a set A. Our proof of Proposition 7.3.1 actually shows that if R and S
both satisfy (F1) in the definition of functions, then R ◦ S also satisfies (F1). As the
surjectivity of a function precisely says its inverse relation satisfies (F1), applying this
to R = f −1 and S = g −1 gives (a) directly.
Similarly, our proof of Proposition 7.3.1 shows that if R and S both satisfy (F2) in the
definition of functions, then R ◦ S also satisfies (F2). As the injectivity of a function
precisely says its inverse relation satisfies (F2), applying this to R = f −1 and S = g −1
gives (b) directly.

8.2. We use the same example for all the three parts. Let A = {0} and B = {0, 1} and
C = {0}. Define f : A → B and g : B → C by setting f (0) = 0 and g(0) = 0 and
g(1) = 0.

Diagram. 1

0 0 g 0
f
A B C
Explanation. Then g ◦ f = id{0} and is thus bijective; see the solution to Exer-
cise 8.3(1) below for a proof. The function f is not surjective because 1 ∈ B and
1 ̸= f (x) for any x ∈ A. The function g is not injective because 0, 1 ∈ B satisfying
g(0) = 0 = g(1) and 0 ̸= 1. So neither f nor g is bijective.

8.3. (a) It suffices to show that the identity function idA on A is a bijection A → A. For
surjectivity, given any x ∈ A, we have idA (x) = x. For injectivity, if x1 , x2 ∈ A
such that idA (x1 ) = idA (x2 ), then x1 = x2 .
(b) If f is a bijection A → B, then Proposition 7.4.3 tells us f −1 is a bijection
B → A.
(c) If f is a bijection A → B and g is a bijection B → C, then g ◦ f is a bijection
A → C by Exercise 8.1.

tutsol.32
8.4. Pick (u, v), (s, t) ∈ R2 . According to the information from Tutorial Exercise 6.3(b),

[(u, v)] = {(x, y) ∈ R2 : y = 3x + (v − 3u)}, and


[(s, t)] = {(x, y) ∈ R2 : y = 3x + (t − 3s)}.

To show that [(u, v)] and [(s, t)] have the same cardinality, it suffices to find a bijection
[(u, v)] → [(s, t)]. There are many choices. Here we use the function f : [(u, v)] → [(s, t)]
defined by setting, for all (x, y) ∈ [(u, v)],

f (x, y) = x, y + (t − 3s) − (v − 3u) .

(Well-defined) Let us first check that the definition of f given indeed assigns every
element of [(u, v)] exactly one element of [(s, t)], as required by the definition of
functions. Take any (x0 , y0 ) ∈ [(u, v)]. Clearly, there is exactly one object that is
equal to x0 , y0 + (t − 3s) − (v − 3u) . So we only need to check that this object
is indeed an element of the codomain [(s, t)].
As (x0 , y0 ) ∈ [(u, v)], we know y0 = 3x0 + (v − 3u). So

y0 + (t − 3s) − (v − 3u) = 3x0 + (v − 3u) + (t − 3s) − (v − 3u) = 3x0 + (t − 3s).



This shows x0 , y0 + (t − 3s) − (v − 3u) ∈ [(s, t)], as required.
(Surjective) Let (z0 , w0 ) ∈ [(s, t)]. Then w0 = 3z0 + (t − 3s). So

w0 + (v − 3u) − (t − 3s) = 3z0 + (t − 3s) + (v − 3u) − (t − 3s) = 3z0 + (v − 3u).



This shows z0 , w0 + (v − 3u) − (t − 3s) ∈ [(u, v)]. Moreover,
 
f z0 , w0 +(v−3u)−(t−3s) = z0 , w0 +(v−3u)−(t−3s)+(t−3s)−(v−3u) = (z0 , w0 ).

(Injective) Let (x1 , y1 ), (x2 , y2 ) ∈ [(u, v)] such that f (x1 , y1 ) = f (x2 , y2 ). According
to the definition of f , this means
 
x1 , y1 + (t − 3s) − (v − 3u) = x2 , y2 + (t − 3s) − (v − 3u) .

So x1 = x2 and y1 + (t − 3s) − (v − 3u) = y2 + (t − 3s) − (v − 3u). The latter


implies y1 = y2 . Thus together we have (x1 , y1 ) = (x2 , y2 ).
Additional comment 1. It is probably easier to see how one may come up with our
function f geometrically. When drawn on the plane, it moves the straight line [(u, v)]
vertically up/down to the straight line [(s, t)]. The exact displacement involved can be
calculated from the points where these lines intersect the y-axis, for example.

y
[(s, t)]

(s, t)

[(u, v)]

t − 3s –
(u, v)
x

displacement – v − 3u
(t − 3s) − (v − 3u)

tutsol.33
Additional comment 2 (repeated from the solutions to Exercise 8.2.5). Some-
times when one defines a function, it is not immediately clear that the definition given
indeed defines a function, i.e., that it defines an object satisfying the definition of func-
tions. In such cases, a proof should be provided. In many other cases, it is clear that the
definition given really defines a function, and so no additional explanation is needed.

8.5. By symmetry, it suffices to show only one direction. Suppose A is finite. Use the defi-
nition of finiteness to find n ∈ N such that A has the same cardinality as {1, 2, . . . , n}.
Then the symmetry and the transitivity of same-cardinality from Proposition 8.2.4 tell
us B has the same cardinality of {1, 2, . . . , n}. So B is finite.
8.6. (a) In the induction step, the author claims that “no i ∈ {1, 2, . . . , k} makes f (xi ) =
yℓ ”. The author did not explain clearly why this is true.
Additional explanation. In fact, this claim may not be true. For example,
consider the case when
k = 1, n = k + 1 = 2, m = 1, x2
A = {x1 , x2 }, B = {y1 }, x1 y1
f
f (x1 ) = y1 , f (x2 ) = y1 . A B
As f (xk+1 ) = f (x2 ) = y1 , we have ℓ = 1. If i = 1, then i = 1 ∈ {1} = {1, 2, . . . , k}
and f (xi ) = f (x1 ) = y1 = yℓ . So some i ∈ {1, 2, . . . , k} makes f (xi ) = yℓ , contrary
to what the author claims.
If we carry on following the author’s argument with this f , then we would need
to construct a function fˆ: {x1 } → {}, which is not possible because {} has no
element, but such fˆ must satisfy fˆ(x1 ) ∈ {}.
(b) The attempt takes care of the case when no i ∈ {1, 2, . . . , k} makes f (xi ) = yℓ .
We can deal with the remaining case separately as follows.
Assume some i ∈ {1, 2, . . . , k} makes f (xi ) = yℓ . Define fˆ: {x1 , x2 , . . . , xk } →
{y1 , y2 , . . . , ym } by setting fˆ(xi ) = f (xi ) for each i ∈ {1, 2, . . . , k}. Then fˆ is
surjective because, for each yh , the surjectivity of f gives some xi such that yh =
f (xi ), and we can require this i ̸= k + 1 by our assumption; so yh = f (xi ) = fˆ(xi ).
As the x’s are all different and the y’s are all different, the induction hypothesis
tells us k ⩾ m. So k + 1 ⩾ m + 1 ⩾ m.

Extra exercises
8.7. (a) Suppose g ◦ f is surjective. Take any z ∈ C. Use the surjectivity of g ◦ f to find
x ∈ A such that (g ◦ f )(x) = z. Define y = f (x). Then
g(y) = g(f (x)) as y = f (x);
= (g ◦ f )(x) by Proposition 7.3.1;
= z.
(b) Suppose g ◦ f is injective. Let x1 , x2 ∈ A such that f (x1 ) = f (x2 ). Then
g(f (x1 )) = g(f (x2 )).
∴ (g ◦ f )(x1 ) = (g ◦ f )(x2 ) by Proposition 7.3.1.
∴ x1 = x2 as g ◦ f is injective.

8.8. Suppose A has the same cardinality as both {1, 2, . . . , m} and {1, 2, . . . , n}. Use the
definition of same cardinality to find bijections f : A → {1, 2, . . . , m} and g : A →
{1, 2, . . . , n}. Then f −1 is a bijection {1, 2, . . . , m} → A by Proposition 7.4.3. In view
of Exercise 8.1, these imply that g ◦ f −1 is a bijection {1, 2, . . . , m} → {1, 2, . . . , n}.
Hence m = n by Theorem 8.1.3.

tutsol.34
8.9. (a) Let f be a surjection A → B that is not an injection. Use the failure of injectivity
to find i, j ∈ {1, 2, . . . , n} such that xi ̸= xj but f (xi ) = f (xj ). Now
x1 , x2 , . . . , xj−1 , xj+1 , . . . , xn
are n − 1 objects with no repetition. Denote these by x̂1 , x̂2 , . . . , x̂n−1 respectively.
Let  = {x̂1 , x̂2 , . . . , x̂n−1 }, so that  = A \ {xj }. Define a function fˆ:  → B
by setting fˆ(x) = f (x) for all x ∈ Â.
We claim that fˆ is surjective. To prove this, consider y ∈ B. Use the surjectivity
of f to find k ∈ {1, 2, . . . , n} such that y = f (xk ).
Case 1: Assume k = j. Then xi ∈ A \ {xj } = Â because xi ̸= xj . Also
fˆ(xi ) = f (xi ) by the definition of fˆ;
= f (xj ) by the choice of i, j;
= f (xk ) as j = k by assumption;
=y by the choice of k.
Case 2: Assume k ̸= j. Then xk ∈ A \ {xj } = Â as the x’s are different. So the
definition of fˆ and the choice of k tell us fˆ(xk ) = f (xk ) = y.
So y = fˆ(x) for some x ∈ Â in all cases. This completes the proof of the claim.
Now fˆ is a surjection  → B, where A = {x̂1 , x̂2 , . . . , x̂n−1 } and B = {y1 , y2 , . . . , ym }.
Since the x̂’s are different and the y’s are different, the Dual Pigeonhole Principle
then implies m ⩽ n − 1 < n, as required.
Diagram. xn ym
.. ..
. .
xj ..
× .
.. yℓ
.
xi ..
.
.. ..
. .
x2 y2
x1 f y1
(b) Let f be an injection A → B that is not a surjection. Use the failure of surjectivity
to find ℓ ∈ {1, 2, . . . , m} such that yℓ ̸= f (x) for any x ∈ A. Now
y1 , y2 , . . . , yℓ−1 , yℓ+1 , . . . , ym
are m−1 objects with no repetition. Denote these by ŷ1 , ŷ2 , . . . , ŷm−1 respectively.
Let B̂ = {ŷ1 , ŷ2 , . . . , ŷm−1 }, so that B̂ = B \ {yℓ }. Define a function fˆ: A → B̂
by setting fˆ(x) = f (x) for all x ∈ A. This function is well defined: for any x ∈ A,
we know f (x) ̸= yℓ by the choice of ℓ, and thus f (x) ∈ B \ {yℓ } = B̂. Note that
fˆ is injective, because if i, j ∈ {1, 2, . . . , n} such that fˆ(xi ) = fˆ(xj ), then the
definition of fˆ tells us f (xi ) = f (xj ), and so xi = xj by the injectivity of f . Now
fˆ is an injection A → B̂, where A = {x1 , x2 , . . . , xn } and B = {ŷ1 , ŷ2 , . . . , ŷm−1 }.
Since the x’s are different and the y’s are different, the Pigeonhole Principle then
implies n ⩽ m − 1 < m, as required.
Diagram. xn ym
.. ..
. .
..
××

. yℓ
.. ..
. .
x2 y2
x1 f y1

tutsol.35
Tutorial solutions for Chapter 9

Sometimes there are other correct answers.


9.1. Define A0 = A \ B and B0 = B. Then A0 ∩ B0 = ∅ and A0 ∪ B0 = A ∪ B by Extra
Exercise 4.9. So it suffices to show that A0 ∪ B0 is finite. Observe that, as A0 = {x ∈
A : x ̸∈ B} ⊆ A and A is finite, we know A0 is also finite by Proposition 9.2.6(1).
Use the definition of finite sets to find bijections

f : {1, 2, . . . , m} → A0 and g : {1, 2, . . . , n} → B0

where m, n ∈ N. Define the function h : {1, 2, . . . , m + n} → A0 ∪ B0 by setting, for


each x ∈ {1, 2, . . . , m + n},
(
f (x), if x ⩽ m;
h(x) =
g(x − m), if x > m.

If x ∈ {1, 2, . . . , m + n} such that x ⩽ m, then x is in the domain of f , and so we can


indeed apply f to x. If x ∈ {1, 2, . . . , m + n} such that x > m, then 0 = m − m <
x − m ⩽ (m + n) − m = n, and so we can indeed apply g to x − m. For every
x ∈ {1, 2, . . . , m + n}, if x ⩽ m, then h(x) = f (x) ∈ A0 ; conversely, if x > m, then
h(x) = g(x − m) ∈ B0 , and so h(x) ̸∈ A0 as A0 ∩ B0 = ∅. Hence

∀x ∈ {1, 2, . . . , m + n} x ⩽ m ⇔ h(x) ∈ A0 . (∗)

Now we verify that h is bijective; this will finish the proof.


(Surjectivity) Let y ∈ A0 ∪ B0 . Then y ∈ A0 or y ∈ B0 by the definition of A0 ∪ B0 .
If y ∈ A0 , then the surjectivity of f gives v ∈ {1, 2, . . . , m} such that y = f (v) =
h(v). If y ∈ B0 , then the surjectivity of g gives w ∈ {1, 2, . . . , n} such that
y = g(w) = g (w + m) − m = h(w + m) as w + m > 0 + m = m. So we have
x ∈ {1, 2, . . . , m + n} which makes y = f (x) in all cases.
(Injectivity) Let x1 , x2 ∈ {1, 2, . . . , m + n} such that h(x1 ) = h(x2 ). In view of (∗),
this implies either x1 ⩽ m and x2 ⩽ m, or x1 > m and x2 > m. If x1 ⩽ m and
x2 ⩽ m, then f (x1 ) = h(x1 ) = h(x2 ) = f (x2 ), and thus x1 = x2 by the injectivity
of f . If x1 > m and x2 > m, then g(x1 − m) = h(x1 ) = h(x2 ) = g(x2 − m), and
thus x1 − m = x2 − m by the injectivity of g, from which we can deduce x1 = x2 .
So x1 = x2 in all cases.
Additional comment. The following diagram gives some idea of why we chose to

tutsol.36
define h in this way:

B0
h g
n g(n) n
.. .. .. .. ..
. . . . .
m+2 g(2) 2
m+1 g(1) 1
m f (m) m
.. .. .. .. ..
. . . . .
2 f (2) 2
1 f (1) 1
f
A0

One reason why small sets should be closed under (binary) union. We may
view two sets as equivalent if and only if their (symmetric) difference is small. In
particular, if S is a set and A, B are small sets, then S should be equivalent to S \ A,
and S \ A should be equivalent to (S \ A) \ B = S \ (A ∪ B). Any notion of equivalence
should be (reflexive, symmetric, and) transitive. So if S is a set and A, B are small sets,
then S should be equivalent to S \ (A ∪ B) by transitivity; this indicates that A ∪ B
should also be small.

9.2. Define A0 = A \ B and B0 = B. Then A0 ∩ B0 = ∅ and A0 ∪ B0 = A ∪ B by


Extra Exercise 4.9. So it suffices to show that A0 ∪ B0 is countable. Observe that,
as A0 = {x ∈ A : x ̸∈ B} ⊆ A and A is countable, we know A0 is also countable by
Proposition 9.2.6(2).
If A0 and B0 are both finite, then Exercise 9.1 tells us A0 ∪ B0 is finite and thus
countable. So suppose at least one of A0 and B0 is infinite.

Case 1: suppose exactly one of A0 and B0 is infinite. Say A0 is finite and B0 is


infinite; the case when A0 is infinite and B0 is finite can be handled similarly. As
B0 is infinite and countable, it has the same cardinality as N. Use this fact and
the definition of finite sets to find bijections

f : {1, 2, . . . , m} → A0 and g : N → B0

where m ∈ N. Define the function h1 : N → A0 ∪ B0 by setting, for each x ∈ N,


(
f (x + 1), if x ⩽ m − 1;
h1 (x) =
g(x − m), if x ⩾ m.

If x ∈ N such that x ⩽ m − 1, then 1 = 0 + 1 ⩽ x + 1 ⩽ (m − 1) + 1 = m, and so


we can indeed apply f to x. If x ∈ N such that x ⩾ m, then x − m ⩾ m − m = 0,
and so we can indeed apply g to x − m. For every x ∈ N, if x ⩽ m − 1, then
h1 (x) = f (x + 1) ∈ A0 ; conversely, if x ⩾ m, then h1 (x) = g(x − m) ∈ B0 , and so
h1 (x) ̸∈ A0 as A0 ∩ B0 = ∅. Hence

∀x ∈ N x ⩽ m ⇔ h1 (x) ∈ A0 . (†)

Now we verify that h1 is bijective; this will give the countability of A0 ∪ B0 .


(Surjectivity) Let y ∈ A0 ∪ B0 . Then y ∈ A0 or y ∈ B0 by the definition of
A0 ∪ B0 . If y ∈ A0 , then the surjectivity of f gives v ∈ {1, 2, . . . , m} such that
y = f (v) = h1 (v − 1). If y ∈ B0 ,then the surjectivity of g gives w ∈ N such
that y = g(w) = g (w + m) − m = h1 (w + m) as w + m ⩾ 0 + m = m. So
we have x ∈ N which makes y = h1 (x) in all cases.

tutsol.37
(Injectivity) Let x1 , x2 ∈ N such that h1 (x1 ) = h1 (x2 ). In view of (†), this
implies either x1 ⩽ m − 1 and x2 ⩽ m − 1, or x1 ⩾ m and x2 ⩾ m. If
x1 ⩽ m−1 and x2 ⩽ m−1, then f (x1 +1) = h1 (x1 ) = h1 (x2 ) = f (x2 +1), and
thus x1 +1 = x2 +1 by the injectivity of f , from which we can deduce x1 = x2 .
If x1 ⩾ m and x2 ⩾ m, then g(x1 − m) = h1 (x1 ) = h1 (x2 ) = g(x2 − m), and
thus x1 − m = x2 − m by the injectivity of g, from which we can deduce
x1 = x2 . So x1 = x2 in all cases.
B0 g N
.. .. .. .. ..
Figure. . . . . .
m+2 g(2) 2
m+1 g(1) 1
m g(0) 0
m−1 f (m) m
.. .. .. .. ..
. . . . .
1 f (2) 2
0 f (1) 1
h1 f
N A0
Case 2: suppose both A0 and B0 are infinite. As A0 and B0 are both infinite and
countable, they have the same cardinality as N. Use this fact to find bijections

f : N → A0 and g : N → B0 .

Define the function h2 : Z → A0 ∪ B0 by setting, for each x ∈ Z,


(
f (x), if x ⩾ 0;
h2 (x) =
g(−x − 1), if x < 0.

If x ∈ Z such that x ⩾ 0, then x is in the domain of f , and so we can indeed


apply f to x. If x ∈ Z such that x < 0, then −x − 1 > −0 − 1 = −1, and thus
x ⩾ 0; so we can indeed apply g to −x − 1.
For every x ∈ Z, if x ⩾ 0, then h2 (x) = f (x) ∈ A0 ; conversely, if x < 0, then
h2 (x) = g(−x − 1) ∈ B0 , and so h2 (x) ̸∈ A0 as A0 ∩ B0 = ∅. Hence

∀x ∈ N x ⩾ 0 ⇔ h2 (x) ∈ A0 . (‡)

We claim that h2 is a bijection. This will tell us Z has the same cardinality as
A0 ∪ B0 , and thus A0 ∪ B0 is countable by Proposition 9.1.4 and Lemma 9.2.1.
(Surjectivity) Let y ∈ A0 ∪ B0 . Then y ∈ A0 or y ∈ B0 by the definition
of A0 ∪ B0 . If y ∈ A0 , then the surjectivity of f gives v ∈ N such that
y = f (v) = h2 (v). If y ∈ B0 , then
 the surjectivity of g gives w ∈ N such that
y = g(w) = g − (−w − 1) − 1 = h2 (−w − 1) as −w − 1 ⩽ −0 − 1 = −1. So
we have x ∈ Z which makes y = h2 (x) in all cases.
(Injectivity) Let x1 , x2 ∈ Z such that h2 (x1 ) = h2 (x2 ). In view of (‡), this
implies either x1 ⩾ 0 and x2 ⩾ 0, or x1 < 0 and x2 < 0. If x1 ⩾ 0 and x2 ⩾ 0,
then f (x1 ) = h2 (x1 ) = h2 (x2 ) = f (x2 ), and thus x1 = x2 by the injectivity
of f . If x1 < 0 and x2 < 0, then g(−x1 − 1) = h2 (x1 ) = h2 (x2 ) = g(−x2 − 1),
and thus −x1 − 1 = −x2 − 1 by the injectivity of g, from which we can deduce
x1 = x2 . So x1 = x2 in all cases.

tutsol.38
h2 A0 f N
.. .. .. .. ..
Figure. . . . . .
2 f (2) 2
1 f (1) 1
0 f (0) 0
−1 g(0) 0
−2 g(1) 1
−3 g(2) 2
.. .. .. .. ..
. . . . .
Z B0 g N

Alternative solution when A0 and B0 are both infinite. As A0 and B0 are


both infinite and countable, they have the same cardinality as N. Use this fact to find
bijections
f : N → A0 and g : N → B0 .
Define the function h3 : N → A0 ∪ B0 by setting, for each x ∈ N,
(
f ( x2 ), if x is even;
h(x) = x−1
g( 2 ), if x is odd.

If x ∈ N such that x is even, say x = 2u where u ∈ Z, then 0 = 20 ⩽ x2 = 2u 2 = u;


this implies x2 = u ∈ N and thus we can indeed apply f to x2 . If x ∈ N such that x is
(2u+1)+1
odd, say x = 2u + 1 where u ∈ Z, then − 12 = 0−1 x−1
2 ⩽ 2 = 2 = u + 1, and so
u + 1 ⩾ 0 as u + 1 ∈ Z; this implies x−1
2 = u + 1 ∈ N and thus we can indeed apply g
to x−1
2 .
For every x ∈ Z, if x is even, then h3 (x) = f ( x2 ) ∈ A0 ; conversely, if x is odd, then
h3 (x) = g( x−1
2 ) ∈ B0 , and so h3 (x) ̸∈ A0 as A0 ∩ B0 = ∅. Hence

∀x ∈ N x is even ⇔ h3 (x) ∈ A0 . (§)

Now we verify that h3 is bijective; this will give the countability of A0 ∪ B0 .


(Surjectivity) Let y ∈ A0 ∪ B0 . Then y ∈ A0 or y ∈ B0 by the definition of A0 ∪ B0 .
If y ∈ A0 , then the surjectivity of f gives v ∈ N such that y = f (v) = f ( 2v
2 ) =
h2 (2v) as 2v is even. If y ∈ B0 , then the surjectivity of g gives w ∈ N such that
y = g(w) = g( (2w+1)−1
2 ) = h1 (2w + 1) as 2w + 1 is odd. So we have x ∈ N which
makes y = h3 (x) in all cases.
(Injectivity) Let x1 , x2 ∈ N such that h3 (x1 ) = h3 (x2 ). In view of (§), this implies
either x1 , x2 are both even, or x1 , x2 are both odd. If x1 , x2 are both even, then
f ( x21 ) = h3 (x1 ) = h3 (x2 ) = f ( x22 ), and thus x21 = x22 by the injectivity of f , from
which we can deduce x1 = x2 . If x1 , x2 are both odd, then g( x12−1 ) = h3 (x1 ) =
h3 (x2 ) = g( x22−1 ), and thus x12−1 = x22−1 by the injectivity of g, from which we
can deduce x1 = x2 . So x1 = x2 in all cases.

tutsol.39
h3 A0 f N
.. .. .. .. ..
Figure. . . . . .
4 f (2) 2
2 f (1) 1
0 f (0) 0
.. .. .. .. ..
. . . . .
5 g(2) 2
3 g(1) 1
1 g(0) 0
g
N B0 N
S0
9.3. (Base step) i=0 Ai = A0 , which is countable. So the proposition is true for n = 0.
(Induction step) Let k ∈ N such that the proposition is true for n = k. We will
prove the proposition for n = k + 1.
k+1
[ k+1
[
Ai = A0 ∪ A1 ∪ · · · ∪ Ak ∪ Ak+1 by the definition of Ai ;
i=0 i=0
k
[  k
[
= Ai ∪ Ak+1 by the definition of Ai .
i=0 i=0
Sk
Here i=0 Ai is countable by the induction hypothesis, and Ak+1 is countable by
Sk  Sk+1
assumption. So Exercise 9.2 tells us i=0 Ai ∪Ak+1 = i=0 Ai is also countable.
This completes the induction.
9.4. (a) Suppose A0 , A1 , A2 , . . . are countable sets. Exercise 9.3 only tells us the following
sets are countable:
0
[ 1
[ 2
[ 3
[ 4
[ 5
[ 6
[ 7
[
Ai , Ai , Ai , Ai , Ai , Ai , Ai , Ai , ...
i=0 i=0 i=0 i=0 i=0 i=0 i=0 i=0
S∞
There is no specific reason why any of these should be equal to i=0SAi . Even

given the fact that the union of all the sets displayed above is equal to i=0 Ai , it
is still not clear why the countability of these individual sets imply the countability
of the union; in fact, this is essentially what one is trying to prove here.
Extra argument. In view of Exercise 9.1, we may perform an induction like
what
Sn we did in Exercise 9.3 to prove that if A0 , A1 , A2 , . . . are finite sets, then
i=0 Ai is finite for every n ∈ N. As deductions are supposed to depend on the
forms of the propositions involved alone according to Terminology 3.1.10, if what
is claimed
S∞ were indeed correct, then the same argument would allow one to deduce
that i=0 Ai is finite whenever A0 , A1 , A2 , . . . are finite. However, this conclusion
is
S∞ not true: let if we let Ai = {i} for each i ∈ N, then each Ai is finite, but
i=0 Ai = N, which is infinite.
Moral. A predicate that is satisfied by arbitrarily large finite sets may not be
satisfied by infinite sets. There is a gap between “arbitrarily large finite” and
“infinite”.
(b) For each i ∈ N, use the countability of Ai to find a bijection
S∞ fi : N → Ai or a
bijection fi : {1, 2, . . .S, ℓ} → Ai where ℓ ∈ N. Define g : i=0 Ai → N × N by

setting, for each x ∈ i=0 Ai ,
g(x) = (ix , jx ) where ix is the smallest element of {i ∈ N : x ∈ Ai } and
jx ∈ N such that fix (jx ) = x.

tutsol.40
(Well-defined)SLet us verify that the definition of g above indeed assigns to every
∞ S∞
element of i=0 A Si∞exactly one element of N × N. Take x ∈ i=0 i . Then
A
the definition of i=0 Ai tells us x ∈ Ai for some i ∈ N. So {i ∈ N : x ∈ Ai }
is nonempty, and thus must have a smallest element, say ix , by the Well-
Ordering Principle. Such an ix must be unique because, if i is another smallest
element of this set, then ix ⩽ i and i ⩽ ix by the smallest-ness of ix and i
respectively, and thus ix = i. As x ∈ Aix and fix is a surjection N → Aix ,
we get jx ∈ N such that fix (jx ) = x. This jx is also unique because fix is
injective.
S∞
(Injectivity) Let x, y ∈ i=0 Ai such that g(x) = g(y). Say g(x) = (i, j) = g(y).
Then the definition of g tells us that x = fi (j) = y.
S∞
Now g is an injection
S∞ i=0 Ai → N × N. Recall from Theorem 9.1.5 that N × N is
countable. So i=0 Ai must also be countable by Corollary 9.2.7(2).
Extra explanation. Here is a procedure that gives the function g defined above.
S∞
1. Input x ∈ i=0 Ai .
2. Search for the smallest i ∈ N such that x ∈ Ai .
3. Search for the smallest j ∈ N such that fi (j) = x.
4. Output (i, j).
Moral. Even wrong proofs may have true conclusions.

9.5. (a) True, because this is the contrapositive of Proposition 9.2.6(2).


(b) True, as shown below.
We prove this by contraposition. Let A, B be sets such that A \ B is countable.
We will show that either A is countable or B is uncountable. If B is uncountable,
then there is nothing to prove. So suppose B is countable. As A \ B and B are
both countable, we know (A \ B) ∪ B is also countable by Exercise 9.2. Note that
Extra Exercise 4.9 tells us (A \ B) ∪ B = A ∪ B. Thus A ∪ B is countable. As
A ⊆ A ∪ B by Tutorial Exercise 4.6, Proposition 9.2.6(2) implies A is countable
too.
Intuition. As mentioned in Exercise 9.2, one may view countable sets as small sets,
and uncountable set as large sets.
(a) This proposition is intuitive because, if a set B has a large subset A, then B should
itself be large.
(b) This proposition is intuitive because, if we take away a small set B from a large
set A, then the result A \ B should remain large.

9.6. Let A be an infinite set. Apply Proposition 9.2.4 to find a countable infinite subset
A0 ⊆ A. Then P(A0 ) is uncountable by Corollary 9.3.2. We know P(A0 ) ⊆ P(A)
because, if S ∈ P(A0 ), then the definition of P(A0 ) tells us S ⊆ A0 ⊆ A, and thus
S ∈ P(A) by the transitivity of ⊆ from Example 6.1.4. Therefore, Proposition 9.2.6(2)
implies that P(A) is also uncountable.
Intuition. On the one hand, as verified above, the power set of a larger set is larger.
On the other hand, we know that the countable infinity is the smallest infinity. Since
the power set of a countable infinite set is already large, the power set of any infinite
set should also be large.

Extra exercises
9.7. Define A∗ = A∪N, so that A ⊆ A∗ by Tutorial Exercise 4.6. From Example 9.1.3(1), we
know N is countable. As A is countable, this implies A∗ is countable too by Exercise 9.2.

tutsol.41
Consider the function fA : N → A∗ satisfying fA (x) = x for all x ∈ A. This function
is injective because if x1 , x2 ∈ N such that fA (x1 ) = fA (x2 ), then x1 = x2 by the
definition of fA . Now N is infinite by Exercise 8.2.7, and fA is an injection N → A∗ .
So Corollary 9.2.7(1) tells us A∗ must also be infinite.
Additional comment. We could not have used this exercise to avoid the case-splitting
for Exercise 9.2 because Exercise 9.2 is used in the proof here.

9.8. (⇒) Suppose A is countable. Apply Exercise 9.7 to find a countable infinite set A∗
such that A ⊆ A∗ . According to the definition of countability, this set A∗ has the same
cardinality as N. Use the definition of same-cardinality to find a bijection g : A∗ → N.
Define f : A → N by setting f (x) = g(x) for all x ∈ A. Then f is an injection because
if x1 , x2 ∈ A such that f (x1 ) = f (x2 ), then

g(x1 ) = g(x2 ) by the definition of f ;


∴ x1 = x2 as g is injective.

(⇐) Let f be an injection A → N. From Example 9.1.3(1), we know N is countable.


So A cannot be uncountable in view of Corollary 9.2.7(2). This means A must be
countable.
9.9. Apply Exercise 9.7 to find countable infinite sets A∗ , B ∗ such that A ⊆ A∗ and B ⊆ B ∗ .
According to the definition of countability, both A∗ and B ∗ have the same cardinal-
ity as N. Use the definition of same-cardinality to find bijections gA : A∗ → N and
gB : B ∗ → N.

Consider the function f : A × B → N × N satisfying f (x, y) = gA (x), gB (y) for all
(x, y) ∈ A × B. This function is injective because if (x1 , y1 ), (x2 , y2 ) ∈ A × B such that
f (x1 , y1 ) = f (x2 , y2 ), then
 
gA (x1 ), gB (y1 ) = gA (x2 ), gB (y2 ) by the definition of f ;
∴ gA (x1 ) = gA (x2 ) and gB (y1 ) = gB (y2 ) by the definition of ordered pairs;
∴ x1 = x2 and y1 = y2 as gA , gB are injective;
∴ (x1 , y1 ) = (x2 , y2 ) by the definition of ordered pairs.

Now we have an injection f : A × B → N × N, of which the codomain N × N is countable


by Theorem 9.1.5. So, in view of Corollary 9.2.7(2), the domain A × B must also be
countable.

tutsol.42
Tutorial solutions for Chapter 10

Sometimes there are other correct answers.


10.1. Let A, B, C, D be finite sets. Then
|A ∪ B ∪ C ∪ D| = |A| + |B| + |C| + |D|
− |A ∩ B| − |A ∩ C| − |A ∩ D| − |B ∩ C| − |B ∩ D| − |C ∩ D|
+ |A ∩ B ∩ C| + |A ∩ B ∩ D| + |A ∩ C ∩ D| + |B ∩ C ∩ D|
− |A ∩ B ∩ C ∩ D|.

Proof. By the Inclusion–Exclusion Rule for two sets,


|A ∪ B ∪ C ∪ D| = |A| + |B ∪ C ∪ D| − |A ∩ (B ∪ C ∪ D)|.
We know how to handle the term |B ∪ C ∪ D| using the Inclusion–Exclusion Rule for
three sets. For the last term,
|A ∩ (B ∪ C ∪ D)|
= |(A ∩ B) ∪ (A ∩ C) ∪ (A ∩ D)|
= |A ∩ B| + |A ∩ C| + |A ∩ D|
− |(A ∩ B) ∩ (A ∩ C)| − |(A ∩ C) ∩ (A ∩ D)| − |(A ∩ D) ∩ (A ∩ B)|
+ |(A ∩ B) ∩ (A ∩ C) ∩ (A ∩ D)|
= |A ∩ B| + |A ∩ C| + |A ∩ D| − |A ∩ B ∩ C| − |A ∩ C ∩ D| − |A ∩ B ∩ D|
+ |A ∩ B ∩ C ∩ D|.
Putting all these together gives
|A ∪ B ∪ C ∪ D| = |A| + |B| + |C| + |D| − |B ∩ C| − |C ∩ D| − |D ∩ B|
+ |B ∩ C ∩ D| − |A ∩ B| − |A ∩ C| − |A ∩ D|
+ |A ∩ B ∩ C| + |A ∩ C ∩ D| + |A ∩ B ∩ D| − |A ∩ B ∩ C ∩ D|.

10.2. Suppose A = {a1 , a2 , . . . , am } and B = {b1 , b2 , . . . , bn }.


(a) By definition, the relations from A to B are precisely the subsets of A × B. So
the number of relations from A to B is
|P(A × B)| = 2|A×B| by Theorem 10.2.7;
|A|×|B|
=2 by Corollary 10.2.4(1);
mn
=2 .

(b) We know from Proposition 7.2.7 that a function f : A → B is completely deter-


mined by f (a1 ), f (a2 ), . . . , f (am ). As |B| = n, there are n choices for each of
these. So by the General Multiplication Rule, the number of functions A → B is
n × n × · · · × n = nm .
| {z }
m-many n’s

tutsol.43
Additional comment. The argument above suggests that functions A → B may
be viewed as tuples in B m .
(c)∗ We know from the Dual Pigeonhole Principle that, if m < n, then there is no
surjection A → B. So suppose m ⩾ n. Let F denote the set of all functions
A → B. For each bj ∈ B, define

Fj = {f ∈ F : bj ̸∈ range(f )}.

As |B| = n = 3, the set of all surjections A → B is F \ (F1 ∪ F2 ∪ F3 ). By the


Difference Rule, the size of this set is |F | − |F1 ∪ F2 ∪ F3 |. From (b), we know
|F | = nm = 3m . Let us calculate |F1 ∪ F2 ∪ F3 | using the Inclusion–Exclusion
Principle for three sets: as in (b),

|F1 | = |F2 | = |F3 | = 2 × 2 × · · · × 2 = 2m ;


| {z }
m-many 2’s

|F1 ∩ F2 | = |F2 ∩ F3 | = |F3 ∩ F1 | = 1 × 1 × · · · × 1 = 1;


| {z }
m-many 1’s

|F1 ∩ F2 ∩ F3 | = 0 as any f ∈ F1 ∩ F2 ∩ F3 must have an empty range,


which is not possible as A ̸= ∅;
∴ |F1 ∪ F2 ∪ F3 | = |F1 | + |F2 | + |F3 | − |F1 ∩ F2 | − |F2 ∩ F3 | − |F3 ∩ F1 |
+ |F1 ∩ F2 ∩ F3 |
= 2m + 2m + 2m − 1 − 1 − 1 + 0 = 2m 3 − 3.

It follows that the number of surjections A → B is 3m − 2m 3 + 3.


(d) We know from the Pigeonhole Principle that, if m > n, then there is no injec-
tion A → B. So suppose m ⩽ n. Similar to the situation in (b), we choose
f (a1 ), f (a2 ), . . . , f (am ) to determine the function f : A → B. Now, we addition-
ally need to ensure that f is injective. This means f (a1 ), f (a2 ), . . . , f (am ) are all
different. So there are
n choices for f (a1 ),
n−1 choices for f (a2 ),
.. ..
. .
n − (m − 1) choices for f (am ).

Therefore, by the General Multiplication Rule, the number of injections A → B is


n!
n × (n − 1) × (n − (m − 1)) = = P (n, m).
(n − m)!

Additional comment. The argument above suggests that injections A → B


may be viewed as m-permutations of B.
(e) We know from the two Pigeonhole Principles that, if m ̸= n, then there is no
bijection A → B. So let us concentrate on the case when m = n. Now we know
from (d) that there are n × (n − 1) × · · · × (n − (n − 1)) = n! injections A → B As
A and B are finite and |A| = m = n = |B|, all these injections are surjective by
Extra Exercise 8.9(b) So there are exactly n! bijections A → B.
Additional comment. The argument above suggests that bijections A → B
may be viewed as permutations of B.

tutsol.44
10.3. (a) Applying Theorem 10.3.15,
   
n n n! n!
+ = +
r r−1 r! (n − r)! (r − 1)! (n − (r − 1))!
(n − r + 1)(n!) r(n!)
= +
r! (n − r + 1)((n − r)!) r((r − 1)!) (n − r + 1)!
n!
= (n − r + 1 + r)
r! (n − r + 1)!
 
(n + 1)(n!) (n + 1)! n+1
= = = .
r! (n − r + 1)! r! ((n + 1) − r)! r

(b) Let A = {1, 2, . . . , n + 1}. By definition, there are n+1



r subsets of A of size r.
For any such subset X, either n + 1 ̸∈ X or n + 1 ∈ X but not both.
• The subsets X ⊆ A of size r where n + 1 ̸∈ X are precisely the subsets of
A \ {n + 1} = {1, 2, . . . , n}. So there are precisely nr of these.
• The subsets X ⊆ A of size r where n + 1 ∈ X are precisely those X0 ∪ {n + 1}
where X0 is asubset of A \ {n + 1} = {1, 2, . . . , n} of size r − 1. So there are
n
precisely r−1 of these.
Hence nr + r−1
n
= n+1
  
r by the Addition Rule.
Additional comment. This counting argument is based on the following:

{X ⊆ A : |X| = r}
= {X ⊆ A : |X| = r and n + 1 ̸∈ X} ∪ {X ⊆ A : |X| = r and n + 1 ∈ X}
= {X ⊆ A \ {n + 1} : |X| = r}
∪ {X0 ∪ {n + 1} : X0 ⊆ A \ {n + 1} and |X| = r − 1}.

0

Pascal’s Triangle. 0

1 1
 
0 1
+
2 2 2
  
0 1 2
+ +
3 3 3 3
   
0 1 2 3
+ + +
4 4 4 4 4
    
0 1 2 3 4
+ + + +
.. .. .. .. .. ..
. . . . . .

10.4. (a) Fix r ∈ N. We proceed by induction on n.


(Base step) If r = 0, then 0r = 00 = 1 = 11 = 0+1
   
r+1 . If r > 0, then
0 1 0+1 0 0+1
    
r = 0 = r+1 = r+1 . So r = r+1 in all cases.

tutsol.45
(Induction step) Let k ∈ N such that 0r + 1 k k+1
   
r + ··· + r = r+1 . Then
       
0 1 k k+1
+ + ··· + +
r r r r
   
k+1 k+1
= + by the induction hypothesis;
r+1 r
 
k+2
= by Exercise 10.3;
r+1
 
(k + 1) + 1
= .
r+1
This completes the induction.
(b) Let A = {0, 1, 2, . . . , n}. Note that |A| = n + 1. By definition, there are n+1

r+1
subsets of A of size r + 1. The largest element of any such subset is exactly one
of 0, 1, 2, . . . , n. For each m ∈ {0, 1, . . . , n}, the subsets of X ⊆ A of size r + 1 of
which the largest element is m are precisely those X0 ∪{m} where X0 is a subset
of {0, 1, . . . , m − 1} of size r; so there are exactly m r of these. Hence, by the
Addition Rule,        
n+1 0 1 n
= + + ··· + .
r+1 r r r
Additional comment. This counting argument is based on the following:
{X ⊆ {0, 1, . . . , n} : |X| = r + 1}
= {X ⊆ {0, 1, . . . , n} : |X| = r + 1 and max X = 0}
∪ {X ⊆ {0, 1, . . . , n} : |X| = r + 1 and max X = 1}
∪ {X ⊆ {0, 1, . . . , n} : |X| = r + 1 and max X = 2}
∪ · · · ∪ {X ⊆ {0, 1, . . . , n} : |X| = r + 1 and max X = n}
= {X0 ∪ {0} : X0 ⊆ {} and |X| = r}
∪ {X0 ∪ {1} : X0 ⊆ {0} and |X| = r}
∪ {X0 ∪ {2} : X0 ⊆ {0, 1} and |X| = r}
∪ · · · ∪ {X0 ∪ {n} : X0 ⊆ {0, 1, . . . , n − 1} and |X| = r}.
0

Figure. 0

1 1
 
0 1
=

2 2 2
  
0 1 2
+
3 3 3 3
   
0 1 2 3
+
4 4 4 4 4
    
0 1 2 3 4
+
5 5 5 5 5 5
     
0 1 2 3 4 5

.. .. .. .. .. .. ..
. . . . . . .

Extra exercises
2
10.5. (a) By definition, a relation on A is a relation from A to A. So there are 2|A|×|A| = 2m
of them by Exercise 10.2(a).

tutsol.46
(b) Consider the following questions about a relation R on A, where xy ranges over
2-permutations of A.
“Is x R y?”
Each way of answering these questions gives rise to a unique reflexive relation R
on A because any such relation R must have x R x for any x ∈ A by reflexivity.
Moreover, all reflexive relations on A can be obtained in this way, and different
ways to answer these questions give rise to different reflexive relations on A. So the
number of reflexive relations on A is equal to the number of ways to answer these
questions. Since |A| = m and the number of 2-permutations of A is P (|A|, 2),
there are exactly P (m, 2) such questions. There are exactly two ways to answer
each of these questions. So, by the Multiplication Rule, the number of ways to
answer all these questions, and hence the number of reflexive relations on A, is

2 × 2 × · · · × 2 = 2P (m,2) .
| {z }
P (m,2)

(c) Consider the following questions about a relation R on A.


(i) “Is x R x?” where x ∈ A.
(ii) “Is x R y ∧ y R x or x ̸R y ∧ y ̸R x?” where {x, y} ⊆ A of size 2.
In view of Tutorial Exercise 3.3, each way of answering these questions gives rise
to a (unique) symmetric relation R on A, and every symmetric relation on A can
be obtained in this way. Moreover, different ways to answer these questions give
rise to different symmetric relations on A. Therefore, the number of symmetric
relations on A is equal to the number of ways to answer these questions.
Since there are |A|

Since |A| = m, there are exactly m questions of type (i). 2
subsets of A of size 2 by definition, there are exactly m

2 questions of type (ii).
There are exactly two ways to answer each of these questions. So, by the Multi-
plication Rule, the number of ways to answer all these questions, and hence the
number of symmetric relations on A, is
m
2 × 2 × · · · × 2 × 2 × 2 × · · · × 2 = 2m+( 2 ) .
| {z } | {z }
m-many 2’s m
2 -many 2’s

(d) Consider the following questions about a relation R on A.


(i) “Is x R x?” where x ∈ A.
(ii) “Is x R y ∧ y ̸R x or x ̸R y ∧ y R x or x ̸R y ∧ y ̸R x?”
where {x, y} ⊆ A of size 2.
As in (c), the number of antisymmetric relations on A is equal to the number
of ways to answer these questions. There are exactly two ways to answer each
question of type (i), and there are exactly three ways to answer each question of
type (ii). So, by the Multiplication Rule, the number of ways to answer all these
questions, and hence the number of antisymmetric relations on A, is
m
2 × 2 × · · · × 2 × 3 × 3 × · · · × 3 = 2m 3( 2 ) .
| {z } | {z }
m-many 2’s m
2 -many 2’s

Additional comment. In (b)–(d), we essentially defined bijections from the set of all
ways to answer all the stated questions to the set of all relations to be counted.

tutsol.47
Tutorial solutions for Chapter 11

Sometimes there are other correct answers.


11.1. (a) K1 : K2 : K3 : K4 : or

(b) Unordered pairs of vertices in V(Kn ) are precisely the 2-combinations of V(Kn ).
Since there is an edge in Kn between any pair of distinct vertices (and there is no
need to worry about the order of the vertices because our graph is undirected),
there are at least |V(K n )|
= n2 edges
 
2 in Kn . There is no other edge because Kn
has no loop. So Kn has exactly n2 edges.


11.2. Each such G is uniquely determined by the set E(G) of its edges. So it suffices to count
the E(G)’s. Define

C1 = {x} : x ∈ {a, b, c} ,

C2 = {x, y} : x, y ∈ {a, b, c} and x ̸= y .
Note that these are respectively the set of all 1-combinations and the set of all 2-combinations
of {a, b, c}.
(a) These E(G)’s are precisely the subsets of C1 ∪ C2 . Therefore, as C1 ∩ C2 = ∅, the
Addition Rule tells us that the number of such graphs is
3 3
|P(C1 ∪ C2 )| = 2|C1 |+|C2 | = 2(1)+(2) = 23+3 = 26 = 64.
(b) The E(G)’s where G has no loop are precisely the subsets of C2 . So there are
3
|P(C2 )| = 2(2) = 23 = 8 such graphs with no loop.
(c) The only cycle whose vertex set is {a, b, c} is abca. So the E(G)’s where G has a
cycle are precisely those sets of the form
X ∪ {{a, b}, {b, c}, {c, a}
where X ⊆ P(C1 ). Hence the number of such graphs that have a cycle is |P(C1 )| =
3
2(1) = 23 = 8.
(d) The number of such graphs that are acyclic is, by the Difference Rule and part (b),
 
number of such graphs that
have no loop and no cycle
   
number of such graphs number of such graphs that
= −
that have no loop have no loop but has a cycle
=8−1=7
because the only such graph that has no loop but has a cycle is abca. So, applying
the Difference Rule again, the number of such graphs that are cyclic is, by part (a),
   
number of number of such graphs
− = 64 − 7 = 57.
such graphs that are acyclic

tutsol.48
11.3. (a) Graph (i) is isomorphic to itself and to (iii), but not to any of the others.
Graph (ii) is isomorphic to itself and to (iv), but not to any of the others.
An isomorphism from any graph here to itself is the identity function on {1, 2, . . . , 8}.
An isomorphism from (i) to (iii) is the function f : {1, 2, . . . , 8} → {1, 2, . . . , 8}
satisfying

f (1) = 1, f (2) = 2, f (3) = 6, f (4) = 7,


f (5) = 8, f (6) = 4, f (7) = 3, f (8) = 5.

An isomorphism from (ii) to (iv) is the function g : {1, 2, . . . , 8} → {1, 2, . . . , 8}


satisfying

g(1) = 2, g(2) = 1, g(3) = 8, g(4) = 5,


g(5) = 7, g(6) = 3, g(7) = 4, g(8) = 6.

Graph (ii) has a cycle of length 5, say 123761, but (i) does not. So (i) is not
isomorphic to (ii).
Alternative explanation of why (i) is not isomorphic to (ii). In (i), every
vertex is in exactly three cycles of length 4. In (ii), every vertex is in exactly two
cycles of length 4. So (i) is not isomorphic to (ii).
Extra explanation.

1 2 6 1 6 1 3 2
6 7 7 2 7 2 4 1
redraw redraw relabel
−−−−→ −−−−→ −−−−→
8 3 4 3 4 3 5 8
5 4 5 8 8 5 6 7

(ii) (iv)

(b) For n = 2, 3, 4, there are 2, 4, 11 respectively.


Explanation.
2 vertices:

3 vertices:

4 vertices:

Moral. Usually we want to count without counting, but sometimes it is easier to


simply count.
Additional comment. It is a famous open question whether there is an efficient
algorithm to determine whether two given graphs are isomorphic.

tutsol.49
11.4. (a) Yes, as proved below.
By definition, if H is a connected component of G, then V(H) ⊆ V(G). As G has
at least one vertex, Proposition 11.3.6 tells us that G has a connected component,
say H0 , with at least one vertex. This implies (∅, {}) is not a connected component
of G because it is a proper subgraph of H0 , and H0 is connected. Thus V(H) ̸= ∅
for all connected components H of G. From Proposition 11.3.6, we already know
that every element of V(G) is in V(H) for some connected component H of G.
Finally, we verify that, for all connected components H1 , H2 of G, if V(H1 ) ∩
V(H2 ) ̸= ∅, then V(H1 ) = V(H2 ).
Let H1 , H2 be connected components of G such that V(H1 ) ∩ V(H2 ) ̸= ∅. Define
H = V(H1 ) ∪ V(H2 ), E(H1 ) ∪ E(H2 ) . We will show that H is connected. In
view of the maximality of H1 and H2 , this will imply H1 = H = H2 , and thus
V(H1 ) = V(H2 ) in particular.
Pick any u, v ∈ V(H) = V(H1 ) ∪ V(H2 ).
Case 1: suppose u, v ∈ V(H1 ) or u, v ∈ V(H2 ). Say u, v ∈ V(H1 ). As H1 is
connected, there is a path between u and v in H1 , hence in G.
Case 2: suppose exactly one of u, v is in V(H1 ). Say u ∈ V(H1 ), so that v ∈
V(H2 ). Take x ∈ V(H1 ) ∩ V(H2 ). As u, x ∈ V(H1 ) and H1 is connected,
there is a path between u and x in H1 , hence in H. As x, v ∈ V(H2 ) and
H2 is connected, there is a path between x and v in H2 , hence in H. So
Lemma 11.1.10 tells us there is a path between u and v in H.
(b) No, as proved below.
Consider the graph G = ({0, 1}, {00}). Here is a drawing on G.

0 1

This graph G has two connected components:

H1 = ({0}, {00}) and H2 = ({1}, {}).

So {E(H) : H is a connected component of G} = {{00}, {}}. This is not a parti-


tion of E(G) because partitions by definition cannot contain the empty set as an
element.
Additional comment. The appearance of the empty set is the only possible
obstacle for the edge sets of the connected components of an undirected graph to
form a partition. To see this, consider any undirected graph G. Define

C = {E(H) : H is a connected component of G} \ {∅}.

We verify that C is a partition of E(G).


As connected components H of G are subgraphs of G, each element E(H) ∈ C is
a subset of E(G). Every E(H) ∈ C is nonempty by the definition of C .
Take any edge xy in G. If x = y, then x is a path of length 0 between x and
y in G. If x ̸= y, then xy is a path of length 1 between x and y in G. So in
all cases we have a path between x and y in G. Apply Theorem 11.3.7 to find a
connected component H of G with both x and y in it. As H is connected, so is
(V(H), E(H) ∪ {xy}) because no vertex is added here. Thus xy ∈ E(H) by the
maximality of the connected component H of G.
Let H1 , H2 be connected components of G such that E(H1 ) ∩ E(H2 ) ̸= ∅. Pick
any xy ∈ E(H1 ) ∩ E(H2 ). Then x, y ∈ V(H1 ) ∩ V(H2 ). So V(H1 ) ∩ V(H2 ) ̸= ∅,

tutsol.50
and thus V(H1 ) = V(H2 ) by part (a). If uv ∈ E(H1 ), then (V(H2 ), E(H2 ) ∪ {uv})
is connected because H2 is connected and no vertex is added here, so uv ∈ E(H2 )
by the maximality of H2 as a connected component of G. Similarly, we see that
every element of E(H2 ) is an element of E(H1 ). These show E(H1 ) = E(H2 ).

11.5. (a) 3 2

4 1

5 6
(b)∗ Let G be an undirected graph with at least one vertex but with no loop. If G is
connected, then there is nothing to prove. So suppose G is not connected. Take
u, v ∈ V(G). We want a path between u and v in G. If u = v, then u is a path
of length 0 between u and v in G. Similarly, if uv ∈ E(G), then uv is a path of
length 1 between u and v in G. So suppose u ̸= v and uv ̸∈ E(G).
Now uv ∈ E(G) by the definition of G. So from Theorem 11.3.7 we obtain a
connected component H of G which has both u and v in it. As G is not connected,
we get vertices a, b in G with no path between them in G. Use Proposition 11.3.6 to
find connected components Ha and Hb of G such that a ∈ V(Ha ) and b ∈ V(Hb ).
We know b ̸∈ V(Ha ) because Ha is connected but there is no path between a and
b in G. So Ha ̸= Hb . Thus H cannot be equal to both Ha and Hb . Say H ̸= Ha .
If ua ∈ E(G), then Theorem 11.3.7 gives some connected component H + that has
both u and a in it, but then

u ∈ V(H + ) ∩ V(H) as u ∈ V(H);


+
∴ H =H by Exercise 11.4(a);
∴ a ∈ V(H) as a ∈ V(H + );
∴ a ∈ V(H) ∩ V(Ha ) as a ∈ V(Ha );
∴ H = Ha by Exercise 11.4(a),

which contradicts the fact that H ̸= Ha . So ua ̸∈ E(G). Similarly, we can show


va ̸∈ E(G). Thus ua, va ∈ E(G) by the definition of G. This guarantees uav is a
path between u and v in G.

11.6. We proceed by induction on n.


(Base step) Pick any x ∈ V(H0 ). The definition of H0 gives a path P between v
and x in G of length 0. Hence P has the form ({x0 }, {}) where x0 = v and x0 = x.
This P is a path between v and x also in H0 because {x0 } = {x} ⊆ V(H0 ) and
{} ⊆ E(H0 ).
(Induction step) Let k ∈ N such that the proposition is true for n = k. Pick any
x ∈ V(Hk+1 ). If x ∈ V(Hk ), then the induction hypothesis directly gives us what
we want. So suppose x ̸∈ V(Hk ). Then the definition of Hk and Hk+1 gives us
a path x0 x1 . . . xk xk+1 in G where x0 = v and xk+1 = x. Then x0 x1 . . . xk is a
path between v and xk in G of length k. So xk ∈ V(Hk ) by the definition of Hk .
Apply the induction hypothesis to find a path y0 y1 . . . yℓ in Hk where y0 = v and
yℓ = xk . Note that xk xk+1 ∈ E(Hk+1 ) because xk ∈ V(Hk ) ⊆ V(Hk+1 ) and
xk+1 ∈ V(Hk+1 ). As yℓ = xk , this tells us y0 y1 . . . yℓ xk+1 is a path between v
and x in Hk+1 , as required.
This completes the induction.

Proof without induction (extra material). Let n ∈ N. Pick any x ∈ V(Hn ). Use
the definition of Hn to find a path x0 x1 . . . xℓ of length at most n in G where x0 = v

tutsol.51
and xℓ = x. Then each xi ∈ V(Hn ) because x0 x1 . . . xi is a path of length at most
ℓ ⩽ n in G. Thus each xi xi+1 ∈ E(Hn ) by the definition of E(Hn ). It follows that
x0 x1 . . . xℓ is a path in Hn .

Extra exercises
11.7. (⊆) Let xy ∈ E(H). As H is a graph, this implies x, y ∈ V(H). As H is a subgraph
of G, this implies xy ∈ E(G).
(⊇) Let xy ∈ E(G) such that x, y ∈ E(H). As H is connected, so is (V(H), E(H)∪{xy})
because no vertex is added here. Thus xy ∈ E(H) by the maximality of the connected
component H of G.
Additional comment. We used this multiple times in the additional comment for
Exercise 11.4.

11.8. (a)∗ We prove the contrapositive. Assume G is not connected. Use the definition of
connectedness to find in G vertices u, v between which there is no path. Use
Proposition 11.3.6 to find a connected component Hu of G that has u in it. Define
Hv to be the subgraph of G where

V(Hv ) = V(G) \ V(Hu ), and


E(Hv ) = {xy ∈ E(G) : x, y ∈ V(Hv )}.

First, we show E(G) = E(Hu ) ∪ E(Hv ). The ⊇ part is true because Hu and Hv
are both subgraphs of G. For the ⊆ part, take any xy ∈ E(G). If exactly one
of the vertices x, y is in Hu , say x ∈ V(Hu ) and y ∈ V(G) \ V(Hu ) = V(Hv ),
then H + = (V (Hu ) ∪ {y}, E(Hu ) ∪ {xy}) is again a connected subgraph of G,
but H is a proper subgraph of H + because y ̸∈ V(Hu ), which contradicts the
maximality of the connected component H of G. So either x, y ∈ V(Hu ) or x, y ∈
V(G) \ V(Hu ) = V(Hv ). If x, y ∈ V(Hu ), then xy ∈ E(Hu ) by Exercise 11.7. If
x, y ∈ V(Hv ), then xy ∈ E(Hv ) by the definition of E(Hv ). So xy ∈ E(Hu )∪E(Hv )
in all cases.
Second, if xy ∈ E(Hu ), then x ∈ V(Hu ) as Hu is an undirected graph, and so
x ̸∈ V(G) \ V(Hu ) = V(Hv ), implying xy ̸∈ E(Hv ) by the definition of E(Hv ).
This shows E(Hu ) ∩ E(Hv ) = ∅.
Third, let k = |V(Hu )|. Then k ⩾ 1 because u ∈ V(Hu ). Also

n − k = |V(G)| − |V(Hu )|
= |V(G) \ V(Hu )| by the Difference Rule;
= |V(Hv )| by the definition of V(Hv );
⩾1 as v ∈ V(G) \ V(Hu ) = V(Hv ) by Theorem 11.3.7.

tutsol.52
Combining all these,

|E(G)| = |E(Hu ) ∪ E(Hv )|


= |E(Hu )| + |E(Hv )| by the Addition Rule;
|V(Hu )| |V(Hv )|
   
⩽ + by Exercise 11.1;
2 2
n−k
   
k
= +
2 2
k(k − 1) (n − k)(n − k − 1)
= + by Theorem 10.3.15;
2 2
1 2
= (n − n − 2nk + 2k 2 )
2
1
= (n2 − 3n + 2) + (2n − 2 − 2nk + 2k 2 )

2
1 
= (n − 1)(n − 2) − 2(k − 1)(n − k − 1)
2
n−1
 

= − (k − 1) (n − k) − 1
2
n−1
 
⩽ as k ⩾ 1 and n − k ⩾ 1.
2

Why is H + connected in the proof above (extra explanations). Take any


vertices a, b in H + .
Suppose a, b ∈ V(Hu ). As Hu is connected, there is a path between a and b
in Hu , and hence in H + .
Suppose exactly one of a, b is in Hu . Say a ∈ V(Hu ) and b = y. As x ∈
V(Hu ) and Hu is connected, there is a path, say x0 x1 . . . xℓ , between a and x
in Hu . Then x0 x1 . . . xℓ y is a path between a and b in H + because y ̸∈ V(Hu ).
Suppose a = y = b. Then y is a path of length 0 between a and b in H + .
So there is a path between a and b in H + in all cases.
(b) There are 2.
Explanation. Here is a complete list:

tutsol.53
Tutorial solutions for Chapter 12

Sometimes there are other correct answers.


12.1. (a) 1 2 3 6 7

4 5 8

9
(b) 7 7 7 7 7 7 7 7 7 7

6 8 6 8 6 8 8 8 6 6 8

8 6 9 6 9 8 9

9
• There are 9

(c) 3ways to choose three vertices for ; amongst these three
3

vertices, there are 1 ways to choose the middle vertex.
• There are 9−3 = 62 ways left to choose two vertices for
 
2 .

• There are 9−3−2 = 43 ways left to choose three vertices for


 
3 ; amongst
these three vertices, there are 31 ways to choose where to attach the final


vertex.
By the Multiplication Rule, the number of such graphs is

9×8×7 6×5 4×3×2


     
9 3 6 4 3
= ×3× × × 3 = 45360.
3 1 2 3 1 3×2×1 2×1 3×2×1

12.2. (a) For n = 1, 2, 3, 4, the numbers are 1, 1, 3, 16 respectively, as listed below.


(n = 1) 1
(n = 2) 1 2
(n = 3) 1 2 3 1 3 2 2 1 3
(n = 4) 1 2 3 4 1 2 4 3 1 3 2 4
1 3 4 2 1 4 2 3 1 4 3 2
2 1 3 4 2 1 4 3 2 3 1 4
2 4 1 3 3 1 2 4 3 2 1 4
3 3 2 2
2 1 1 2 1 3 1 4
4 4 4 3

tutsol.54
Additional comment. We can check whether any tree is missing or double-
counted via some extra counting. For example, consider trees of the shape

whose vertices are precisely 1, 2, 3, 4. There are 4! ways to assign 1, 2, 3, 4 to the


four vertices here, say, from left to right. Each such assignment gives the same
graph as exactly one other assignment. More specifically, if a, b, c, d are distinct
elements of {1, 2, 3, 4}, then

a b c d and d c b a

are drawings of the same graph

({1, 2, 3, 4}, {ab, bc, cd}),

and no other assignment gives a drawing of this graph. This tells us that the
number of such vertex assignments is exactly twice the number of such graphs.
Thus there are exactly 4!/2 = 12 such graphs; this number matches with what we
had in the solutions.
(b) For n = 1, 2, 3, 4, the numbers are 1, 1, 1, 2 respectively.
(n = 1)
(n = 2)
(n = 3)

(n = 4)

Additional comment. These are the “shapes” of the trees we got in (a).
(c) For n = 1, 2, 3, 4, the numbers are 1, 1, 2, 4 respectively.
(n = 1) (n = 2) (n = 3)

(n = 4)

Additional comment. These are the different ways to choose roots for the trees
we got in (b).
Moral. It is best if we can count without counting. Nevertheless, it is sometimes easier
to count by counting.

12.3. (⇒) Suppose G is a tree. Let u, v ∈ V(G) such that uv ̸∈ E(G). If u = v, then uv is
a loop and thus (V(G), E(G) ∪ {uv}) is cyclic. So suppose u ̸= v. Use connectedness
to find a path P between u and v in G. Note that P must have length at least 2
because uv ̸∈ E(G). So V(P ), E(P ) ∪ {uv} is a cycle in (V(G), E(G) ∪ {uv}), making
(V(G), E(G) ∪ {uv}) cyclic.

tutsol.55
(⇐) We prove by contraposition. Suppose G is not a tree. As G is acyclic, this tells us
G is unconnected. Find u, v ∈ V(G) between which there is no path in G. Note that
u ̸= v because ({u}, {}) is a path between u and u in G. Also uv ̸∈ E(G).
Suppose, towards a contradiction, we have a cycle in (V(G), E(G) ∪ {uv}), say,

C = x1 x2 . . . xℓ x1 .

Note that uv ∈ E(C) because G is acyclic. Renaming the x’s if needed, we may assume
u = x1 and v = xℓ . Then, as ℓ ⩾ 3, we have a path x1 x2 . . . xℓ between u and v in G,
which contradicts our choice of u, v.
Alternative proof for ⇐. Assume that adding any new edge makes G cyclic. We
show G is a tree, i.e., it is both acyclic and connected. We know that G is acyclic by
hypothesis. For connectedness, pick any u, v ∈ V(G).
Case 1: suppose uv ∈ E(G). There are two subcases.
Case 1.1: suppose u = v. Then ({u}, {}) is a path between u and v in G.
̸ v. Then uv is a path between u and v in G.
Case 1.2: suppose u =
Case 2: suppose uv ̸∈ E(G). Consider the graph

Ĝ = (V(G), E(G) ∪ {uv}).

By assumption, we know Ĝ is cyclic. So the definition of cyclic graphs tells us


that Ĝ either has a loop or has a cycle.
Case 2.1: suppose Ĝ has a loop. As G is acyclic, it has no loop. Now Ĝ has
a loop, and the only difference between G and Ĝ is the additional edge uv
in Ĝ. So it must be the case that uv is a loop, i.e., that u = v. In this case,
we have the path ({u}, {}) between u and v in G.
Case 2.2: suppose Ĝ has a cycle. As G is a acyclic, it has no cycle. Now Ĝ
has a cycle, and the only difference between G and Ĝ is the additional edge uv
in Ĝ. So it must be the case that some/all cycles in Ĝ have uv in it. Consider
a cycle x1 x2 . . . xℓ x1 in Ĝ. Renaming the x’s if needed, we may assume u = x1
and v = xℓ . Then, as ℓ ⩾ 3, we have the path x1 x2 . . . xℓ between u and v
in G.

So there is a path between u and v in G in all cases.

12.4. As G is finite, it has only finitely many connected components. Let H1 , H2 , . . . , Hk list
all the connected components of G without repetition. As G is unconnected, we know
k > 1. By the definition of connected components, each Hi is connected. In addition,
each Hi is acyclic because G is acyclic. So each Hi is a tree. It follows that

|E(G)|
= |E(H1 ) ∪ E(H2 ) ∪ · · · ∪ E(Hk )| by the additional comment
in Tutorial Exercise 11.4(b);
= |E(H1 )| + |E(H2 )| + · · · + |E(Hk )| by the Addition Rule;
= |V(H1 )| − 1 + |V(H2 )| − 1 + · · · + |V(Hk )| − 1 by Theorem 12.1.6;
= |V(H1 )| + |V(H2 )| + · · · + |V(Hk )| − k
= |V(H1 ) ∪ V(H2 ) ∪ . . . V(Hk )| − k by the Addition Rule;
= |V(G)| − k by Tutorial Exercise 11.4(a);
< |V(G)| − 1 as k > 1.

tutsol.56
12.5. No. One counterexample is the graph G drawn below.

This graph is not connected, but |E(G)| = 6 ⩾ 4 = 5 − 1 = |V(G)| − 1.


12.6. No. One counterexample is the graph G drawn below.

This graph is cyclic, but |E(G)| = 3 ⩽ 4 = 5 − 1 = |V(G)| − 1.


12.7. We proceed by strong induction on the number of vertices in T .
(Base step) Let T be a rooted tree with exactly one vertex. Then this vertex is
terminal, and there is no internal vertex. So

number of internal vertices = 0 = 1 − 1 = number of terminal vertices − 1.

(Induction step) Let k ∈ Z+ such that the theorem is true for all rooted trees with at
most k vertices in which every internal vertex has exactly two children. Consider a
rooted tree T with exactly k + 1 vertices in which every internal vertex has exactly
two children. Let r be the root of T . Then r must be internal because otherwise
T has exactly one vertex, and 1 < 1 + 1 ⩽ k + 1. So r has exactly two children by
assumption, say u and v.
Observe that urv is a path between u and v in T . By Proposition 12.1.3, this is
the only path between u and v in T . Therefore, in the graph

H = (V(T ) \ {r}, E(T ) \ {ru, rv}),

there is no path between u and v, and thus the vertices u, v are in different con-
nected components by Theorem 11.3.7. Let Hu be a connected component of H
containing u, and let Hv be a connected component of H containing v. Being
connected components, we know Hu and Hv are each connected in particular.
Also Hu and Hv are acyclic because they are subgraphs of the acyclic graph T .
So both Hu and Hv are trees. We will treat u and v as the roots of Hu and Hv
respectively. Denote by tu and tv the number of terminal vertices in Hu and Hv
respectively. As neither Hu nor Hv has the vertex r in it, both Hu and Hv have
at most k vertices.
There is a path P between the root r and any other vertex x in T by the connect-
edness of T . As u and v are the only children of the root r in T , any such path P
has either u or v in it. Deleting the vertex r and the edge ru or rv depending
on whether u or v is in P , we obtain a path between either u or v and the same
vertex x in H. In view of Proposition 12.1.3, one can obtain any path between u
or v and a vertex in H in this way.
One consequence of the previous paragraph is that, in view of Theorem 11.3.7
and Tutorial Exercise 11.4(a), any vertex x ∈ V(T ) \ {r} is either in Hu or in Hv .
Another consequence is that, for all vertices x, y in Hu , we know x is a parent of y
in T if and only if x is a parent of y in Hu ; similarly for Hv . Thus, since r is not
the child of any vertex in T , every internal vertex has exactly two children both in
Hu and in Hv . Applying the induction hypothesis to the rooted trees Hu and Hv ,
we deduce that Hu has tu − 1 internal vertices and Hv has tv − 1 internal vertices.
On the one hand, all the terminal vertices in Hu and in Hv are terminal vertices
in T . Moreover, the rooted tree T has no other terminal vertex because r is not

tutsol.57
a terminal vertex in T as discussed above. So T has exactly tu + tv terminal
vertices. On the other hand, all the internal vertices in Hu and in Hv are internal
vertices in T . In addition to these, the rooted tree T has exactly one more internal
vertex r. So T has exactly (tu − 1) + (tv − 1) + 1 = tu + tv − 1 internal vertices. So

(number of internal vertices in T ) = (number of terminal vertices in T ) − 1.

This completes the induction.

Diagram. r

u v

Hu Hv

Extra exercises
12.8. (a) 2 2 2
3 3 3
1 1 1
4 4 4
5 5 5
(b) Note that G is itself a spanning tree of G. So G has at least one spanning tree. To
show that G has at most one spanning tree, it suffices to prove that any spanning
tree of G must be equal to G.
Let T be any spanning tree of G. The definition of spanning trees already tells us
V(G) = V(T ). We know E(T ) ⊆ E(G) as T is a subgraph of G.
Finally, we prove E(G) ⊆ E(T ) by contradiction. Suppose we have an edge e ∈
E(G) \ E(T ). Then (V(T ), E(T ) ∪ {e}) is cyclic by Tutorial Exercise 12.3 because
T is a tree. However, this is a subgraph of an acyclic graph G. So we have the
required contradiction.
(c)∗ Assume G has exactly one spanning tree, say T . It suffices to show that G = T .
The definition of spanning trees already tells us V(G) = V(T ). We know E(T ) ⊆
E(G) as T is a subgraph of G. We prove E(G) ⊆ E(T ) by contradiction.
Suppose we have an edge uv ∈ E(G) \ E(T ). Thus H = (V(T ), E(T ) ∪ {uv}) is
cyclic by Tutorial Exercise 12.3. Since H is a subgraph of a graph G without any
loop, it must contain a cycle, say C = x1 x2 . . . xk x1 . Now T , being a tree, has
no cycle, and the only difference between H and T is the additional edge uv. So
uv ∈ E(C). Renaming the x’s if needed, we may assume u = x1 and v = x2 .
Define
T̂ = (V(G), (E(T ) ∪ {uv}) \ {x1 xk }).
Note that uv = x1 x2 ̸= x1 xk because they appear in different positions in the cy-
cle C. So T̂ ̸= T . Since G has exactly one spanning tree, to reach a contradiction,
we verify that T̂ is a spanning tree of G. By definition, we know V(T̂ ) = V(G).
(Connectedness) Take any a, b ∈ V(T̂ ). Note that V(T̂ ) = V(G) = V(T ). Use
the connectedness of T to find a path P = y0 y1 . . . yℓ in T where y0 = a and
yℓ = b.
Case 1: suppose x1 xk ̸∈ E(P ). Then P is a path between a and b in T̂ .

tutsol.58
Case 2: suppose x1 xk ∈ E(P ). Swapping a and b if needed, say x1 = yr and
xk = yr+1 . Now in T̂ ,
• between a and yr there is a path y0 y1 . . . yr ;
• between yr and yr+1 there is a path x1 x2 . . . xk ;
• between yr+1 and b there is a path yr+1 yr+2 . . . yℓ .
So two applications of Lemma 11.1.10 give us a path between a and b in T̂ .
(Acyclicity) Note that T̂ , being a subgraph of a graph G with no loop, cannot
have any loop. Suppose T̂ has a cycle, say D = z1 z2 . . . zm z1 . Now T does not
contain a cycle, and the only edge that is in T̂ but not in T is uv. So uv ∈ E(D).
Renaming the z’s if needed, we may assume u = z1 and v = zm . Note that

x2 x3 . . . xk x1 and z1 z2 . . . zm

are both paths between u and v in T . These two paths are distinct because the edge
x1 xk is in the first path but not the second one. So T is cyclic by Theorem 11.2.5.
This contradicts the assumption that T is a tree.
Additional comment. Notice that the proof of connectedness above resembles a
part of the proof of Theorem 12.1.4. One can extract from this a fact that is used
in both proofs: if C is a cycle in a connected undirected graph G, then removing
one e ∈ E(C) from G does not disconnect G.
12.9. There is no path of length |V(T )| in T because this would require |V(T )| + 1 vertices
in T , which T does not have. So there is ℓ ∈ N such that T contains no path of
length ℓ. Apply the Well-Ordering Principle to find the smallest such ℓ ∈ N. In view
of the smallestness of ℓ, the tree T has a path of length ℓ − 1, say x0 x1 . . . xℓ−1 .
We claim that x0 x1 is the only edge containing x0 in T . Suppose not. Say x0 y ∈ E(T ),
where y ̸= x1 . If y = xi , where y ∈ {2, 3, . . . , ℓ − 1}, then x0 x1 . . . xi x0 is a cycle in T ,
contradicting the acyclicity of T . So y ̸= xi for any y ∈ {1, 2, . . . , ℓ − 1}. This makes
yx0 x1 . . . xℓ−1 a path of length ℓ in T , contradicting the choice of ℓ. This contradiction
proves the claim.
In a similar way, one can prove that xℓ−2 xℓ−1 is the only edge containing xℓ−1 in T .
Note that T is a tree and is thus connected. So, since T has at least two vertices, it
has a path of length at least two, and hence it has at least one edge. This gives a path
of length one in T . So ℓ ⩾ 2. As ℓ − 1 ⩾ 2 − 1 = 1, we know x0 ̸= xℓ−1 .

tutsol.59

You might also like