Download as pdf or txt
Download as pdf or txt
You are on page 1of 35

COMP210: Articial Intelligence

Lecture 20. Towards efcient propositional reasoning


Boris Konev

http://www.csc.liv.ac.uk/konev/COPM210/

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 1/2

Overview
Entailment, satisability, and validity. Conjunctive normal form. Satisability as a search problem.

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 2/2

Propositional Logic for KR


Given a knowledge base KB and a property , check if KB |= Use truth tables Prove from KB Relate with validity and satisability

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 3/2

Validity and Satisability


A formula is said to be valid (or a tautology) iff it is true under every interpretation. A formula is said to be satisable (or consistent) iff it is true under at least one interpretation. A formula is said to be unsatisable (or inconsistent or contradictory) iff it is not made true under any interpretation. If a formula is a valid then is unsatisable.

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 4/2

Validity, Satisability, and Entailment


Implications for Knowledge Representation Deduction Theorem: KB |= if and only if (KB ) is valid Or,. . . KB |= if and only if (KB ) is unsatisable
reductio ad absurdum

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 5/2

Satisability Checking
Given a knowledge base KB and a property , check if (KB ) is satisable If not satisable, is implied by KB Otherwise, an interpretation of propositions would give us a countermodel

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 6/2

Countermodel (1)
To check if
(hot smoky re) (alarm_beeps smoky) |= (alarm_beeps switch_on_sprinklers) ?

(re switch_on_sprinklers)

we form
(hot smoky re) (alarm_beeps smoky) (re switch_on_sprinklers) (alarm_beeps switch_on_sprinklers)

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 7/2

Countermodel (2)
But
(hot smoky re) (alarm_beeps smoky) (re switch_on_sprinklers) (alarm_beeps switch_on_sprinklers)

is true under the interpretation I :


I(hot) = F I(smoky) = T I(re) = F I(alarm_beeps) = T I(switch_on_sprinklers) = F
Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 8/2

Example: Truth Tables and Satisability


Using a truth table show whether
(p q) (q p)

is a tautology, consistent or inconsistent.


p T q T (p q) (q p) (p q) (q p)

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 9/2

Example: Truth Tables and Satisability


Using a truth table show whether
(p q) (q p)

is a tautology, consistent or inconsistent.


p T q T (p q) (q p) (p q) (q p) T

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 9/2

Example: Truth Tables and Satisability


Using a truth table show whether
(p q) (q p)

is a tautology, consistent or inconsistent.


p T q T (p q) (q p) (p q) (q p) T T

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 9/2

Example: Truth Tables and Satisability


Using a truth table show whether
(p q) (q p)

is a tautology, consistent or inconsistent.


p q (p q) (q p) (p q) (q p) T T T

T T T F

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 9/2

Example: Truth Tables and Satisability


Using a truth table show whether
(p q) (q p)

is a tautology, consistent or inconsistent.


p q (p q) (q p) (p q) (q p) T F T T T T

T T T F F T

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 9/2

Example: Truth Tables and Satisability


Using a truth table show whether
(p q) (q p)

is a tautology, consistent or inconsistent.


p T T F F q T F T F (p q) (q p) (p q) (q p) T F T T T F T T T

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 9/2

Example: Truth Tables and Satisability


Using a truth table show whether
(p q) (q p)

is a tautology, consistent or inconsistent.


p T T F F q T F T F (p q) (q p) (p q) (q p) T F T T T T F T T T T T

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 9/2

Exercises
Complete the truth table for ((p q) (q p))
p T T F F q T F T F (p q) (q p) ((p q) (q p))

Show that the formula (p q) r is satisable. Find an interpretation which satises (p q) (r s). Show p p is unsatisable. Show p p is valid.
Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 10/2

Efciency
A truth table contains 2n rows Its construction requires 2n steps. . . Can we do better than that? Not really: Theory says that this is a very hard problem In practice, not so bad But we have to transform (KB ) into a normal form

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 11/2

Equivalent Formulae
Two formulae A and B are equivalent, written A B iff A and B have the same truth values for every interpretation. Show
(p q) (p q).

