Knowledge Representation (KR) - Rule-Based Representation, Semantic Networks, Frames
Knowledge Representation (KR) - Rule-Based Representation, Semantic Networks, Frames
Rule-based representation,
semantic networks, frames
Knowledge Definition
“The fact or condition of knowing something
with familiarity gained through experience or
association.” (Webster’s Dictionary, 1988)
(Knowing something via seeing, hearing,
touching, feeling, and tasting.)
- IF name is “Ahmet”
AND weather is cold
THEN tell Ahmet 'Wear a coat'
Example
IF … THEN Rules
Rule: Red_Light
antecedent
IF the light is red (left-hand-side)
THEN stop consequent
Rule: Green_Light (right-hand-side)
IF the light is green
THEN go
Production Rules
the light is red ==> stop
the light is green ==> go
Production Rules
• Frequently used to formulate the
knowledge in expert systems
• Excellent modeling of human behavior
• Examples
–IF condition, THEN conclusion
–Conclusion, IF condition
–IF condition, THEN conclusion1 (OR)
ELSE conclusion2
Forms of Rules
• IF premise, THEN conclusion
– IF income is high,
THEN chance of being audited by the IRS is high
• Conclusion, IF premise
– The chance of being audited is high,
IF income is high
• Inclusion of ELSE
– IF income is high, OR deductions are unusual,
THEN chance of being audited by the IRS is high
ELSE chance of being audited is low
• More Complex Rules
– IF credit rating is high AND salary is more than $30,000, OR assets are
more than $75,000, AND payment history is not "poor,"
THEN approve a loan up to $10,000, AND list the loan in category "B”
Rule-based reasoning: rules
• A rule-based system, therefore, either
– identifies a pattern and draws conclusions
about what it means,
or
– identifies a pattern and advises what should
be done about it,
or
– identifies a pattern and takes appropriate
action.
Inferencing
• Reasoning (Thinking)
• The computer is programmed so that it can
make inferences
• Performed by the Inference Engine
Rules - A simple example
Knowledge base consisting of facts and rules, a rule interpreter
to match the rule conditions against facts and for executing the
rules.
Rules:
R1: IF: Raining, Outside(x), Has_Umbrella(x)
THEN: Uses_Umbrella(x)
R2: IF: Raining, Outside(x)
NOT Has_Umbrella(x)
THEN: Wet(x)
R3: IF: Wet(x)
THEN: Gets_Cold(x)
R4: IF: Sunny, Outside(x)
THEN: Gets_Sun_Tan(x)
Initial facts: Raining, Outside(John)
Knowledge and Inference Rules
• Two types of rules are common in AI:
– Knowledge rules and Inference rules
• Knowledge rules (declarative rules), state all the facts and
relationships about a problem
• Inference rules (procedural rules), advise on how to solve a
problem, given that certain facts are known
• Inference rules contain rules about rules (metarules)
• Knowledge rules are stored in the knowledge base
• Inference rules become part of the inference engine
• Example:
– IF needed data is not known THEN ask the user
– IF more than one rule applies THEN fire the one with the highest
priority value first
Rules representing relation,
recommendation and directive
• Relation
IF the ‘fuel tank’ is empty
THEN the car is not running
• Recommendation
IF the season is autumn
AND the sky is cloudy
AND the forecast is drizzle
THEN the advice is ‘take an umbrella’
• Directive
IF the car is not running
AND the ‘fuel tank’ is empty
THEN the action is ‘refuel the car’
Example
Rules for diagnosing household emergency.
Rule 1: IF coughing
THEN smoky
Rule 2: IF wet and NOT raining
THEN burst pipe
Rule 3: IF NOT coughing AND alarm rings
THEN burglary
Rule 4: IF smoky AND hot
THEN fire
Example (continue)
Try to prove fire (R4)
Try to prove smoky and hot (R1 for smoky)
Are you coughing? – no (smoky fails, therefore fire
fails)
Try to prove burst pipe (R2)
Are you getting wet? No (burst pipe fails)
Not coughing (known) and alarm rings.
Is there an alarm ringing? Yes
GO
NEW YORK
JOHN
Who Where
How
BUS
Semantic networks
Semantic networks represent propositional information.
Relations between propositions are of primary interest because
they provide the basic structure for organizing knowledge.
Some important relations are:
– “IS-A” (is an instance of). Refers to a member of a class,
where a class is a group of objects with one or more
common attributes (properties). For example, “Tom IS-A
bird”.
– “A-KIND-OF”. Relates one class to another, for example
“Birds are A-KIND-OF animals”.
– “HAS-A”. Relates attributes to objects, for example “Mary
HAS-A cat”.
– “CAUSE”. Expresses a causal relationship, for example “Fire
CAUSES smoke”.
Semantic network
Abraracourcix
Astérix
Cétautomatix
Obélix
Gaul
Panoramix is-a
AKO
is-a Dog
Human
barks-
at Idéfix
Ordralfabetix
Relationships
• without relationships, knowledge is an unrelated collection of
facts
• relationships express structure in the collection of facts
– this allows the generation of meaningful new knowledge
• generation of new facts
• generation of new relationships
• relationships can be arbitrarily defined by the knowledge
engineer
– allows great flexibility
– for reasoning, the inference mechanism must know how
relationships can be used to generate new knowledge
Example of semantic network
has-part
Vehicle Wheels
has-part
isa Motor
has-part
Doors Automobile
num-wheels 4
isa
Size
Small Sports Car 2
num-doors
instance
Corvette
c o v e re d _ b y
a n im a l
tr a v e ls _ b y s k in
f ly in g
is a is a
tr a v e ls _ b y
b ir d fis h
fe a th e r s
c o v e re d _ b y s w im m in g
is a is a is a is a
o s tr ic h p e n g u in can ary r o b in
tr a v e ls _ b y c o lo u r
c o lo u r
w a lk in g y e llo w
tra v e ls _ b y
re d
in s ta n c e _ o f
in s ta n c e _ o f
O pus
T w e e ty
c o lo u r
w h ite
Semantic network
Animal Plant
is a is a is a is a
is a is a is a is a
is a is a
German Bull
Shepherd dog
Example of semantic network
IS – PART Hierarchy
Dog
is part is part
is part
Head Body Appendages Tail
is part is part
is part is part
is part
Ears Nose Eyes Mouth Legs Paws
Example of semantic network
Example of semantic network
is a isa
Bird Aircraft
isa isa
Fly
Flamingo Boeing 747
passenger
John
32
Exceptions in IS - A relation
Nodes and Arcs
• Arcs define binary relationships that hold
between objects denoted by the nodes.
mother age
Sue john 5
age father
age(john,5)
34 Max wife(sue,max)
age age(max,34)
...
OAV-Triples
• object-attribute-value triplets
– can be used to characterize the knowledge in a
semantic net
– quickly leads to huge tables
Object Attribute Value
Astérix profession teacher
Obélix size extra large
Idéfix size petite
Panoramix wisdom infinite
OAV-Triples
Object Attribute Value
Airplane NumberOfEngines 2
Airplane NumberOfEngines 3
Airplane NumberOfEngines 4
Airplane TypeOfEngines Jet
Airplane TypeOfEngines Propeller
Airplane TypeOfWings Conventional
Airplane TypeOfWings SweptBack
Advantages of Semantic Networks
• Easy to visualize
• Formal definitions of semantic networks have
been developed.
• Related knowledge is easily clustered.
• Efficient in space requirements
– Objects represented only once
– Relationships handled by pointers
Problems with Semantic Networks
• expressiveness
– no internal structure of nodes
– relationships between multiple nodes
– no easy way to represent heuristic information
– extensions are possible
– best suited for binary relationships
• efficiency
– may result in large sets of nodes and links
Frames
• Offered by Marvin Minsky in 1975
• frames consist of a group of slots (attributes) and fillers
(associated values) to define a stereotypical objects
Slots can contain all kinds of items
rules, facts, images, video, comments, debugging info,
questions, hypotheses, other frames
Frame Name
Slot # 1 Value #1
Slot # 2 Value #2
Slot # 3 Value #3
Slot # 4 Value #4
Frames
• Frames – semantic net with properties
• A frame can represent a specific entry, or a general
concept
• Frames are implicitly associated with one another
because the value of a slot can be another frame
3 components of a frame
Book Frame
• frame name Slot → Filler
• attributes (slots) • Title → AI. A modern Approach
• values (fillers: list of values,
• Author → Russell & Norvig
range, string, etc.)
• Year → 2003
Frame Example
Slot Name Filler
name Astérix
height small
weight low
profession teacher
intension teaching
intelligence very high
marital status Single
Property inheritance
Semantic networks and Frames support the
useful form of inference - property
inheritance.
Semantic Networks and Frames use different
notations but are effectively the same.
They provide a simple and intuitive way of
representing facts about objects, and
essentially semantic networks are just
diagrammatic forms of frames.
Semantic Network
subclass animal subclass
has-part
reptile mammal head
subclass
size colour
large elephant grey
instance instance
likes
clyde nellie apples
Frame
Mammal:
Subclass: Animal
Has_part: head
Elephant:
Subclass: mammal
Colour: grey
Size: large
Nellie:
Instance: elephant
Likes: apples
Frame and semantic net
Example of Frame
Vehicle
isa Wheels: Yes
isa
Automobile
Doors: Yes Cycle
Motor: Yes Wheels: <4
Wheels: 4
isa
isa
Spots Car Bicycle
Doors: 2 Motor: No
Size: Small Wheels: 2
instance
Corvette
License:xyz2
Inheritance feature of frame
Hotel Chair
•what → chair
Hotel Room •height →20-40cm
Hotel Phone
•what → room •legs →4
•what → phone
•where →hotel
•billing → guest
•contains→
–hotel chair
–hotel phone
Hotel Bed
–hotel bed •what → bed
•size →king
Mattress
•part → mattress
•price → 100$
Example of Frame
hotel chair
hotel room superclass: chair
superclass: room height: 20-40cm
location:hotel legs: 4
contains: (hotel
chair, hotel phone use: sitting
hotel bed)
hotel phone
superclass: phone
use: calling room service
hotel bed billing: through room
superclass: bed
mattress
use: sleeping
superclass: cushion
size: king
firmness: firm
part: (mattress frame)
Frame Advantages
• fairly intuitive for many applications
– similar to human knowledge organization
– suitable for causal knowledge
– easier to understand than logic or rules
• very flexible