Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
3 views54 pages

Lec2 Propositional Logic

The document discusses propositional logic, a fundamental area of logic that deals with propositions and their relationships through connectives. It covers key concepts such as truth values, truth tables, logical equivalences, and various types of propositions including conjunction, disjunction, implication, and biconditional. Applications of propositional logic in computer science are also highlighted, emphasizing its importance in areas like AI, programming languages, and databases.

Uploaded by

adh2498
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views54 pages

Lec2 Propositional Logic

The document discusses propositional logic, a fundamental area of logic that deals with propositions and their relationships through connectives. It covers key concepts such as truth values, truth tables, logical equivalences, and various types of propositions including conjunction, disjunction, implication, and biconditional. Applications of propositional logic in computer science are also highlighted, emphasizing its importance in areas like AI, programming languages, and databases.

Uploaded by

adh2498
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

[CSED261] Discrete Mathematics for Computer Science

Lecture 2
Propositional Logic

Suha Kwak
[email protected]
Dept. of Computer Science and Engineering
Logic
• Logic
• Study of valid reasoning
• Fundamental to CS
• Allows to represent knowledge in a precise, mathematical way
• Enables valid inferences using a set of precise rules
• Applications in CS
• Classical AI
• Programming languages
• Databases
• Computer architecture
• Automated testing and program analysis
• … and many others

• Simplest logic = propositional logic


2
Summary
• The language of propositions
• Connectives
• Truth values
• Truth tables
• Applications
• Translating English sentences
• System specifications
• Logic puzzles
• Logic circuits
• Logical equivalences
• Important equivalences
• Showing equivalence
• Satisfiability
3
Propositional Logic

4
Propositional Logic
• A proposition is a declarative sentence that is either true
or false, but not both.

• Are the following sentences propositions?


• Toronto is the capital of Canada. >> Yes
• Read this carefully. >> No
• 1+2=3 >> Yes
• 𝑥𝑥 + 1 = 2 >> No
• What time is it? >> No

• Propositional logic
• The area of logic that deals with propositions
• The branch of logic that studies ways of joining and/or
modifying propositions to form more complicated ones

5
Propositional Logic
• Constructing propositions
• Propositional variables: 𝑝𝑝, 𝑞𝑞, 𝑟𝑟, 𝑠𝑠, …
• The proposition that is always true is denoted by 𝑇𝑇 and the
proposition that is always false is denoted by 𝐹𝐹.
• Compound propositions constructed from logical connectives
and other propositions
• Connectives
Negation ¬
Conjunction ∧
Disjunction ∨
Exclusive OR ⨁
Implication →
Biconditional

6
Negation
• The negation of a proposition 𝑝𝑝 is denoted by ¬𝑝𝑝
and has the following truth table:
𝑝𝑝 ¬𝑝𝑝
𝑇𝑇 𝐹𝐹
𝐹𝐹 𝑇𝑇

• Example
• The negation of the proposition “Today is Friday.” is “It is not
the case that today is Friday.”; in simple English, “It is not Friday
today.”
• The negation of the proposition “At least 10 inches of rain fell
today in Miami.” is “Less than 10 inches of rain fell today in
Miami.”

7
Conjunction
• The conjunction of propositions 𝑝𝑝 and 𝑞𝑞 is denoted by
𝑝𝑝 ∧ 𝑞𝑞 and has the following truth table:
𝑝𝑝 𝑞𝑞 𝑝𝑝 ∧ 𝑞𝑞
𝑇𝑇 𝑇𝑇 𝑇𝑇
𝑇𝑇 𝐹𝐹 𝐹𝐹
𝐹𝐹 𝑇𝑇 𝐹𝐹
𝐹𝐹 𝐹𝐹 𝐹𝐹

• Example
• If 𝑝𝑝 is “Today is Friday.” and 𝑞𝑞 denotes “It is raining today.”
then 𝑝𝑝 ∧ 𝑞𝑞 denotes “Today is Friday and it is raining today.”
This proposition is true on rainy Fridays.

8
Disjunction
• The disjunction of propositions 𝑝𝑝 and 𝑞𝑞 is denoted by
𝑝𝑝 ∨ 𝑞𝑞 and has the following truth table:
𝑝𝑝 𝑞𝑞 𝑝𝑝 ∨ 𝑞𝑞
𝑇𝑇 𝑇𝑇 𝑇𝑇
𝑇𝑇 𝐹𝐹 𝑇𝑇
𝐹𝐹 𝑇𝑇 𝑇𝑇
𝐹𝐹 𝐹𝐹 𝐹𝐹

• Example
• If 𝑝𝑝 denotes “I am at home.” and 𝑞𝑞 denotes “It is raining.”
then 𝑝𝑝 ∨ 𝑞𝑞 denotes “I am at home or it is raining.”

9
The Connective OR in English
• In English, OR has two distinct meanings.
• Inclusive OR
• “Students who have taken C1 or C2 may take this class.”
 The students have taken at least one of the two courses.
• Identical to the disjunction
• Exclusive OR (⨁)
• “Soup or salad comes with the entrée.”
 Only one of them will be served.
