THE UNIVERSITY OF WESTERN ONTARIO
LONDON
CANADA
DEPARTMENT OF COMPUTER SCIENCE
Computer Science 2209A
Applied Logic for Computer Science
Midterm Test
October 22, 2024
VERSION: A
9:30 AM - 11:20 AM
Instructions
1. Please fill in the boxes below on this page completely. Be sure to print your name legibly.
2. Fill in your information completely at the top of the bubble sheet. Make sure to
mark the bubble for the test version, which is either A or B.
3. CALCULATORS AND NOTES ARE NOT PERMITTED.
4. DO NOT UNSTAPLE THE BOOKLET.
5. Fill in the bubble corresponding to the correct answer to each question. Note that only bubble
sheets will be graded.
6. This test consists of 38 multiple-choice questions. The questions are printed on both sides of the
paper, starting on Page 2 and continuing through Page 8. Please ensure that your booklet is
complete.
7. You must submit this booklet, the bubble sheet, and all rough work sheets.
8. Marks: 38 marks total (1 mark per question).
STUDENT INFORMATION
Student’s Name (Print):
Student ID Number (Print):
UWO ID (Print):
(Your UWO email without “@uwo.ca”.)
PAGE 1
VERSION: A
October 22, 2024
Midterm Test
Computer Science 2209A
1: If s represents ”You are short.”, p represents ”You are poetic.”, and n represents ”You are nervous.”,
then You’re both short and either poetic or nervous” translates into logic as:
A: ((s ∧ p) ∨ n)
B: (s ∧ (p ∨ n))
C: s ∧ p ∨ n
D: (s ∨ (p ∧ n))
2: To prove for all n ≥ 1,
1 + 3 + 5 + · · · + (2n − 1) = n2
using mathematical induction, which of the following represents the inductive step correctly?
A: To prove 1 + 3 + 5 + · · · + (2k) = (k + 1)2 , assuming 1 + 3 + 5 + · · · + (2k − 1) = (k − 1)2 .
B: To prove 1 + 3 + 5 + · · · + (2k + 2) = (k + 1)2 , assuming 1 + 3 + 5 + · · · + (2k − 1) = k 2 .
C: To prove 1 + 3 + 5 + · · · + (2k + 1) = (k + 1)2 , assuming 1 + 3 + 5 + · · · + (2k − 1) = k 2 .
D: To prove 1 + 3 + 5 + · · · + (2k) = k 2 , assuming 1 + 3 + 5 + · · · + (2k − 1) = (k − 1)2 .
3: What is correct for the following argument? (Note: trout is the name of a fish)
• Premise 1: All fish can fly.
• Premise 2: A trout is a fish.
• Conclusion: Therefore, a trout can fly.
A: The argument is valid and the conclusion is true.
B: The argument is invalid and the conclusion is true.
C: The argument is invalid and the conclusion is false.
D: The argument is valid and the conclusion is false.
4: Which of the following logical expressions is a contradiction?
A: ¬(A ∨ B) ∧ (A ∧ ¬B)
B: (A ∧ ¬B) ∧ (B → A)
C: (A ∧ B) ∨ (¬A ∧ ¬B)
D: (A → B) ∧ (¬A → ¬B)
5: In the expression ¬P ∧ S → Q ∨ R, which logical connective is evaluated last according to precedence
rules?
A: ¬
B: →
C: ∧
6: Which of the following is correct?
A: ¬p → q |=| ¬q → p
B: ¬p → q |=| ¬p → ¬q
C: ¬p → q |=| q → p
D: ¬p → ¬q |=| ¬p → q
PAGE 2
D: ∨
Midterm Test
Computer Science 2209A
VERSION: A
October 22, 2024
7: What are the left and the right scope for implication in ((¬p) ∨ q) ↔ (r → p)?
A: The left scope is ((¬p) ∨ q), and the right scope is (r → p).
B: The left scope is ((¬p) ∨ q) ↔ (, and the right scope is p).
C: The left scope is r, and the right scope is p.
D: The left scope is q), and the right scope is (r.
8: When is the conclusion guaranteed to be true?
A: Whenever the argument is valid AND the premises are all true.
B: Whenever the argument is valid, OR the premises are all true.
C: Whenever the argument is valid.
D: The conclusion is never guaranteed to be true.
9: Which of the following is true about the validity of an argument?
A: If {A1 , A2 , . . . , An } |= C, then {A1 , A2 , . . . , An , ¬C} is contingent.
B: If {A1 , A2 , . . . , An } |= C, then {A1 , A2 , . . . , An , ¬C} is satisfiable, but not a tautology.
C: If {A1 , A2 , . . . , An } |= C, then (A1 ∧ A2 ∧ · · · ∧ An ∧ ¬C) is a tautology.
D: If {A1 , A2 , . . . , An } |= C, then (A1 ∧ A2 ∧ · · · ∧ An ) → C is a tautology.
10: Suppose A, B and C are formulas. Which one of the following is correct?
A: The formula (A ∨ C) ∧ ((A ∨ C) ∨ (B ∧ C)) simplifies to (A ∨ C).
B: The formula (A ∨ B) ∧ ((A ∨ (B ∧ C)) simplifies to (A ∨ B).
C: The formula A ∨ (A ∧ (B ∨ C)) simplifies to A ∨ (B ∧ C).
D: The formula (A ∧ B) ∨ (A ∧ (B ∨ C)) simplifies to A ∧ B.
11: Which of the following is a Conjunctive Normal Form (CNF) of (p ∧ q) ∨ (r ∧ (p ∨ ¬q)) ∨ (¬p ∧ q)?
A: q ∧ r
B: q ∨ r
C: (q ∨ r) ∧ p
D: q ∨ r ∨ p
12: Which of the following is a Disjunctive Normal Form (DNF) of (p → q) ∧ (¬q → r)?
A: q ∧ (r ∨ ¬p)
B: q ∧ p ∧ r
C: q ∨ (¬p ∧ r)
D: (¬q ∧ r) ∨ p
PAGE 3
VERSION: A
October 22, 2024
Midterm Test
Computer Science 2209A
13: Which of the following is a Conjunctive Normal Form (CNF) of f in the following truth table?
p q
r f
1 1 1 1
1 1 0 0
1 0 1 1
1 0 0 1
0 1 1 0
0 1 0 1
0 0 1 0
0 0 0 0
A: (¬p ∧ ¬q ∧ ¬r) ∨ (¬p ∧ q ∧ ¬r) ∨ (¬p ∧ q ∧ r) ∨ (p ∧ q ∧ ¬r)
B: (¬p ∨ ¬q ∨ r) ∧ (p ∨ ¬q ∨ ¬r) ∧ (p ∨ q ∨ ¬r) ∧ (p ∨ q ∨ r)
C: (p ∧ q ∧ r) ∨ (p ∧ ¬q ∧ r) ∨ (p ∧ ¬q ∧ ¬r) ∨ (¬p ∧ ¬q ∧ r)
D: (p ∨ q ∨ ¬r) ∧ (¬p ∨ q ∨ r) ∨ (¬p ∨ ¬q ∨ r) ∧ (¬p ∨ ¬q ∨ ¬r)
14: Which of the following is (are) tautologically equivalent to ((p → q) ∧ (r ↔ s)) ∨ t?
A: (p ∨ ¬q) ∧ ((r ∧ s) ∨ (¬r ∧ ¬s)) ∨ t
B: Only (¬p ∨ q) ∧ ((r ∨ ¬s) ∧ (¬r ∨ s)) ∨ t
C: Only (¬p ∨ q) ∧ ((r ∧ s) ∨ (¬r ∧ ¬s)) ∨ t
D: Both B and C.
15: Which of the following is tautologically equivalent to ¬((p ∧ ¬q) ∨ (¬r ∧ s))?
A: (¬p ∧ q) ∨ (r ∧ ¬s)
B:(¬p ∨ q) ∧ (r ∨ ¬s)
C: (¬p ∨ ¬q) ∧ (¬r ∨ ¬s)
D: (¬p ∧ q) ∨ (r ∧ ¬s)
16: Which of the following is the dual of the formula (p ∨ ¬q ∨ r) ∧ (¬p ∨ q)?
A: (¬p ∧ q ∧ ¬r) ∨ (p ∧ ¬q)
B: (p ∧ ¬q ∧ r) ∨ (¬p ∧ q)
C: (¬p ∨ q ∨ ¬r) ∧ (p ∨ ¬q)
D: (p ∨ ¬q ∨ r) ∨ (¬p ∨ q)
17: Which of the following is true?
A: ¬p ∧ q ∧ ¬r is a CNF, but not a DNF.
B: ¬p ∧ q ∧ ¬r is a DNF, but not a CNF.
C : ¬p ∧ q ∧ ¬r is both a DNF, and a CNF.
D: (p ∨ ¬q ∨ r) ∧ (¬p ∨ q) is a DNF.
PAGE 4
Midterm Test
Computer Science 2209A
VERSION: A
October 22, 2024
18: Which of the following is true?
A: The Toffoli gate is reversible, but the not gate is not reversible.
B: The Toffoli gate and the not gate are both reversible.
C: The Toffoli gate and the and gate are both reversible.
D: The Toffoli gate and the or gate are both reversible.
19: Which of the following represents a circuit that takes inputs x, y and z and outputs a 1 iff x and y
have the same value and y and z have opposite values?
A: (x + y + z̄)(x̄ + ȳ + z)
B: xy + yz̄
C: (x + y)(y + z̄)
D: xyz̄ + x̄ȳz
In the next two questions, consider the following circuit.
20: Which of the following is the output of the circuit?
A: (x + y + z)(x + ȳ + z)(x + ȳ + z̄)
B: xȳz + xȳz + xȳz̄
C: x + y + z
D: xyz + xȳz + xȳz̄
21: To which of the following does the circuit simplify?
A: xyz
B: xz + xȳ
C: xyz
¯
D: xz̄ + xy
22: How many distinct n-ary connectives exist?
A: 2n
n
2
B: 2(2 )
C: 2(n )
D: n2
23: Which of the following is not an adequate set of connectives?
A: {|}
B: {↓}
C: {∧, ¬}
D: {∧}
C: p ∨ q
D: p ∧ q
24: To which of the following does (p|q)|(p|q) simplify?
A: ¬p ∨ ¬q
B: ¬p ∧ ¬q
PAGE 5
VERSION: A
October 22, 2024
Midterm Test
Computer Science 2209A
25: To which of the following does (p ↓ q) ↓ (p ↓ q) simplify?
A: ¬p ∨ ¬q
B: ¬p ∧ ¬q
C: p ∨ q
D: p ∧ q
26: In the following code fragment what formula leads to the execution of P1 ?
If (C1 and C2 and C3 ) then
P3
else
if (not C1 and C2 ) then
P4
else
P1
A: ¬(C1 ∧ C2 ∧ C3 ) ∧ ¬(C1 ∧ C2 )
B: ¬(C1 ∧ C2 ∧ C3 ) ∧ (¬C1 ∧ C2 )
C: ¬(C1 ∧ C2 ∧ C3 ) ∧ (C1 ∨ ¬C2 )
D: None of A, B or C.
27: If
A1 : p → q ∧ r |= (p → q) ∧ (p → r)
A2 : (s → p) ∨ (t → q) |= (s → q) ∨ (t → p)
which of the following is true?
A: A1 and A2 both are valid arguments.
B: A1 is a valid argument, but A2 is invalid.
C: A2 is a valid argument, but A1 is invalid.
D: A1 and A2 both are invalid arguments.
28: Let F be the formula ((p → q) → q) → ((q → p) → p). Which of the following is true?
A: F is a contradiction.
B: ∅ |= F is a valid argument.
C: F is satisfiable, but not a tautology.
D: F is contingent.
29: Let A and B be formulas. Which of the following is not true?
A: A ⊢ B iff ∅ ⊢ A → B.
B: If A |= B, then A ⊢ B.
C: A ⊢ B iff A → B.
D: ∅ ⊢ A ∨ ¬A.
30: Let A, A1 , A2 and A3 be formulas. Which of the following is not true?
A: A1 , A2 , A3 ⊢ A iff ∅ ⊢ A1 ∧ A2 ∧ A3 → A.
B: A1 , A2 , A3 ⊢ A iff ∅ ⊢ A1 → (A2 → (A3 → A)).
C: If A1 , A2 , A3 ⊢ A, then A1 , A2 , A3 |= A.
D: ∅ ⊢ (A ∧ ¬A).
PAGE 6
Midterm Test
Computer Science 2209A
VERSION: A
October 22, 2024
In questions 31, 32, 33, 34 and 35, consider the following argument.
1
A∧B ⊢A∧B
2
A∧B ⊢A
3
A∧B ⊢B
4
A∧B ⊢B∨C
5
A ∧ B ⊢ A ∧ (B ∨ C)
6
A∧C ⊢A∧C
7
A∧C ⊢A
8
A∧C ⊢C
9
A∧C ⊢B∨C
10
A ∧ C ⊢ A ∧ (B ∨ C)
11
(A ∧ B) ∨ (A ∧ C) ⊢ A ∧ (B ∨ C)
31: Which rule of formal deduction has been used in row 1?
A: Reflexivity
B: ∧+
C: ∧−
D: ∨+
32: Which rule of formal deduction has been used to deduce row 8 from row 6?
A: ∨−
B: ∧+
C: ∧−
D: ∨+
33: Which rule of formal deduction has been used to deduce row 10 from rows 7 and 9?
A: ∨−
B: ∧+
C: ∧−
D: ∨+
34: Which rule of formal deduction has been used to deduce row 11 from rows 5 and 10?
A: ∨−
B: ∧+
C: ∧−
D: ∨+
35: Which rule of formal deduction has been used to deduce row 9 from row 8?
A: ∨−
B: ∧+
C: ∧−
PAGE 7
D:∨+
VERSION: A
October 22, 2024
Midterm Test
Computer Science 2209A
In questions 36 and 37 consider the following argument.
Premise 1: p → q
Premise 2: ¬p → r
Premise 3: q ∨ r → s
Conclusion: s
36: To show that the argument is valid using resolution which of the following is true?
A: We have to show that the set {¬p ∨ q, p ∨ r, (¬q ∧ ¬r) ∨ s, ¬s} is satisfiable.
B: We have to show that the set {p ∧ ¬q, ¬p ∧ ¬r, (q ∨ r) ∧ ¬s, s} is inconsistent.
C: We have to show that the set {¬p ∨ q, p ∨ r, (¬q ∧ ¬r) ∨ s, ¬s} is inconsistent.
D: We have to show that the set {p ∧ ¬q, ¬p ∧ ¬r, (q ∨ r) ∧ ¬s, s} is satisfiable.
37: To check the validity of the argument using the Set of Support Strategy, which of the following is true?
A: The initial auxiliary set is {¬p ∨ q, p ∨ r, (¬q ∧ ¬r) ∨ s}, and the initial set of support is {s}.
B: The initial auxiliary set is {¬p ∨ q, p ∨ r, (¬q ∧ ¬r) ∨ s}, and the initial set of support is {¬s}.
C: The initial auxiliary set is {p ∧ ¬q, ¬p ∧ ¬r, (q ∨ r) ∧ ¬s}, and the initial set of support is {s}.
D: The initial auxiliary set is {p ∧ ¬q, ¬p ∧ ¬r, (q ∨ r) ∧ ¬s}, and the initial set of support is {¬s}.
38: Which of the following is true?
A: The resolvent of p ∨ ¬q ∨ r ∨ s and q ∨ r ∨ p ∨ t is p ∨ r ∨ s ∨ t.
B: The resolvent of p ∨ ¬q ∨ r ∨ s and q ∨ r ∨ p ∨ t is p ∨ r ∨ s.
C: The resolvent of p ∨ ¬q ∨ r ∨ s and q ∨ r ∨ p ∨ t is q ∨ t ∨ ¬q.
D: p ∨ ¬q ∨ r ∨ s and q ∨ r ∨ p ∨ t cannot be resolved.
PAGE 8