p q - UCSD CSE

CSE 20: Discrete Mathematics
for Computer Science
Prof. Shachar Lovett
2
Today’s Topics: More
Propositional Logic
1.
2.
Necessary and sufficient
Negating a Disjunctive or Conjunctive
Proposition

3.
DeMorgan’s Law
Converting from Truth Table to
Proposition
3
1. Necessary and
sufficient
Or, how to sound smart and win arguments on
Reddit or other blog/forum of your choice
4
Necessary and Sufficient
p

p

is NECESSARY for q
¬p→¬q
(“no p, no q!”)
is SUFFICIENT for q
p→q
 Note
(“p is all we need to know!”)
that ¬p→¬q is equivalent to q→p
 So if p is necessary and sufficient for q, then
p iff q.
5
Your turn: Practice
p = Get an A on the final.
ii.
q = Get an A in the class.
iii. r = Do the homework.
How many of the
iv. s = Get an A on
necessary / sufficient
everything.
sentences are true?
 p is necessary for q
 p is sufficient for q
A. 0 or 1
 r is necessary for p
B. 2
 r is sufficient for s
C. 3
 s is sufficient for q
D. 4
E. 5
i.
6
Be a beacon of rational
thought in the online world
1



point extra credit on the midterm:
Make correct, good, topical use necessary
or sufficient (1/2 pt each) in an online
discussion
Link to your comment/post on TED to
collect your points. Obviously no venues or
topics that are NSFW/racist/sexist/etc.
Max 1pt per person
7
2. Negating a Disjunctive or
Conjunctive Proposition
DeMorgan’s Law
Be the fact-checker!
8
My opponent says I have 10 speeding tickets and
took bribes from that oil company. That is not true!
p = has 10 speeding tickets
q = took bribes
Which of the following is equivalent to (p ∧ q)?
A.
B.
C.
D.
E.
¬p ∧ ¬q
¬p ∨ ¬q
¬p ¬∧ ¬q
¬p → ¬q
p∨q
9
Laws to memorize
 DeMorgan’s
 (p

∧ q) ≡ ¬p ∨ ¬q
(p ∨ q) ≡ ¬p ∧ ¬q
 Distributive
 Associative
10
2. Converting from Truth
Table to Proposition
Disjunctive and Conjunctive Normal Forms
11
DNF and CNF

DNF: Disjunctive Normal Form

OR of ANDs (terms)
e.g. (p∧¬q) ∨ (¬p∧¬r)

CNF: Conjunctive Normal Form

AND of ORs (clauses)
e.g. (p∨¬q) ∧ (¬p∨¬r)
12
DNF and CNF
I.
II.
III.
IV.
(p∧¬q) ∨ (¬p∧¬r)
(¬p∧(p∨q)∧¬r) ∨ (p∧r)
(p ∧ r) ∨ ¬(r ∧ ¬q)
(p∨q∨r) ∧ (p∨¬q)
Categorize the above propositions:
A. I is CNF and IV is DNF
B. I and III are DNF and IV is CNF
C. I is DNF and IV is CNF
D. I, II and III are DNF and IV is CNF
E. None/more/other
13
Equivalence of p → q and
¬p ∨ q
 When we write a
p q ¬p
p→q
¬p ∨ q
T
T
F
T
T
T
F
F
F
F
F
T
T
T
T
F
F
T
T
T
proposition, we are
trying to describe
what is true
 One way to think
about this:



Look for the rows
that are true
Describe the input
values for that row
“or” them together
14
Disjunctive normal form (DNF)
p q p→q
pq
T
T
T
T
F
F
F
T
T
pq
F
F
T
pq
pq 
OR
(pq)  (pq)  (pq)
15
Disjunctive normal form (DNF)
 Convert
A.
B.
C.
D.
E.
the predicate pq to DNF
(pq)(pq)
(pq)(pq)
(pq)(pq)
(pq)(pq)
None/more/other
16
Conjunctive normal form (CNF)
p q p q
T
T
T
T
F
F
F
T
F
F
F
T
pq 
pq
p q
(p q)  (p  q)
AND
17
Conjunctive normal form (CNF)
 Convert
A.
B.
C.
D.
E.
the predicate pq to CNF
pq
pq
(pq)(pq)
(pq)(pq)
None/more/other
CNF vs DNF

Every predicate can be written both as a CNF
and as a DNF
Which one is more effective (requires less
connectives to write):
A. CNF
B. DNF
C. Both require the same number
D. Depends on predicate
E. None/more/other

Negating a CNF

Say s is a predicate with a DNF
s  (pq)(pr)(pr)(pq)

We want to compute s. Which one of the
following is easiest to compute:
A.
B.
C.
D.
CNF for s
DNF for s
Both are equally easy to compute
None/more/other