𝑝𝑝 𝑞𝑞 𝑝𝑝⨁𝑞𝑞
𝑇𝑇 𝑇𝑇 𝐹𝐹
𝑇𝑇 𝐹𝐹 𝑇𝑇
One of 𝑝𝑝 and 𝑞𝑞 must be true, 𝐹𝐹 𝑇𝑇 𝑇𝑇
but not both. 𝐹𝐹 𝐹𝐹 𝐹𝐹
10
Implication
• If 𝑝𝑝 and 𝑞𝑞 are propositions, then 𝑝𝑝 → 𝑞𝑞 is a conditional
statement or implication, which is read as “if 𝑝𝑝, then 𝑞𝑞”
and has this truth table:
𝑝𝑝 (antecedent) 𝑞𝑞 (consequent) 𝑝𝑝 → 𝑞𝑞
𝑇𝑇 𝑇𝑇 𝑇𝑇
𝑇𝑇 𝐹𝐹 𝐹𝐹
𝐹𝐹 𝑇𝑇 𝑇𝑇
𝐹𝐹 𝐹𝐹 𝑇𝑇

• Example
• If you get 100% on the final, then you will get an A.
• If I am elected, then I will lower taxes.

11
Implication
• Understanding implication
• In 𝑝𝑝 → 𝑞𝑞, there does not need to be any connection between
the antecedent and the consequent.
• The “meaning” of 𝑝𝑝 → 𝑞𝑞 depends only on the truth values of
𝑝𝑝 and 𝑞𝑞.
• These implications are perfectly fine, but would not be used in
ordinary English.
• “If the moon is made of green cheese then I’m a king.”
• “If 1 + 1 = 3, then your grandma wears combat boots.”

12
Implication
• Different ways of expressing 𝑝𝑝 → 𝑞𝑞
• If 𝑝𝑝, then 𝑞𝑞 • 𝑝𝑝 implies 𝑞𝑞
• If 𝑝𝑝, 𝑞𝑞 • 𝑝𝑝 only if 𝑞𝑞
• 𝑞𝑞 if 𝑝𝑝 • 𝑞𝑞 when 𝑝𝑝
• 𝑝𝑝 is sufficient for 𝑞𝑞 • 𝑞𝑞 whenever 𝑝𝑝
• 𝑞𝑞 is necessary for 𝑝𝑝 • 𝑞𝑞 follows from 𝑝𝑝
• A sufficient condition for 𝑞𝑞 is 𝑝𝑝. • 𝑞𝑞 unless ¬𝑝𝑝
• A necessary condition for 𝑝𝑝 is 𝑞𝑞.

13
Converse, Contrapositive, and Inverse
• From 𝑝𝑝 → 𝑞𝑞, we can form new conditional statements.
• Converse: 𝑞𝑞 → 𝑝𝑝
• Contrapositive: ¬𝑞𝑞 → ¬𝑝𝑝
• Inverse: ¬𝑝𝑝 → ¬𝑞𝑞

• Find the converse, inverse, and contrapositive of


“It’s raining is a sufficient condition for my not going to town.”
𝑝𝑝 → 𝑞𝑞 where “𝑝𝑝 = it’s rainy.” and “𝑞𝑞 = I’m not going to town.”
Converse of 𝑝𝑝 → 𝑞𝑞 ⇔ 𝑞𝑞 → 𝑝𝑝
⇔ “If I’m not going to town, it’s raining.”
Inverse of 𝑝𝑝 → 𝑞𝑞 ⇔ ¬𝑝𝑝 → ¬𝑞𝑞
⇔ “If it’s not raining, I’m going to town.”
contrapositive of 𝑝𝑝 → 𝑞𝑞 ⇔ ¬𝑞𝑞 → ¬𝑝𝑝
⇔ “If I’m going to town, it is not raining.”
14
Biconditional
• If 𝑝𝑝 and 𝑞𝑞 are propositions, then one can form the
biconditional proposition 𝑝𝑝 𝑞𝑞, “𝑝𝑝 if and only if 𝑞𝑞.”
• The biconditional 𝑝𝑝 𝑞𝑞 denotes the proposition with
this truth table:
𝑝𝑝 (antecedent) 𝑞𝑞 (consequent) 𝑝𝑝 𝑞𝑞
𝑇𝑇 𝑇𝑇 𝑇𝑇
𝑇𝑇 𝐹𝐹 𝐹𝐹
𝐹𝐹 𝑇𝑇 𝐹𝐹
𝐹𝐹 𝐹𝐹 𝑇𝑇

• Example
• If 𝑝𝑝 denotes “I am at home.” and 𝑞𝑞 denotes “It is raining.”,
then 𝑝𝑝 𝑞𝑞 denotes “I am at home if and only if it is raining.”
15
Biconditional
• Alternative ways 𝑝𝑝 𝑞𝑞 is expressed in English
• 𝑝𝑝 is necessary and sufficient for 𝑞𝑞.
• If 𝑝𝑝 then 𝑞𝑞, and conversely.
• 𝑝𝑝 iff 𝑞𝑞.

16
Truth Tables for Compound Propositions
• A way to construct a truth table:
• A row for every possible combination of values for the atomic
propositions
• A column for the truth value of each expression (including the
atomic propositions) occurring in the compound proposition

• Example: 𝑝𝑝 ∨ 𝑞𝑞 → ¬𝑟𝑟
𝑝𝑝 𝑞𝑞 𝑟𝑟 ¬𝑟𝑟 𝑝𝑝 ∨ 𝑞𝑞 𝑝𝑝 ∨ 𝑞𝑞 → ¬𝑟𝑟
𝑇𝑇 𝑇𝑇 𝑇𝑇 𝐹𝐹 𝑇𝑇 𝐹𝐹
𝑇𝑇 𝑇𝑇 𝐹𝐹 𝑇𝑇 𝑇𝑇 𝑇𝑇
𝑇𝑇 𝐹𝐹 𝑇𝑇 𝐹𝐹 𝑇𝑇 𝐹𝐹
𝑇𝑇 𝐹𝐹 𝐹𝐹 𝑇𝑇 𝑇𝑇 𝑇𝑇
⋮ ⋮ ⋮ ⋮ ⋮ ⋮

