MA0301 ELEMENTARY DISCRETE MATHEMATICS NTNU, SPRING 2020

Solutions 12 Exercise 1. Let B be a Boolean . For x, y, z ∈ B find the dual expressions of

i)(x +y ¯) · (¯z + y) ii) (1 + x) · y + x · y¯ · z iii)(x · y + 1) · (0 + x) · z

Solution. Recall the definition of dual expression: it consists in the statement obtained by replacing + by ·, · by +, 1 by 0, and 0 by 1. According to this, we have that the required dual expressions are following: (1) (x · y) + (z · y), (2) ((0 · x) + y) · (x + y + z), (3) ((x + y) · 0) + (1 · x) + z. 

Exercise 2. 1) Let the natural number N be our universe. We start by defining the property P (q): q is even. We define the relation R on N as follows: ∀n,m (n, m) ∈ R iff P (n + m). a) Show that R is an equivalence relation. b) Can you determine how many equivalence classes the relation R has? 2) Given the set F = {a, b, c, d, e} with an ordering described by the diagram

d e

b c

a

Write down all subsets of F in which the element c is a minimal element.

Solution. 1) a) We will show that R is reflexive, symmetric and transitive. Take m ∈ N. Note that (m, m) ∈ R since P (m + m) is true (m + m = 2m is an even number). Hence R is reflexive. For the symmetric property, assume that (m, n) ∈ R. This means that P (m + n) is true. Since m + n = n + m, then P (n + m) is true. Hence (n, m) ∈ R and so R is symmetric. Finally, for transitivity, assume that (m, n), (n, p) ∈ R. This implies that P (m + n) and P (n + p) are both

Date: April 24, 2020. 1 2 MA0301 ELEMENTARY DISCRETE MATHEMATICS NTNU, SPRING 2020 true, i.e. m + n and n + p are both even integers. Their sum is also an even integer, let us say, (m + n) + (n + p) = 2r, for some r ∈ N. Note that 2r = m + n + n + p = m + p + 2n ⇒ m + p = 2r − 2n = 2(r − n).

Then m + p is also an even integer. We have that P (m + p) is true and hence (m, p) ∈ R. Then R is transitive. We conclude that R is an equivalence relation. 1) b) We show that R has two equivalence classes: the even natural numbers and the odd natural numbers. First note that (1, 2) 6∈ R since 1 + 2 = 3 is not an even number. Now, let m be an odd natural number. This means that there is a non-negative natural number k ∈ N0 such that m = 2k + 1. Then we have that (1, m) ∈ R since 1 + m = 1 + 2k + 1 = 2k + 2 = 2(k + 1) is even. Then the odd natural numbers belong to the same equivalence class. In order to see that they indeed form an equivalence class, notice that if n = 2r is even, then 1 + n = 2r + 1 is odd, and so (1, n) 6∈ R. Hence {1, 3, 5, 7,...} is an equivalence class. Finally, if n = 2r is even, then (2, n) ∈ R since 2 + n = 2 + 2r = 2(r + 1) is even. Hence the even natural numbers form an equivalence class. We conclude that R has the two following equivalence classes:

{1, 3, 5, 7,...}, {2, 4, 6, 8,...}.

2) Recall the definition of minimal element: x ∈ P is minimal if there is no y ∈ P such that x 6= y and y ≤ x. Now, let G be a subset of F such that c is minimal in G. Obviously c ∈ G. According to the diagram, we have that a ≤ c, c ≤ d, c ≤ e and b and c are not comparable. Then a 6∈ G since otherwise it would contradict that c is minimal in G. Since there is no problem with the remaining three elements of F , we can freely choose them to belong to G. This corresponds to the following eight subsets: {c}, {c, b}, {c, d}, {c, e}, {c, b, d}, {c, b, e}, {c, d, e}, {c, b, d, e}.



Exercise 3. a) Let G be a planar graph with eight vertices. What is the maximal number of edges possible in G? b) Let G be a finite graph. Can G have a subgraph H (H is supposed to be different from G) so that G and H are isomorphic? c) Consider the graph G with V (G) := {a, b, c, d, e, f} and E(G) := {{a, c}, {a, d}, {a, e}, {b, e}, {b, f}}. i) Determine G − a ii) Find the connected components of G − a.

Solution. a) We know that a maximal planar graph with |V | > 2 vertices has precisely 3|V | − 6 edges. Then the maximum number of edges possible in G is 3 · 8 − 6 = 18. b) No. We will show it by contradiction. Let G = (V,E) be the initial graph and assume that there is a subgraph H = (V1,E1) such that H 6= G and G and H are isomorphic. The definition of graph isomorphism establishes that there exists a function f : V → V1 such that f is a bijection and

