30X Sections

CMSC250 Section 030x: Midterm 1 Answer Key
1. (15 points) Translate each of the following English sentences into formal statements using the
logical operators (∀, ∃, ∨, ∧, ¬, and →). You may also use mathematical grouping and set
notations, as needed. Under each translation that you provide, you will then write its negation
as a formal statement (using the logical operators, domains and predicates).
(a) English statement: “There are at least 2 people in this class who have blue eyes.” Assume
the domain P = {all people in this class}, and the predicate B(x) = “x has blue eyes”.
Solution:
Restatement: ∃x, y ∈ P [B(x) ∧ B(y) ∧ (x 6= y)]
Negation: ∀x, y ∈ P [¬B(x) ∨ ¬B(y) ∨ (x = y)]
(b) English statement: “There is at most one positive integer that when squared equals itself.”
Domain: Z+ (all the positive integers); Predicate: I(x) = “x2 = x”.
Solution:
Restatement: ∀m, n[(m = n) ∨ (m 6= m2 ) ∨ (n 6= n2 )]
Negation: ∃m, n[(m 6= n) ∧ (m = m2 ) ∧ (n = n2 )].
(c) English statement: “For every rational there is an integer that when multiplied by that
rational results in an integer product. Domains: Z and Q (the integers and the rationals);
Predicate: I(a, b) = “a · b ∈ Z”.
Solution:
Restatement: ∀q ∈ Q ∃n ∈ Z[q · n ∈ Z].
Negation: ∃q ∈ Q ∀n ∈ Z[q · n 6∈ Z].
1
2. (20 points) Logic and Circuits.
(a) Derive a DNF (Disjunctive Normal Form) representation for the output S (use the method
that was presented in the textbook and was used in class).
P
T
T
T
T
F
F
F
F
Q
T
T
F
F
T
T
F
F
R
T
F
T
F
T
F
T
F
S
T
F
F
F
F
F
T
T
Answer
Solution: S = (P ∧ Q ∧ R) ∨ (¬P ∧ ¬Q ∧ R) ∨ (¬P ∧ ¬Q ∧ ¬R)
(b) Using only AND, OR, and NOT gates that take up to two inputs, draw a circuit corresponding to the expressions below for inputs x and y:
v = (x ∧ ¬y) ∨ (¬x ∧ y)
Page 2
x
y
x
y
Com put ed by Wolfram !Alpha
Solution:
Page 3
3. (25 points) For this question, you will perform the following operation 57 − 101 in binary
arithmetic using the twos-complement arithmetic that was discussed in class. To simplify
matters, assume that all numbers are 8-bits in length, and perform your calculations in parts:
(a) Write 57 (base-10) in base-2:
(a)
00111001
(b)
01100101
(b) Write 101 (base-10) in base-2:
(c) Convert the base-2 number from part(b) into its twos-complement form:
(c)
10011011
(d) Perform the operation by summing the last two numbers, i.e., the numbers from part(a)
and part(c); leave your answer in twos-complement form:
(d)
11010100
(e) Using the twos-complement, rewrite the number you computed in part(d) as a positive
base-2 integer:
(e)
Page 4
00101100
4. (20 points) For this (two part) problem, assume that ×, =, 6=, 0, and 1 have their usual
meanings. All domains considered contain at least 0 and 1. For the following sentence
(∀x)[x 6= 0 → (∃y)[x × y = 1]],
(a) Give (specify) a non-empty domain where the sentence is true.
Solution: Q: note that for every x = a/b there is a y = b/a, such that xy = 1.
(b) Give (specify) a non-empty domain where the sentence is false.
Solution: Z: note that an infinite number of integers contain no multiplicative inverses in the integers, e.g., let x = 2, now no integer y exists such that xy = 1.
Page 5
5. (20 points) Prove that for integers a and b, if a2 + b2 is odd then a + b is odd. You may use
the fact that the sum of evens is even, the sum of two odds is even and the sum of an even and
an odd is odd.
Your proof should employ contraposition and cases.
Solution:
Proof. By contraposition, we need to show that a + b is even implies that a2 + b2 is even.
We consider the following cases:
Case. a and b even. Then let a = 2k and b = 2l, for integers k and l, and by substitution
a2 + b2 = (2k)2 + (2l)2 = 4k 2 + 4l2 = 2(2k 2 + 2l2 ).
Because the integers are closed under addition, this last term is even.
Case. a and b odd. Then let a = 2k + 1 and b = 2l + 1, for integers k and l. Substituting,
a2 + b2 = (2k + 1)2 + (2l + 1)2 = (4k 2 + 4k + 1) + (4l2 + 4l + 1)
= 4k 2 + 4l2 + 4k + 4l + 2 = 2(2k 2 + 2l2 + 2l + 2k + 1),
and that last term is an even number.
Case. a is even and b is odd. The sum of an even and an odd integer is odd, and therefore
the implication is vacuously true, and there is nothing left to prove.
Having shown that in each case the implication holds, we conclude that the proposition is
true.
Page 6
√
6. (20 points) Prove that for any rational numbers a and b, a 6= 0 that a 2 − b is irrational.
Solution:
√
√
Proof. BWOC assume not. Then a 2 − 2 is rational, meaning that a 2 − b = r, where
r ∈ Q. Rearranging terms gives:
√
√
√
r+b
a 2−b=r =a 2=r+b= 2=
, where a 6= 0.
a
√
But this means that an irrational number, 2, can be expressed as a rational number,
r+b
, which is a contradiction.
a
Page 7