Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Introduction To Artificial Intelligence: Chapter 3: Kwoledge Representation and Reasoning (1) Logic Agents

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

Introduction to

Artificial Intelligence
Chapter 3: Kwoledge
Representation and Reasoning
(1) Logic Agents
Nguyễn Hải Minh, Ph.D
nhminh@fit.hcmus.edu.vn

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 1


Outline
1. Knowledge-Based Agents
2. The Wumpus World

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 2


Knowledge-Based Agents
❑Human intelligence is achieved not purely by reflex
mechanisms but by reasoning that operate on internal
representation of knowledge

Reasoning

In AI, this approach to intelligence is embodied in


knowledge-based agents.
7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 3
Knowledge-Based Agents
❑Problem-solving agents in chapter 2:
o State-space model:
• Limited knowledge
• Inflexible
• Cannot make deduction
o Constraint satisfaction problem solver:
• Enabling some parts of the agent to work in a
domain-independent way
• More efficient algorithms
• Can be developed to logical agents
7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 4
Knowledge-Based Agents
❑Knowledge-based agents:
o Can combine and recombine information
o Can learn new knowledge about the environment
o Can adapt the changes in the environment by
updating the relevant knowledge

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 5


Knowledge-Based Agents
❑KB = Knowledge base
o A set of sentences or facts (in a logic language)
❑Inference
o Derive (infer) new sentences from old ones
❑A simple model for reasoning:

New
Evidence
evidence
perceives
KB
infers
Agent
7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 6
Knowledge-Based Agents
❑A simple model for reasoning:
o KB = {A → (B or C)}, then given A and Not C, we can
infer that B is true
o B is now added to the KB even though it is not
explicitly asserted

A, Not C B
perceives

KB:
infers A → (B or C)
Agent A, Not C, B
7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 7
A generic knowledge-based agent

Inference mechanisms are hidden


inside TELL and ASK

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 8


A generic knowledge-based agent
❑Declarative approach
o Empty KB → TELL the agent the facts (sentences) one by
one until it knows how to operate in its environment.
❑Procedural approach
o Encode desired behaviors directly as program code.
❑Combine approach
→ Partially autonomous
❑Learning approach (chapter 4)
o Provide a knowledge-based agent with mechanisms that
allow it to learn for itself.
→ Fully autonomous
7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 9
The Wumpus World

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 10


The Wumpus World - PEAS
❑Performance measure
o +1000 for climbing out of the cave with gold
o -1000 for death
o -1 per step, -10 for using the arrow
o Ends when agent dies or climbs out of the cave
❑Environment
o A 4×4 grid of rooms
o Agent starts in the square [1,1], facing to the right
o Gold and Wumpus locations are random
o Each square can be a pit, with probability 0.2

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 11


The Wumpus World - PEAS
❑Actuators:
o Move forward, TurnLeft/Right 90o
o Grab, Shoot, Climb
❑Sensors: 5 sensors to perceive:
o Stench
o Breeze
o Glitter Percept: [Stench, Breeze, None, None, None]
o Bump
o Scream

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 12


The Wumpus World - Characterization
❑Fully Observable: No – only local perception
❑Deterministic: Yes – outcomes 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

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 13


Exploring a wumpus world

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 14


Exploring a wumpus world

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 15


Exploring a wumpus world

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 16


Exploring a wumpus world

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 17


Exploring a wumpus world

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 18


Exploring a wumpus world

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 19


Exploring a wumpus world

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 20


Exploring a wumpus world

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 21


Logic in general
❑Logics are formal languages for representing
information such that conclusions can be drawn
❑Syntax defines the sentences in the language
❑Semantics define the "meaning" of sentences
o i.e., define truth of a sentence in a specific world
❑E.g., the language of arithmetic
o x+2 ≥ y is a sentence; x2+y > {} is not a sentence
o x+2 ≥ y is true iff the number x+2 is no less than
the number y
o x+2 ≥ y is true in a world where x = 7, y = 1
o x+2 ≥ y is false in a world where x = 0, y = 6
7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 22
Entailment
❑Entailment means that one thing follows from
another:
KB ╞ α

❑Knowledge base KB entails sentence α if and


only if α is true in all worlds where KB is true
o E.g., the KB containing “Apple is red” and “Tomato is
red” entails “Either the apple or the tomato is red”
o E.g., x+y = 4 entails 4 = x+y
o Entailment is a relationship between sentences (i.e.,
syntax) that is based on semantics

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 23


Models
❑Logicians typically think in terms of models, which are
formally structured worlds with respect to which truth
can be evaluated
❑We say m is a model of a sentence α if α is true in m
❑M(α) is the set of all models of α
❑Then KB ╞ α iff M(KB)  M(α)
o E.g. KB = Apple and tomato are red
o α = Apple is red

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 24


Entailment in the wumpus world
Situation after detecting
nothing in [1,1], moving right,
breeze in [2,1]

Consider possible models for


KB assuming only pits

3 Boolean choices  8
possible models

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 25


Wumpus models

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 26


Wumpus models

❑KB = wumpus-world rules + observations

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 27


Wumpus models

❑KB = wumpus-world rules + observations


❑α1 = "[1,2] is safe", KB ╞ α1, proved by model checking

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 28


Wumpus models

❑KB = wumpus-world rules + observations


❑α2 = "[2,2] is safe", KB ╞ α2
7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 29
Inference
❑KB ├i α = sentence α can be derived from KB by
procedure i
❑Soundness: i is sound if whenever KB ├i α, it is also true
that KB╞ α
❑Completeness: i is complete if whenever KB╞ α, it is also
true that KB ├i α
❑Preview: we will define a logic (first-order logic) which is
expressive enough to say almost anything of interest, and
for which there exists a sound and complete inference
procedure.
❑That is, the procedure will answer any question whose
answer follows from what is known by the KB.

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 30


No independent access to the world
• The reasoning agent often gets its knowledge about the
facts of the world as a sequence of logical sentences and
must draw conclusions only from them without
independent access to the world.
• Thus it is very important that the agent’s reasoning is
sound!

7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS 31


Summary
❑Intelligent agents need knowledge about the world for
making good decisions.
❑The knowledge of an agent is stored in a knowledge base in
the form of sentences in a knowledge representation
language.
❑ A knowledge-based agent needs a knowledge base and an
inference mechanism. It operates by storing sentences in its
knowledge base, inferring new sentences with the inference
mechanism, and using them to deduce which actions to take.
❑A representation language is defined by its syntax and
semantics, which specify the structure of sentences and how
they relate to the facts of the world.
❑The interpretation of a sentence is the fact to which it refers.
If this fact is part of the actual world, then the sentence is true.

32
7/12/2020 Nguyễn Hải Minh @ FIT - HCMUS

You might also like