17
Equivalent Propositions
• Two propositions are equivalent if they always have the
same truth value.

• Example:
• Show using a truth table that the implication is equivalent to
the contrapositive.
• Solution:
𝑝𝑝 𝑞𝑞 ¬ 𝑝𝑝 ¬ 𝑞𝑞 𝑝𝑝 → 𝑞𝑞 ¬𝑞𝑞 → ¬ 𝑝𝑝
𝑇𝑇 𝑇𝑇 𝐹𝐹 𝐹𝐹 𝑇𝑇 𝑇𝑇
𝑇𝑇 𝐹𝐹 𝐹𝐹 𝑇𝑇 𝐹𝐹 𝐹𝐹
𝐹𝐹 𝑇𝑇 𝑇𝑇 𝐹𝐹 𝑇𝑇 𝑇𝑇
𝐹𝐹 𝐹𝐹 𝑇𝑇 𝑇𝑇 𝑇𝑇 𝑇𝑇

18
Equivalent Propositions
• Two propositions are equivalent if they always have the
same truth value.

• Example:
• Show using a truth table that neither the converse nor inverse
of an implication are not equivalent to the implication.
• Solution:
𝑝𝑝 𝑞𝑞 ¬ 𝑝𝑝 ¬ 𝑞𝑞 𝑝𝑝 → 𝑞𝑞 ¬ 𝑝𝑝 → ¬ 𝑞𝑞 𝑞𝑞 → 𝑝𝑝
𝑇𝑇 𝑇𝑇 𝐹𝐹 𝐹𝐹 𝑇𝑇 𝑇𝑇 𝑇𝑇
𝑇𝑇 𝐹𝐹 𝐹𝐹 𝑇𝑇 𝐹𝐹 𝑇𝑇 𝑇𝑇
𝐹𝐹 𝑇𝑇 𝑇𝑇 𝐹𝐹 𝑇𝑇 𝐹𝐹 𝐹𝐹
𝐹𝐹 𝐹𝐹 𝑇𝑇 𝑇𝑇 𝑇𝑇 𝑇𝑇 𝑇𝑇

19
Applications of
Propositional Logic

20
Translating English Sentences
• Steps to convert an English sentence to a statement in
propositional logic
• Identify atomic propositions and represent them using
propositional variables.
• Determine appropriate logical connectives.

• Example
• “If I go to Harry’s or to the country, I will not go shopping.”
𝑝𝑝 = “I go to Harry’s.”
𝑞𝑞 = “I go to the country.”
𝑟𝑟 = “I will go shopping.”

If 𝑝𝑝 or 𝑞𝑞 then not 𝑟𝑟.

𝑝𝑝 ∨ 𝑞𝑞 → ¬𝑟𝑟
21
Translating English Sentences
• Example (cont’d)
• “You can access the Internet from campus only if you are a
computer science major or you are not a freshman.”
𝑝𝑝 = “You can access the Internet from campus.”
𝑞𝑞 = “You major in computer science.”
𝑟𝑟 = “You are a freshman.”

𝑝𝑝 → 𝑞𝑞 ∨ ¬𝑟𝑟

22
System Specification
• System and Software engineers take requirements in
English and express them in a precise specification
language based on logic.

• Express in propositional logic:


• “The auto-reply cannot be sent when the file system is full.”
𝑝𝑝 = “The automated reply can be sent.”
𝑞𝑞 = “The file system is full.”

𝑞𝑞 → ¬𝑝𝑝

23
Consistent System Specification
• A list of propositions is consistent if it is possible to assign
truth values to the proposition variables so that each
proposition is true.
τ
• Are these specifications consistent?
• “The diagnostic message is stored in the buffer or it is
retransmitted.” 𝑝𝑝 ∨ 𝑞𝑞
• “If the diagnostic message is stored in the buffer, then it is
retransmitted.” (𝑝𝑝 → 𝑞𝑞)
• “The diagnostic message is not stored in the buffer.” ¬𝑝𝑝
𝑝𝑝 = “The diagnostic message is stored in the buffer.”
𝑞𝑞 = “The diagnostic message is retransmitted.”

When 𝑝𝑝 is false and 𝑞𝑞 is true, all three statements are true!


The specifications are consistent.
24
Consistent System Specification
• Are these specifications consistent?
• “The diagnostic message is stored in the buffer or it is
retransmitted.” 𝑝𝑝 ∨ 𝑞𝑞
• “If the diagnostic message is stored in the buffer, then it is
retransmitted.” (𝑝𝑝 → 𝑞𝑞)
• “The diagnostic message is not stored in the buffer.” ¬𝑝𝑝
• “The diagnostic message is not retransmitted.” ¬𝑞𝑞
𝑝𝑝 = “The diagnostic message is stored in the buffer.”
𝑞𝑞 = “The diagnostic message is retransmitted.”

There is no satisfying assignment.


The specifications are inconsistent.

25
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.”

• What are the types of A and B?

Raymond Smullyan
(Born 1919)
26
Logic Puzzles (cont’d)
• Solution:
• 𝑎𝑎 = “A is a knight .” (¬𝑎𝑎 = “A is a knave.”)
• 𝑏𝑏 = “B is a knight.” (¬𝑏𝑏 = “B is a knave.”)
• If A is a knight, 𝑎𝑎 is true. Since knights tell the truth, B is a
knight as well. Then 𝑎𝑎 ∧ ¬𝑏𝑏 ∨ ¬𝑎𝑎 ∧ 𝑏𝑏 would have to be
true according to the statement of B, but it is not. So, A is not a
knight and therefore ¬𝑎𝑎 must be true.
• If A is a knave, then B must not be a knight since knaves always
lie. Then both ¬𝑎𝑎 and ¬𝑏𝑏 hold since both are knaves.

