Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett

Similar presentations


Presentation on theme: "CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett"— Presentation transcript:

1 CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett

2 Today’s Topics: Necessary and sufficient Converse error
Normal forms: DNFs, CNFs Converting from Truth Table to Proposition

3 1. Necessary and sufficient
Or, how to sound smart and win arguments on Reddit

4 Necessary and Sufficient
p is NECESSARY for q ¬p→¬q (“no p, no q!”) p is SUFFICIENT for q p→q (“p is all we need to know!”) Note 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.
q = Get an A in the class. r = Do the homework. s = Get an A on everything. p is necessary for q p is sufficient for q r is necessary for p r is sufficient for s s is sufficient for q How many of the necessary / sufficient sentences are true? 0 or 1 2 3 4 5

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. Converse error Or, how to lose arguments on Reddit

8 Converse error Confusing 𝑝→𝑞 with 𝑞→𝑝 p q p→q q→p T F

9 She’s a witch! See if you can spot the converse error in this video clip:

10 Remember this. If something is made out of wood, then it floats
Remember this? If something is made out of wood, then it floats. Therefore, if she floats, then she is made out of wood (and therefore a witch!) What is the argument form: (p → q)  (q → p) (¬p → ¬q)  (¬q → ¬p) (p → q)  (p → q) (¬p → ¬q)  (¬p → ¬q) Other/none/more than one

11 Step-by-step truth table for (p→q) → (q→p)
So, is the argument form valid? Valid Not valid In your groups, say in words what it is about this table that shows it is valid or not valid.

12 Converse error Here is another example with the same form: If this shape is a square, then this shape is a rectangle. Therefore, if this shape is a rectangle, then this shape is a square. No! p→ q and q→p are the converse of each other. It is not safe to assume that if p→q is true, then q→p is also true! The converse could be true though…as in the equal sides/square example. If both p→q and q→p are true, then we say p↔q (“p iff q”).

13 3. Negating a Disjunctive or Conjunctive Proposition
DeMorgan’s Law

14 Be the fact-checker! 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)? ¬p ∧ ¬q ¬p ∨ ¬q ¬p ¬∧ ¬q ¬p → ¬q p ∨ q

15 Laws to memorize DeMorgan’s Distributive Associative
(p ∧ q) ≡ ¬p ∨ ¬q (p ∨ q) ≡ ¬p ∧ ¬q Distributive Associative

16 4. Converting from Truth Table to Proposition
Disjunctive and Conjunctive Normal Forms

17 DNF and CNF DNF: Disjunctive Normal Form CNF: Conjunctive 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)

18 DNF and CNF (p∧¬q) ∨ (¬p∧¬r) (¬p∧(p∨q)∧¬r) ∨ (p∧r) (p ∧ r) ∨ ¬(r ∧ ¬q)
(p∨q∨r) ∧ (p∨¬q) Categorize the above propositions: I is CNF and IV is DNF I and III are DNF and IV is CNF I is DNF and IV is CNF I, II and III are DNF and IV is CNF None/more/other

19 Equivalence of p → q and ¬p ∨ q
When we write a 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 p q ¬p p → q ¬p ∨ q T F

20 Disjunctive normal form (DNF)
p q p → q T F pq OR pq pq pq  (pq)  (pq)  (pq) terms

21 Disjunctive normal form (DNF)
Convert 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

22 Conjunctive normal form (CNF)
p q p q T F pq AND p q pq  (p q)  (p  q) clauses

23 Conjunctive normal form (CNF)
Convert the predicate pq to CNF pq pq (pq)(pq) (pq)(pq) None/more/other

24 CNFs vs DNFs Every predicate can be written both as a CNF and as a DNF
Which one is more effective (requires less connectives to write): CNF DNF Both require the same number Depends on predicate None/more/other

25 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. By simply applying de-Morgan laws, what do you get? CNF for s DNF for s Both are equally easy to compute None/more/other

26 CNFs vs DNFs Negating a CNF gives us a DNF, and vice versa
So, if a Boolean formula f can be expressed by a CNF with S clauses Then its negation ~f can be expressed by a DNF with S terms Conclusion: #formulas expressed as a CNF with S clauses = #formulas expressed as a DNF with S terms

27 CNFs vs DNFs Another way to prove this:
#clauses in CNF = #F in truth table #terms in DNF = #T in truth table #functions with S many F in truth table = #functions with S many T in truth table

28 CNFs vs DNFs In general, both are very inefficient ways
Function on n inputs has 2n rows in truth table Typically about half T, half F Both CNFs and DNFs need size ~2n-1 n=100  299 > # atoms in universe


Download ppt "CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett"

Similar presentations


Ads by Google