Notes
Notes
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.
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.
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
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 ...
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.
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
(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.
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”.
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
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.
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
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
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
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.
(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.
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.
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.
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.
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.
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:
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.
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.
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.
Extra exercises
1.8. Let p, q, r be propositional variables. Consider the compound expressions
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.
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 .
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.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
(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) .
“there exists one x such that P (x)” or “there is 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)”.
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.
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.
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:
¬∀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
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) .
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,
(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
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
as ∀y1 , y2 , . . . , ym Q(x1 , x2 , . . . , xn , y1 , y2 , . . . , ym ).
(2) We may abbreviate
as ∀y1 , y2 , . . . , ym ∈ E Q(x1 , x2 , . . . , xn , y1 , y2 , . . . , ym ).
(3) We may abbreviate
as ∃y1 , y2 , . . . , ym Q(x1 , x2 , . . . , xn , y1 , y2 , . . . , ym ).
(4) We may abbreviate
as ∃y1 , y2 , . . . , ym ∈ E Q(x1 , x2 , . . . , xn , y1 , y2 , . . . , ym ).
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).
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.
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
(2) The integer −1231 is odd because −1231 = 2 × (−616) + 1, where −616 is an integer.
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.
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.
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 .
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.
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 .
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.
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.
26
Proof. The integer 2 is even because 2 = 2×1 where 1 is an integer. Also 22 = 4 = 2×2.
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.
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.
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.
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.
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.
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.
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 .
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:
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.
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.
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 , . . . }.
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)}.
Note 4.1.7. Let U be a set and P (x) be a predicate over U . For all objects z,
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
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).
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).
z 2 − 1 = (z − 1)(z + 1) = 0.
∴ z − 1 = 0 or z + 1 = 0.
∴ z = 1 or z = −1.
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)
∀z (z ∈ A ⇒ z ∈ B) and ∀z (z ∈ B ⇒ z ∈ A)
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).
Note 4.2.2. We avoid using the symbol ⊂ because it may have different meanings to different
people.
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 ⊆.
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.
• {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.
∅, {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}, . . .
A ∪ B = {x : x ∈ A or x ∈ B}.
A ∩ B = {x : x ∈ A and x ∈ B}.
A \ B = {x : x ∈ A and x ̸∈ B}.
36
U
A B A B A B B
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.
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.
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 :
Since the columns under “x ∈ A ∪ B” and “x ∈ A ∩ B” are the same, for any x ∈ U ,
x∈A∪B ⇔ x∈A∩B
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 ∩.
38
Proof. (1) By the definition of ⊆, we need to show that
∀z (z ∈ A ∩ B ⇒ z ∈ A).
∀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.
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?
39
(g) {1, 2} ⊆ {3, 2, 1}. (h) {3, 3, 2} ⊊ {3, 2, 1}.
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}}.
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).
Example 5.1.2. (1) (1, 2) ̸= (2, 1), although {1, 2} = {2, 1}.
√
(2) (3, 0.5) = ( 9, 12 ).
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
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 )
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
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)
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)}.
44
5.2 Operations on relations
A B C A B
R
y
R S
x y
z
x S◦R
R−1
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
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
A B C
S
R y
S −1
R−1
z
x S◦R
R−1 ◦ S −1
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
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.
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;
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,
47
Example 5.3.8. Following Example 5.3.4, define
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:
aRb ⇔ a − b is even.
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
• 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.
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
50
CS1231 Chapter 6
∀x ∈ A (x R x).
∀x, y ∈ A (x R y ⇒ y R x).
∀x, y, z ∈ A (x R y ∧ y R z ⇒ x R z).
∀ ∀
∀ ∀
∃ ∃
∃
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;
Example 6.1.3. Let R denote the equality relation on a set A, i.e., for all x, y ∈ A,
xRy ⇔ x = y.
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.
x R′ y ⇔ x < y.
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
Example 6.1.8. Let R denote the divisibility relation on Z+ , i.e., for all x, y ∈ Z+ ,
xRy ⇔ x | y.
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
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
[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;
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}}.
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]?
Example 6.3.9. Let A be a set. Then from Example 6.2.2 we know A/= is equal to
{{x} : x ∈ 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.
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).
xRy ⇔ x ⩽ y.
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.
Example 6.4.6. Let R2 denote the divisibility relation on Z+ , i.e., for all x, y ∈ Z+ ,
x R2 y ⇔ x | y.
(2) S ♯ = {x ∈ Q⩾0 : 0 < x < 5} has no smallest element because if x ∈ S ♯ , then x/2 ∈ S ♯
and x/2 < x.
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.
R = {(a, a), (a, b), (a, c), (b, a), (b, b), (b, c), (c, a), (c, b), (c, c), (d, d), (e, e)}.
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
reflexive
b c ∧ ¬symmetric
∧ ¬transitive
∧ ¬antisymmetric
a
¬reflexive
c ∧ ¬symmetric
∧ ¬transitive
∧ ¬antisymmetric
b b
a a
¬reflexive ¬reflexive
c ∧ ¬symmetric c ∧ symmetric
∧ transitive ∧ ¬transitive
∧ antisymmetric ∧ ¬antisymmetric
R = {}
¬reflexive
c ∧ symmetric
∧ transitive
∧ antisymmetric
57
(i) reflexive, (ii) symmetric, (iii) antisymmetric, (iv) transitive.
Extra exercises
6.8. For each of the relations defined below, determine whether it is
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.,
∀x ∈ A ∃y ∈ B (x, y) ∈ 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.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?
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
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
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).
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.
7.3 Composition
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,
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.
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 .
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)).
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.
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) .
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.
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}
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
surjection
injection
A B A B
Figure 8.1: Injections, surjections, and the number of elements in the domain and the
codomain
xk+1 ym
xk × ..
.
.. yℓ
.
.. ..
. .
x2 y2
x1 f y1
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.
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.
69
0 1 2 3 4 ··· 0 1 2 ···
g h
1 2 3 4 5 ··· 0 2 4 ···
(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)
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.
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.
Recall from Tutorial Exercise 6.3(b) that the equivalence classes have the form
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
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
.. .. ..
. . .
2 b2
1 b1
0 b0
bijection
N B
73
.. .. ..
. . .
−3 5
−2 3
−1 1
.. .. ..
. . .
2 4
1 2
0 0
Z N
Proof sketch.
.. .. .. .. .. .
. . . . . ..
(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.
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
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.
.. .. .. .. .. ..
. . . . . .
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
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
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.
Corollary 9.2.7. (1) A set B is infinite if there is an injection f from some infinite 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.
77
0 1 2 3 4 ...
f (0) ∈
/ ∈ ∈
/ ∈
/ ∈
/ ...
f (1) ∈ ∈
/ ∈ ∈
/ ∈ ...
f (2) ∈
/ ∈ ∈ ∈
/ ∈ ...
f (3) ∈
/ ∈
/ ∈ ∈
/ ∈
/ ...
f (4) ∈ ∈
/ ∈ ∈ ∈
/ ...
.. .. .. .. .. .. ..
. . . . . . .
R ∈ ∈ ∈
/ ∈ ∈ ...
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) . (†)
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.
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 σ
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.
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
Proof. Proceed by induction on n as in Tutorial Exercise 9.3 using Tutorial Exercise 9.1.
Y
A B X
Example 10.1.2. The sets {1, 2} and {3, 4, 5} are disjoint. Note that
Proposition 10.1.3 (Addition Rule). Let A and B be disjoint finite sets. Then |A ∪ B| =
|A| + |B|.
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|.
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
Theorem 10.1.7 (Inclusion–Exclusion Rule for two sets). Let A, B be finite sets. Then
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
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.
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.
|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)
83
g1 (1) (f (1), g1 (1)) 1
g1 (2) (f (1), g1 (2)) 2
f (1) .. .. ..
. . .
g1 (n) (f (1), g1 (n)) n
.. .. .. ..
. . . .
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}
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
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 )).
• 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 ).
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.
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
i∈S ⇔ di = 1
{ } 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).
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.
n! = n × (n − 1)! = n × (n − 1) × (n − 2)! = · · ·
= n × (n − 1) × · · · × 1 × 0! = n × (n − 1) × · · · × 1.
(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.
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)!
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
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:
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.
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.
89
Theorem 10.3.15. For all r, n ∈ N,
n!
, if r ⩽ n;
n
= r! (n − r)!
r
0, if r > n.
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
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
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.
(2) When there is no risk of ambiguity, we may write an edge {x, y} as xy.
Here is a drawing of G.
b d
s m
h k
92
are subgraphs of G. Here are drawings of G1 and G2 respectively.
b d b d
s m h m
h k s
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
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
b d b d
s s
h k h
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
s s
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
u = x0
P
ys+1 ys
xt
... v = xk = y0
Q
w = yℓ ...
94
Proof. Let P = x0 x1 . . . xk and Q = y0 y1 . . . yℓ , so that k, ℓ ∈ N and
x0 = u, xk = v = y0 , w = yℓ .
x0 x1 . . . xt ys+1 ys+2 . . . yℓ
{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
b d
s s
h k h
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 ...
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
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)
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.
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 + ).
+
a Q2
Hu b
Q1
u v
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.
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
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
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).
3 2
4 1
5 6
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
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.
b d b d
s m s m
h k h k
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
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.
(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,
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,
Hu u v Hv
mu vertices mv vertices
mu − 1 edges mv − 1 edges
mu + mv vertices
mu + mv − 1 edges
Exercise 12.1.7. Which proof technique(s) is/are used in our proof of Theorem 12.1.6? 12b
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,
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.
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;
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;
– root
– terminal vertex
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.
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
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
• 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
(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
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).
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:
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.
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.
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.
From these, we deduce that ¬∃x ∃y Q(x, y) is true if and only if ∀x ∀y ¬Q(x, y) is true.
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
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).
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.
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;
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
(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?
∃x ¬(x ∈ R ⇔ x ̸∈ x).
∃x ¬(x ∈ R ⇔ x ̸∈ x).
5a, page 44
Let P (n) be the predicate
over Z⩾2 .
sol.7
For all (k + 1)-tuples (x1 , x2 , . . . , xk+1 ) and (y1 , y2 , . . . , yk+1 ),
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.
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
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 .
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 } .
Case 1: this procedure stops after finitely many steps. Then a run results in
m1 , m2 , . . . , mℓ and g1 , g2 , . . . , gℓ
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
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:
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.
• 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.
sol.15
Tutorial solutions for Chapter 1
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.
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.
(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 ∨.
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.)
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.
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:
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
∀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
¬∃x, y ∈ A (x ̸= y ∧ x R y ∧ y R 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 .
∃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 ).
∃x1 , x2 , y1 , y2 ∈ R ¬(y1 = x1 2 ∧ y2 = x2 2 ∧ y1 ̸= y2 → x1 ̸= x2 ).
∃x ∈ R ¬ (∃y ∈ R y = x2 ) → x ⩾ 0 .
(∃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 .
(∃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) .
tutsol.9
Tutorial solutions for Chapter 3
∀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.
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
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 ∪, ∩, \.
∀x ∈ A ∀S1 , S2 ∈ C (x ∈ S1 ∧ x ∈ S2 ⇒ S1 = S2 ).
∀x ∈ A ∃!S ∈ C x ∈ S.
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.
over Z+ .
B0 ∪ B1 ∪ · · · ∪ Bk ∪ Bk+1
= B0 ∩ B1 ∩ · · · ∩ Bk ∪ Bk+1 by the induction hypothesis;
= B0 ∩ B1 ∩ · · · ∩ Bk ∩ Bk+1 by De Morgan’s Laws.
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 ∪.
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 ∪.
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
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
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 .
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.
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 c 2 3
d e 4 5
tutsol.21
Alternative proof. By the definition of relation inverse, we know R−1 is a relation
from B to A. So
tutsol.22
Tutorial solutions for Chapter 6
b e
(x1 , y1 ) x
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
[(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
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) ,
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.
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
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.
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
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
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.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
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.
tutsol.31
Tutorial solutions for Chapter 8
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),
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
(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) .
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
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.
f : {1, 2, . . . , m} → A0 and g : N → B0
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 .
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
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.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
tutsol.42
Tutorial solutions for Chapter 10
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 )}.
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
{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
+ + + +
.. .. .. .. .. ..
. . . . . .
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)
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
(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
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)
3 vertices:
4 vertices:
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
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
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
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,
tutsol.53
Tutorial solutions for Chapter 12
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 .
vertex.
By the Multiplication Rule, the number of such graphs is
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
a b c d and d c b a
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
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.
(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
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
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