Transcript Document

Princess Nora University
Faculty of Computer & Information Systems
ARTIFICIAL
INTELLIGENCE (CS 461D)
Dr. Abeer Mahmoud
Computer science Department
Dr.Abeer Mahmoud
(CHAPTER-7)
LOGICAL AGENTS
Dr.Abeer Mahmoud
3
Some General Representations
Logical Representations
Production Rules
Semantic Networks
1.
2.
3.
•
4.
Conceptual graphs, frames, scripts
Description Logics (not covered in this course )
Dr.Abeer Mahmoud
4
Non-Logical Representations?
Dr.Abeer Mahmoud
5
Non-Logical Representations?
Production rules
2. Semantic networks
1.
• Conceptual graphs
• Frames
• Scripts
Dr.Abeer Mahmoud
6
Production Rules
Dr.Abeer Mahmoud
7
Production Rules
• Rule set of <condition,action> pairs
• “if condition then action”
• Match-resolve-act cycle
• Match: Agent checks if each rule’s condition holds
• Resolve:
• Multiple production rules may fire at once (conflict set)
• Agent must choose rule from set (conflict resolution)
• Act: If so, rule “fires” and the action is carried out
Dr.Abeer Mahmoud
8
Rules
If Animal has hair
And Animal produces milk
Then animal is a mammal
IF
THEN
animal has feather,
animal is bird.
IF
animal flies,
AND
animal lays eggs,
THEN
.
animal is bird.
Dr.Abeer Mahmoud
9
IF
the interest-rate out look is down,
THEN do not buy money-market funds..
Rules-of-Thumb
• An apple a day keeps the doctor away .
• A stitch in time saves nine .
Dr.Abeer Mahmoud
10
Fuzzy Rules
IF
you’re old,
THEN you have owned several homes .
IF
you have owned several homes THEN
you have had numerous headaches .
IF
THEN
the interest-rate out look is up and the risk
you can accept is low,
buy a conservative money-market
fund .
Dr.Abeer Mahmoud
11
IF
THEN
the interest-rate out look is up and the risk
you can accept is high,
buy aggressive money-market fund .
Rules with certainty factors
IF
the patient is sneezing,
AND
has a runny nose,
AND
has watery eyes,
THEN
the patient has cold, CF=0.5 .
Dr.Abeer Mahmoud
12
Production Rules Example
• IF (at bus stop AND bus arrives)
THEN action(get on the bus)
• IF (on bus AND not paid AND have oyster card)
THEN action(pay with oyster) AND add(paid)
• IF (on bus AND paid AND empty seat)
THEN sit down
Dr.Abeer Mahmoud
Inference Engine
 The inference engine is a generic control mechanism for
navigating through and manipulating knowledge and deduce
results in an organized manner
 It applies a specific task take data and drive conclusions
 The inference engine is the part of the system that chooses
which facts and rules to apply when trying to solve the user’s
query
Dr.Abeer Mahmoud
Inference Engine
 The forward chaining , backward chaining and tree search
are some of the techniques used for drawing inferences from
the knowledge base
Inferences from rules
1. Goal driven = backward chaining
2. Data driven= forward chaining
Dr.Abeer Mahmoud
15
 Goal driven or backward chaining
An inference technique which uses IF-THEN rules to repetitively
break a goal into smaller sub-goals which are easier to prove
Dr.Abeer Mahmoud
Example : KB contains Rule set :
Rule 1: if A and C then F
Rule 2: if A and
E then G
Rule 3: if B
then E
Rule 4: if G
then D
Dr.Abeer Mahmoud
Dr.Abeer Mahmoud
 Data driven or Forward chaining
An inference technique which uses IF-THEN rules to deduce a
problem solution from initial data
Dr.Abeer Mahmoud
Dr.Abeer Mahmoud
Dr.Abeer Mahmoud
21
Advantages of Rules
• Rules are easy to understand
• Inference and explanation are easy to derive
• Modifications and maintenance are relatively easy
• Uncertainty is easily combined with rules
• Each rule is usually independent of all others
Dr.Abeer Mahmoud
22
Graphical Representation
Dr.Abeer Mahmoud
23
Graphical Representation
• Graphs easy to store in a computer
• To be of any use must impose a formalism
• Jason is 15, Bryan is 40, Arthur is 70, Jim is 74
• How old is Julia?
Dr.Abeer Mahmoud
24
Semantic Networks
• Because the syntax is the same
• We can guess that Julia’s age is similar to Bryan’s
• Formalism imposes restricted syntax
Dr.Abeer Mahmoud
25
Semantic Networks
• Graphical representation (a graph)
• Links indicate subset, member, relation, ...
• Equivalent to logical statements (usually FOL)
• Easier to understand than FOL?
• Example: natural language understanding
• Sentences with same meaning have same graphs
• e.g. Conceptual Dependency Theory (Schank)
Dr.Abeer Mahmoud
26
Semantic Networks
In this scheme , knowledge is represented in terms of objects
and relationships between objects
The objects are denoted as nodes of a graph. The relationship
between two objects are denoted as a link between the
corresponding two nodes
The most common form of semantic network uses the link
between nodes to represent IS-A and HAS relationships
between objects
Dr.Abeer Mahmoud
27
Example of semantic network
Dr.Abeer Mahmoud
28
ANIMAL
BIRD
MAMMAL
CARNIVORE
HAIR
MILK
PRODUCTION
LAYS
EGGS
FEATHERS
FLYS
FORWARD
EYES
FORWARD
TEETH
EATS
MEAT
CLAWS
A Semantic network for animal kingdom
Dr.Abeer Mahmoud
Example of Semantic Network
covering
head
part of
animal
skin
fish
is a
swim
travel
travel
fly
is a
feathers
wings
covering
color
ostrich
travel
walk
red
has
bird
sound
is a
part of
is a
value
is a
travel
is a
opus
robin
is a
penguin
sound
canary
is a
has
color
value
brown
has
color
value
yellow
sing
tweety
has
color
value
white
Dr.Abeer Mahmoud
30
Frames
o In this technique, knowledge is decomposed into highly
modular pieces called frames, which are generalized
record structures
o Knowledge consist of concepts, situation, attributes of
concepts , relationships between concepts , and
procedure to handle relationships
 Each concept may be represented as a separate frame
 The attributes, the relationships between concepts and the
