MAD101 Exercise
MAD101 Exercise
edu/class/cs103/tools/truth-table-tool/
Section 1.1
1) Which of these are propositions? What are the truth values of those that are
propositions?
The following sentences are propositions
a) Boston is the capital of Massachusetts. (True)
b) Miami is the capital of Florida (False, the correct answer is Tallahassee)
c) 2 + 3 = 5. (True)
d) 5 + 7 = 10 (False)
2) Which of these are propositions? What are the truth values of those that are
propositions?
The following sentences are propositions
c) There are no black flies in Maine. (False)
e) The moon is made of green cheese (False)
Section 1.2
3.
4.
5.
Section 1.4
1. Let P(x) denote the statement “x ≤ 4”. What are these truth values?
P(0): True
P(4): True
P(6): False
2. Let P(x) be the statement “the word x contains the letter a.” What are these
truth values?
a) P (orange) : True
b) P (lemon) : False
c) P (true) : False
d) P (false): True
3. Let Q(x, y) denote the statement “x is the capital of y”. What are these truth
values?
a) Q(Denver, Colorado) : True
b) Q(Detroit, Michigan) : False ( The correct answer is Lansing)
c) Q(Massachusetts, Boston) : True
d) Q(New York, New York): False(The correct answer is Albany)
4. State the value of x after the statement if P(x) then x := 1 is executed, where
P(x) is the statement “x > 1”, if the value of x when this statement is reached is
a) x = 0.
x=0
b)x = 1.
x=1
c) x = 2
x=1
5. Let P(x) be the statement “x spends more than five hours every weekday in
class,” where the domain for x consists of all students. Express each of these
a) ∃xP(x)
There exists a student who spends more than five hours every weekday in class.
b)∀xP(x)
All students spend more than five hours every weekday in class
c)∃x ¬P(x)
There exists a student who does not spend more than five hours weekday in
class
d) ∀x ¬P(x)
There are no students that spend more than five hours weekday in class
7. Let P(x) be the statement “x = x2 ”. If the domain consists of the integers, what
are these truth values?
a) P(0)
True ( 0 = 0)
b) P(1)
True ( 1 = 1)
c) P(2)
False ( 2 = 4)
d) P(−1)
False ( -1 = 1)
e) ∃xP(x)
True ( if x = 0, then 0 = 0 )
f ) ∀xP(x)
False ( if x = -1, then -1 = 1
8. Let Q(x) be the statement “x + 1 > 2x.” If the domain consists of all integers,
what are these truth values?
a) Q(0)
True ( 1 > 0)
b) Q(−1)
True ( 0 > -2)
c) Q(1)
False (2 > 2)
d) ∃xQ(x)
True ( If x = 0, then the statement is true)
e) ∀xQ(x)
False ( If x = 1, then the statement is false)
f ) ∃x¬Q(x)
True ( If x = 1, then the statement is flase)
9. Determine the truth value of each of these statements if the domain consists
of all integers.
a) ∀n(n + 1 > n)
True ( n + 1 > n ↔ 1> 0 )
b) ∃n(2n = 3n)
True ( If n = 0 , then the statement is true)
c) ∃n(n = −n)
True ( If n = 0, then the statement is true)
d) ∀n(3n ≤ 4n)
False ( 3 n ≤ 4 n ↔ n ≥0 , If n < 0 then the statement is false)
10. Determine the truth value of each of these statements if the domain consists
of all real numbers.
a) ∃x(x3 = −1)
True ( If x = -1 then the statement is true)
b) ∃x(x4 < x2 )
True ( If x = 0.5, then the statement is true)
c) ∀x((−x)2 = x2 )
True
d) ∀x(2x > x)
False (2 x> x ↔ x >0 , the statement is false when x < 0)
11. Determine the truth value of each of these statements if the domain for all
variables consists of all integers.
a) ∀n(n2 ≥ 0)
True
b) ∃n(n2 = 2)
False (The solutions n=± √2 are not intergers)
c) ∀n(n2 ≥ n)
True ( n2 ≥ n↔ n ≥ 1∨n ≤ 0), the statement is true for all integers)
d) ∃n(n2 < 0)
False
12. Suppose that the domain of the propositional function P(x) consists of the
integers 0, 1, 2, 3, and 4. Write out each of these propositions using disjunctions,
conjunctions, and negations.
a) ∃xP(x)
P(0) v P(1) v P(2) v P(3) v P(4)
b) ∀xP(x)
P(0) ^ P(1) ^ P(2) ^ P(3) ^ P(4)
c) ∃x¬P(x)
¬P(0) v ¬P(1) v ¬P(2) v ¬P(3) v ¬P(4)
d) ∀x¬P(x)
¬P(0) ^ ¬P(1) ^ ¬P(2) ^ ¬P(3) ^ ¬P(4)
e) ¬∃xP(x)
¬( P(0) v P(1) v P(2) v P(3) v P(4))
f ) ¬∀xP(x)
¬(P(0) ^ P(1) ^ P(2) ^ P(3) ^ P(4))
13.Suppose that the domain of the propositional function P(x) consists of the
integers 1, 2, 3, 4, and 5. Express these statements without using quantifiers,
instead using only negations, disjunctions, and conjunctions.
a) ∃xP(x)
P(1) v P(2) v P(3) v P(4) v P(5)
b) ∀xP(x)
P(1) ^ P(2) ^ P(3) ^ P(4) ^ P(5)
c) ¬∃xP(x)
¬( P(1) v P(2) v P(3) v P(4) v P(5))
d) ¬∀xP(x)
¬(P(1) ^ P(2) ^ P(3) ^ P(4) ^ P(5))
Section 1.5
1. Find the argument form for the following argument and determine whether it is
valid. Can we conclude that the conclusion is true if the premises are true?
If Socrates is human, then Socrates is mortal.
Socrates is human.
∴ Socrates is mortal.
P: Socrates is human
Q Socrates is mortal
1. P → Q Premise
2. P Premise
3. Q Modus ponen from (1) and (2)
Conclusion: Socrates is mortal
2. Use rules of inference to show that the hypotheses “Randy works hard”, “If
Randy works hard, then he is a dull boy”, and “If Randy is a dull boy, then he will
not get the job” imply the conclusion “Randy will not get the job”.
P: Randy works hard
Q: He is a dull boy
R: Randy will not get the job
1. P Premise
2. P → Q Premise
3. Q → R Premise
4. P → R Hypothetical syllogism
5. R Modus ponen from (1) and 4)
Conclusion: Randy will not get the job
c) “I am either clever or lucky”. “I am not lucky”. “If I am lucky, then I will win the
lottery”
Summary
P: I am clerver
Q: I am lucky
R: I win the lottery
1. P v Q Premise
2. ¬ Q Premise
3. Q → R Premise
4. P Disjunctive syllogism from (1) and (2)
Conclusin: I am clever
d) “Every computer science major has a personal computer”. “Ralph does not
have a personal computer”. “Ann has a personal computer”.
Summary
P(x): x is a computer science major
Q(x): x has a personal computer
1. ∀x( P(x) →Q(x)) Premise
2. ¬Q(Ralph) Premise
3. Q(Ann) Premise
4. P(Ralph) → Q(Ralph)
5. ¬P(Ralph) Disjunctive syllogism from (2) and (4)
Conclusion: Ralph is not computer science major
e) “What is good for corporations is good for the United States”. “What is good for
the United States is good for you”. “What is good for corporations is for you to
buy lots of stuff”.
p: good for corporations
q: good for the United States
r: good for you
g: x you buy lots of stuff
1. p → q Premise
2. q → r Premise
3. g → p Premise
4. g → q Hypothetical syllogism from (1) and (3)
5. g →r Hypothetical syllogism from (2) and (4)
6. p → r Hypothetical syllogism from (1) and (2)
Conclusion: You buy lots of stuff is good for United States, you buy lots of stuff is
good for you, what is good for corporations is good for you
f ) “All rodents gnaw their food”. “Mice are rodents”. “Rabbits do not gnaw their
food”. “Bats are not rodents.
Summary
P(x): x is rodents
Q(x): x gnaw their food
1. ∀x(P(x) →Q(x)) Premise
2. P(Mice) Premise
3. ¬Q(Rabbits) Premise
4. ¬P(Bats) Premise
5. P(Mice) →Q(Mice)
6. P(Rabbits) →Q(Rabbits)
7. Q(Mice) Modus ponen from (2) and (5)
8. ¬P(Rabbits) Modus tollen from (3) and (6)
Conclusion: Mice gnaw their food and Rabbits are not rodents
b) Everyone who eats granola every day is healthy. Linda is not healthy.
Therefore, Linda does not eat granola every day.
True
c) No man is an island. Manhattan is an island. Therefore, Manhattan is not a
man.
Not valid
d) A convertible car is fun to drive. Isaac's car is not a convertible. Therefore,
Isaac's car is not fun to drive.
Not valid
e) If Mai knows French, Mai is smart. But Mai doesn't know French. So, she is
not smart.
Not valid
f) Lin can't go fishing if she doesn't have a bike. Last week, Lin went fishing with
her friends. Therefore, she has got a bike.
Valid
Section 2.1
2.1 Sets 1. List the members of these sets.
a) {x | x is a real number such that x2 = 1}
S = {-1,1}
b) {x | x is a positive integer less than 12}
S = {1,2,3,4,5,6,7,8,9,10,11,12}
c) {x | x is the square of an integer and x < 100}
S={0,1,4,9,16,25,36,49,64,81}
d) {x | x is an integer such that x2 = 2}
S={∅ }
2. For each of the following sets, determine whether 2 is an element of that set.
a) {x ∈ R | x is an integer greater than 1} : yes
b) {x ∈ R | x is the square of an integer} : no
c) {2,{2}} : yes
d) {{2},{{2}}} : no
e) {{2},{2,{2}}} : no
f ) {{{2}}} : no
8. How many elements does each of these sets have where a and b are distinct
elements?
a) P({a, b, {a, b}}): 3
b) P({∅, a, {a}, {{a}}}):4
c) P(P(∅)):0
9. Find A2 and A3 if
a) A = {1, 3}
{1,3} x {1,3} = {(1,1),(1,3),(3,1),(3,3)}
{1,3} x {1,3} x {1,3} = {(1,1,1),(1,1,3),(1,3,1),(1,3,3),(3,1,1),(3,3,3)}
b) A = {1, a }
10. Let A 1,2,3 and B 1, a. What is the cardinality of each of these sets? a)
a) A B: 6
b) A^2 :9
c) PB : 4
d) P B A
e) A B: 4
11. Find the truth set of each of these predicates where the domain is the set of
integers.
a) P (x): x2 < 3
{0,1}
b) Q(x): x2 > x
c) R(x): 2x + 1 = 0: ∅
Section 2.2
1. Let A = {1, 2, 3, 4, 5} and B = {0, 3, 6}. Find
a) A ∪ B: {1,2,3,4,5,0,6}
b) A ∩ B: {3}
c) A – B: {1,2,4,5}
d) B − A.: {0,6}
Section 2.3
a) f (n) = n – 1: yes
b) f (n) = n2 +1: no
c) f (n) = n3: no
n
d) f(n) = 2 : no
b) f (x) = −3 x 2+7 : no
d) f (x) = x 5+ 1: yes
a) a 0 2
b) a 1 -1
c) a 4 182
d) a 5 -461
Step 8: 8 9
b) a binary search.
i:=1
j:=8
Step 1: i < j
m = (i+j)/2= 4
9 > a m=5: i = m + 1 = 5
Step 2: I < j
m = (i+j)/2= 6
9 > a m=8 : i = m + 1 = 7
Step 3: i < j
m = (i+j)/2= 7
9 == a m=9 : location = 7
If i > n
Location = i
5. Use the bubble sort to sort 3, 1, 5, 7, 4, showing the lists obtained at each
step.
Section 3.2
1. Determine whether each of these functions is O(x).
a) f (x) = 10
if x > 10 then x > f(x) = 10
|f(x)| ≤ C|g(x)| whenever x > k = 10, C = 1 . Therfore, f(x) is O(x)
b) f (x) = 3x + 7
If x > 7, then 4x > 3x + 7
f(x)| ≤ C|g(x)| when x > 7, C = 4
Therefore f(x) is O(x)
c) f ( x )=x 2 + x +1
x 2+ 1> 0 , ∀ x
↔ x2 + x +1> x , ∀ x
There is no k,C such that f(x)| ≤ C|g(x)| and x > k for every
arbitrarily large x.Therefore, f(x) is not O(x)
d) f (x) = 5 log x
Observe that, x <e x whenever x >1
↔ log ( x ) < x whenever x>1
c) f (x) = x log x
x <e x , when x >1
4
x
d) f ( x )=
2
x4 2
Suppose that there is c,k for which ≤ C x whenever x >k
2
x2
Observe that when x > k > 0: ≤C
2
x2
The inequality ≤ C cannot hold for all x with x > k. Therefore, f(x)
2
is not O( x 2).
e) f ( x )=2 x
Cx2
Observe that lim =¿ 0 ¿, C is a consant.
x→ ∞ 2x
Therefore, the inequality 2 x ≤ Cx2cannot hold for all x with x >k. f(x) is not O( x 2).
3
x +2 x
f) f ( x )=
2 x +1
Observe that x 3< 2 x 3∧2 x< x2 whenever x> 2
x3 +2 x 2
<x
2 x +1
C= 1, |f(x)| ≤ C|g(x)| when x > k = 2. Therefore, f(x) is O( x 2).
3.Find the least integer n such that f(x) is O(x) for each of these functions.
a) f ( x) 2 x 3 x 2 log x
2 x 3 x 2 log x 2 x 3 x3 , x 0
2 x 3 x 2 log x 3 x 3
C= 3, |f(x)| ≤ C|g(x)| when x > k = 0 Therefore, n = 3.
b) f ( x) 3 x 3 (log x) 4
3 x 3 (log x) 4 3 x 3 x 3 , x 1
3 x 3 (log x) 4 4 x 3
C= 4, |f(x)| ≤ C|g(x)| when x > k = 1 Therefore, n = 3.
x4 x2 1
c) f ( x)
x3 1
Simplify fraction first.
x4 x2 1 1
x
x 1
3
x 1
1
x 2 x, x 1
x 1
C= 2, |f(x)| ≤ C|g(x)| when x > k = 1.Therefore, n = 1.
a)( n 2 8)(n 1)
(n 2 8)(n 1) n3 n 2 8n 2
Biggest term is n3 so the function is O(n3 ).
Section 3.3
1. Consider the algorithm
procedure giaithuat(a 1 , a2 , a3 , … , an : integers)
count:= 0 for i:= 1 to n do
Section 3.4
1. Does 17 divide each of these numbers?
a) 68
17 | 68, 68 / 17 = 4
b) 84
17 ∤ 84 , 84 / 17 = 84 /17
c) 357
17 | 357, 357 / 17 = 21
d) 1001
17 ∤ 1001, 1001 / 17 = 1001 / 17
2. What are the quotient and remainder when
a) 19 is divided by 7?
19 = 7 x 2 + 5
Therefore, q = 2 and r = 5
b) −111 is divided by 11?
Dividen must be a positive integer
c) 789 is divided by 23?
789 = 23 x 34 + 7
Therefore, q = 34 and r = 7
d) 1001 is divided by 13?
1001 = 13 x 77
Therefore, q = 77 and r = 0
e) 0 is divided by 19?
Dividen must be a positive integer
f ) 3 is divided by 5?
3=5x0+3
Therefore, q = 0 and r = 3
3. Suppose that a and b are integers, a ≡ 4 (mod 13), and b ≡ 9 (mod 13). Find
the integer c with 0 ≤ c ≤ 12 such that
a) c ≡ 9a (mod 13)
c ≡ 9(4) (mod 13)
c ≡ 36 (mod 13)
10 ≡ 36 (mod 13) because 36 = 13 · 2 + 10
c = 10
b) c ≡ 11b (mod 13)
c ≡ 11(9) (mod 13)
c ≡ 99 (mod 13)
8 ≡ 99 (mod 13) because 99 = 13 x 7 + 8
c=8
c) c ≡ a + b (mod 13)
c ≡ 4 + 9 (mod 13)
c ≡ 13 (mod 13)
0 ≡ 13 (mod 13) because 13 = 13 x 1 + 0
c=0
e)
b) 103
17 ∤103 - 5
103 ≢ 5 (mod 17)
c) −29
17 | (5-(-29) = 34
-29 ≡ 5 (mod 17)
d) −122
17 ∤ (5-(-122) = 127
-122 ≢ 5 (mod 17)
0 mod 15 = 0
Result: 0
0 mod 11 = 0
Result: 0
c) (193 mod 23)2 mod 31
193 mod 23 = 9
92 mod 31=81mod 31
81 mod 31=19
Result: 19
d) (893 mod 79)4 mod 26
893 mod 79=24
Result: 16
b) (1010110101)₂
= (1 × 2⁹) + (0 × 2⁸) + (1 × 2⁷) + (0 × 2⁶) + (1 × 2⁵)
+ (1 × 2⁴) + (0 × 2³) + (1 × 2²) + (0 × 2¹) + (1 × 2⁰)
= (693)₁₀
c) (1110111110)₂
= (1 × 2⁹) + (1 × 2⁸) + (1 × 2⁷) + (0 × 2⁶) + (1 × 2⁵)
+ (1 × 2⁴) + (1 × 2³) + (1 × 2²) + (1 × 2¹) + (0 × 2⁰)
= (958)₁₀
d) (111110000011111)₂
= (1 × 2¹⁴) + (1 × 2¹³) + (1 × 2¹²) + (1 × 2¹¹) + (1 × 2¹⁰)
+ (0 × 2⁹) + (0 × 2⁸) + (0 × 2⁷) + (0 × 2⁶) + (0 × 2⁵)
+ (1 × 2⁴) + (1 × 2³) + (1 × 2²) + (1 × 2¹) + (1 × 2⁰)
= (31775)₁₀
12. Convert 69 to
a) a binary expansion
Remainder
Division Quotient (Digit) Digit #
69/2 34 1 0
34/2 17 0 1
17/2 8 1 2
8/2 4 0 3
4/2 2 0 4
2/2 1 0 5
1/2 0 1 6
= (1000101)2
b) a base 6 expansion
Remainder
Division Quotient (Digit) Digit #
69/6 11 3 0
11/6 1 5 1
1/6 0 1 2
= (153)6
c) a base 9 expansion
Remainder
Division Quotient (Digit) Digit #
69/9 7 6 0
7/9 0 7 1
= (76)9
Section 3.5
2. Find the prime factorization of each of these integers.
a) 39
31 x 131
b) 81
34
c) 101
101
d) 143
111 x 131
e) 289
172
f ) 899
291 x 311
6) Find these values of the Euler φ-function.
Section 3.6
1. Suppose pseudo-random numbers are produced by using: x n+1=(3 x n+ 11) mod 13
. If x 3= 5, find x 2 and x 4.
x 4 =( 3 x3 +11 ) mod13=( 3∗5+11 ) mod 13=0
x 5=( 3 x 4 +11 ) mod13=11
…
This sequence contains 3 different numbers before repeating. Therefore,
x 3=x 5=11
b) If x 3 = 3, find x 2 and x 4.
x 4 =( 2 x 3 +7 ) mod 9=¿ 4
3. Using the function f(x) = (x + 10) mod 26 to encrypt messages. Answer each
of these questions.
A B C D E F G H I J K L M
0 1 2 3 4 5 6 7 8 9 10 11 12
N O P Q R S T U V W X Y Z
13 14 15 16 17 18 19 20 21 22 23 24 25
1 20 24
Decoding
BUY
Section 4.1
n (n+1)(2 n+1)
1. Let P (n) be the statement that 12 +22+ 32+ …+n2 = for the
6
positive integer n.
a) What is the statement P (1)?
1(1+ 1)(1+2)
P(1): 1 =
6
b) Show that P (1) is true, completing the basis step of the proof.
1(1+ 1)(1+2)
=1 , so P(1) is true
6
e) Complete the inductive step, identifying where you use the inductive
hypothesis.
3.
4.
Section 4.3
18
19