Raymond Smullyan
(Born 1919)
27
Logic Circuits
• Electronic circuits
• Each input/output signal can be viewed as a 0 or 1.
• 0 represents False.
• 1 represents True.

• Complicated circuits are constructed from three basic


circuits called gates.

28
Logic Circuits
• More complicated digital circuits can be constructed by
combining these basic circuits.
• Building a circuit for each piece of the output expression
• Combining them

29
Propositional Equivalences

30
Tautology, Contradiction, and Contingency
• Tautology
• A proposition which is always true
• Example: 𝑝𝑝 ∨ ¬𝑝𝑝

• Contradiction
• A proposition which is always false
• Example: 𝑝𝑝 ∧ ¬𝑝𝑝

• Contingency
• A proposition which is neither a tautology nor a contradiction

𝑝𝑝 ¬𝑝𝑝 𝑝𝑝 ∨ ¬𝑝𝑝 𝑝𝑝 ∧ ¬𝑝𝑝


𝑇𝑇 𝐹𝐹 𝑇𝑇 𝐹𝐹
𝐹𝐹 𝑇𝑇 𝑇𝑇 𝐹𝐹

31
Logical Equivalence
• Definition
• Two compound propositions 𝑝𝑝 and 𝑞𝑞 are logically equivalent if
𝑝𝑝 𝑞𝑞 is a tautology.
• Two compound propositions 𝑝𝑝 and 𝑞𝑞 are equivalent if and only
if the columns in a truth table giving their truth values agree.
𝑝𝑝 𝑞𝑞 ¬𝑝𝑝 ¬𝑝𝑝 ∨ 𝑞𝑞 𝑝𝑝 → 𝑞𝑞
𝑇𝑇 𝑇𝑇 𝐹𝐹 𝑇𝑇 𝑇𝑇
𝑇𝑇 𝐹𝐹 𝐹𝐹 𝐹𝐹 𝐹𝐹
𝐹𝐹 𝑇𝑇 𝑇𝑇 𝑇𝑇 𝑇𝑇
𝐹𝐹 𝐹𝐹 𝑇𝑇 𝑇𝑇 𝑇𝑇

• Notation
• 𝑝𝑝 ⟺ 𝑞𝑞 or 𝑝𝑝 ≡ 𝑞𝑞

32
De Morgan’s Laws
• De Morgan’s laws
• ¬ 𝑝𝑝 ∨ 𝑞𝑞 ≡ ¬𝑝𝑝 ∧ ¬𝑞𝑞
• ¬ 𝑝𝑝 ∧ 𝑞𝑞 ≡ ¬𝑝𝑝 ∨ ¬𝑞𝑞


Augustus De Morgan
(1806-1871)
• Proof
𝑝𝑝 𝑞𝑞 ¬𝑝𝑝 ¬𝑞𝑞 (𝑝𝑝 ∨ 𝑞𝑞) ¬(𝑝𝑝 ∨ 𝑞𝑞) ¬𝑝𝑝 ∧ ¬𝑞𝑞
𝑇𝑇 𝑇𝑇 𝐹𝐹 𝐹𝐹 𝑇𝑇 𝐹𝐹 𝐹𝐹
𝑇𝑇 𝐹𝐹 𝐹𝐹 𝑇𝑇 𝑇𝑇 𝐹𝐹 𝐹𝐹
𝐹𝐹 𝑇𝑇 𝑇𝑇 𝐹𝐹 𝑇𝑇 𝐹𝐹 𝐹𝐹
𝐹𝐹 𝐹𝐹 𝑇𝑇 𝑇𝑇 𝐹𝐹 𝑇𝑇 𝑇𝑇

33
Key Logical Equivalences
• Identity laws • Idempotent laws
• 𝑝𝑝 ∧ 𝑇𝑇 ≡ 𝑝𝑝 • 𝑝𝑝 ∨ 𝑝𝑝 ≡ 𝑝𝑝
• 𝑝𝑝 ∨ 𝐹𝐹 ≡ 𝑝𝑝 • 𝑝𝑝 ∧ 𝑝𝑝 ≡ 𝑝𝑝

• Domination laws • Negation laws


• 𝑝𝑝 ∨ 𝑇𝑇 ≡ 𝑇𝑇 • 𝑝𝑝 ∨ ¬𝑝𝑝 ≡ 𝑇𝑇
• 𝑝𝑝 ∧ 𝐹𝐹 ≡ 𝐹𝐹 • 𝑝𝑝 ∧ ¬𝑝𝑝 ≡ 𝐹𝐹

• Double Negation law


• ¬ ¬𝑝𝑝 ≡ 𝑝𝑝

34
Key Logical Equivalences
• Commutative laws
• 𝑝𝑝 ∨ 𝑞𝑞 ≡ 𝑞𝑞 ∨ 𝑝𝑝
• 𝑝𝑝 ∧ 𝑞𝑞 ≡ 𝑞𝑞 ∧ 𝑝𝑝

• Associative laws
• 𝑝𝑝 ∧ 𝑞𝑞 ∧ 𝑟𝑟 ≡ 𝑝𝑝 ∧ 𝑞𝑞 ∧ 𝑟𝑟
• 𝑝𝑝 ∨ 𝑞𝑞 ∨ 𝑟𝑟 ≡ 𝑝𝑝 ∨ 𝑞𝑞 ∨ 𝑟𝑟