(1) {a, b} ∈ E ⇔ {f(a), f(b)} ∈ E1

Since H is subgraph of G, we have that V1 ⊆ V and E2 ⊆ E. However, since V is finite and f is a bijection, then V1 has the same size that of V and hence V = V1. Note that f also induces a bijective correspondence between E and E1 given by (1). Since E is also finite and E1 ⊆ E, we MA0301 ELEMENTARY DISCRETE MATHEMATICS NTNU, SPRING 2020 3 have that E = E1. Then we conclude H = (V,E) = G, which is a contradiction. Hence, a finite graph cannot have a subgraph isomorphic to itself. c) i) The set of vertices of G−a is given by V (G−a) = {b, c, d, e, f}. For the case of set of edges, we have to delete all the edges with contain a. The resulting set of edges is E(G − a) = {{b, e}, {b, f}}. c) ii) Note that there is no edge in G − a such that contains the vertex c. The same happens with d. Hence these vertices are isolated. On the other hand, the remaining three vertices belong to the same connected component since we have the path e → b → f. Hence the connected components of G − a are given by ({a}, ∅), ({c}, ∅) and ({b, e, f}, {{b, e}, {b, f}}). 

Exercise 4. Let G be a planar graph with fewer than 12 vertices. Show that G has a vertex of degree at most 4. (Hint: Recall the formula |E| ≤ 3|V | − 6.)

Solution. If |V | ≤ 2, the result follows immediately. Assume now that 2 < |V | < 12. Recall the formula |E| ≤ 3|V | − 6 for a planar graph G = (V,E) such that |V | > 2. By the formula of the sum of the degrees we have X (2) deg(v) = 2|E| ≤ 2(3|V | − 6) = 6|V | − 12 < 6|V | − |V | = 5|V |, v∈V where in the last inequality we used that |V | < 12. If every vertex has degree at least 5, we would have that X X deg(v) ≥ 5 = 5|V |, v∈V v∈V and according to (2), we would get that 5|V | < 5|V |, which is clearly a contradiction. Then our assumption is false and we conclude that G has a vertex of degree at most 4. 

Exercise 5. Show that the following graph is not planar.

(Hint: Notice that, in the case that the graph is planar, it contains no triangles. Then, any face would be bordered by at least 4 edges)

Solution. We proceed by contradiction. Assume that the graph is planar. We see that |V | = 11 and |E| = 20. Since we are assuming that the graph is planar, we can apply Euler’s formula in order to get that |F | = 2 − 11 + 20 = 11. The main observation is that the graph does not contain any 4 MA0301 ELEMENTARY DISCRETE MATHEMATICS NTNU, SPRING 2020 triangle and then any face is bordered by at least 4 edges. On the other hand, each edge borders two faces since there are no cut-edges in the graph. Then X X 2|E| = (no. of edges bordering f) ≥ 4 = 4|F |. f∈F f∈F Since |E| = 20 and |F | = 11, the above inequality tell us that 40 = 2 · 20 ≥ 4 · 11 = 44, which is a contradiction. We conclude then that the graph is not planar as we wanted to show.  Pn 2 2 Exercise 6. Use induction to show that for all natural numbers: 4 k=1(k + 2k)(k + 4) = (n + n)(n + 4)(n + 5).

Solution. We proceed by mathematical induction on n. For the base case n = 1, note that 1 X 4 (k2 + 2k)(k + 4) = 4(1 + 2)(1 + 4) = 60 = (12 + 1)(1 + 4)(1 + 5), k=1 and then the base case holds. For the induction hypothesis, assume that the formula holds for a natural number m. We will show that the formula holds for m + 1. Indeed, by splitting the sum and using the induction hypothesis, we have m+1 X 4 (k2 + 2k)(k + 4) = (m2 + m)(m + 4)(m + 5) + 4((m + 1)2 + 2(m + 1))((m + 1) + 4) k=1 = (m2 + m)(m + 4)(m + 5) + 4((m + 1)2 + 2(m + 1))(m + 5) = (m + 5)[m(m + 1)(m + 4) + 4(m + 1)(m + 1 + 2)] = (m + 1)(m + 5)[m(m + 4) + 4(m + 3)] = (m + 1)(m + 5)(m2 + 8m + 12) = (m + 1)(m + 5)(m + 2)(m + 6) = (m + 1)(m + 2)(m + 5)(m + 6) = (m + 1)((m + 1) + 1)((m + 1) + 4)((m + 1) + 5) = ((m + 1)2 + (m + 1))((m + 1) + 4)((m + 1) + 5). Hence the formula holds for m + 1. By mathematical induction, we conclude that the formula holds for all natural numbers n ∈ N.  Exercise 7. Use the laws of logic to simplify the statement: p∨(p∧q)∨(p∧q∧¬r)∧(p∧r∧t)∨t

