Tutorial 1: Propositional Logics
Tutorial 1: Propositional Logics
(1) if ((i+j ≤ p+q) && (i ≤ p) && (1) if (((i+j ≤ p+q) && (i ≤ p) &&
((j > q) || (List1[i] ≤ List2[j]))) (j > q)) || ((i+j ≤ p+q) && (i ≤
(2) List3[k] = List1[i] p) && (List1[i] ≤ List2[j])))
Consider the above two pieces of code. They are taken from two
different versions of Mergesort. Do they do the same thing? (Note
that && = “and”, || = “or”.)
Observation: The two pieces of code are the same except for line 1.
Solution:
s t s ⊕t s ∧ ¬t ¬s ∧ t (s ∧ ¬t) ∨ (¬s ∧ t)
T T F F F F
T F T T F T
F T T F T T
F F F F F F
Solution:
No, they are not logically equivalent. Set w = F , s = F and
t = T . w ∧ (s ⊕ t) = F but (w ∨ s) ⊕ (w ∨ t) = T .
Solution:
(a) Not equivalent. Set p = T , q = F , then p → q = F but
q → p = T.
(b) Equivalent. p → q ≡ ¬p ∨ q ≡ (¬¬q) ∨ (¬p) ≡ ¬q → ¬p.
Or truth table.
p q p → q ¬q ¬p ¬q → ¬p
T T T F F T
T F F T F F
F T T F T T
F F T T T T
(c) Not equivalent. Set p = F , q = F , then (p → q) → q = F
but p → q = T
For each of the following pair of propositions, either prove that the
two propositions are logically equivalent without using truth table,
or give a counterexample to show that the propositions are not
logically equivalent.
(a) (i) p → (q → r )
(ii) (p ∧ q) → r
(b) (i) (¬(p → ¬q)) → (¬(p ∧ r ) ∨ s)
(ii) (¬r → p) → ((p ∧ q) → s)