• Distributive laws
• 𝑝𝑝 ∨ 𝑞𝑞 ∧ 𝑟𝑟 ≡ 𝑝𝑝 ∨ 𝑞𝑞 ∧ 𝑝𝑝 ∨ 𝑟𝑟
• 𝑝𝑝 ∧ 𝑞𝑞 ∨ 𝑟𝑟 ≡ 𝑝𝑝 ∧ 𝑞𝑞 ∨ 𝑝𝑝 ∧ 𝑟𝑟

• Absorption laws
• 𝑝𝑝 ∨ 𝑝𝑝 ∧ 𝑞𝑞 ≡ 𝑝𝑝
• 𝑝𝑝 ∧ 𝑝𝑝 ∨ 𝑞𝑞 ≡ 𝑝𝑝
35
More Logical Equivalences
• Those involving conditional or biconditional statements
X

PE= GPVE )1178 VP)

36

Constructing New Logical Equivalences
• We can show that two expressions are logically
equivalent by developing a series of logically equivalent
statements.
• To prove that 𝑝𝑝 ≡ 𝑞𝑞, we produce a series of equivalences
beginning with 𝑝𝑝 and ending with 𝑞𝑞:
𝑝𝑝 ≡ 𝑝𝑝1 , (𝑝𝑝1 ≡ 𝑝𝑝2 ), … , (𝑝𝑝𝑛𝑛 ≡ 𝑞𝑞)

• Keep in mind that whenever a proposition (represented


by propositional variables) occurs in the equivalences
listed earlier, it may be replaced by an arbitrarily complex
compound proposition.

37
Equivalence Proofs
• Show that ¬ 𝑝𝑝 ∨ ¬𝑝𝑝 ∧ 𝑞𝑞 ≡ ¬𝑝𝑝 ∧ ¬𝑞𝑞.
• Solution:
¬ 𝑝𝑝 ∨ ¬𝑝𝑝 ∧ 𝑞𝑞 ≡ ¬𝑝𝑝 ∧ ¬ ¬𝑝𝑝 ∧ 𝑞𝑞
De Morgan
¬ 𝑝𝑝 ∨ ¬𝑝𝑝 ∧ 𝑞𝑞 ≡ ¬𝑝𝑝 ∧ ¬ ¬𝑝𝑝 ∨ ¬𝑞𝑞
Double negation
¬ 𝑝𝑝 ∨ ¬𝑝𝑝 ∧ 𝑞𝑞 ≡ ¬𝑝𝑝 ∧ 𝑝𝑝 ∨ ¬𝑞𝑞
Distributive
¬ 𝑝𝑝 ∨ ¬𝑝𝑝 ∧ 𝑞𝑞 ≡ (¬𝑝𝑝 ∧ 𝑝𝑝) ∨ ¬𝑝𝑝 ∧ ¬𝑞𝑞
Contradiction
¬ 𝑝𝑝 ∨ ¬𝑝𝑝 ∧ 𝑞𝑞 ≡ 𝐹𝐹 ∨ ¬𝑝𝑝 ∧ ¬𝑞𝑞
Identity
¬ 𝑝𝑝 ∨ ¬𝑝𝑝 ∧ 𝑞𝑞 ≡ ¬𝑝𝑝 ∧ ¬𝑞𝑞

38
Disjunctive Normal Form
• Definition soP
PNP
• A propositional formula is in disjunctive normal form (DNF)
if it consists of a disjunction of disjuncts where each disjunct
consists of a conjunction of atomic formulas or the negation
of an atomic formula.

• Shortly, a DNF is an OR of ANDs.

• Examples
a D C
• 𝑝𝑝 ∧ ¬𝑞𝑞 ∨ 𝑝𝑝 ∧ ¬𝑞𝑞 is a DNF.
• 𝑝𝑝 ∧ 𝑝𝑝 ∨ 𝑞𝑞 is not.

• Every compound proposition can be put in DNF.

39
Disjunctive Normal Form
• Converting 𝑝𝑝⨁𝑞𝑞⨁𝑟𝑟 into a DNF pqp 00 0 11 10

Es O "
𝑝𝑝 𝑞𝑞 𝑟𝑟 𝑝𝑝⨁𝑞𝑞⨁𝑟𝑟 T →
1 1
𝑇𝑇 𝑇𝑇 𝑇𝑇 𝑇𝑇 (𝑝𝑝 ∧ 𝑞𝑞 ∧ 𝑟𝑟)
𝑇𝑇 𝑇𝑇 𝐹𝐹 𝐹𝐹 (3) Disjunction
𝑇𝑇 𝐹𝐹 𝑇𝑇 𝐹𝐹 of them
𝑇𝑇 𝐹𝐹 𝐹𝐹 𝑇𝑇 (𝑝𝑝 ∧ ¬𝑞𝑞 ∧ ¬𝑟𝑟)
𝐹𝐹 𝑇𝑇 𝑇𝑇 𝐹𝐹
𝐹𝐹 𝑇𝑇 𝐹𝐹 𝑇𝑇 (¬𝑝𝑝 ∧ 𝑞𝑞 ∧ ¬𝑟𝑟) (4) Simplifying it
by logical
𝐹𝐹 𝐹𝐹 𝑇𝑇 𝑇𝑇 (¬𝑝𝑝 ∧ ¬𝑞𝑞 ∧ 𝑟𝑟)
equivalences
𝐹𝐹 𝐹𝐹 𝐹𝐹 𝐹𝐹

(1) Truth table (2) A disjunct for


each row where
𝑝𝑝⨁𝑞𝑞⨁𝑟𝑟 = 𝑇𝑇

40
Disjunctive Normal Form
• Find the DNF of 𝑝𝑝 ∨ 𝑞𝑞 → ¬𝑟𝑟