Solution. Recall the absorption law for propositions: a ∨ (a ∧ b) ≡ a. By absorption law, we have that p ∨ (p ∧ q) ≡ p, p ∨ (p ∧ q ∧ ¬r) ≡ p, (p ∨ (p ∧ q)) ∨ (p ∧ q ∧ ¬r) ≡ p, ((p ∧ r) ∧ t) ∨ t ≡ t. Notice that we also use the associative law. We conclude then that p ∨ (p ∧ q) ∨ (p ∧ q ∧ ¬r) ∧ (p ∧ r ∧ t) ∨ t = p ∧ t.

 MA0301 ELEMENTARY DISCRETE MATHEMATICS NTNU, SPRING 2020 5

Exercise 8. Lewis–Zax (page 67): exercise 6.1. Let f be any function. Suppose that the inverse relation f −1 = {(y, x): y = f(x)} is a function. Is f −1 a bijection? Explain.

Solution. Let f : A → B be the function of the statement. Then f −1 ⊆ B × A and we assume that it is a function. We will show that f −1 : B → A is injective and surjective. For surjectivity, take x ∈ A. Since f is a function, we can find y = f(x) ∈ B. Then (y, x) ∈ f −1 and hence f −1 −1 −1 is surjective. For injectivity, take y1, y2 ∈ B such that f (y1) = f (y2) = x ∈ A. By definition −1 of f , we have that f(x) = y1 and f(x) = y2. However, since f is a function, we have that −1 −1 −1 y1 = y2. Then f is injective. Since f is both injective and surjective, we conclude that f is a bijection.  n Pn n k n−k Exercise 9. Use the binomial theorem (a + b) = k=0 k a b to compute the number 27 X 27 (−3)2i+1 i i=0 Solution. Observe that: 27 27 X 27 X 27 (−3)2i+1 = (−3) · ((−3)2)i i i i=0 i=0 27 X 27 = −3 9i i i=0 27 X 27 = −3 9i127−i i i=0 = −3(9 + 1)27 = −3 · 1027 = −3000000000000000000000000000.



Exercise 10. Draw the state diagram D(M) of the automaton M with states S := {s0, s1, s2}, accepting states Y := {s0}, input alphabet I := {a, b}, described in the state table T (M): ν a b

s0 s0 s1 s1 s0 s2 s2 s2 s2 Solution. According to the table, the diagram associated to the automaton M is the following

a a

b b start s0 s1 s2 a

b 6 MA0301 ELEMENTARY DISCRETE MATHEMATICS NTNU, SPRING 2020



Exercise 11. Draw the state diagram D(M) of the automaton M with states S := {s0, s1, s2}, accepting states Y := {s0, s2}, input alphabet I := {a, b}, described in the following state table T (M): ν a b

s0 s1 s0 s1 s2 s0 s2 s2 s1 Which of the following input words are accepted by M and which are not accepted by M? 1) bbaab 2) abbab 3) aabbb 4) babaab 5) aaabbb

Solution. According to the table, the diagram associated to the automaton M is the following

b a

a a start s0 s1 s2 b b

(1) bbaab is not accepted: the sequence of steps is s0 → s0 → s0 → s1 → s2 → s1 and s1 is not an accepting state.

(2) abbab is accepted: the sequence of steps is s0 → s1 → s0 → s0 → s1 → s0. (3) aabbb is accepted: the sequence of steps is s0 → s1 → s2 → s1 → s0 → s0. (4) babaab is not accepted: the sequence of steps is s0 → s0 → s1 → s0 → s1 → s2 → s1. (5) aaabbb is accepted: the sequence of steps is s0 → s1 →2→ s2 → s1 → s0 → s0.  Exercise 12. Let Σ := {a, b} and define the language L := {ambn |m, n > 0}. Construct an au- tomaton A0 which will accept the language L(A0).

