Title: Artificial Intelligence: Logic agents
1Artificial Intelligence Logic agents
2AI in the News
- April 6, 2005 GIDEON - Global Infectious Disease
and Epidemiology Network. Media review by Vincent
J. Felitti. JAMA, the Journal of the American
Medical Association ( Vol. 293, No. 13, pages
1674-1675 subscription req'd.). "GIDEON The
Global Infectious Disease and Epidemiology
Network is a superbly designed expert system
created to help physicians diagnose any
infectious disease (337 recognized) in any
country of the world (224 included). The program
was created and has been progressively refined
over more than a decade by a talented group of
Americans, Canadians, and Israelis -
- December 13, 2004 WebMed dispenses advice to
students. By Robyn Shelton. Orlando Sentinel.
"The site -- 24/7 WebMed -- takes students
through questions, judges the severity of their
symptoms and offers guidance for what to do next.
... 'It's decision-support systems, or artificial
intelligence in a way,' said Dr. Scott Gettings,
DSHI medical director. 'The system learns about
you as you flow through and answer questions and
determines how ill you are.' It makes no attempt
to go further and diagnose the patient's illness
-- but gauges the seriousness of the symptoms.
'This is not intended to take the place of human
interaction, but to augment it,' said Dr. Michael
Deichen, associate director of clinical services
at the UCF Student Health Center. 'It really just
helps the students know with what urgency they
should be evaluated.'"
3Thinking Rationally
- Computational models of human thought processes
- Computational models of human behavior
- Computational systems that think rationally
- Computational systems that behave rationally
4Logical Agents
- Reflex agents find their way from Arad to
Bucharest by dumb luck - Chess program calculates legal moves of its king,
but doesnt know that a piece cannot be on 2
different squares at the same time - Logic (Knowledge-Based) agents combine general
knowledge with current percepts to infer hidden
aspects of current state prior to selecting
actions - Crucial in partially observable environments
5Outline
- Knowledge-based agents
- Wumpus world
- Logic in general
- Propositional and first-order logic
- Inference, validity, equivalence and
satifiability - Reasoning patterns
- Resolution
- Forward/backward chaining
6Knowledge Base
- Knowledge Base set of sentences represented in
a knowledge representation language and
represents assertions about the world. - Inference rule when one ASKs questions of the
KB, the answer should follow from what has been
TELLed to the KB previously.
tell
ask
7Generic KB-Based Agent
8Abilities KB agent
- Agent must be able to
- Represent states and actions,
- Incorporate new percepts
- Update internal representation of the world
- Deduce hidden properties of the world
- Deduce appropriate actions
9Description level
- The KB agent is similar to agents with internal
state - Agents can be described at different levels
- Knowledge level
- What they know, regardless of the actual
implementation. (Declarative description) - Implementation level
- Data structures in KB and algorithms that
manipulate them e.g propositional logic and
resolution.
10A Typical Wumpus World
Wumpus
11Wumpus World PEAS Description
12Wumpus World Characterization
- Observable?
- Deterministic?
- Episodic?
- Static?
- Discrete?
- Single-agent?
13Wumpus World Characterization
- Observable? No, only local perception
- Deterministic? Yes, outcome exactly specified
- Episodic? No, sequential at the level of actions
- Static? Yes, Wumpus and pits do not move
- Discrete? Yes
- Single-agent? Yes, Wumpus is essentially a
natural feature.
14Exploring the Wumpus World
- 1,1 The KB initially contains the rules of the
environment. The first percept is none,
none,none,none,none, move to safe cell e.g. 2,1 - 2,1 breeze which indicates that there is a pit
in 2,2 or 3,1, return to 1,1 to try next
safe cell
15Exploring the Wumpus World
- 1,2 Stench in cell which means that wumpus is
in 1,3 or 2,2 - YET not in 1,1
- YET not in 2,2 or stench would have been
detected in 2,1 - THUS wumpus is in 1,3
- THUS 2,2 is safe because of lack of breeze in
1,2 - THUS pit in 1,3
- move to next safe cell 2,2
16Exploring the Wumpus World
- 2,2 move to 2,3
- 2,3 detect glitter , smell, breeze
- THUS pick up gold
- THUS pit in 3,3 or 2,4
-
17What is a logic?
- A formal language
- Syntax what expressions are legal (well-formed)
- Semantics what legal expressions mean
- in logic the truth of each sentence with respect
to each possible world. - E.g the language of arithmetic
- X2 gt y is a sentence, x2y is not a sentence
- X2 gt y is true in a world where x7 and y 1
- X2 gt y is false in a world where x0 and y 6
18Entailment
- One thing follows from another
- KB ?
- KB entails sentence ? if and only if ? is true
in worlds where KB is true. - E.g. xy4 entails 4xy
- Entailment is a relationship between sentences
that is based on semantics.
19Models
- Logicians typically think in terms of models,
which are formally structured worlds with respect
to which truth can be evaluated. - m is a model of a sentence ? if ? is true in m
- M(?) is the set of all models of ?
20Wumpus world model
21Wumpus world model
22Wumpus world model
23Wumpus world model
24Wumpus world model
25Wumpus world model
26Logical inference
- The notion of entailment can be used for logic
inference. - Model checking (see wumpus example) enumerate
all possible models and check whether ? is true. - If an algorithm only derives entailed sentences
it is called sound or truth preserving. - Otherwise it just makes things up.
- i is sound if whenever KB -i ? it is also true
that KB ? - Completeness the algorithm can derive any
sentence that is entailed. - i is complete if whenever KB ? it is also
true that KB-i ?
27Schematic perspective
If KB is true in the real world, then any
sentence ? derived From KB by a sound inference
procedure is also true in the real world.
28Standard Logical Equivalences
29Terminology
- A sentence is valid iff its truth value is t in
all interpretations ( f) - Valid sentences true, Øfalse, P V Ø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
30Examples
Sentence
Valid?
wealthy gt wealthy
valid
Øwealthy V wealthy
satisfiable, not valid
wealthy gt happy
w t, h f
inverse
satisfiable, not valid
(w gt h)gt(Øw gtØh)
wf, ht w gth t, Øw gtØh f
contrapositive
valid
(w gt h) gt (h gtØw)
w V h V (w gt h)
valid
w V h V Øw V h
31Examples
Sentence
Valid?
wealthy gtwealthy
valid
Øwealthy V wealthy
satisfiable, not valid
wealthy gt happy
w t, h f
inverse
satisfiable, not valid
(w gth) gt(Øw gtØh)
wf, ht w gtht, Øw gtØh f
contrapositive
valid
(w gth)gt(Øh gt Øw)
w V h V (w gt h)
valid
w V h V Øw V h
32Inference
- 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
33Validity and Inference
((P V H) ØH) gt P
Ø
P
H
P
H
(P
H)
H
((P
H)
ØH) gt
P
V
V
V
T
T
T
F
T
T
F
T
T
T
F
T
T
F
T
F
F
F
F
T
34Rules of Inference
- a - b
- a b
- Valid Rules of Inference
- Modus Ponens
- And-Elimination
- And-Introduction
- Or-Introduction
- Double Negation
- Unit Resolution
- Resolution
35Examples in Wumpus World
- Modus Ponens a gt b, a - b(WumpusAhead
WumpusAlive) gt Shoot, (WumpusAhead
WumpusAlive) - Shoot - And-Elimination a b - a(WumpusAhead
WumpusAlive) - WumpusAlive - Resolution a V b, Øb V g - a V g(WumpusDead V
WumpusAhead), (ØWumpusAhead V Shoot)
(WumpusDead V Shoot)
36Proof Using Rules of Inference
- Prove A gt B, (A B) gt C, Therefore A gt C
- A gt B - ØA V B
- A B gt C - Ø(A B) V C - ØA V ØB V C
- So ØA V B resolves with ØA V ØB V C deriving
- ØA V C
- This is equivalent to A gt C
37Rules of Inference (continued)
- And-Introduction a1, a2, , an a1 a2 an
- Or-Introduction ai a1 V a2 V ai
V an - Double NegationØØa a
- Unit Resolution (special case of resolution)a V
b Alternatively Øa gt b Øb
Øb a
a
38Wumpus 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 V P2,1)R3 B1,2 ? (P1,1
V P1,3 V P2,2) - Square 1,1 has no breeze, Square 1,2 has a
breezeR4 ØB1,1R5 B1,2
39Inference in Wumpus World
- Apply biconditional elimination to R2R6 (B1,1
gt (P1,2 V P2,1)) ((P1,2 V P2,1) gt B1,1) - Apply AE to R6R7 ((P1,2 V P2,1) gt B1,1)
- Contrapositive of R7R8 (ØB1,1 gt Ø(P1,2 V
P2,1)) - Modus Ponens with R8 and R4 (ØB1,1)R9 Ø(P1,2 V
P2,1) - de MorganR10 ØP1,2 ØP2,1
40Searching 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
41Full Resolution Rule Revisited
- Start with Unit Resolution Inference Rule
- Full Resolution Rule is a generalization of this
rule - For clauses of length two
42Resolution 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 V P1,3 V P2,2 - Resolve R15 and R13R16 P1,1 V P1,3
- Resolve R16 and R1R17 P1,3
43Resolution 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.
44Conjunctive Normal Form
- Conjunctive Normal Form is a disjunction of
literals. - Example(A V B V ØC) (B V D) (Ø A) (BVC)
45CNF Example
- Example (A V B) ? (C gt D)
- Eliminate ?
- ((A V B) gt (C gt D)) ((C gt D) gt (A V B)
- Eliminate gt
- (Ø (A V B) V (ØC V D)) (Ø(ØC V D) V (A V B) )
- Drive in negations((ØA ØB) V (ØC V D)) ((C
ØD) V (A V B)) - Distribute(ØA V ØC V D) (ØB V ØC V D) (C V A
V B) (ØD V A V B)
46Resolution 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)
47Simple Inference in Wumpus World
- KB R2 R4 (B1,1 ? (P1,2 V P2,1)) ØB1,1
- Prove ØP1,2 by adding the negation P1,2
- Convert KB P1,2 to CNF
48Horn Clauses
- Real World KBs are often a conjunction of Horn
clauses - Horn clause
- proposition symbol or
- (conjunction of symbols) gt symbol
- ExamplesC (B gt A) (C D gt B)
49Forward Chaining
- Fire any rule whose premises are satisfied in the
KB. - Add its conclusion to the KB until query is
found.
50Forward Chaining Example
P gt Q L M gt P B L gt M A P gt L A B gt
L A B
51Forward Chaining Example
P gt Q L M gt P B L gt M A P gt L A B gt
L A B
52Forward Chaining Example
P gt Q L M gt P B L gt M A P gt L A B gt
L A B
53Forward Chaining Example
P gt Q L M gt P B L gt M A P gt L A B gt
L A B
54Forward Chaining Example
P gt Q L M gt P B L gt M A P gt L A B gt
L A B
55Forward Chaining Example
P gt Q L M gt P B L gt M A P gt L A B gt
L A B
56Forward Chaining Example
P gt Q L M gt P B L gt M A P gt L A B gt
L A B
57Forward Chaining Example
P gt Q L M gt P B L gt M A P gt L A B gt
L A B
58Backward 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
59Backward Chaining Example
P gt Q L M gt P B L gt M A P gt L A B gt
L A B
60Backward Chaining Example
P gt Q L M gt P B L gt M A P gt L A B gt
L A B
61Backward Chaining Example
P gt Q L M gt P B L gt M A P gt L A B gt
L A B
62Backward Chaining Example
P gt Q L M gt P B L gt M A P gt L A B gt
L A B
63Backward Chaining Example
P gt Q L M gt P B L gt M A P gt L A B gt
L A B
64Backward Chaining Example
P gt Q L M gt P B L gt M A P gt L A B gt
L A B
65Backward Chaining Example
P gt Q L M gt P B L gt M A P gt L A B gt
L A B
66Backward Chaining Example
P gt Q L M gt P B L gt M A P gt L A B gt
L A B
67Backward Chaining Example
P gt Q L M gt P B L gt M A P gt L A B gt
L A B
68Backward Chaining Example
P gt Q L M gt P B L gt M A P gt L A B gt
L A B
69Backward Chaining Example
P gt Q L M gt P B L gt M A P gt L A B gt
L A B
70Forward Chaining vs. Backward Chaining
- FC is data-drivenit may do lots of work
irrelevant to the goal - BC is goal-drivenappropriate for problem-solving