chap01 propos logic
DESCRIPTION
Chap01 Propos LogicTRANSCRIPT
![Page 1: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/1.jpg)
Propositional Logic (Outline)
The Language of Propositions
Logical operators (connectives):
NegationConjunctionDisjunctionImplication (contrapositive, inverse, converse)Biconditional
Truth ValuesTruth Tables
Application Examples:
Translating English SentencesSystem SpecificationsLogic Puzzles
Logical Equivalences
Important EquivalencesShowing Equivalence
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 1/37
![Page 2: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/2.jpg)
Propositions
Definition
A proposition is a declarative sentence that is either true or false,but not both.
Examples of propositions
It rained yesterday in College Station.
Houston is the capital of Texas.
1 + 0 = 1
0 + 0 = 2
Examples that are not propositions
Sit down!
What time is it?
x + 1 = 2
x + y = z
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 2/37
![Page 3: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/3.jpg)
Propositional Logic
The area of logic that deals with propositions is calledpropositional logic.
Constructing propositions
Propositional variables represent propositions: p, q, r , s , . . .
(Similar to variables in algebra.)The proposition that is always true is denoted by T and theproposition that is always false is denoted by F . They arecalled truth values.
Examples
1 p=”The sky was blue in College Station today at 10am.”
2 q=”2+2=4”
3 r=”All students in this classroom are freshmen.”
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 3/37
![Page 4: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/4.jpg)
Compound Propositions
Compound propositions: constructed from logical operatorsand propositional variables
Negation ¬ (not)Conjunction ∧ (and)Disjunction ∨ (or)Implication → (conditional)Biconditional ↔
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 4/37
![Page 5: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/5.jpg)
Negation
The negation of a proposition p is denoted by ¬p and has thistruth table:
p ¬p
T F
F T
Negation reverses a truth value.
Negation is a unary operation. All other logical operations arebinary.
Example
If p denotes “The earth is round.”, then ¬p denotes “It is not the
case that the earth is round.”, or more simply, “The earth is not
round.”
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 5/37
![Page 6: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/6.jpg)
Conjunction
The conjunction of propositions p and q is denoted by p ∧ q
and has this truth table:
p q p ∧ q
T T T
T F F
F T F
F F F
Example
If p denotes “I am at home.” and q denotes “It is raining.” thenp ∧ q denotes “I am at home and it is raining.”
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 6/37
![Page 7: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/7.jpg)
Disjunction (Inclusive “or”)
The disjunction of propositions p and q is denoted by p ∨ q
and has this truth table:
p q p ∨ q
T T T
T F T
F T T
F F F
Example
If p denotes “I am at home.” and q denotes “It is raining.” thenp ∨ q denotes “I am at home or it is raining.”
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 7/37
![Page 8: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/8.jpg)
The Connective Or in English
In English the conjunction “or” has two distinct meanings:
Inclusive Or – In the sentence “Students who have taken
CSCE222 or Math302 may take CSCE221,” we assume thatstudents need to have taken one of the prerequisites, but mayhave taken both. This is the meaning of disjunction. For p ∨ q
to be true, either one or both of p and q must be true.Exclusive Or – When reading the sentence “Soup or salad
comes with this entrée,” we do not expect to be able to getboth soup and salad. This is the meaning of Exclusive Or(Xor). In p ⊕ q , one of p and q must be true, but not both.The truth table for ⊕ is:
p q p ⊕ q
T T F
T F T
F T T
F F F
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 8/37
![Page 9: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/9.jpg)
ImplicationIf p and q are propositions, then p → q is a conditionalstatement or implication which is read as “if p, then q ” andhas this truth table:
p q p → q
T T T
T F F
F T T
F F T
In p → q , p is the hypothesis (antecedent or premise) and q
is the conclusion (or consequence).The first two rows are easy to understand.The last two rows are not so obvious: “One can deriveanything from a false hypothesis.”
Example
If p denotes “I am at home.” and q denotes “It is raining.” thenp → q denotes “If I am at home then it is raining.”
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 9/37
![Page 10: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/10.jpg)
Understanding Implication
In p → q there does not need to be any connection betweenthe hypothesis or the conclusion. The “meaning” of p → q
depends only on the truth values of p and q.
These implications are perfectly fine, but would not be used inordinary English.
Examples
1 “If the moon is made of green cheese, then I have more
money than Bill Gates. ”
2 “If the moon is made of green cheese then I’m on welfare.”
3 “If 1 + 1 = 3, then your grandma wears combat boots.”
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 10/37
![Page 11: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/11.jpg)
Understanding Implication (cont)
One way to view the logical conditional is to think of anobligation or contract.
“If I am elected, then I will lower taxes.”“If you get 100% on the final, then you will get an A.”
If the politician is elected and does not lower taxes, then thevoters can say that he or she has broken the campaign pledge.Something similar holds for the professor. This corresponds tothe case where p is true and q is false.
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 11/37
![Page 12: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/12.jpg)
Different Ways of Expressing p → q
if p, then q p implies q
if p, q p only if q
q unless ¬p q when p
q if p p is sufficient for q
q whenever p q is necessary for p
q follows from p
a necessary condition for p is q
a sufficient condition for q is p
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 12/37
![Page 13: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/13.jpg)
Converse, Contrapositive, and Inverse
From p → q we can form new conditional statements.
q → p is the converse of p → q
¬q → ¬p is the contrapositive of p → q¬p → ¬q is the inverse of p → q
Example
Find the converse, inverse, and contrapositive of “If it is raining
then I do not go to town.”converse:
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 13/37
![Page 14: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/14.jpg)
Converse, Contrapositive, and Inverse
From p → q we can form new conditional statements.
q → p is the converse of p → q
¬q → ¬p is the contrapositive of p → q¬p → ¬q is the inverse of p → q
Example
Find the converse, inverse, and contrapositive of “If it is raining
then I do not go to town.”converse:
“If I do not go to town, then it is raining.”inverse:
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 13/37
![Page 15: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/15.jpg)
Converse, Contrapositive, and Inverse
From p → q we can form new conditional statements.
q → p is the converse of p → q
¬q → ¬p is the contrapositive of p → q¬p → ¬q is the inverse of p → q
Example
Find the converse, inverse, and contrapositive of “If it is raining
then I do not go to town.”converse:
“If I do not go to town, then it is raining.”inverse:
“If it is not raining, then I go to town.”contrapositive:
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 13/37
![Page 16: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/16.jpg)
Converse, Contrapositive, and Inverse
From p → q we can form new conditional statements.
q → p is the converse of p → q
¬q → ¬p is the contrapositive of p → q¬p → ¬q is the inverse of p → q
Example
Find the converse, inverse, and contrapositive of “If it is raining
then I do not go to town.”converse:
“If I do not go to town, then it is raining.”inverse:
“If it is not raining, then I go to town.”contrapositive:
“If I go to town, then it is not raining.”
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 13/37
![Page 17: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/17.jpg)
Biconditional
If p and q are propositions, then we can form thebiconditional proposition p ↔ q, read as “p if and only if q.”The biconditional p ↔ q denotes the proposition with thistruth table:
p q p ↔ q
T T T
T F F
F T F
F F T
If p denotes “I am at home.” and q denotes “It is raining.”then p ↔ q denotes “I am at home if and only if it is raining.”
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 14/37
![Page 18: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/18.jpg)
Expressing the Biconditional
Some alternative ways “p if and only if q” is expressed inEnglish:
p is necessary and sufficient for q
if p then q, and, if q then pp iff q (iff means “if and only if”)
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 15/37
![Page 19: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/19.jpg)
Truth Tables For Compound Propositions
Construction of a truth table:
Rows
Need a row for every possible combination of values for theatomic propositions.
Columns
Need a column for the compound proposition (usually at farright)Need a column for the truth values of each expression thatoccurs in the compound proposition as it is built up. (Thisincludes the atomic propositions.)
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 16/37
![Page 20: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/20.jpg)
Example Truth Table
Construct a truth table for p ∨ q → ¬r
p q r ¬r p ∨ q p ∨ q → ¬r
T T T F T F
T T F T T T
T F T F T F
T F F T T T
F T T F T F
F T F T T T
F F T F F T
F F F T F T
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 17/37
![Page 21: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/21.jpg)
Equivalent Propositions
Two propositions are equivalent if they always have the sametruth value.
Example
Show using a truth table that the implication is equivalent to thecontrapositive of an implication.
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 18/37
![Page 22: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/22.jpg)
Equivalent Propositions
Two propositions are equivalent if they always have the sametruth value.
Example
Show using a truth table that the implication is equivalent to thecontrapositive of an implication.
p q ¬p ¬q p → q ¬q → ¬p
T T F F T T
T F F T F F
F T T F T T
F F T T T T
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 18/37
![Page 23: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/23.jpg)
Using a Truth Table to Show Non-Equivalence
Example
Show using truth tables that neither the converse nor inverse of animplication are equivalent to the implication.
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 19/37
![Page 24: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/24.jpg)
Using a Truth Table to Show Non-Equivalence
Example
Show using truth tables that neither the converse nor inverse of animplication are equivalent to the implication.
p q ¬p ¬q p → q ¬p → ¬q q → p
T T F F T T T
T F F T F T T
F T T F T F F
F F T T T T T
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 19/37
![Page 25: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/25.jpg)
Problem
How many rows are there in a truth table with n propositionalvariables?Solution:
n = 2 variables: 4 rowsn = 3 variables: 8 rowsn variables:
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 20/37
![Page 26: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/26.jpg)
Problem
How many rows are there in a truth table with n propositionalvariables?Solution:
n = 2 variables: 4 rowsn = 3 variables: 8 rowsn variables:2n (We will see how to get this in Chapter 6)
Note that this means that with n propositional variables, wecan construct 2n distinct (i.e., not equivalent) propositions.
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 20/37
![Page 27: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/27.jpg)
Precedence of Logical Operators
Operator Precedence
¬ 1 (highest)
∧ 2
∨, ⊕ 3
→ 4
↔ 5 (lowest)
Parenthesized subexpressions come first, followed by negationoperator.
Then multiplicative operator (∧), followed by additiveoperators (∨, ⊕), followed by implication operator (→),followed by biconditional operator (↔).
Use parentheses if you have any doubt.
Evaluate ties left-to-right for multiplicative and additiveoperators.
Evaluate ties right-to-left for negation, implication andbiconditional.
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 21/37
![Page 28: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/28.jpg)
Precedence of Logical Operators (cont)
Examples
1 p ∨ q → ¬r is equivalent to (p ∨ q)→ (¬r). (If the intendedmeaning is p ∨ (q → ¬r) then parentheses must be used.)
2 p → q → r ↔ s ∨ t ∨ u is equivalent to(p → (q → r))↔ ((s ∨ t) ∨ u).
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 22/37
![Page 29: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/29.jpg)
Translating English Sentences
Steps to convert an English sentence to a statement inpropositional logic
Identify atomic propositions and represent using propositionalvariables.Determine appropriate logical operators (connectives)
“If I go to the cinema or to my friend’s place, I will not go
shopping.”
p = “I go to the cinema.”q = “I go to my friend’s place.”r = “I will go shopping.”
It corresponds to “If p or q, then not r”. Then we express it,formally, as p ∨ q → ¬r .
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 23/37
![Page 30: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/30.jpg)
Example
Translate the following sentence into propositional logic:“You can access the Internet from campus only if you are a
computer science major or you are not a freshman.”
Solution:
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 24/37
![Page 31: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/31.jpg)
Example
Translate the following sentence into propositional logic:“You can access the Internet from campus only if you are a
computer science major or you are not a freshman.”
Solution:
Leta=“You can access the Internet from campus.”c=“You are a computer science major.”
f =”You are a freshman.”Then we can represent this sentence as a→ (c ∨ ¬f )
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 24/37
![Page 32: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/32.jpg)
System Specifications
System and software engineers take requirements in Englishand express them in a precise specification language based onlogic.
Example
Express in propositional logic:“The automated reply cannot be sent when the file system is full.”
Solution:
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 25/37
![Page 33: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/33.jpg)
System Specifications
System and software engineers take requirements in Englishand express them in a precise specification language based onlogic.
Example
Express in propositional logic:“The automated reply cannot be sent when the file system is full.”
Solution:
Letp=“The automated reply can be sent.”
q=“The file system is full.”
Then the sentence can be represented as q → ¬p.
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 25/37
![Page 34: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/34.jpg)
Consistent System Specifications
Definition
A list of propositions is consistent if it is possible to assign truthvalues to the proposition variables so that each proposition is true.
Example
Are these specifications consistent?“The diagnostic message is stored in the buffer or it is
retransmitted.”
“The diagnostic message is not stored in the buffer.”
“If the diagnostic message is stored in the buffer, then it is
retransmitted.”
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 26/37
![Page 35: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/35.jpg)
Consistent System Specifications
Definition
A list of propositions is consistent if it is possible to assign truthvalues to the proposition variables so that each proposition is true.
Example
Are these specifications consistent?“The diagnostic message is stored in the buffer or it is
retransmitted.”
“The diagnostic message is not stored in the buffer.”
“If the diagnostic message is stored in the buffer, then it is
retransmitted.”
Solution: Let p=“The diagnostic message is stored in the buffer.”
q=“The diagnostic message is retransmitted.”
The specifications can be written as: p ∨ q, ¬p, p → q.When p is false and q is true then all three statements are true.So the specifications are consistent.
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 26/37
![Page 36: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/36.jpg)
Consistent System Specifications (cont)
Example
What if add this specification “The diagnostic message is not
retransmitted.” to the previous three specifications.
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 27/37
![Page 37: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/37.jpg)
Consistent System Specifications (cont)
Example
What if add this specification “The diagnostic message is not
retransmitted.” to the previous three specifications.Solution: We are adding ¬q.But there is no satisfying assignment of truth values in order tomake all four specifications true (see the table below).So the specifications are not consistent.
p q p ∨ q ¬p p → q ¬q
T T T F T F
T F T F F T
F T T T T F
F F F T T T
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 27/37
![Page 38: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/38.jpg)
Logic Puzzles
An island has two kinds of inhabitants: knights, who alwaystell the truth, and knaves, who always lie. You go to theisland and meet two inhabitants A and B.
1 A says “B is a knight.”2 B says “The two of us are of opposite types.”
What are the types of A and B?Solution:
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 28/37
![Page 39: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/39.jpg)
Logic Puzzles
An island has two kinds of inhabitants: knights, who alwaystell the truth, and knaves, who always lie. You go to theisland and meet two inhabitants A and B.
1 A says “B is a knight.”2 B says “The two of us are of opposite types.”
What are the types of A and B?Solution:
Let p=”A is a knight.” and q=”B is a knight.”Then ¬p represents the proposition that A is a knave and ¬qthat B is a knave.If A is a knight, then p is true. Since knights tell the truth, qmust also be true by (1). Then, by (2), (p ∧ ¬q)∨(¬p ∧ q)would have to be true, but it is not.
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 28/37
![Page 40: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/40.jpg)
Logic Puzzles
An island has two kinds of inhabitants: knights, who alwaystell the truth, and knaves, who always lie. You go to theisland and meet two inhabitants A and B.
1 A says “B is a knight.”2 B says “The two of us are of opposite types.”
What are the types of A and B?Solution:
Let p=”A is a knight.” and q=”B is a knight.”Then ¬p represents the proposition that A is a knave and ¬qthat B is a knave.If A is a knight, then p is true. Since knights tell the truth, qmust also be true by (1). Then, by (2), (p ∧ ¬q)∨(¬p ∧ q)would have to be true, but it is not.
Therefore, A is not a knight and ¬p must be true. If A is aknave, then by (1) B must not be a knight (¬q is true) sinceknaves always lie. So, then both ¬p and ¬q hold since bothare knaves.
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 28/37
![Page 41: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/41.jpg)
Tautologies, Contradictions, and Contingencies
Definition
A tautology is a proposition which is always true.
Examplep ∨ ¬p
Definition
A contradiction is a proposition which is always false.
Examplep ∧ ¬p
p ¬p p ∨ ¬p p ∧ ¬p
T F T F
F T T F
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 29/37
![Page 42: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/42.jpg)
Tautologies, Contradictions, and Contingencies (cont)
Definition
A contingency is a proposition which is neither a tautology nor acontradiction.
Examplesp
¬p
p ∧ q
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 30/37
![Page 43: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/43.jpg)
Logically Equivalent
Definition
Two compound propositions p and q are logically equivalent ifp ↔ q is a tautology.
We write this as p ≡ q or, sometimes, as p ⇔ q where p andq are compound propositions.Two compound propositions p and q are equivalent if and onlyif the columns in a truth table giving their truth values agree.
Example
This truth table shows that ¬p ∨ q is equivalent to p → q.
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
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 31/37
![Page 44: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/44.jpg)
De Morgan’s Laws
¬(p ∧ q) ≡ ¬p ∨ ¬q (First Law)
¬(p ∨ q) ≡ ¬p ∧ ¬q (Second Law)
This truth table shows that De Morgan’s Second Law holds.
p q ¬p ¬q (p ∨ q) ¬(p ∨ q) ¬p ∧ ¬q
T T F F T F F
T F F T T F F
F T T F T F F
F F T T F T T
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 32/37
![Page 45: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/45.jpg)
Key Logical Equivalences
Identity Laws: p ∧ T ≡ p and p ∨ F ≡ p
Domination Laws: p ∨ T ≡ T and p ∧ F ≡ F
Idempotent Laws: p ∨ p ≡ p and p ∧ p ≡ p
Double Negation Law: ¬(¬p) ≡ p
Negation Laws: p ∨ ¬p ≡ T and p ∧ ¬p ≡ F
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 33/37
![Page 46: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/46.jpg)
Key Logical Equivalences (cont)
Commutative Laws: p ∨ q ≡ q ∨ p and p ∧ q ≡ q ∧ p
Associative Laws: (p ∨ q) ∨ r ≡ p ∨ (q ∨ r) and(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)
Distributive Laws: p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r) andp ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)
Absorption Laws: p ∨ (p ∧ q) ≡ p and p ∧ (p ∨ q) ≡ p
For more logical equivalences, see Table 7 and 8, p. 28.
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 34/37
![Page 47: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/47.jpg)
Constructing New Logical Equivalences
We can show that two expressions are logically equivalent bydeveloping a series of logically equivalent statements.
To prove that we produce a series of equivalences beginningwith A and ending with B:
A ≡ A1, A1 ≡ A2, . . . , An ≡ B
Keep in mind that whenever a proposition (represented by apropositional variable) occurs in the equivalences listed earlier,it may be replaced by an arbitrarily complex compoundproposition.
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 35/37
![Page 48: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/48.jpg)
Equivalence Proofs
Example
Show that ¬(p ∨ (¬p ∧ q)) is logically equivalent to (¬p ∧ ¬q)Solution:
¬(p ∨ (¬p ∧ q))
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 36/37
![Page 49: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/49.jpg)
Equivalence Proofs
Example
Show that ¬(p ∨ (¬p ∧ q)) is logically equivalent to (¬p ∧ ¬q)Solution:
¬(p ∨ (¬p ∧ q))≡ ¬p ∧ (¬(¬p ∧ q)) by the second De Morgan’s law≡ ¬p ∧ (¬(¬p) ∨ ¬q) by the first De Morgan’s law≡ ¬p ∧ (p ∨ ¬q) by the double negation law≡ (¬p ∧ p) ∨ (¬p ∧ ¬q) by the distributive law≡ F ∨ (¬p ∧ ¬q) by the negation law≡ (¬p ∧ ¬q) ∨ F by the commutative law≡ (¬p ∧ ¬q) by the identity law
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 36/37
![Page 50: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/50.jpg)
Equivalence Proofs (cont)
Example
Show that (p ∧ q)→ (p ∨ q) is a tautology.Solution:
(p ∧ q)→ (p ∨ q)
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 37/37
![Page 51: Chap01 Propos Logic](https://reader031.vdocuments.net/reader031/viewer/2022032014/55cf98eb550346d0339a7392/html5/thumbnails/51.jpg)
Equivalence Proofs (cont)
Example
Show that (p ∧ q)→ (p ∨ q) is a tautology.Solution:
(p ∧ q)→ (p ∨ q)≡ ¬(p ∧ q) ∨ (p ∨ q) by truth table for →≡ (¬p ∨ ¬q) ∨ (p ∨ q) by the first De Morgan’s law≡ (p ∨ ¬p) ∨ (q ∨ ¬q) by associative and
commutative laws≡ T ∨ T by truth tables≡ T by the domination law
Teresa Leyk (CSCE 222) Discrete Structures – The Foundations (Part 1): Propositional Logic Fall 2012 37/37