• Solution: From the truth table, you will get


𝑝𝑝 ∧ 𝑞𝑞 ∧ ¬𝑟𝑟 ∨ 𝑝𝑝 ∧ ¬𝑞𝑞 ∧ ¬𝑟𝑟 ∨ ¬𝑝𝑝 ∧ 𝑞𝑞 ∧ ¬𝑟𝑟
∨ ¬𝑝𝑝 ∧ ¬𝑞𝑞 ∧ 𝑟𝑟 ∨ ¬𝑝𝑝 ∧ ¬𝑞𝑞 ∧ ¬𝑟𝑟
which can be reduced to
¬𝑝𝑝 ∧ ¬𝑞𝑞 ∨ ¬𝑟𝑟
by logical equivalences.

• This proposition is true when 𝑟𝑟 is false or both 𝑝𝑝 and 𝑞𝑞


are false.

41
Conjunctive Normal Form
• Definition
• A compound proposition is in Conjunctive Normal Form (CNF)
if it is a conjunction of disjunctions.
CGNF ≈
POY
• Shortly, a CNF is an AND of ORs.

• Every proposition can be put in an equivalent CNF.

• How to obtain CNF?


• By eliminating implications, moving negation inwards, and
using the distributive and associative laws
• By truth table as in the case of DNF

42
Conjunctive Normal Form
• Put the following into CNF: ¬ 𝑝𝑝 → 𝑞𝑞 ∨ 𝑟𝑟 → 𝑝𝑝
( Pi 7 q ) V ( TPVP )
• Solution
• Eliminating implications: ( P178) VD
¬ ¬𝑝𝑝 ∨ 𝑞𝑞 ∨ ¬𝑟𝑟 ∨ 𝑝𝑝
/ pVnrrp / ( quorup ) >
• Moving negation inwards and eliminating double negation:
𝑝𝑝 ∧ ¬𝑞𝑞 ∨ ¬𝑟𝑟 ∨ 𝑝𝑝 ( PV 7 ) qVirvp )

• Converting to CNF using associative and distributive laws:


𝑝𝑝 ∨ ¬𝑟𝑟 ∧ ¬𝑞𝑞 ∨ ¬𝑟𝑟 ∨ 𝑝𝑝

43
Conjunctive Normal Form
• Converting 𝑝𝑝⨁𝑞𝑞⨁𝑟𝑟 into a CNF
𝑝𝑝 𝑞𝑞 𝑟𝑟 𝑝𝑝⨁𝑞𝑞⨁𝑟𝑟
𝑇𝑇 𝑇𝑇 𝑇𝑇 𝑇𝑇
𝑇𝑇 𝑇𝑇 𝐹𝐹 𝐹𝐹 (¬𝑝𝑝 ∨ ¬𝑞𝑞 ∨ 𝑟𝑟) (3) Conjunction
𝑇𝑇 𝐹𝐹 𝑇𝑇 𝐹𝐹 (¬𝑝𝑝 ∨ 𝑞𝑞 ∨ ¬𝑟𝑟) of them
𝑇𝑇 𝐹𝐹 𝐹𝐹 𝑇𝑇
𝐹𝐹 𝑇𝑇 𝑇𝑇 𝐹𝐹 (𝑝𝑝 ∨ ¬𝑞𝑞 ∨ ¬𝑟𝑟)
𝐹𝐹 𝑇𝑇 𝐹𝐹 𝑇𝑇 (4) Simplifying it
by logical
𝐹𝐹 𝐹𝐹 𝑇𝑇 𝑇𝑇
equivalences
𝐹𝐹 𝐹𝐹 𝐹𝐹 𝐹𝐹 (𝑝𝑝 ∨ 𝑞𝑞 ∨ 𝑟𝑟)

(1) Truth table (2) A conjunct for


each row where
𝑝𝑝⨁𝑞𝑞⨁𝑟𝑟 = 𝐹𝐹

