Discrete Structures for Computer Science

Slides:



Advertisements
Similar presentations
Propositional Equivalences
Advertisements

Propositional Equivalences
CS128 – Discrete Mathematics for Computer Science
Syllabus Every Week: 2 Hourly Exams +Final - as noted on Syllabus
1 Section 1.2 Propositional Equivalences. 2 Equivalent Propositions Have the same truth table Can be used interchangeably For example, exclusive or and.
Discrete Mathematics Math 6A Instructor: M. Welling.
Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?
Rosen 1.6. Approaches to Proofs Membership tables (similar to truth tables) Convert to a problem in propositional logic, prove, then convert back Use.
Adapted from Discrete Math
Intro to Discrete Structures
Mathematical Structures A collection of objects with operations defined on them and the accompanying properties form a mathematical structure or system.
Propositional Equivalences
Tautologies, contradictions, contingencies
1 CMSC 250 Discrete Structures CMSC 250 Lecture 1.
Reading: Chapter 4 (44-59) from the text book
CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, November 2015Introduction & Propositional Logic 1.
Section 1.2: Propositional Equivalences In the process of reasoning, we often replace a known statement with an equivalent statement that more closely.
Venn Diagrams Truth Sets & Valid Arguments Truth Sets & Valid Arguments Truth Tables Implications Truth Tables Implications Truth Tables Converse, Inverse,
Mathematics for Comter I Lecture 3: Logic (2) Propositional Equivalences Predicates and Quantifiers.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 01: Boolean Logic Sections 1.1 and 1.2 Jarek Rossignac.
Foundations of Discrete Mathematics Chapter 1 By Dr. Dalia M. Gil, Ph.D.
Law of logic Lecture 4.
CS-7081 Application - 1. CS-7082 Example - 2 CS-7083 Simplifying a Statement – 3.
Discrete Structures for Computer Science Presented By: Andrew F. Conn Slides adapted from: Adam J. Lee Lecture #1: Introduction, Propositional Logic August.
Chapter 1 Logic and Proof.
Chapter 1 Propositional Logic
Chapter 1 Logic and Proof.
Logic.
Discrete Mathematical
Chapter 7. Propositional and Predicate Logic
2. The Logic of Compound Statements Summary
Conditional Statements
Lecture 1.2: Equivalences, and Predicate Logic
Propositional Equivalences
Propositional Logic.
The Foundations: Logic and Proofs
CSE15 Discrete Mathematics 01/23/17
CSNB 143 Discrete Mathematical Structures
COMP 1380 Discrete Structures I Thompson Rivers University
Methods of proof Section 1.6 & 1.7 Wednesday, June 20, 2018
Citra Noviyasari, S.Si, MT
Logical Equivalence of Propositions
MATH 245 Spring 2009 This is mathematics for computer science
(CSC 102) Discrete Structures Lecture 2.
Mathematics for Computing
The Foundations: Logic and Proofs
Propositional Calculus: Boolean Algebra and Simplification
Administrivia Course Web:
Propositional Equivalences
Information Technology Department
CS 220: Discrete Structures and their Applications
CHAPTER 1: LOGICS AND PROOF
CS201: Data Structures and Discrete Mathematics I
CSE 311 Foundations of Computing I
Propositional Equivalences
CSE 311 Foundations of Computing I
Propositional Logic.
CSE 311 Foundations of Computing I
Discrete Mathematics Dr.-Ing. Erwin Sitompul
Lecture 2: Propositional Equivalences
Discrete Mathematics CMP-200 Propositional Equivalences, Predicates & Quantifiers, Negating Quantified Statements Abdul Hameed
CSE 321 Discrete Structures
Chapter 7. Propositional and Predicate Logic
Foundations of Discrete Mathematics
COMP 1380 Discrete Structures I Thompson Rivers University
Logic Logic is a discipline that studies the principles and methods used to construct valid arguments. An argument is a related sequence of statements.
Discrete Structures Prepositional Logic 2
Logical and Rule-Based Reasoning Part I
CS201: Data Structures and Discrete Mathematics I
The Foundations: Logic and Proofs
Presentation transcript:

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

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

Today’s topics Some more English translation. Logic puzzles. Propositional equivalences.

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

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

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

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!

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?

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!

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”

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! ¬𝒂 →𝒃 𝒃→𝒂∧𝒃 ¬𝒂∧𝒂 ⊥∎

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→𝑎 ¬ 𝑎 ′ →𝑐

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.

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

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?

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…

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.

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

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

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

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

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

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

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

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

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!

Prove: (p  q)  (p  r)  p  (q  r)

Prove that (p  q)  (p  q) is a tautology

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

Extra slides

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”

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

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.

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.

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