The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.

propositional logic: ... –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.

Discover the best professional documents and content resources in AnyFlip Document Base.
Search
Published by , 2016-06-04 20:00:03

Propositional Logic - Duke University

propositional logic: ... –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.

Propositional Logic

Tuesday, January 15, 2013 Chittu Tripathy Lecture 03

Today’s Menu

Some Applications of Propositional Logic

• Translating English to Propositional Logic
• Logic Puzzles
• Combinatorial Logic Circuits
• Boolean Information Retrieval

Propositional Equivalence

• Equivalences
• Key Equivalences
• CNF and DNF

Satisfiability

Tuesday, January 15, 2013 Chittu Tripathy Lecture 03

Translating English Sentences

Steps

• Identify atomic propositions and represent using

propositional variables.
• Determine appropriate logical connectives.

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: Let the variables p, q, and r represent:
p : You can access the internet from campus.
q : You are a computer science major.
r : You are a freshman.

p → (q ∨ ¬r )

Tuesday, January 15, 2013 Chittu Tripathy Lecture 03

Logic Puzzles

• An island has two kinds of inhabitants, knights, who always tell the truth,
and knaves, who always lie.

• You go to the island and meet A and B.

– A says “B is a knight.”
– B says “The two of us are of opposite types.”

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,

respectively. Then p represents the proposition that A is a knave and q

that B is a knave.

– If A is a knight, then p is true. Since knights tell the truth, q must also be true.
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.

– 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.

Tuesday, January 15, 2013 Chittu Tripathy Lecture 03

Combinatorial Logic Circuits

input/output signal: ppp132 Logic qqq213
Circuit qn
– 0 represents F
– 1 represents T

pm

Tuesday, January 15, 2013 Chittu Tripathy Lecture 03

Combinatorial Logic Circuits

input/output signal: ppp312 Logic qqq321
Circuit qn
– 0 represents F
– 1 represents T p ⊕q
XOR
pm

Logic Gates: p∧q p p ∨q p
¬p p q q
p q

NOT AND OR
(inverter)

Tuesday, January 15, 2013 Chittu Tripathy Lecture 03

Combinatorial Logic Circuits

input/output signal: ppp123 Logic qqq213
Circuit qn
– 0 represents F
– 1 represents T

pm

Logic Gates: p∧q p
¬p p q p ∨q p
p q q p ⊕q

NOT AND OR XOR
(inverter) ¬ (p ∨q)
p
Two Special Logic Gates: q
p ¬ (p ∧ q)
q

NAND = AND followed by NOT NOR = OR followed by NOT

Complex Combinatorial Circuits can be constructed from these gates.

Tuesday, January 15, 2013 Chittu Tripathy Lecture 03

Example of Combinatorial Logic Circuit

¬((p ∧ ¬q) ∨ (¬ p ∧ q)) ∧ (p ∨ q)

p p ∧ ¬q
¬p
¬((p ∧ ¬q) ∨ (¬ p ∧ q))

q ¬p∧q

¬q
p ∨q

¬((p ∧ ¬q) ∨ (¬ p ∧ q)) ∧ (p ∨ q)

How can we show this to be equivalent to

a simple AND gate, that is p ∧ q ?

Tuesday, January 15, 2013 Chittu Tripathy Lecture 03

Boolean Information Retrieval

Document 1: The earth is perfectly spherical. It it? No. It is an

oblate spheroid. That is, the earth is slightly flatter at the poles and
slightly more bulging at the equator.

Document 2: Is the cricket ball perfectly spherical? Well, almost,

but has a slightly raised sewn seam. The seam prevents it from being
perfectly spherical. On the other hand, the seam helps with the
swinging of the ball or to produce sideways deflection after pitching.

Document 3: Is the soccer ball perfectly spherical? Well, almost.

Actually, it is a spherical polyhedron.

Query: (ball AND spherical) AND (bulging OR seam) Result

Document 1: 0 1 10 0
Document 2: 1 1 01 1
Document 3: 1 1 00 0

Tuesday, January 15, 2013 Chittu Tripathy Lecture 03

Propositional Equivalence

Tuesday, January 15, 2013 Chittu Tripathy Lecture 03

Tautology, Contradiction, Contingency

• A tautology is a proposition which is always TRUE.

– Example: p ∨¬p

• A contradiction is a proposition which is always FALSE.

– Example: p ∧¬p

• A contingency is a proposition which is neither a
tautology nor a contradiction, such as most previous

propositions p we have seen

p ¬p p ∨¬p p ∧¬p
F
TFT F

FTT

For any contingency p
 p ∨¬p is a tautology
 p ∧¬p is a contradiction

Tuesday, January 15, 2013 Chittu Tripathy Lecture 03

Propositional Equivalence

• Tewquoivcaolmenptoiuf npd↔pqropisoasittaiountos lpogayn.d q are logically
• In other words, p and q always evaluate to the

same truth value for any truth assignment to the

cporomppoosuitniodnparlovpaorisaibtiloenssthpaatncdonqs.titute the
• We write this as p ⇔ q or p ≡ q .

Example: Show that ¬p ∨ q ≡ p → q ≡ ¬q → ¬p .

p q ¬p ¬q ¬p ∨ q p→ q ¬q → ¬p

TT F F T T T

TF F T F F F

FT T F T T T

FF T T T T T