44
DNF and CNF: Another Interpretation
• DNF as a disjunction of unit logic functions
𝑝𝑝 𝑞𝑞 𝑟𝑟 𝑓𝑓1 𝑝𝑝, 𝑞𝑞, 𝑟𝑟 → 𝔹𝔹 𝑠𝑠 ≡ 𝑝𝑝⨁𝑞𝑞⨁𝑟𝑟
𝑇𝑇 𝑇𝑇 𝑇𝑇 𝑇𝑇
𝑠𝑠, if 𝑝𝑝,𝑥𝑥 𝑞𝑞,
<𝑟𝑟0 = (𝑇𝑇, 𝑇𝑇, 𝑇𝑇),
𝑇𝑇 𝑇𝑇 𝐹𝐹 𝑓𝑓1 𝑝𝑝, 𝑞𝑞, 𝑟𝑟 = � 𝐹𝐹
𝐹𝐹, otherwise.
𝑥𝑥 ≥ 0
𝑇𝑇 𝐹𝐹 𝑇𝑇 𝑓𝑓6 𝑝𝑝, 𝑞𝑞, 𝑟𝑟 = (𝑝𝑝 ∧ 𝑞𝑞 ∧ 𝑟𝑟) 𝐹𝐹
𝑇𝑇 𝐹𝐹 𝐹𝐹 𝑇𝑇
𝑓𝑓5 𝑝𝑝, 𝑞𝑞, 𝑟𝑟 → 𝔹𝔹
𝐹𝐹 𝑇𝑇 𝑇𝑇 𝐹𝐹
𝐹𝐹 𝑇𝑇 𝐹𝐹 𝑠𝑠, if 𝑝𝑝,𝑥𝑥𝑞𝑞,<𝑟𝑟0 = (𝐹𝐹, 𝑇𝑇, 𝑇𝑇), 𝑇𝑇
𝑓𝑓5 𝑝𝑝, 𝑞𝑞, 𝑟𝑟 = �
𝐹𝐹, otherwise.
𝑥𝑥 ≥ 0
𝐹𝐹 𝐹𝐹 𝑇𝑇 𝑇𝑇
𝑓𝑓6 𝑝𝑝, 𝑞𝑞, 𝑟𝑟 = 𝐹𝐹
𝐹𝐹 𝐹𝐹 𝐹𝐹 Sunh 𝐹𝐹
8
𝑝𝑝⨁𝑞𝑞⨁𝑟𝑟 ≡ � 𝑓𝑓𝑖𝑖 𝑝𝑝, 𝑞𝑞, 𝑟𝑟
𝑖𝑖=1
𝑝𝑝⨁𝑞𝑞⨁𝑟𝑟 ≡ 𝑓𝑓1 𝑝𝑝, 𝑞𝑞, 𝑟𝑟 ∨ 𝐹𝐹 ∨ 𝐹𝐹 ∨ 𝑓𝑓4 𝑝𝑝, 𝑞𝑞, 𝑟𝑟 ∨ 𝐹𝐹 ∨ 𝑓𝑓6 𝑝𝑝, 𝑞𝑞, 𝑟𝑟 ∨ 𝑓𝑓7 𝑝𝑝, 𝑞𝑞, 𝑟𝑟 ∨ 𝐹𝐹
𝑝𝑝⨁𝑞𝑞⨁𝑟𝑟 ≡ 𝑝𝑝 ∧ 𝑞𝑞 ∧ 𝑟𝑟 ∨ 𝑝𝑝 ∧ ¬𝑞𝑞 ∧ ¬𝑟𝑟 ∨ ¬𝑝𝑝 ∧ 𝑞𝑞 ∧ ¬𝑟𝑟 ∨ ¬𝑝𝑝 ∧ ¬𝑞𝑞 ∧ ¬𝑟𝑟
45
DNF and CNF: Another Interpretation
• CNF as a conjunction of unit logic functions
𝑝𝑝 𝑞𝑞 𝑟𝑟 𝑔𝑔1 𝑝𝑝, 𝑞𝑞, 𝑟𝑟 → 𝔹𝔹 𝑠𝑠 ≡ 𝑝𝑝⨁𝑞𝑞⨁𝑟𝑟
𝑇𝑇 𝑇𝑇 𝑇𝑇 𝑇𝑇
𝑠𝑠, if 𝑝𝑝,𝑥𝑥𝑞𝑞,<𝑟𝑟0 = (𝑇𝑇, 𝑇𝑇, 𝑇𝑇),
𝑇𝑇 𝑇𝑇 𝐹𝐹 𝑔𝑔1 𝑝𝑝, 𝑞𝑞, 𝑟𝑟 = � 𝐹𝐹
𝑇𝑇, otherwise.
𝑥𝑥 ≥ 0
𝑇𝑇 𝐹𝐹 𝑇𝑇 𝑓𝑓6 𝑝𝑝, 𝑞𝑞, 𝑟𝑟 = 𝑇𝑇 𝐹𝐹
𝑇𝑇 𝐹𝐹 𝐹𝐹 𝑇𝑇
𝑔𝑔5 𝑝𝑝, 𝑞𝑞, 𝑟𝑟 → 𝔹𝔹
𝐹𝐹 𝑇𝑇 𝑇𝑇 𝐹𝐹
𝐹𝐹 𝑇𝑇 𝐹𝐹 𝑠𝑠, if 𝑝𝑝,𝑥𝑥𝑞𝑞,<𝑟𝑟 0 = (𝐹𝐹, 𝑇𝑇, 𝑇𝑇), 𝑇𝑇
𝑔𝑔5 𝑝𝑝, 𝑞𝑞, 𝑟𝑟 = �
𝑇𝑇, otherwise.
𝑥𝑥 ≥ 0
𝐹𝐹 𝐹𝐹 𝑇𝑇 𝑇𝑇
𝑓𝑓6 𝑝𝑝, 𝑞𝑞, 𝑟𝑟 = (𝑝𝑝 ∨ ¬𝑞𝑞 ∨ ¬𝑟𝑟)
𝐹𝐹 𝐹𝐹 𝐹𝐹 𝐹𝐹
8
𝑝𝑝⨁𝑞𝑞⨁𝑟𝑟 ≡ � 𝑔𝑔𝑖𝑖 𝑝𝑝, 𝑞𝑞, 𝑟𝑟
𝑖𝑖=1
𝑝𝑝⨁𝑞𝑞⨁𝑟𝑟 ≡ 𝑇𝑇 ∧ 𝑔𝑔2 𝑝𝑝, 𝑞𝑞, 𝑟𝑟 ∧ 𝑔𝑔3 𝑝𝑝, 𝑞𝑞, 𝑟𝑟 ∧ 𝑇𝑇 ∧ 𝑔𝑔5 𝑝𝑝, 𝑞𝑞, 𝑟𝑟 ∧ 𝑇𝑇 ∧ 𝑇𝑇 ∧ 𝑔𝑔8 𝑝𝑝, 𝑞𝑞, 𝑟𝑟
𝑝𝑝⨁𝑞𝑞⨁𝑟𝑟 ≡ (¬𝑝𝑝 ∨ ¬𝑞𝑞 ∨ 𝑟𝑟) ∧ (¬𝑝𝑝 ∨ 𝑞𝑞 ∨ ¬𝑟𝑟) ∧ (𝑝𝑝 ∨ ¬𝑞𝑞 ∨ ¬𝑟𝑟) ∧ (𝑝𝑝 ∨ 𝑞𝑞 ∨ 𝑟𝑟)
46
Propositional Satisfiability
• Definition
• A compound proposition is satisfiable if there is an assignment
of truth values to its variables that make it true. When no such
assignments exist, the compound proposition is unsatisfiable.
• A compound proposition is unsatisfiable if and only if
its negation is a tautology.

