Download Propositional Logic: Inference Problem & Resolution Algorithm - Prof. Milos Hauskrecht and more Exams Computer Science in PDF only on Docsity!
CS 1571 Intro to AI M. Hauskrecht
CS 1571 Introduction to AI
Lecture 15
Milos Hauskrecht [email protected] 5329 Sennott Square
Propositional logic
Announcements
Midterm exam:
- Wednesday, October 25, 2006 Course web page: http://www.cs.pitt.edu/~milos/courses/cs1571/
CS 1571 Intro to AI M. Hauskrecht Logical inference problem Logical inference problem :
- Given:
- a knowledge base KB (a set of sentences) and
- a sentence (called a theorem) ,
- Does a KB semantically entail? In other words: In all interpretations in which sentences in the KB are true, is also true? Question: Is there a procedure (program) that can decide this problem in a finite number of steps? Answer: Yes. Logical inference problem for the propositional logic is decidable. KB |= α?
α
Solving logical inference problem In the following: How to design the procedure that answers: Three approaches:
- Truth-table approach
- Inference rules
- Conversion to the inverse SAT problem
- Resolution-refutation KB |= α?
CS 1571 Intro to AI M. Hauskrecht α Truth-table approach Problem:
- We need to check all possible interpretations for which the KB is true (models of KB) whether is true for each of them Truth table :
- enumerates truth values of sentences for all possible interpretations (assignments of True/False to propositional symbols) Example: α P Q (^) P ∨Q True True True True False False False False False True True True True False False False KB |= α? P ⇔ Q True False False True KB (P ∨ ¬Q)∧ Q Inference rules approach. Problem with the truth table approach:
- the truth table is exponential in the number of propositional symbols (we checked all assignments)
- KB is true on only a smaller subset How to make the process more efficient? Solution: check only entries for which KB is True. This is the idea behind the inference rules approach Inference rules:
- Represent sound inference patterns repeated in inferences
- Can be used to generate new (sound) sentences from the existing ones KB |= α?
CS 1571 Intro to AI M. Hauskrecht Inference rules for logic
- Modus ponens
- If both sentences in the premise are true then conclusion is true.
- The modus ponens inference rule is sound.
- We can prove this through the truth table.
B
A ⇒ B, A premise conclusion A B A ⇒ B False False True False True True True True True False False True **Example. Inference rules approach. KB: Theorem:
3.**
P ∧ Q
P ⇒ R
(Q ∧ R)⇒ S
P ∧ Q P ⇒ R (Q ∧ R)⇒S S
**CS 1571 Intro to AI M. Hauskrecht Example. Inference rules approach. KB: Theorem:
5.**
6. From 1 and And-elim
P ∧ Q
P ⇒ R
(Q ∧ R)⇒ S P
R
Q
P ∧ Q P ⇒ R (Q ∧ R)⇒S S
i n A
A 1 ∧ A 2 ∧ A
**Example. Inference rules approach. KB: Theorem:
6.**
7. From 5,6 and And-introduction
P ∧ Q
P ⇒ R
(Q ∧ R)⇒ S P
R
Q
( Q ∧R )
P ∧ Q P ⇒ R (Q ∧ R)⇒S S
n n A A A
A A A
1 ∧^2 ∧
**CS 1571 Intro to AI M. Hauskrecht Example. Inference rules approach. KB: Theorem:
7.**
8. From 7,3 and Modus ponens
P ∧ Q
P ⇒ R
(Q ∧ R)⇒ S S
P
R
Q
( Q ∧R )
P ∧ Q P ⇒ R (Q ∧ R)⇒S S
Proved: S
B
A ⇒B, A
**Example. Inference rules approach. KB: Theorem:
3.**
**4. From 1 and And-elim
- From 2,4 and Modus ponens
- From 1 and And-elim
- From 5,6 and And-introduction
- From 7,3 and Modus ponens**
P ∧ Q
P ⇒ R
(Q ∧ R)⇒ S S
P
R
Q
( Q ∧R )
P ∧ Q P ⇒ R (Q ∧ R)⇒S S
Proved: S
CS 1571 Intro to AI M. Hauskrecht Normal forms Sentences in the propositional logic can be transformed into one of the normal forms. This can simplify the inferences. Normal forms used: Conjunctive normal form (CNF)
- conjunction of clauses (clauses include disjunctions of literals) Disjunctive normal form (DNF)
- Disjunction of terms (terms include conjunction of literals)
( A ∨B)∧(¬A∨¬C∨D)
( A ∧¬B)∨(¬A∧C)∨(C∧¬D )
Conversion to a CNF Assume:
- Eliminate
- Reduce the scope of signs through DeMorgan Laws and double negation
- Convert to CNF using the associative and distributive laws and
¬( ¬A ∨B)∨(¬C∨A)
( A ∧¬B)∨(¬C∨A )
¬( A ⇒B)∨(C⇒ A )
( A ∨¬C∨A)∧(¬B∨¬C∨A )
( A ∨¬C)∧(¬B∨¬C∨A )
CS 1571 Intro to AI M. Hauskrecht Satisfiability (SAT) problem Determine whether a sentence in the conjunctive normal form (CNF) is satisfiable (I.e. can evaluate to true) It is an instance of a constraint satisfaction problem:
- Variables:
- Propositional symbols (P, R, T, S)
- Values: True, False
- Constraints:
- Every conjunct must evaluate to true, at least one of the literals must evaluate to true
- All techniques developed for CSPs can be applied to solve the logical inference problem. Why?
( P ∨Q∨¬R)∧(¬P∨¬R∨S)∧(¬P∨Q∨¬T) K
Inference problem and satisfiability Inference problem:
- we want to show that the sentence is entailed by KB Satisfiability:
- The sentence is satisfiable if there is some assignment (interpretation) under which the sentence evaluates to true Connection: Consequences:
- inference problem is NP-complete
- programs for solving the SAT problem can be used to solve the inference problem α KB |= α if and only if (KB ∧¬ α) is unsatisfiable
CS 1571 Intro to AI M. Hauskrecht Resolution algorithm Algorithm:
- Convert KB to the CNF form;
- Apply iteratively the resolution rule starting from (in CNF form)
- Stop when :
Contradiction (empty clause) is reached:
- No more new sentences can be derived
A ,¬A→O
Example. Resolution. KB: Theorem: Step 1. convert KB to CNF:
- KB: Step 2. Negate the theorem to prove it via refutation Step 3. Run resolution on the set of clauses
P ∧ Q
S
P Q
( P ∧ Q)∧(P⇒R)∧[(Q∧R)⇒S ] S
P ∧Q
P ⇒ R ( ¬P ∨ R)
(Q ∧ R)⇒ S ( ¬Q ∨¬R∨S) ( ¬ P ∨ R ) (^ ¬Q^ ∨¬R∨S) ¬ S
P Q ( ¬ P ∨ R) ( ¬ Q ∨¬R∨S) ¬S
CS 1571 Intro to AI M. Hauskrecht Example. Resolution. KB: (^ P^ ∧^ Q)∧(P⇒R)∧[(Q∧R)⇒S] Theorem: S
P Q ( ¬ P ∨ R) ( ¬ Q ∨¬R∨S) ¬S
Example. Resolution. KB: (^ P^ ∧^ Q)∧(P⇒R)∧[(Q∧R)⇒S] Theorem: S
P Q ( ¬ P ∨ R) ( ¬ Q ∨¬R∨S) ¬S
R
Example. Resolution. KB: Theorem: S
( P ∧ Q)∧(P⇒R)∧[(Q∧R)⇒S ] S
P Q ( ¬ P ∨ R) ( ¬ Q ∨¬R∨S) ¬S
R (^ ¬R^ ∨S)
Contradiction Proved: S