procedures are allotted to slots in a frame
 The contents of a slot may be of any data type –numbers, strings,
functions or procedures and so on
 The frames may be linked to other frames, providing the same
kind of inheritance as that provided by a semantic network
Dr.Abeer Mahmoud
31
Frame Representations
• Semantic networks where nodes have structure
• Frame with a number of slots (age, height, ...)
• Each slot stores specific item of information
• When agent faces a new situation
• Slots can be filled in (value may be another frame)
• Filling in may trigger actions
• May trigger retrieval of other frames
• Inheritance of properties between frames
• Very similar to objects in OOP
Dr.Abeer Mahmoud
Frames
• Basic frame design
Frame Name:
Object1
Class:
Object2
Properties:
Property1
Value1
Property2
Value2
***
***
***
***
Dr.Abeer Mahmoud
33
Example: Frame Representation
Dr.Abeer Mahmoud
34
Frame Representation of the “animal kingdom”
MAMMAL
A-KIND-OF
CARNIVORE
ANIMAL
A-KIND-OF
APPEARANCE
SKIN COVER
HAIR
ANIMAL
BIRD
A-KIND-OF
ANIMAL
SKIN COVER
FEATHER
FORWARD
EYES
POINTED
TEETH
ACTIVITY
PRODUCES
MILK
APPENDGES
ACTIVITY
CLAWS
EATS
MEAT
ACTIVITY
FLY
LAYS EGGS
Dr.Abeer Mahmoud
Example of Frame Based System
truck
class: vehicle
basket
dimensions
2*3*1.5
material
tin
producer
reg.
number
producer
model
model
owner
owner
superclass:
vehicle
reg. number
tonnage
part of
bask
et
John’s car
car
class: vehicle
class: car
reg. number
producer
model
owner
number of
doors
horse-power
4
reg. number
LV97
producer
BMW
model
520
owner
John
John
number of
doors
2
age
22
length
of driving
2
Dr.Abeer
Mahmoud
36
Chair frame
Dr.Abeer Mahmoud
37
Flexibility in Frames
• Slots in a frame can contain
• Information for choosing a frame in a situation
• Relationships between this and other frames
• Procedures to carry out after various slots filled
• Default information to use where input is missing
• Blank slots: left blank unless required for a task
• Other frames, which gives a hierarchy
Dr.Abeer Mahmoud
38
Script
Dr.Abeer Mahmoud
39
• Script Concept :
• Scripts accounted for information about Stereotypical events
• Eg – going to restaurant
taking bus
Visiting the dentist
• Scripts are inherently episodic in origin
• It arise fro experience and are applied to understand new
events
Dr.Abeer Mahmoud
40
• The acquisition of script is the result of repeated exposure to
a given situation
• Ex: children learn the restaurant script by going to restaurant
over and over again
• As a psychological theory of memory, scripts suggested that
people would remember an event in terms of its associated
script
Dr.Abeer Mahmoud
41
RESTAURANT SCRIPT
Example of
a script
Track :
Roles:
Fast food restaurent
Customer ©
Server (S)
Props
Counter
Tray
Food
Mony
Napkins
Salt/pepper/catsup/straws
Entry Conditions: Customer is hungry
Customer has money
Scene 1:entry
Customer park car
Customer enters restaurant
Customer waits in line at the counter
Customer reads the menu on the wall and makes a decision about what to order
Dr.Abeer Mahmoud
42
Scene 2: order
Customer give order to server
Server fills order by putting food on tray
Customer pays server
Scene 3: eating
Customer gets napkins, straws, salt
Customer takes tray on unoccupied table
Customer eats food quickly
Scene 4: exit
Customer cleans up table
Customer discard trash
Customer leave restaurant
Customer drives away
Dr.Abeer Mahmoud
43
Results :
• Customer no longer hungry
• Customer has less money
• Customer is happy
• Customer is unhappy
• Customer is too full
• Customer has upset stomach
Options
Dr.Abeer Mahmoud
44
Knowledge Representation
Scheme
Advantages
Production •simple syntax
Rules
•easy to understand
simple interpreter
•highly modular
•flexible (easy to add
or modify)
Semantic
Networks
•easy to follow
hierarchy easy to trace
association
•flexible
Disadvantages
•hard to follow hierarchy
•inefficient for large systems
•not all knowledge can be
expressed as rules
•poor at representing structure
descriptive knowledge
•meaning attached to nodes
might be ambiguous
•exception handling is
difficult
Dr.Abeer Mahmoud
45
Knowledge Representation
Scheme
Advantages
Disadvantages
Frames
•expressive power
•difficult to Program
•easy to setup slots for new
•difficult for inference
properties and relations
•lack of software
•easy to include default
information and detect missing
values
Formal
Logic
•facts asserted independently of
use
•assurance that all and only
valid consequences are asserted
(precision)
•Completeness
•separation of
representation and
processing
•inefficient with large
data sets
•very slow with large
knowledge base
Dr.Abeer Mahmoud
46
Thank you
End of
Chapter 7part2
Dr.Abeer Mahmoud