Instructions To Students: NOT NOT
Instructions To Students: NOT NOT
you to do so. A 1 1 1 1 1 1 1 B R
HT 2 2 2 2 2 2 2 E U
2. On the right, write down your Student Number NT 3 3 3 3 3 3 3 H W
Total
CS1231
by the definition of f .
(F2) Let x ∈ A and y1 , y2 ∈ B satisfying (x, y1 ), (x, y2 ) ∈ f . Then the definition of f gives
t1 , t2 ∈ I(2) such that
Looking at the first coordinates, we see (2t1 , 4t1 2 ) = x = (2t2 , 4t2 2 ). This implies 2t1 = 2t2 ,
and thus t1 = t2 . It follows that
y1 = (t1 4 − t1 2 , t1 3 − t1 ) = (t2 4 − t2 2 , t2 3 − t2 ) = y2 .
1
CS1231
Note that
Diagrams (extra).
s = −4 s=4 t=2
A t = −2
2
CS1231
2. (a) Is it true that, for all sets A and B, every function f : A → B, when considered as a subset
of A × B, has the same cardinality as its domain A? Prove that your answer is correct.
[4 marks]
Solution. Yes, as shown below.
(Surjectivity) Let (x, y) ∈ f . Then y = f (x) and thus g(x) = (x, f (x)) = (x, y).
(Injectivity) Let x1 , x2 ∈ A such that g(x1 ) = g(x2 ). Then (x1 , f (x1 )) = (x2 , f (x2 )) by the
definition of g. This implies x1 = x2 .
(Injectivity) Let (x1 , y1 ), (x2 , y2 ) ∈ f such that h(x1 , y1 ) = h(x2 , y2 ). Then x1 = x2 by the
definition of h. Also y1 = f (x1 ) = f (x2 ) = y2 . So (x1 , y1 ) = (x2 , y2 ).
(b) Is it true that, for all sets A and B, every function f : A → B, when considered as a subset
of A × B, has the same cardinality as its codomain B? Prove that your answer is correct.
[4 marks]
Solution. No, as shown below.
3
CS1231
3. Is it true that, for all sets A, if there is a surjection f from A to some countable set B, then A is
countable? Prove that your answer is correct. [4 marks]
Solution. No, as shown below.
Consider the function f : P(N) → {1} such that f (x) = 1 for every x ∈ P(N). This is a surjection
because ∅ ∈ P(N) and f (∅) = 1. Now {1} is a finite set, as witnessed by id{1} . So it is countable
by Proposition 9.1.3. However, we know from Corollary 9.3.2 that P(N) is uncountable.
4. There are 30 sets, of which 20 are countable and 24 are infinite. How many of them are both
countable and infinite? Explain your answer. [3 marks]
Solution. 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 countable by Proposition 9.1.3.
So |C ∪ I| = 30. Also, by the Inclusion–Exclusion Rule,
|C ∪ I| = |C| + |I| − |C ∩ I|
= 20 + 24 − |C ∩ I|.
Hence, the number of sets that are both countable and infinite here is
|C ∩ I| = 20 + 24 − |C ∪ I| = 20 + 24 − 30 = 14.
Alternative solution. There are 30 sets, of which 24 are infinite. So the Difference Rule tells us
30 − 24 = 6 of these are finite. All these 6 sets are countable in view of Proposition 9.1.3. The
rest are infinite. Since there are 20 countable sets here, the number of countable infinite sets here
is 20 − 6 = 14 by the Difference Rule.
4
CS1231
Calculate the number of subgraphs of T that satisfy all of the following: (a) it contains the vertex r,
(b) when r is considered the root, it has height 3 and all parents have exactly two children, and
(c) when r is considered the root, all the terminal vertices of the subgraph are terminal vertices of T .
Show your working, where it is indicated where each term comes from. [2 marks]
Solution.
• There is 1 way to choose top vertex r.
• For each of these 2 children, there are 32 ways to choose its two children.
• For each of these 2 × 2 = 4 children, there are again 32 ways to choose its two children.
Each such sequence of choices gives rise to a required subgraph, and each required subgraph is
constructed from exactly one such sequence of choices. Therefore, the number of such graphs is
also 4374.
5
CS1231
1
2 3
4 5 6 7
Calculate the number of graphs that satisfy all of the following: (a) it is isomorphic to G, and
(b) it has the same vertices as G. Show your working, where it is indicated where each term comes
from. [2 marks]
Solution.
• There are 7 ways to choose a new label x1 ∈ {1, 2, . . . , 7} for the vertex that is labelled 1
in G.
• There are 7 − 1 = 6 ways to choose a new label x2 ∈ {1, 2, . . . , 7} \ {x1 } for the vertex that
is labelled 2 in G.
• There are 7 − 2 = 5 ways to choose a new label x3 ∈ {1, 2, . . . , 7} \ {x1 , x2 } for the vertex
that is labelled 3 in G.
• ...
• There are 7 − 6 = 1 ways to choose a new label x7 ∈ {1, 2, . . . , 7} \ {x1 , x2 , . . . , x6 } for the
vertex that is labelled 7 in G.
By the General Multiplication Rule, the number of such sequences of choices is 7 × 6 × · · · × 1 = 7!.
Each such sequence of choices gives rise to a required graph, and each required graph is constructed
from exactly 8 such sequences:
a a a a
b c b c b c b c
de f g de gf ed f g ed gf
a a a a
c b c b c b c b
f g de gf de f g ed gf ed
are drawings of the same graph. Therefore, the number of such graphs is 7!/8 = 630.
Alternative solution.
• There are 7 ways to choose a new label x1 ∈ {1, 2, . . . , 7} for the vertex that is labelled 1
in G.
• There are 7−1 = 62 ways to choose a subset {x2 , x3 } ⊆ {1, 2, . . . , 7} \ {x1 } of new labels
2
for the set {2, 3} of vertices in G, where x2 < x3 .
• There are 6−2 = 42 ways to choose a subset {x4 , x5 } ⊆ {1, 2, . . . , 7} \ {x1 , x2 , x3 } of size 2
2
to make edges x2 x4 and x2 x5 .
• There are 4−2 = 22 ways to choose a set {x6 , x7 } ⊆ {1, 2, . . . , 7} \ {x1 , x2 , . . . , x5 } of size 2
2
to make edges x3 x6 and x3 x7 .
By the General Multiplication Rule, the number of such sequences of choices is 7 × 62 × 42 × 22 =
630. Each such sequence of choices gives rise to a required graph, and each required graph is
constructed from exactly one such sequence. Therefore, the number of such graphs is also 630.
5
CS1231
6
CS1231
8. A tuberoot is defined to be a connected loopless undirected finite graph in which no two distinct
cycles share a common vertex. Here are drawings of two tuberoots.
• • • • • •
• • • • •
• • •
•
• • • • • •
• • • • • •
• • • • •
• • •
•
• • • • • •
(i) How many tuberoots are there with exactly 7 vertices and exactly 2 cycles if we count isomorphic
tuberoots as one? Explain your answer. [3 marks]
Solution. There are exactly 4, as listed below.
• • • • • • • •
• • • • • • • • • •
• • • • • • • • •
•
e b
d a
f c i j
h g
7
CS1231
is a cycle in G. It is distinct from C, because it contains the edge xi+s xi+s+1 ̸∈ E(C),
but it shares the vertex xi+s with C. This contradicts the fact that G is a tuberoot,
and thus proves the claim.
...
z2 ...
x
xi i+s z1
u = x0 ... xn = v
zr xj xj+t P
...
C ...
Use the claim to obtain i, s ∈ N such that 0 ⩽ i ⩽ i + s ⩽ n and V(P ) ∩ V(C) =
{xi , xi+1 , . . . , xi+s }. Notice x0 = u ̸∈ V(C) and xn = v ̸∈ V(C). Since xi , xi+s ∈ V(C),
actually 0 < i ⩽ i + s < n. So x0 x1 . . . xi−1 ˚xi+s+1 xi+s+2 . . . xn is a path between u
and v in G ◁ C.
Case 2: suppose exactly one of u, v is in V(G)\V(C). Say u ∈ V(G)\V(C) and v = ˚. In
view of the connectedness of G, there is a path in G between u and some vertex in C. Use the
Well-Ordering Principle to find such a path P = x0 x1 . . . xn of shortest length, where x0 = u
and xn ∈ V(C). By the minimality of the length of P , we know x0 , x1 , . . . , xn−1 ̸∈ V(C).
Then x0 x1 . . . xn−1 ˚ is a path in G ◁ C between u and v by the definition of G ◁ C.
8
CS1231
[2 marks]
Solution. By the Difference Rule and the Addition Rule,
|V(G ◁ C)| = |(V(G) \ V(C)) ∪ {˚}| = |V(G)| − |V(C)| + |{˚}| = |V(G)| − |V(C)| + 1.
When constructing G ◁ C from G, all the edges in C are removed, and each edge ab ∈ E(G)
where a ∈ V(C) and b ̸∈ V(C) is replaced by an edge ˚b ∈ E(G ◁ C). We show that this
replacement process is injective, which will imply
by the Addition Rule and the definition of G ◁ C, and thus |E(G ◁ C)| = |E(G)| − |E(C)|.
Let a1 , a2 ∈ V(C) and b1 , b2 ∈ V(G) \ V(C) such that a1 b1 , a2 b2 ∈ E(G) and ˚b1 = ˚b2 .
Then b1 = b2 because b1 ̸= ˚ ̸= b2 . Suppose a1 ̸= a2 . Say C = z1 z2 . . . zℓ z1 , where z1 = a1
and zk = a2 . Note that a1 , a2 , b1 are three different vertices. So b1 z1 z2 . . . zk b2 is a cycle in G.
It is distinct from C because it contains the vertex b1 , but it shares the vertex a1 with C.
This contradicts the hypothesis that G is a tuberoot.
9
CS1231
|E(G)| = |V(G)| − 1 + c.
[4 marks]
Solution. (Base step) Let G be a tuberoot with no cycle. By the definition of tuberoots,
we know G is loopless and connected. So G is acyclic and is thus a tree. It follows from
Theorem 12.1.10 that |E(G)| = |V(G)| − 1 = |V(G)| − 1 + 0.
(Induction step) Let k ∈ N such that the proposition is true for all tuberoots with exactly
k cycles. Consider a tuberoot G with exactly k + 1 cycles. Pick any cycle C in G. We know
from (iii) that G ◁ C is connected. Since G has no loop and the construction of G ◁ C does
not introduce any loop, we know that G ◁ C is again loopless. Being a tuberoot, no distinct
cycles in G share a common vertex. Since all cycles in G ◁ C are cycles in G by (iv), the same
is true in G ◁ C. Therefore, we deduce that G ◁ C is a tuberoot. By (iv) again, the tuberoot
G ◁ C has exactly one fewer cycles than G. So G ◁ C has exactly k cycles. The induction
hypothesis then tells us |E(G ◁ C)| = |V(G ◁ C)| − 1 + k. By this and (v),
Alternative way to complete the induction step. Let k ∈ N such that the proposition is
true for all tuberoots with exactly k cycles. Consider a tuberoot Gk+1 with exactly k+1 cycles.
Pick any cycle C in Gk+1 . Take e ∈ E(C). Let Gk be the graph obtained from Gk+1 by
removing the edge e, i.e.,
As Gk+1 is a connected and e comes from a cycle in Gk+1 , we can show that Gk is connected
by following the proof of Theorem 12.1.4. As Gk is a subgraph of the loopless graph Gk+1
where no two distinct cycles share a common vertex, we know Gk also has no loop, and no
two distinct cycles in Gk share a common vertex too. These show that Gk is a tuberoot.
Now we count the number of cycles in Gk . In the construction from Gk+1 to Gk , only vertices
and edges in C are affected. As no distinct cycles share a common vertex in the tuberoot Gk+1 ,
the graph Gk inherits all the cycles in Gk+1 except C. Conversely, all cycles in Gk are cycles
in Gk+1 because Gk is a subgraph of Gk+1 . So the cycles in Gk are precisely the cycles
in Gk+1 excluding C. As Gk+1 has k + 1 cycles, we deduce that Gk has k cycles. Hence
END OF PAPER
10
CS1231
Use this page if and only if you need extra space for your answers, in which case (1) indicate the question
number(s) clearly below, and (2) indicate in the original answer space that you are using this page for
that question. Do not use this space for rough work.