CPE204 Discrete Mathematics (Week 2)
CPE204 Discrete Mathematics (Week 2)
Propositional Logic
Dr. Nehad Ramaha,
Computer Engineering Department
Karabük Universities 1
The class notes are a compilation and edition from many sources. The instructor does not claim intellectual property or ownership of the lecture notes.
Because implication statements play such an
essential role in mathematics, a variety of
terminology is used to express p → q:
“if p, then q”.
“q, if p”.
“p, only if q”.
“p implies q”.
“p is sufficient for q”.
“q is necessary for p”.
“q follows from p”.
2
Example:
◦ Proposition p: Alice is smart.
◦ Proposition q: Alice is honest.
p → q:
◦ That Alice is smart is sufficient for Alice to be honest.
◦ “Alice is honest” if “Alice is smart”.
q → p:
◦ That Alice is smart is necessary for Alice to be honest.
◦ “Alice is honest” only if “Alice is smart”.
3
Another binary operator bidirectional implication
↔: p↔q corresponds to p is T if and only if q is T.
Example: A student gets A if and only if his
weighted total is ≥90%.
Truth table for bidirectional implication:
p q p↔q
T T T
T F F
F T F
F F T 4
Actually, Exclusive Or ⨁ operator can be
expressed by using other operators:
◦ p ⨁ q is the same as : ¬ (p↔q).
Truth table for XOR operator:
p q p⨁q
T T F
T F T
F T T
F F F
5
Operator Precedence
¬ 1
˄ 2
˅ 3
→ 4
↔ 5
Example:
◦ ¬p ^ q means (¬ p) ^ q
◦ p ^ q → r means (p ^ q) →r
6
Using the logic operators, we can construct more
complicated logical formulas. (They are called
compound propositions)
Example:
◦ Proposition p: Alice is smart.
◦ Proposition q: Alice is honest.
¬p ^ q: Alice is not smart but honest.
p ˅ (¬p ^ q): Either Alice is smart, or she is not
smart but honest.
p→¬q: If Alice is smart, then she is not honest.
7
We can also go in the other direction, translating
English sentences to logical formulas:
Example:
◦ Proposition p: Alice is smart.
◦ Proposition q: Alice is honest.
Alice is either smart or honest, but Alice is not
honest if she is smart:
◦ (p ˅ q) ^ (p →¬ q).
That Alice is smart is necessary and sufficient for
Alice to be honest:
◦ (q → p) ^ (p → q). (This is often written as p ↔ q).
8
Definitions:
◦ A compound proposition that is always True is
called a tautology.
◦ Two propositions p and q are logically equivalent if
their truth tables are the same.
◦ Namely, p and q are logically equivalent if p ↔ q is
a tautology, (q → p) ^ (p → q).
◦ If p and q are logically equivalent, we write p ≡ q.
9
Example:
◦ Look at the following two compound propositions: p→q and q˅¬p.
p q p→q p q ¬p q∨¬ p
T T T T T F T
T F F T F F F
F T T F T T T
F F T F F T T
The last column of the two truth tables are identical. Therefore
(p→q) and (q˅¬p) are logically equivalent.
So (p→q) ↔ (q˅¬p) is a tautology.
Thus: (p→q) ≡ (q˅¬p).
10
Example:
◦ By using truth table, prove p ⨁ q ≡ ¬ (p ↔ q).
p q p⨁q p q (p ↔ q) ¬ (p ↔ q)
T T T T
T F T F
F T F T
F F F F
11
We have a number of rules for logical
equivalence. For example: De Morgan Law
De Morgan Law:
◦ ¬(p ˄ q) ≡ ¬ p ˅ ¬ q (1)
◦ ¬(p ˅ q) ≡ ¬ p ˄ ¬ q (2)
The following is the truth table proof for (1).
p q p˄q ¬(p˄ q) p q ¬p ¬q ¬p˅¬q
T T T F T T F F F
T F F T T F F T T
F T F T F T T F T
F F F T F F T T T
12
Distributivity lows:
◦ p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r) (1)
◦ p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r) (2)
The following is the truth table proof of (2). The proof of (1) is
similar.
13
Contrapositives low:
◦ Contrapositive of p → q is ¬q → ¬p. They are logically equivalent.
◦ p → q ≡ ¬q → ¬p
14
15
16
By using these laws, we can prove two
propositions are logical equivalent.
Example 1: Prove ¬ (p ˅ (¬p ˄ q)) ≡ ¬p ˄ ¬q.
Negation low
Identity low
17
Note: K→L ≡ ¬ K ˅ L
18
19