Discrete Mathematics I: Solution
Discrete Mathematics I: Solution
Exercise 1. You live in a strange country where the only coins are 3 cent coins and 5 cent coins.
What are the possible prices you can pay with just these two coins? As it turns out, quite a lot.
Let P (n) stand for the proposition that for the money amount n ≥ 8 cent, you can build it up with
just 3 and 5 cent pieces.
• Prove that for any n ≥ 8 that P(n) holds using strong induction.
• Can you come up with a proof that does not use strong induction but just "regular" induction?
If not, why not? (briefly summarize where the problem lies or briefly show how you could use
"regular" induction. You do not need to give a full proof.)
Solution:
We use strong induction to prove that for the money amount n ≥ 8 cent, you can build it up
with just 3 and 5 cent pieces.
Let P (n) ::= [∃k, l ∈ N : 3k + 5l = n] we prove that for any n ≥ 8 that P (n) is true.
Inductive Hypothesis: We assume for some n ≥ 12 and for all 12 ≤ k ≤ n that P (k) is
true.
Induction step:
From the induction hypothesis we know that P (n − 5) is also true since if n = 12 then n − 5 = 8
and P (8) is true. Also, we know that we can reach n − 5 by removing a 5 cent coin since we
can make the collection adding up to an amount larger than 12 simply by adding a number of 5
cents to one of the base cases. We can make 6 cents using two 3 cent coins as 3 ∗ 2 = 6. Now
we can use the collection of coins used to construct n − 5 and add two 3 cent coins to it to make
n − 5 + 3 ∗ 2 = n + 1 and so we can organize n + 1 as well.
We conclude using the principle of mathematical induction that P (n) is true for all n ≥ 8.
2023 1
Discrete Mathematics I
Exercise sheet 8 2023
Exercise 2. A robot moves on the two-dimensional integer grid (it can go in the negatives too).
It starts out at (0,0) and is allowed to move in any of these four ways:
1. right 2, down 1;
2. left 2, up 1;
3. right 1, up 3;
4. left 1, down 3.
We will gradually prove that this robot can never reach the position (1,1) (1 right and 1 up from
the starting position).
(a) Give a full mathematical description of this state machine (domain of the states, starting state
and transitions).
Solution:
states::= Z × Z
(b) Show that the following predicate is a preserved invariant of the state machine:
P ((x, y)) := [∃k ∈ Z s.t. 3x − y = 7k]
Note: x represents the horizontal position (left-right) and y the vertical position (up-down).
Solution:
We show that P ((x, y)) is a preserved invariant of the defined state-machine by analysing the
transition of the state-machine.
Suppose P ((x, y)) is true for some (x, y) ∈ Z2 , so there exists k ∈ Z such that 3x − y = 7k.
We now show that it holds in the next state too for any transition:
• If the robot moved (+2, −1): Then the next state is (x + 2, y − 1). Since P ((x, y)) holds,
we have:
3x − y = 7k ⇔ 3x − y = 7(k + 1) − 7
⇔ 3x − y + 7 = 7(k + 1)
⇔ 3x + 6 − y + 1 = 7(k + 1)
⇔ 3(x + 2) − (y − 1) = 7(k + 1)
So P ((x + 2, y − 1)) holds too.
• If the robot moved (−2, +1): Then the next state is (x − 2, y + 1). Since P ((x, y)) holds,
we have:
3x − y = 7k ⇔ 3x − y = 7(k − 1) + 7
⇔ 3(x − 2) − (y + 1) = 7(k − 1)
So P ((x − 2, y + 1)) holds too.
2023 2
Discrete Mathematics I
Exercise sheet 8 2023
• If the robot moved (+1, +3): Then the next state is (x + 1, y + 3). Since P ((x, y)) holds,
we have:
3x − y = 7k ⇔ 3x − y + 3 − 3 = 7k
⇔ 3(x + 1) − (y + 3) = 7k
So P ((x + 1, y + 3)) holds too.
• If the robot moved (−1, −3): Then the next state is (x − 1, y − 3). Since P ((x, y)) holds,
we have:
3x − y = 7k ⇔ 3x − y − 3 + 3 = 7k
⇔ 3(x − 1) − (y − 3) = 7k
So P ((x − 1, y − 3)) holds too.
Hence, if P ((x, y)) holds for some arbitrary state then it will also hold for the next state, and
so P is a preserved invariant of the state machine. □
(c) Using this result, conclude that the state (1,1) is unreachable.
Solution:
As shown above, P is a preserved invariant. Additionally, P holds for the initial state, (0, 0),
since 3 × 0 − 0 = 7 × 0. So P holds for all reachable states.
Now suppose for a contradiction that (1, 1) is a reachable state. Then, P ((1, 1)) holds. But
there is no k ∈ Z such that 3 − 1 = 2 = 7k, so we have a contradiction. Hence, (1, 1) is not
reachable. □
2023 3
Discrete Mathematics I
Exercise sheet 8 2023
Exercise 3. The function sub returns the set of all subformulas of a formula in propositional
logic. For example, for the formula F = ((P1 ∧ P2 ) ∨ ¬P3 ), sub(F ) = {((P1 ∧ P2 ) ∨ ¬P3 ), (P1 ∧
P2 ), ¬P3 , P1 , P2 , P3 }. Prove by induction on the number of connectives (i. e. ∧, ∨, →, ↔ ¬) in a
formula that if a propositional formula A has n connectives, it holds that |sub(A)| ≤ 2n + 1.
Solution:
Proof by strong induction on the number of connectives in a formula that if a propositional
formula A has n connectives, it holds that |sub(A)| ≤ 2n + 1.
Base Case: n = 0 i.e. 0 connectives. Then the formula is A is an atom Pi which has ex-
actly one sub-formula (itself), so 1 ≤ 2 ∗ 0 + 1. The base case is true
Induction Hypothesis: Assume for some A ∈ PROP having k connectives, that |sub(A)| ≤
2k + 1.
Conclusion: we have proved it for n = 0 and we have proved that if it is true for n = k then
it is true for n = k + 1, therefore by the principle of mathematical induction, P (n) is true for
A ∈ P ROP with n ≥ 0 connectives in A.
2023 4