Tuesday, January 15, 2013 Chittu Tripathy Lecture 03

De Morgan’s Laws

¬(p ∧ q) ≡ ¬p ∨ ¬q
¬(p ∨ q) ≡ ¬p ∧ ¬q

p q ¬p ¬q p ∧ q ¬(p ∧q) ¬p ∨¬q p ∨q ¬(p ∨q) ¬p∧¬q

T TF F T F FTF F
T FF T F T TTF F
F TT F F T TTF F
F FT T F T TFT T

Tuesday, January 15, 2013 Chittu Tripathy Lecture 03

Key Logical Equivalences

Identity Laws

Domination Laws

Idempotent laws Exercise: Prove these
Double Negation Law laws using Truth Table.

Negation Laws

Commutative Laws

Associative Laws

Distributive Laws

Absorption Laws Chittu Tripathy Lecture 03

Tuesday, January 15, 2013

More Logical Equivalences

The following logical equivalences (Rosen 1.3) are
often useful for solving problems. They can be
proved using Truth Tables. They can use used to
prove more logical equivalences!

Logical Equivalences Involving Logical Equivalences Involving
Conditional Statements Biconditional Statements

Tuesday, January 15, 2013 Chittu Tripathy Lecture 03

Example of Equivalence Proof

Example: Show that
is logically equivalent to

Solution:

Exercise: Show that

¬((p ∧ ¬q) ∨ (¬ p ∧ q)) ∧ (p ∨ q) ≡ p ∧ q .

Tuesday, January 15, 2013 Chittu Tripathy Lecture 03

Disjunctive Normal Form (DNF)

A propositional formula is in disjunctive normal form (DNF) if it
consists of a disjunction of (1, … ,n) disjuncts where each disjunct
consists of a conjunction of (1, …, m) atomic formulas or the
negation of an atomic formula.

In other words, a DNF is an OR of ANDs.

Example: (p ∧ ¬q) ∨ (¬ p ∧ q) ∨ (p ∨ q) DNF
(p ∧ q ∧ r) ∨ (¬p ∧ q ∨ ¬r)

(p ∧ (q ∨ r)) ∨ (¬p ∧ q ∨ ¬r) Not DNF
¬(p ∨ q)

Tuesday, January 15, 2013 Chittu Tripathy Lecture 03

Conjunctive Normal Form

A compound proposition is in Conjunctive Normal
Form (CNF) if it is a conjunction of disjunctions.

In other words, a CNF is an AND of ORs.

Example: (p ∨ ¬q) ∧ (¬ p ∨ q) ∧ (p ∨ q) CNF
(p ∨ q ∨ r) ∧ (¬p ∨ q ∨ ¬r)

(p ∨ (q ∧ r)) ∧ (¬p ∨ q ∨ ¬r) Not CNF
¬(p ∧ q)

Tuesday, January 15, 2013 Chittu Tripathy Lecture 03

Proposition to CNF and DNF

Proposition

⇔DNF CNF

Every compound proposition
can be rewritten in CNF or DNF.

Tuesday, January 15, 2013 Chittu Tripathy Lecture 03

Proposition ⇔ DNF
• Construct the Truth Table for the proposition
• Pick each row that evaluates to T

–If a variable r in this row is T then write it as it; otherwise,
write the negation of it, i.e., ¬r

–OR these written literals (literal = variable or its complement)

Example: Truth Table for p  q → r

≡p q r r p  q p  q → r p  q → r
TTT F T F
TTF T T
TFT F T T (pqr)

F

TFF T T T (pqr)
FTT F T
FTF T T F
FFT F F
FFF T F T (pqr)

Tuesday, January 15, 2013 T (pqr) Lecture 03

T (pqr)

Chittu Tripathy

Proposition ⇔ CNF

Express the formula using AND, OR and NOT. To convert
it to CNF move negation inwards and use the distributive
and associative laws.

Example: Convert the following formula to CNF:
(p → q ) (r → p )

Solution:

1. Eliminate implication signs
(p  q)  (r  p)

2. Move negation inwards; eliminate double negation
(p ∧  q)  (r  p)

3. Convert to CNF using associative/distributive laws
(p  r  p) ∧ ( q  r  p)

Tuesday, January 15, 2013 Chittu Tripathy Lecture 03

Propositional Satisfiability

• A compound proposition is satisfiable if there exists a truth
assignment to its variables that make it TRUE. When no such
assignments exist, the compound proposition is unsatisfiable.

• A compound proposition is unsatisfiable iff its negation is a
tautology.

Examples: Test if the following propositions are satisfiable.

1

Solution: Satisfiable. Assign T to p, q, and r.

2
Solution: Satisfiable. Assign T to p and F to q.

3

Solution: Not satisfiable. We cannot find a possible truth
assignment to the variables!

Tuesday, January 15, 2013 Chittu Tripathy

Lecture 03

How Hard is Satisfiablity?

• Satisfiability can be checked using a truth table
• Size of the truth table doubles with each variable
• Therefore, size (#rows) of truth table is exponential in the

number of variables
• In general, no better way is known to test satisfiability efficiently

Million-Dollar Problem: P = NP?

The P=NP? Problem is all about finding an
efficient (polynomial time algorithm) to test
satisfiability.

Tuesday, January 15, 2013 Chittu Tripathy Lecture 03


Click to View FlipBook Version