Draw up a truth table for (p q) and (p q) and check their truth values are the same.
p T q T pq p p q

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 12/2

Equivalent Formulae
Two formulae A and B are equivalent, written A B iff A and B have the same truth values for every interpretation. Show
(p q) (p q).

Draw up a truth table for (p q) and (p q) and check their truth values are the same.
p T T F F
Boris Konev

q T F T F

pq T F T T

p p q F F T T T F T T

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 12/2

Equivalent Transformations I
Where A, B and C are propositions or propositional formulae and T and F are true and false respectively. Idempotent laws
AA A AA A

Associative laws
(A B) C A (B C) (A B) C A (B C)

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 13/2

Equivalent Transformations II
Commutative laws
AB BA AB BA

Distributive laws
A (B C) (A B) (A C) A (B C) (A B) (A C)

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 14/2

Equivalent Transformations III


Identity laws
AT AF AF AT A A F T

Complement laws
A A A A (A) T F
Boris Konev

F T A F T

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 15/2

Equivalent Transformations IV
de Morgans laws
(A B) A B (A B) A B

laws for and


A B A B A B (A B) (B A)

We can use these laws to simplify expressions and to prove equivalences.

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 16/2

Example
Simplify the following expression.
(P Q) (P Q) (P Q) (P Q)

given de Morgans laws Complement laws

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 17/2

Example
Prove the following equivalence
((P Q) P ) F ((P Q) P ) ((P Q) P ) ((Q P ) P ) (Q (P P )) (Q T ) T F

given de Morgans laws Commutative laws Associative laws Complement laws Complement laws Complement laws

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 18/2

Exercise
Show (P Q) P Q

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 19/2

Normal Forms
It is often useful to transform formulae into normal forms. These are logically equivalent formulae but have syntactically different forms that may be more suitable for reasoning with. Recall two formulae A and B are equivalent, written A B if and only if the truth values for A and B are the same for each interpretation.

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 20/2

Negation Normal Form


A formula is in negation normal form if negations appear only in front of propositions and the only operators are , , and . First remove and operators. Then apply de Morgans laws and remove double negations (complement laws). Initial Formula AB AB (A B) (A B) A (A B)
Boris Konev

Final Formula (A B) (B A) A B A B A B A A B

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 21/2

Example
((p q) r) p ((p q) r) p ((p q) r) p ((p q) r) p ((p q) r) p ((p q) r) p ((p q) r) p

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 22/2

Conjunctive Normal Form


A formula is in Conjunctive Normal Form if it is of the form A1 A2 . . . Ak where each Ai is a disjunction of propositions or their negations.
Example

(p q) r (p r s) is in CNF. (p q) r (p r s) is not in CNF. (p q) r (p (r s)) is not in CNF.

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 23/2

Translation into CNF


To translate into CNF rst translate into NNF. Apply distribution laws or commutativity laws until in the correct form. Initial Formula A (B C) (B C) A AB AB Final Formula (A B) (A C) (B A) (C A) BA BA

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 24/2

Example
Translate ((p q) r) p into CNF. We rst translate into NNF and obtain ((p q) r) p.
((p q) r) p ((p q) p) (r p) (p q p) (r p)

Note the latter could be transformed into


(p q) (r p)

which is an equivalent formula also in CNF.

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 25/2

Normal Forms Exercise


Transform the following into NNF and CNF.
((p q) r) (q) p

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 26/2

Satisability as a Search Problem


States are partial assignmentssome propositions get values, some are possibly unassigned Operations are deciding whether a (yet unassigned) proposition is true or false Initial state: empty partial assignment Goal state: an assignment making the formula true

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 27/2

Summary
Validity, Satisability, and Entailment. Dened and examined equivalent formulae. Dened negation normal form and conjunctive normal form. Weve shown how to translate into these normal forms. In the next lecture we will use one of these normal forms as part of a proof method.

Boris Konev

COMP210: Articial Intelligence. Lecture 20. Towards efcient propositional reasoning p. 28/2

You might also like