Solution. Let A be an automaton which accepts the language L. First observe that if a word starts with b or finishes with a, the automaton will not accept such word. This means that if in the initial state appears a b, then we will have to send the next step to a sink. The same will happen when we are testing b’s: if after a b appears an a, then we will go to a sink. Then an example of such automaton A is represented in the following diagram: MA0301 ELEMENTARY DISCRETE MATHEMATICS NTNU, SPRING 2020 7

b a

a b a start s0 s1 s2 s3

a b b

In this case, the state s3 is a sink.  Exercise 13. a) Draw the table for the automaton A in Fig. 1. b) Find the language L(A) accepted by the automaton A in Fig. 1.

b a a

a a b b start s0 s1 s2 s3 s4 b

a b

Figure 1. The automaton A.

Solution. a) According to Fig. 1, the table for the automaton A is the following A ν a b

s0 s1 s0 s1 s2 s0 s2 s2 s3 s3 s1 s4 s4 s4 s4 b) Notice that the accepting state is s4 and once that we reach it, we stay there. We only can reach it thought s3 reading b, and we can only reach s3 through s2 reading b. Following the same idea, we see that we can only reach s2 by reading the subword aa. Hence, we conclude that we can only reach s4 by reading a word containing the subword aabb. This is the language accepted by the automaton A.  Exercise 14. Lewis–Zax (page 197/198): exercise 19.1: Draw a deterministic finite automaton that accepts all and only strings from the alphabet Σ = {a, b}, of length at least 3, in which every third symbol is a b. For example, the automaton should accept abb and aaba and bbbbbbb, but not ab or bba or aabaaa. 19.2 a) Show the full computation of the DFA of Figure 19.14, for the alphabet Σ = {a, b}, on input ababaa. 8 MA0301 ELEMENTARY DISCRETE MATHEMATICS NTNU, SPRING 2020

b) Describe in English the language accepted by this DFA. 19.4 Draw deterministic finite automata that accept the following languages, using the alphabet Σ = {a, b}.

(1) Strings with abab as a substring. (2) Strings with neither aa nor bb as a substring. (3) Strings with an odd number of occurrences of a and a number of occurrences of b that is divisible by 3. (4) Strings with both ab and ba as substrings.

Proof. 19.1. The diagram is the following. Note that the first states are not accepting states since we need that the string is of length at least 3. After checking the first three letters, the string can be accepted as long as the desired condition holds.

a, b a, b a start s0 s1 s2 s3

b a

a, b a, b s4 s5 s6

b

19.2. a) According to the figure in the book, the sequence of states is 0010100. b) Note that the states 0 and 1 are accepting while the state 2 is a sink. The only way of getting the sing is that the string has the subword bb. Otherwise, it will end up in the other states. Hence, the accepted language is given by the strings which do not contain two consecutive b’s. 19.4.

b a a a a b a b start s0 s1 s2 s3 s4

b b Figure 2. (1) MA0301 ELEMENTARY DISCRETE MATHEMATICS NTNU, SPRING 2020 9

a

a a start s0 s1 s2

a b b b b s3

Figure 3. (2)

b

b b start s0 s1 s2

a a a a a a

b b s3 s4 s5

b Figure 4. (3)

a start s0 s1 a

b b

b s2 s3 b

a a

b a s4 s5 a, b

Figure 5. (4) 10 MA0301 ELEMENTARY DISCRETE MATHEMATICS NTNU, SPRING 2020

 Exercise 15. Draw the state diagram of the finite state machine N corresponding to the transition table N ν ω 0 1 0 1

s0 s0 s1 0 0 s1 s1 s2 0 0 s2 s2 s3 0 0 s3 s3 s4 0 0 s4 s4 s5 0 0 s5 s5 s0 0 1 What is the output corresponding to the input sequence 0110111011?

Solution. According to the table, we have the following diagram

0, 0 0, 0 0, 0

1, 0 1, 0 start s0 s1 s2

1, 1 1, 0

s5 s4 s3 1, 0 1, 0

0, 0 0, 0 0, 0

The output corresponding to the input sequence 0110111011 is 0000000010. 

Exercise 16. Given two states s0, s1 (s0 being the starting state), complete the following diagram by adding arrows:

start s0 s1

so that it becomes a state diagram of the finite state machine M, which is supposed to recognise (with an output 1) every 0 appearing in an input string x that is preceded by another 0.

Solution. The complete diagram is the following:  MA0301 ELEMENTARY DISCRETE MATHEMATICS NTNU, SPRING 2020 11

1,0 0,1

0,0 start s0 s1 1,0