Download presentation
Presentation is loading. Please wait.
1
Discrete Structures for Computer Science
Presented By: Andrew F. Conn Slides adapted from: Adam J. Lee Lecture #2: Logic Puzzles and Propositional Equivalence August 31st, 2016
2
Announcements The course website is up Homework 1 will be posted to the website today Due: Before class, two Wednesday’s from now 9/14 Monday’s class is cancelled Your schedule reflects this
3
Today’s topics Some more English translation. Logic puzzles.
Propositional equivalences.
4
English sentences can often be translated into propositional sentences
But why would we do that?!? Reasoning about law Philosophy and epistemology Verifying complex system specifications Note on Aristotle, mechanization of law, system specifications, RFCs
5
Find logical connectives Create logical expression
Example #1 Example: You can see an R-rated movie only if you are over 17 or you are accompanied by your legal guardian. Let: r “You can see an R-rated movie” o “You are over 17” a “You are accompanied by your legal guardian Translation: r (o a) Find logical connectives Translate fragments Create logical expression
6
Example #2 Example: You can have free coffee if you are senior citizen and it is a Tuesday Let: c “You can have free coffee” s “You are a senior citizen” t “It is a Tuesday” Translation: (s t) c
7
Example #3 Example: If you are under 17 and are not accompanied by your legal guardian, then you cannot see the R-rated movie. Let: r “You can see the R-rated movie” u “You are under 17” a “You are accompanied by your legal guardian Translation: (u ¬a) ¬r Note: The above translation is the contrapositive of the translation from example 1!
8
A technical support conundrum
Alice and Bob are technical support agents. If an agent is having a bad day, he or she will always lie to you. If an agent is having a good day, he or she will always tell you the truth. Alice tells you that Bob is having a bad day. Bob tells you that he and Alice are both having the same type of day. Can you trust the advice you receive from Alice during your call? How do we solve this type of problem?
9
Solving logic puzzles is easy!
Step 1: Identify rules and constraints Step 2: Assign propositions to key concepts Step 3: Make assumptions and reason logically!
10
Technical support revisited
Alice and Bob are technical support agents. If an agent is having a bad day, he or she will always lie to you. If an agent is having a good day, he or she will always tell you the truth. Alice tells you that Bob is having a bad day. Bob tells you that he and Alice are both having the same type of day. Can you trust the advice you receive from Alice during your call? Step 1: Identify the rules of the puzzle Good day = tell the truth Bad day = lie! Step 2: Assign propositions to the key concepts in the puzzle a “Alice is having a good day” b “Bob is having a good day”
11
Step 3: Working it out If Alice is having a good day, then she is telling the truth about Bob and he is a liar. This is consistent with his statement that Alice and he are having the same type of day. If Alice is having a bad day, then she is telling a lie about Bob and he is having a good day. Thus Bob always tells the truth and he and Alice are having the same day. This implies that Alice is having a good day. This contradicts the assumption that we made about Alice having a bad day. Formal Proof: The second proof presented in symbols! ¬𝒂 →𝒃 𝒃→𝒂∧𝒃 ¬𝒂∧𝒂 ⊥∎
12
Another example Consider a group of friends: Frank, Anna, and Chris. If Frank is not the oldest, then Anna is. If Anna is not the youngest, then Chris is the oldest. Determine the relative ages of Frank, Anna, and Chris. Propositions: 𝑓≡ “Frank is the oldest” 𝑎≡ “Anna is the oldest” 𝑎 ′ ≡ “Anna is the youngest” 𝑐≡ “Chris is the oldest” Rules: ¬f→𝑎 ¬ 𝑎 ′ →𝑐
13
Step 3: Working it out Argument 1: Assume Frank is not the oldest. Then Anna is the oldest based on Rule 1. Then Chris is the oldest based on Rule 2. This is a contradiction and thus we know Frank is the oldest. Argument 2: Assume Anna is not the youngest. Then Chris is the oldest by Rule 2. This contradicts with Frank being the oldest and thus Anna is the youngest. By process of elimination we have that Chris is the middle child.
14
Sometimes no solution is a solution!
Alice and Bob are technical support agents. Alice says “I am having a good day.” Bob says “I am having a good day.” Can you trust either Alice or Bob? Step 1: Identify rules Good day = tell the truth Bad day = lie Step 2: Assign propositions a = Alice is having a good day b = Bob is having a good day
15
Group work! Problem 1: Alice and Bob are technical support agents working to fix your computer. Alice tells you that Bob is having a bad day today and that you should expect a long wait before your computer is fixed. Bob tells you not to worry, Alice is just having a bad day---your computer will be ready in no time. Question: Can you draw any conclusions about when your computer will be fixed? If so, what can you learn?
16
Another word on Implication
There are some important definitions related to implication Given p q: q p is its converse ¬q ¬p is its contrapositive ¬p ¬q is its inverse The contrapositive of the converse! Are any of these equivalent to p q? Yes, implication and its contrapositive always have the same truth value. Why might this be useful? Why: Maybe easier to prove…
17
Propositional equivalences: preliminaries
Definition: A tautology is a compound proposition that is always true, regardless of the truth values of the propositions occurring within it. Definition: A contradiction is a compound proposition that is always false, regardless of the truth values of the propositions occurring within it. Definition: A contingency is a compound proposition whose truth value is dependent on the propositions occurring within it.
18
Examples Are the following compound propositions tautologies, contradictions, or contingencies? p ¬p p ¬p T F p ¬p ¬p p p q tautology p ¬p p ¬p T F contradiction contingency Draw truth tables on the board p q p q T F
19
What are logical equivalences and why are they useful?
Definition: Compound propositions p and q are logically equivalent if p q is a tautology. The notation p q means that p and q are logically equivalent. Logical equivalences are extremely useful! Aid in the construction of proofs Allow us to simplify compound propositions Example: r s r s Let: p r s q r s This will help many of you recognize when implications are true! r s p q p q T F
20
DeMorgan’s laws allow us to distribute negation over compound propositions
If “p or q” isn’t true, then neither p nor q is true Two laws: (p q) p q (p q) p q Prove: (p q) p q If “p and q” isn’t true, then at least one of p or q is false p q p q p q (p q) p q T F
21
End of 8/31/16 Lecture We ran a little too close on time and needed to stop here. The rest of this slide deck will be reviewed on 9/7/16
22
Using DeMorgan’s laws Use DeMorgan’s laws to negate the following expressions: “Bob is wearing blue pants and a sweatshirt” b s (b s) b s Bob is not wearing blue pants or is not wearing a sweatshirt “I will drive or I will walk” d w (d w) d w I will not drive and I will not walk
23
Group work! Problem 2: Prove that ¬(p q) and ¬p ¬q are logically equivalent, i.e., ¬(p q) ¬p ¬q. This is the second DeMorgan’s law. Problem 3: Use DeMorgan’s laws to negate the following propositions: Today I will go running or ride my bike Tom likes both pizza and beer
24
Sometimes using truth tables to prove logical equivalencies can become cumbersome
Recall that for an equivalence with n propositions, we need to build a truth table with 2n rows Fine for tables with n = 2, 3, or 4 Consider n = 30---we would need 1,073,741,824 rows in the truth table! Another option: Direct manipulation of compound propositions using known logical equivalencies
25
There are many useful logical equivalences
Name p T p p F p Identity laws p F F p T T Domination laws p p p p p p Idempotent laws (p) p Double negation law p q q p p q q p Commutative laws (p q) p q
26
More useful logical equivalences
Name (p q) r p (q r) (p q) r p (q r) Associative laws p (q r) (p q) (p r) p (q r) (p q) (p r) Distributive laws (p q) p q ¬(p q) ¬p ¬q DeMorgan’s laws p (p q) p p (p q) p Absorption laws p p T p p F Negation laws More equivalencies in the book!
27
Prove: (p q) (p r) p (q r)
28
Prove that (p q) (p q) is a tautology
29
Final Thoughts Logic can help us solve real world problems and play challenging games Logical equivalences help us simplify complex propositions and construct proofs More on proofs later in the course Next time: Predicate logic and quantification Please read section 1.3
30
Extra slides
31
Technique #2: Truth table
The previous argument can actually be captured in a truth table Step 1: Identify the rules of the puzzle Good day = tell the truth Bad day = lie! Step 2: Assign propositions to the key concepts in the puzzle a “Alice is having a good day” b “Bob is having a good day” Step 3: Assign propositions to the claims made by Alice and Bob ca “Bob is having a bad day” cb “Alice and I are having the same type of day”
32
Step 4: Fill in the truth table
This is the only row that is consistent with the rules of the puzzle! a b ca cb T F Possible good day/bad day combinations Truth values of claims ca and cb
33
Formal argumentation (cont.)
Step 3 (cont.): Assume that Alice is having a good day (i.e., proposition a is true) Since Alice is telling the truth, we know that Bob is having a bad day (i.e., ¬b) Since Bob is lying, his claim that he and Alice are having the same type of day, is actually stating that he and Alice are having different types of day. Therefore, the assumption that Alice is having a good day is consistent with the rules of the puzzle. Result: Alice is having a good day and we can trust her for all of our tech support needs! Step 3: Make assumptions and reason logically about these propositions Assume Alice is having a bad day and is thus lying (i.e., ¬a). Since she says Bob is having a bad day, this means that Bob is actually having a good day (i.e., b). Bob’s claim that he and Alice are having the same type of day is a contradiction, because Alice is having a bad day (by assumption) and Bob cannot lie (since proposition b is true). This contradiction tells us that Alice cannot be having a bad day.
34
Solution Assume that Anna is the oldest Assume that Anna is the middle
Contradiction: If Anna isn’t the youngest, Chris must be the oldest (by rule 2), and we can’t have two oldest people. Thus, Frank is the oldest (by rule 1) Assume that Anna is the middle Contradiction: If Anna isn’t the youngest, Chris must be the oldest (by rule 2), but rule 1 tells us that Frank is the oldest. Solution: Frank is the oldest, Chris is in the middle, and Anna is the youngest.
35
can use this equivalence
Example derivation We proved this earlier in lecture! Prove: (p q) (p r) p (q r) (p q) (p r) (¬p q) (¬p r) (¬p ¬p) (q r) ¬p (q r) p (q r) a b a b (twice) Commutative and associative laws Idempotent law a b a b Equivalence is bidirectional, so we can use this equivalence both ways
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.