• Examples
• 𝑝𝑝 ∨ ¬𝑞𝑞 ∧ 𝑞𝑞 ∨ ¬𝑟𝑟 ∧ (𝑟𝑟 ∨ ¬𝑝𝑝)
Satisfiable: It is true when 𝑝𝑝 = 𝑇𝑇, 𝑞𝑞 = 𝑇𝑇, 𝑟𝑟 = 𝑇𝑇.
• 𝑝𝑝 ∨ 𝑞𝑞 ∨ 𝑟𝑟 ∧ ¬𝑝𝑝 ∨ ¬𝑞𝑞 ∨ ¬𝑟𝑟
Satisfiable: It is true when 𝑝𝑝 = 𝑇𝑇, 𝑞𝑞 = 𝐹𝐹.
• 𝑝𝑝 ∨ ¬𝑞𝑞 ∧ 𝑞𝑞 ∨ ¬𝑟𝑟 ∧ 𝑟𝑟 ∨ ¬𝑝𝑝 ∧ 𝑝𝑝 ∨ 𝑞𝑞 ∨ 𝑟𝑟 ∧ (¬𝑝𝑝 ∨ ¬𝑞𝑞 ∨ ¬𝑟𝑟)
Unsatisfiable. Why?
but .

T 47
Notation

⋁𝑛𝑛𝑗𝑗=1 𝑝𝑝𝑗𝑗 is used for 𝑝𝑝1 ∨ 𝑝𝑝2 ∨ ⋯ ∨ 𝑝𝑝𝑛𝑛

𝑛𝑛
⋀𝑗𝑗=1 𝑝𝑝𝑗𝑗 is used for 𝑝𝑝1 ∧ 𝑝𝑝2 ∧ ⋯ ∧ 𝑝𝑝𝑛𝑛

48
Sudoku
• What is Sudoku?
• A Sudoku puzzle is represented by a 9 × 9 grid made up of nine
3 × 3 subgrids, known as blocks. Some of the 81 cells of the
puzzle are assigned one of the numbers 1, 2, … 9.
• The puzzle is solved by assigning numbers to each blank cell so
that every row, column and block contains each of the nine
possible numbers.

49
Sudoku
• Encoding as a satisfiable problem
• Let 𝑝𝑝(𝑖𝑖, 𝑗𝑗, 𝑛𝑛) denote the proposition that is true when the
number 𝑛𝑛 is in the cell in the 𝑖𝑖 th row and the 𝑗𝑗 th column.
• There are 9 × 9 × 9 = 729 such propositions.
• In the sample puzzle, 𝑝𝑝(5,1,6) is true, but 𝑝𝑝(5, 𝑗𝑗, 6) is false for
𝑗𝑗 = 2, 3, … , 9.

50
Sudoku
• Encoding as a satisfiable problem (cont’d)
• For each cell with a given value, assert 𝑝𝑝(𝑖𝑖, 𝑗𝑗, 𝑛𝑛), when the cell
in row 𝑖𝑖 and column 𝑗𝑗 has the given value.
• Assert that every row contains every number:
⋀9𝑖𝑖=1 ⋀9𝑛𝑛=1 ⋁9𝑗𝑗=1 𝑝𝑝(𝑖𝑖, 𝑗𝑗, 𝑛𝑛)
• Assert that every column contains every number:
⋀9𝑗𝑗=1 ⋀9𝑛𝑛=1 ⋁9𝑖𝑖=1 𝑝𝑝(𝑖𝑖, 𝑗𝑗, 𝑛𝑛)
• Assert that each of the 3 x 3 blocks contain every number:
⋀2𝑟𝑟=0 ⋀2𝑠𝑠=0 ⋀9𝑛𝑛=1 ⋁3𝑖𝑖=1 ⋁3𝑗𝑗=1 𝑝𝑝(3𝑟𝑟 + 𝑖𝑖, 3𝑠𝑠 + 𝑗𝑗, 𝑛𝑛)
• Assert that no cell contains more than one number. Take the
conjunction over all values of 𝑛𝑛, 𝑛𝑛′, 𝑖𝑖, and 𝑗𝑗, where each
variable ranges from 1 to 9 and 𝑛𝑛 ≠ 𝑛𝑛′ :
𝑝𝑝 𝑖𝑖, 𝑗𝑗, 𝑛𝑛 → ¬ 𝑝𝑝 𝑖𝑖, 𝑗𝑗, 𝑛𝑛′
51
Sudoku
• How to solve the Sudoku satisfiable problem?
• We need to find an assignment of truth values to the 729
variables of the form 𝑝𝑝(𝑖𝑖, 𝑗𝑗, 𝑛𝑛) that makes the
conjunction of the assertions true.
• Those variables that are assigned 𝑇𝑇 yield a solution to the
puzzle.

52
How Hard is Satisfiablity?
• Satisfiability can be checked using a truth table.
• Size of the truth table doubles with each variable.
• Therefore, the size of truth table is exponential in the
number of variables.
• In general, no better way is known to test satisfiability
efficiently.
• However, this is too complex even for modern computers
for large problems.
• There has been much work on developing efficient
methods for solving satisfiability problems.

53
54

You might also like