Download - Introduction iii
![Page 1: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/1.jpg)
1
UNIT-3
KNOWLEDGE REPRESENTATION
![Page 2: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/2.jpg)
2
Agents that reason logically(Logical agents)
• A Knowledge based Agent• The Wumpus world environment• Representation, Reasoning and Logic• Logics – An Introduction• Propositional Logic• An Agent for the wumpus world –
Propositional Logic
![Page 3: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/3.jpg)
3
Abilities 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
![Page 4: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/4.jpg)
4
Agents that Reason Logically
• Logical agents have knowledge base, from which they draw conclusions• TELL: provide new facts to agent• ASK: decide on appropriate action
![Page 5: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/5.jpg)
5
Sample: Wumpus World
• Show original wumpus game• goal is to shoot wumpus• example of logical reasoning
• Our version:• Find gold, avoid wumpus, climb back
out of cave
![Page 6: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/6.jpg)
6
A Wumpus Agent
• Agent does not perceive its own location (unlike sample game), but it can keep track of where it has been
• Percepts:• Stench – wumpus is nearby• Breeze – pit is nearby• Glitter – gold is here• Bump – agent has just bumped against a
wall• Scream – agent has heard another player
die
![Page 7: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/7.jpg)
7
Wumpus Agent
• Actuators:• Forward, Turn Left, Turn Right• Grab (gold)• Shoot (shoots arrow forward until hits
wumpus or wall)•agent only has one arrow
• Climb (exit the cave)• Environment:
• 4x4 grid, start at (1,1) facing right
![Page 8: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/8.jpg)
8
Wumpus Agent
• Death• Agent dies if it enters a pit or square
with wumpus• Goal: get gold and climb back out. Don’t
die.• 1000 points for climbing out of cave
with gold• 1 point penalty for each action taken• 10,000 point penalty for death
![Page 9: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/9.jpg)
9
Some complex reasoning examples
• Start in (1,1)• Breeze in (1,2) and (2,1)• Probably a pit in (2,2)
• Smell in (1,1) – where can you go?• Pick a direction – shoot• Walk in that direction• Know where wumpus is
![Page 10: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/10.jpg)
10
Another example solution
No perception 1,2 and 2,1 OK
Move to 2,1
B in 2,1 2,2 or 3,1 P?
1,1 V no P in 1,1
Move to 1,2 (only option)
![Page 11: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/11.jpg)
11
Example solution
S and No S when in 2,1 1,3 or 1,2 has W
1,2 OK 1,3 W
No B in 1,2 2,2 OK & 3,1 P
![Page 12: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/12.jpg)
12
AI Models and Propositional Logic
•The Role of a Model•Represent The Environment•Assimilate Knowledge•Learning•Simulation•Inference
![Page 13: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/13.jpg)
13
Models
• If we are going to create programs that are intelligent, then we need to figure out how to represent models
• They allow us to predict certain things about the future.
![Page 14: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/14.jpg)
14
The Role of a Model
• Represent the environment
• Provide a structure for the assimilation of new knowledge
![Page 15: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/15.jpg)
15
Represent The Environment
• Features in the environment must be represented as features in the model
• They should be able to act in the model just as they do in the environment
• Needs to be able to represent both long term qualities of the environment and short term states.
![Page 16: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/16.jpg)
16
Assimilate Knowledge
• A model of the world allows an agent to organize new information in the context of what it already knows and draw conclusions.
![Page 17: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/17.jpg)
17
Learning
• An AI agent may start ready programmed with knowledge, or it may have to learn it from experience
• The model may change in response to new experiences.
![Page 18: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/18.jpg)
18
Simulation
• Simulate the real environment to test potential actions.
• The model needs to accept simulated sensory input and it needs to feed simulated actions back in without actually making those actions in reality
• It needs an imagination
![Page 19: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/19.jpg)
19
Inference
• Inference is the process of deriving a conclusion based on what is known
![Page 20: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/20.jpg)
20
Representation, Reasoning and logic
![Page 21: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/21.jpg)
21
Logic in general
![Page 22: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/22.jpg)
22
Ontological and Epistemological Assumptions
• ontological assumption :It is understood in connection to the logic of functioning of the agent.
- question is: “What does the agent do?” This means discussing both what the agent is and what its behavior constitutes of.
• Epistemological assumptions: It consider the nature of knowledge.
- question is: “On what knowledge does the agent base its actions?” It is important to discuss the origins of knowledge as well as concepts such as learning and memory.
![Page 23: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/23.jpg)
23
Types of logic
![Page 24: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/24.jpg)
24
The use of logic
• A logic: formal language for representing information, rules for drawing conclusions
• Two kinds of logics:• Propositional Logic
• Represents facts
• First Order Logic • Represents facts, objects, and relations
RQP
)()( xMammalxCatx
![Page 25: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/25.jpg)
25
Entailment
• One thing follows from anotherKB |= (knowledge base entails alpha)
• KB entails sentence if and only if is true in worlds where KB is true.
g. x+y=4 entails 4=x+y
• Entailment is a relationship between sentences that is based on semantics.
![Page 26: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/26.jpg)
26
Propositional Logic
• Represents facts as being either true or false• Formally represented by a letter, e.g. P or Q.• Actually refer to facts about the environment, e.g.
the speed limit in town is 30mph• Single facts can be combined into sentences using
Boolean operators• These sentences, if true, can become facts in the KB.• A KB is said to entail a sentence if it is true in the
KB
![Page 27: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/27.jpg)
27
Logic consists of
• Logical constants: true, false• Proposition symbols: P, Q, R, ...• Logical connectives: & (or ^), , ¬, →, ↔ • Parentheses: ( )• Propositional logic is an extremely simple
representation
![Page 28: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/28.jpg)
28
Basic symbols
• Expressions only evaluate to either “true” or “false.”
• P “P is true”• ¬P “P is false” negation• P V Q “either P is true or Q is true or both” disjunction• P ^ Q “both P and Q are true” conjunction• P => Q “if P is true, the Q is true” implication• P Q “P and Q are either both true or both false”
equivalence
![Page 29: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/29.jpg)
29
For example
![Page 30: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/30.jpg)
30
Syntax rules for propositional logic
• The constants true and false are propositions by themselves.
• A proposition symbol such as P or Q is a proposition by itself.
• Wrapping parentheses around a proposition produces proposition.
![Page 31: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/31.jpg)
31
Ambiguity
The grammar can be ambiguous, for example: P & Q R.
It is best to use parentheses to eliminate ambiguity. When ambiguity is present, we resolve it with
operator precedence:(highest) : ¬ ,& , ,, (lowest) For example: ¬P Q & R ) Sis equivalent to: ((¬ P) (Q & R)) S
![Page 32: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/32.jpg)
32
Limitations of Propositional Logic
1. It is too weak, i.e., has very limited expressiveness:• Each rule has to be represented for each situation:
e.g., “don’t go forward if the wumpus is in front of you” takes 64 rules
2. It cannot keep track of changes:• If one needs to track changes, e.g., where the agent has been
before then we need a timed-version of each rule. To track 100 steps we’ll then need 6400 rules for the previous example.
Its hard to write and maintain such a huge rule-baseInference becomes intractable
![Page 33: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/33.jpg)
33
Inference rules
![Page 34: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/34.jpg)
34
An Agent for the wumpus world – Propositional Logic
![Page 35: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/35.jpg)
35
Example of using logic in Wumpus World
StenchAgent
Start Breeze
• KB contains:
2,2
2,1
1,2
1,1
S
S
S
S
2,2
2,1
1,2
1,1
B
B
B
B
![Page 36: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/36.jpg)
36
KB also contains knowledge of environment
• No stench no wumpus nearby
• Stench wumpus nearby
3,12,22,11,12,13
1,32,21,21,11,22
1,22,11,11,11
:
:
:
WWWWSR
WWWWSR
WWWSR
3,12,22,11,12,14 : WWWWSR
![Page 37: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/37.jpg)
37
We can determine where wumpus is!
• Method 1: Truth table
• At least 14 symbols currently: S1,1, S2,1,
S1,2, S2,2, W1,1, W2,1, W1,2, W2,2, W3,1, W1,3, B1,1,
B2,1, B1,2, B2,2
214 rows, ouch!
![Page 38: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/38.jpg)
38
We can determine where wumpus is!
• Method 2: Inference• Modus Ponens
• And-Elimination
1,22,11,1
1,22,11,11,11 :
WWW
WWWSR
1,22,11,1 WWW
![Page 39: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/39.jpg)
39
Inference continued...
• Modus Ponens and And-Elimination again:
• One more Modus Ponens:
1,32,21,21,1
1,32,21,21,11,22 :
WWWW
WWWWSR
3,12,22,11,1
3,12,22,11,12,14 :
WWWW
WWWWSR
![Page 40: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/40.jpg)
40
Inference continued...
• Unit Resolution:
3,1
2,1
3,12,1
2,2
3,12,22,1
1,1
3,12,22,11,1
W
W
WW
W
WWW
W
WWWW
Wumpus is in (1,3)!!!Shoot it. Shoot where?
![Page 41: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/41.jpg)
41
Determining action based on knowledge
• Propositional logic cannot answer well the question “What action should I take?”
• It only answers “Should I take action X?”
ForwardForwardPA
ShootForwardWA
A
A
3,12,1
3,12,1
![Page 42: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/42.jpg)
42
Propositional logic seems inefficient
• Rule: “Shoot if the wumpus is in front of you”• 16 x 4 = 64 rules for the 4x4 grid
• Ditto for pits
![Page 43: Introduction iii](https://reader035.vdocuments.site/reader035/viewer/2022062513/55511a1cb4c905f10b8b5155/html5/thumbnails/43.jpg)
43
First-order logic to the rescue
• Uses variables to represent generalities• Can reduce rules significantly