01 Propositional Logic 4p
01 Propositional Logic 4p
Proofs
Chapter 1, Part I: Propositional Logic
Propositional Logic
Section 1.1
In English “or” has two distinct meanings. In p → q there does not need to be any connection
• “Inclusive Or” - In the sentence “Students who have taken CS202 or Math120 between the antecedent or the consequent. The
may take this class,” we assume that students need to have taken one of the
prerequisites, but may have taken both. This is the meaning of disjunction. For “meaning” of p → q depends only on the truth values of
p ∨ q to be true, either one or both of p and q must be true. p and q.
• “Exclusive Or” - When reading the sentence “Soup or salad comes with this
entrée,” we do not expect to be able to get both soup and salad. This is the These implications are perfectly fine, but would not be
meaning of Exclusive Or (Xor). In p ⊕ q , one of p and q must be true, but not
both. The truth table for ⊕ is: used in ordinary English.
p q P⊕q • “If the moon is made of green cheese, then I have more
T T F money than Bill Gates. ”
T F T • “If the moon is made of green cheese then I’m on welfare.”
F T T
• “If 1 + 1 = 3, then your grandma wears combat boots.”
F F F
Understanding Implication 2 Converse, Contrapositive, and Inverse
One way to view the logical conditional is to From p → q we can form new conditional statements .
think of an obligation or contract. • q→p is the converse of p → q
• ¬q → ¬p is the contrapositive of p → q
• “If I am elected, then I will lower taxes.” • ¬p → ¬q is the inverse of p → q
• “If you get 100% on the final, then you will get an A.” Example: Find the converse, inverse, and contrapositive
of “It raining is a sufficient condition for my not going to
If the politician is elected and does not lower town.”
taxes, then the voters can say that he or she has Solution:
broken the campaign pledge. Something similar converse: If I do not go to town, then it is raining.
holds for the professor. This corresponds to the inverse: If it is not raining, then I will go to town.
case where p is true and q is false. contrapositive: If I go to town, then it is not raining.
Problem
How many rows are there in a truth table with n
propositional variables?
Applications of
Solution: 2n We will see how to do this in
Chapter 6. Propositional Logic
Note that this means that with n propositional Section 1.2
variables, we can construct 2n distinct (that is,
not equivalent) propositions.
Applications of Propositional Logic:
Example
Summary
Translating English to Propositional Logic Problem: Translate the following sentence into
propositional logic:
System Specifications
“You can access the Internet from campus only if you
Boolean Searching are a computer science major or you are not a
freshman.”
Logic Puzzles
One Solution: Let a, c, and f represent respectively
Logic Circuits “You can access the internet from campus,” “You are a
computer science major,” and “You are a freshman.”
AI Diagnosis Method (Optional)
a → ( c f )
Raymond
Logic Puzzles Smullyan Section Summary 2
(Born 1919)
An island has two kinds of inhabitants, knights, who always tell the truth, and Tautologies, Contradictions, and Contingencies.
knaves, who always lie.
You go to the island and meet A and B. Logical Equivalence
• A says “B is a knight.” • Important Logical Equivalences
• B says “The two of us are of opposite types.”
• Showing Logical Equivalence
Example: What are the types of A and B?
Solution: Let p and q be the statements that A is a knight and B is a knight, Normal Forms (optional, covered in exercises in text)
respectively. So, then ¬p represents the proposition that A is a knave and ¬q
that B is a knave.
• Disjunctive Normal Form
• If A is a knight, then p is true. Since knights tell the truth, q must also be true. • Conjunctive Normal Form
Then (p ∧ ¬ q) ∨ (¬ p ∧ q) would have to be true, but it is not. So, A is not a
knight and therefore ¬p must be true. Propositional Satisfiability
• If A is a knave, then B must not be a knight since knaves always lie. So, then both
¬p and ¬q hold since both are knaves.
• Sudoku Example
Tautologies, Contradictions, and
De Morgan’s Laws
Contingencies
A tautology is a proposition which is always true. ( p q ) p q Augustus De Morgan
1806-1871
• Example: p ∨ ¬p ( p q ) p q
A contradiction is a proposition which is always false.
• Example: p ∧ ¬p This truth table shows that De Morgan’s Second Law holds.
p q ¬p ¬q (p ∨ q) ¬(p ∨ q) ¬p ∧ ¬q
A contingency is a proposition which is neither a
T T F F T F F
tautology nor a contradiction, such as p
T F F T T F F
P ¬p p ∨ ¬p p ∧ ¬p F T T F T F F
T F T F F F T T F T T
F T T F
Two compound propositions p and q are logically equivalent if p↔q Identity Laws: p T p, pF p
is a tautology.
We write this as p⇔q or as p≡q where p and q are compound
propositions. Domination Laws: p T T, pF F
Two compound propositions p and q are equivalent if and only if
the columns in a truth table giving their truth values agree.
This truth table shows that ¬p ∨ q is equivalent to p → q.
Idempotent laws: p p p, p p p
p q ¬p ¬p ∨ q p→q
T T F T T Double Negation Law: ( p ) p
T F F F F
F T T T T Negation Laws: p p T , p p F
F F T T T
Key Logical Equivalences 2 Constructing New Logical Equivalences
Commutative Laws: p q q p, p q q p We can show that two expressions are logically
equivalent by developing a series of logically equivalent
Associative Laws: ( p q) r p ( q r ) statements.
( p q) r p ( q r ) To prove that A ≡ B we produce a series of
equivalences beginning with A and ending with B.
Distributive Laws: ( p ( q r )) ( p q) ( p r ) A A1
( p ( q r )) ( p q) ( p r ) An B
Keep in mind that whenever a proposition (represented
Absorption Laws: p ( p q) p p ( p q) p by a propositional variable) occurs in the equivalences
listed earlier, it may be replaced by an arbitrarily
complex compound proposition.
Solution: ( p q ) ( q r ) ( r p )
( p q) → ( p q) ( p q) ( p q) by truth table for → Solution: Satisfiable. Assign T to p, q, and r.
( p q ) ( p q ) by the first De Morgan law ( p q r ) ( p q r )
( p p ) ( q q ) by associative and Solution: Satisfiable. Assign T to p and F to q.
commutative laws
laws for disjunction ( p q ) ( q r ) ( r p ) ( p q r ) ( p q r )
T T by truth tables Solution: Not satisfiable. Check each possible
assignment of truth values to the propositional
T by the domination law
variables and none will make the proposition true.
exist, the compound proposition is unsatisfiable. n
j =1
p j is used for p1 p2 pn
A compound proposition is unsatisfiable if and
only if its negation is a tautology.
Needed for the next example.
Sudoku Encoding as a Satisfiability Problem 2
A Sudoku puzzle is represented by a 9×9 grid made For each cell with a given value, assert p(i,j,n), when
up of nine 3×3 subgrids, known as blocks. Some of the cell in row i and column j has the given value.
the 81 cells of the puzzle are assigned one of the
Assert that every row contains every number.
numbers 1,2, …, 9.
9 9 9
The puzzle is solved by assigning numbers to each
blank cell so that every row, column and block
p ( i, j, n)
i =1 n =1 j =1
contains each of the nine possible numbers.
Assert that every column contains every number.
Example
9 9 9
p ( i, j, n)
j =1n =1 i =1
Let p(i,j,n) denote the proposition that is true Assert that each of the 3 × 3 blocks contain every
when the number n is in the cell in the ith row number. 2 2 9 3 3
and the jth column. p ( 3r + i,3s + j, n)
r = 0 s = 0 n =1 i =1 j =1
There are 9 × 9 × 9 = 729 such propositions.
(this is tricky - ideas from chapter 4 help)
In the sample puzzle p(5,1,6) is true, but p(5,j,6) Assert that no cell contains more than one number.
is false for j = 2,3,…9 Take the conjunction over all values of n, n’, i, and j,
where each variable ranges from 1 to 9 and n ≠ n’ , of
p ( i , j , n ) → p ( i , j , n )
Solving Satisfiability Problems
To solve a Sudoku puzzle, we need to find an assignment of
truth values to the 729 variables of the form p(i,j,n) that
makes the conjunction of the assertions true. Those
variables that are assigned T yield a solution to the puzzle.