Title: Artificial Intelligence 1: logic agents
1Artificial Intelli-gence 1 logic agents
Notes adapted from lecture notes for CMSC 421 by
B.J. Dorr
- Lecturer Tom Lenaerts
- Institut de Recherches Interdisciplinaires et de
Développements en Intelligence Artificielle
(IRIDIA) - Université Libre de Bruxelles
2Standard Logical Equivalences
3Terminology
- A sentence is valid iff its truth value is t in
all interpretations (² f) - Valid sentences true, false, P Ç P
- A sentence is satisfiable iff its truth value is
t in at least one interpretation - Satisfiable sentences P, true, P
- A sentence is unsatisfiable iff its truth value
is f in all interpretations - Unsatisfiable sentences P Æ P, false, true
4Examples
Sentence
Valid?
wealthy ) wealthy
valid
wealthy Ç wealthy
satisfiable, not valid
wealthy ) happy
w t, h f
inverse
satisfiable, not valid
(w ) h) ) (w ) h)
wf, ht w)h t, w ) h f
contrapositive
valid
(w ) h) ) (h )w)
w Ç h Ç (w) h)
valid
w Ç h Ç w Ç h
5Examples
Sentence
Valid?
wealthy ) wealthy
valid
wealthy Ç wealthy
satisfiable, not valid
wealthy ) happy
w t, h f
inverse
satisfiable, not valid
(w ) h) ) (w ) h)
wf, ht w)h t, w ) h f
contrapositive
valid
(w ) h) ) (h )w)
w Ç h Ç (w) h)
valid
w Ç h Ç w Ç h
6Inference
- KB i a
- Soundness Inference procedure i is sound if
whenever KB i a, it is also true that KB ² a - Completeness Inference procedure i is complete
if whenever KB ² a, it is also true that KB i a
7Validity and Inference
((P Ç H) Æ H) ) P
P
H
P
H
(P
H)
H
((P
H)
H) )
P
Ç
Ç
Æ
Ç
Æ
T
T
T
F
T
T
F
T
T
T
F
T
T
F
T
F
F
F
F
T
8Rules of Inference
- a b
- a b
- Valid Rules of Inference
- Modus Ponens
- And-Elimination
- And-Introduction
- Or-Introduction
- Double Negation
- Unit Resolution
- Resolution
9Examples in Wumpus World
- Modus Ponens a ) b, a b(WumpusAhead Æ
WumpusAlive) ) Shoot, (WumpusAhead Æ WumpusAlive)
Shoot - And-Elimination a Æ b a(WumpusAhead Æ
WumpusAlive) WumpusAlive - Resolution a Ç b, b Ç g a Ç g(WumpusDead Ç
WumpusAhead), ( WumpusAhead Ç Shoot)
(WumpusDead Ç Shoot)
10Proof Using Rules of Inference
- Prove A ) B, (A Æ B) ) C, Therefore A ) C
- A ) B A Ç B
- A Æ B ) C (A Æ B) Ç C A Ç B Ç C
- So A Ç B resolves with A Ç B Ç C deriving
A Ç C - This is equivalent to A ) C
11Rules of Inference (continued)
- And-Introduction a1, a2, , an a1 Æ a2 Æ Æ an
- Or-Introduction ai a1 Ç a2 Ç ai
Ç an - Double Negation a a
- Unit Resolution (special case of resolution)a Ç
b Alternatively a ) b b
b a
a
12Wumpus World KB
- Proposition Symbols for each i,j
- Let Pi,j be true if there is a pit in square i,j
- Let Bi,j be true if there is a breeze in square
i,j - Sentences in KB
- There is no pit in square 1,1R1 P1,1
- A square is breezy iff pit in a neighboring
squareR2 B1,1 , (P1,2 Ç P2,1)R3 B1,2 , (P1,1
Ç P1,3 Ç P2,2) - Square 1,1 has no breeze, Square 1,2 has a
breezeR4 B1,1R5 B1,2
13Inference in Wumpus World
- Apply biconditional elimination to R2R6 (B1,1)
(P1,2 Ç P2,1)) Æ ((P1,2 Ç P2,1) ) B1,1) - Apply AE to R6R7 ((P1,2 Ç P2,1) ) B1,1)
- Contrapositive of R7R8 ( B1,1 ) (P1,2 Ç
P2,1)) - Modus Ponens with R8 and R4 ( B1,1)R9 (P1,2
Ç P2,1) - de MorganR10 P1,2 Æ P2,1
14Searching for Proofs
- Finding proofs is exactly like finding solutions
to search problems. - Can search forward (forward chaining) to derive
goal or search backward (backward chaining) from
the goal. - Searching for proofs is not more efficient than
enumerating models, but in many practical cases,
its more efficient because we can ignore
irrelevant propositions
15Full Resolution Rule Revisited
- Start with Unit Resolution Inference Rule
- Full Resolution Rule is a generalization of this
rule - For clauses of length two
16Resolution Applied to Wumpus World
- At some point we determine the absence of a pit
in square 2,2R13 P2,2 - Biconditional elimination applied to R3 followed
by modus ponens with R5R15 P1,1 Ç P1,3 Ç P2,2 - Resolve R15 and R13R16 P1,1 Ç P1,3
- Resolve R16 and R1R17 P1,3
17Resolution Complete Inference Procedure
- Any complete search algorithm, applying only the
resolution rule, can derive any conclusion
entailed by any knowledge base in propositional
logic. - Refutation completeness Resolution can always be
used to either confirm or refute a sentence, but
it cannot be used to enumerate true sentences.
18Conjunctive Normal Form
- Conjunctive Normal Form is a disjunction of
literals. - Example(A Ç B Ç C) Æ (B Ç D) Æ ( A) Æ (B Ç
C)
19CNF Example
- Example (A Ç B) , (C ) D)
- Eliminate ,
- ((A Ç B) ) (C ) D)) Æ ((C ) D) ) (A Ç B)
- Eliminate )
- ( (A Ç B) Ç ( C Ç D)) Æ ( ( C Ç D) Ç (A Ç B)
) - Drive in negations(( A Æ B) Ç ( C Ç D)) Æ
((C Æ D) Ç (A Ç B)) - Distribute( A Ç C Ç D) Æ ( B Ç C Ç D) Æ (C
Ç A Ç B) Æ ( D Ç A Ç B)
20Resolution Algorithm
- To show KB ² a, we show (KB Æ a) is
unsatisfiable. - This is a proof by contradiction.
- First convert (KB Æ a) into CNF.
- Then apply resolution rule to resulting clauses.
- The process continues until
- there are no new clauses that can be added (KB
does not entail a) - two clauses resolve to yield empty clause (KB
entails a)
21Simple Inference in Wumpus World
- KB R2 Æ R4 (B1,1 , (P1,2 Ç P2,1)) Æ B1,1
- Prove P1,2 by adding the negation P1,2
- Convert KB Æ P1,2 to CNF
22Horn Clauses
- Real World KBs are often a conjunction of Horn
clauses - Horn clause
- proposition symbol or
- (conjunction of symbols) ) symbol
- ExampleC Æ (B ) A) Æ (C Æ D ) B)
23Forward Chaining
- Fire any rule whose premises are satisfied in the
KB. - Add its conclusion to the KB until query is
found.
24Forward Chaining Example
P ) Q L Æ M ) P B Æ L ) M A Æ P ) L A Æ B ) L A B
25Forward Chaining Example
P ) Q L Æ M ) P B Æ L ) M A Æ P ) L A Æ B ) L A B
26Forward Chaining Example
P ) Q L Æ M ) P B Æ L ) M A Æ P ) L A Æ B ) L A B
27Forward Chaining Example
P ) Q L Æ M ) P B Æ L ) M A Æ P ) L A Æ B ) L A B
28Forward Chaining Example
P ) Q L Æ M ) P B Æ L ) M A Æ P ) L A Æ B ) L A B
29Forward Chaining Example
P ) Q L Æ M ) P B Æ L ) M A Æ P ) L A Æ B ) L A B
30Forward Chaining Example
P ) Q L Æ M ) P B Æ L ) M A Æ P ) L A Æ B ) L A B
31Forward Chaining Example
P ) Q L Æ M ) P B Æ L ) M A Æ P ) L A Æ B ) L A B
32Backward Chaining
- Motivation Need goal-directed reasoning in order
to keep from getting overwhelmed with irrelevant
consequences - Main idea
- Work backwards from query q
- To prove q
- Check if q is known already
- Prove by backward chaining all premises of some
rule concluding q
33Backward Chaining Example
P ) Q L Æ M ) P B Æ L ) M A Æ P ) L A Æ B ) L A B
34Backward Chaining Example
P ) Q L Æ M ) P B Æ L ) M A Æ P ) L A Æ B ) L A B
35Backward Chaining Example
P ) Q L Æ M ) P B Æ L ) M A Æ P ) L A Æ B ) L A B
36Backward Chaining Example
P ) Q L Æ M ) P B Æ L ) M A Æ P ) L A Æ B ) L A B
37Backward Chaining Example
P ) Q L Æ M ) P B Æ L ) M A Æ P ) L A Æ B ) L A B
38Backward Chaining Example
P ) Q L Æ M ) P B Æ L ) M A Æ P ) L A Æ B ) L A B
39Backward Chaining Example
P ) Q L Æ M ) P B Æ L ) M A Æ P ) L A Æ B ) L A B
40Backward Chaining Example
P ) Q L Æ M ) P B Æ L ) M A Æ P ) L A Æ B ) L A B
41Backward Chaining Example
P ) Q L Æ M ) P B Æ L ) M A Æ P ) L A Æ B ) L A B
42Backward Chaining Example
P ) Q L Æ M ) P B Æ L ) M A Æ P ) L A Æ B ) L A B
43Backward Chaining Example
P ) Q L Æ M ) P B Æ L ) M A Æ P ) L A Æ B ) L A B
44Forward Chaining vs. Backward Chaining
- FC is data-drivenit may do lots of work
irrelevant to the goal - BC is goal-drivenappropriate for problem-solving