Topic 4 Knowledge Representation
Topic 4 Knowledge Representation
REPRESENTATION
1
KNOWLEDGE
What is knowledge?
How?
What?
When?
Why?
2
KNOWLEDGE
What is knowledge?
Knowledge,
like love,
is one of those words that
everyone knows the meaning
of, yet finds hard to define.
Like love, knowledge has
many meanings.
3
KNOWLEDGE
What is knowledge?
4
KNOWLEDGE
What is knowledge?
5
KNOWLEDGE
Facts
KNOWLEDGE
Heuristic
Procedural
Rules
6
TYPES OF KNOWLEDGE
Types of knowledge
7
TYPES OF KNOWLEDGE
Procedural knowledge Rules
Strategies
Agendas
Procedures
Declarative knowledge Concepts
Objects
Facts
Meta-knowledge Knowledge about the other types of
knowledge and how to use them
Heuristic knowledge Rules of thumb
8
TYPES OF KNOWLEDGE
Example:
Procedural knowledge
to boil an egg we must do… then…
Declarative knowledge
my room no. is 2079
Meta-knowledge
if you want to know about heart attack, please read this book
Heuristic knowledge
the clouds looks dark and heavy, … heavy rain might fall…
Structural Knowledge 9
KNOWLEDGE
HIERARCHY This is Siti phone
number…
Information
Siti Fatimah
Data Phone Knowledge
No.
10
KNOWLEDGE
REPRESENTATION
Definition
11
KNOWLEDGE
REPRESENTATION
Knowledge
Representation
Knowledge
Representation
Methods Logic
Rule
14
KNOWLEDGE
REPRESENTATION
Object-Attribute-Value (O-A-V)
Color Gold
15
KNOWLEDGE
REPRESENTATION
Semantic Network
Definition :: ”method of knowledge representation using
a graph made up of nodes and arcs”
Graphical view of problem’s important objects, properties
and relationships.
Nodes represent objects & arcs represent the relationship.
Arcs are commonly labeled with terms “IS-A” or “HAS”
Exceptional handling some exceptions for certain cases.
“All birds can fly and ostrich is bird can ostrich fly?
17
KNOWLEDGE
REPRESENTATION
Semantic Network Wings
has Wings
is-a
is-a
Parrot
Parrot Bird
Bird Animal Air
Air
Animal
breathe
travel
Fly
Fly
Ostrich
Ostrich
travel Walk
Walk
18
KNOWLEDGE
REPRESENTATION
Frame
Definition :: ”a data structure for
representing stereotypical knowledge
of some concept or object”
19
KNOWLEDGE
REPRESENTATION
Frame
20
KNOWLEDGE
REPRESENTATION
Rule
Definition :: Rules ”a knowledge structure that relates some
known information to other information and that can be concluded
or inferred to be known”
21
KNOWLEDGE
REPRESENTATION
Rule
Statement “IF” antecedent and “THEN”
consequent
22
KNOWLEDGE
REPRESENTATION
A rule can have multiple antecedents joined by the keywords AND
(conjunction), OR (disjunction) or
a combination of both.
IF antecedent 1 IF antecedent 1
AND antecedent 2OR antecedent 2
. .
. .
. .
AND antecedent n OR antecedent n
THEN consequent THEN consequent
23
KNOWLEDGE
REPRESENTATION
The antecedent of a rule incorporates two parts: an object (linguistic
object) and its value. The object and its value are linked by an operator.
The operator identifies the object and assigns the value. Operators such
as is, are, is not, are not are used to assign a symbolic value to a
linguistic object.
Expert systems can also use mathematical operators to define an object
as numerical and assign it to the numerical value.
24
KNOWLEDGE
REPRESENTATION
Rules can represent relations, recommendations, directives, strategies and
heuristics:
Relation
IF the ‘fuel tank’ is empty
THEN the car is dead
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 dead
AND the ‘fuel tank’ is empty
THEN the action is ‘refuel the car’
25
KNOWLEDGE
REPRESENTATION
Strategy
IF the car is dead
THEN the action is ‘check the fuel tank’;
step1 is complete
IF step1 is complete
AND the ‘fuel tank’ is full
THEN the action is ‘check the battery’;
step2 is complete
Heuristic
IF the spill is liquid
AND the ‘spill pH’ < 6
AND the ‘spill smell’ is vinegar
THEN the ‘spill material’ is ‘acetic acid’
26
CONFLICT
RESOLUTION
Given the set of rules below:
Rule 1:
IF the ‘traffic light’ is green
THEN the action is go
Rule 2:
IF the ‘traffic light’ is red
THEN the action is stop
Rule 3:
IF the ‘traffic light’ is red
THEN the action is go
27
CONFLICT
RESOLUTION
We have two rules, Rule 2 and Rule 3, with the same IF
part.
Thus both of them can be set to fire when the condition
part is satisfied.
These rules represent a conflict set.
The inference engine must determine which rule to fire
from such a set.
A method for choosing a rule to fire when more than one
rule can be fired in a given cycle is called conflict
resolution.
28
CONFLICT
RESOLUTION
In forward chaining, BOTH rules would be fired.
Rule 2 is fired first as the topmost one, and as a
result, its THEN part is executed and linguistic object
action obtains value stop.
However, Rule 3 is also fired because the condition
part of this rule matches the fact ‘traffic light’ is red,
which is still in the database.
As a consequence, object action takes new value go.
29
METHODS USED FOR CONFLICT
RESOLUTION
1. Fire the rule with the highest priority. In simple
applications, the priority can be established by placing
the rules in an appropriate order in the knowledge base.
Usually this strategy works well for expert systems
with around 100 rules.
2. Fire the most specific rule.
This method is also known as the longest matching
strategy.
It is based on the assumption that a specific rule
processes more information than a general one.
30
METHODS USED FOR CONFLICT
RESOLUTION
3. Fire the rule that uses the data most recently
entered in the database.
This method relies on time tags attached to each
fact in the database.
In the conflict set, the expert system first fires the
rule whose antecedent uses the data most recently
added to the database.
31
KNOWLEDGE
REPRESENTATION
Logic
Often referred to
propositional logic
and predicate calculus.
32
KNOWLEDGE
REPRESENTATION
Logic
Propositional logic
AnB C
Predicate calculus.
33
SELECTING KNOWLEDGE
REPRESENTATION
Should choose a knowledge representation technique that best
matches the way the expert mentally models the problem’s
knowledge.
34
SELECTING KNOWLEDGE
REPRESENTATION
Rule-based
Suitable if the expert discusses the problem primarily using IF/THEN type
statements.
Frame-based
Appropriate if the experts describes the problem by referencing important
objects and their relationships.
When the expert considers several similar objects when solving the problems.
35
RULE-BASED ES
Production system
Definition: Production
ANTECEDENT CONSEQUENT
Situation Action
Or
IF SituationTHEN Action
36
RULE-BASED ES
Production system
Long-termMemory
Long-term Memory Short-termMemory
Short-term Memory
(Productions)
(Productions) (Situations)
(Situations)
Reasoning Actions
Reasoning
Situations
38
RULE-BASED ES
39
RULE-BASED ES
40
RULE-BASED ES
Modules in rule-based ES:
Knowledge Base
Models a human’s long-term memory as a set of rules.
Working Memory
Models a human’s short-term memory and contains problem facts both
entered and inferred by the firing of the rules.
Inference Engine
Models human reasoning by combining problem facts contained in the
working memory with rules contained in the knowledge base to infer new
information.
41
RULE-BASED ES
Rule-based model
KnowledgeBase
Knowledge Base WorkingMemory
Working Memory
(Rules)
(Rules) (Facts)
(Facts)
Conclusions
InferenceEngine
Inference Engine
Facts
42
RULE-BASED ES
Rule contained in the knowledge base represent
the productions contained in the long-term
memory and the facts contained in the working
memory represent the situations in the short-term
memory.
The inference engine acts as the reasoning module
and compares the facts with the antecedents or
premises of the rules to see which ones can fire.
Not necessarily an exact match for human
problem solving, but provide a reasonable model
for replicating the behavior with a computer.
43
RULE-BASED ES
Additional subsystems:
User interface – the medium which the user views and interacts
with the system.
44
RULE-BASED ES
Rule-based system architecture
InferenceEngine
Inference Engine
Working
Working Explanations
Explanations Knowledge
Knowledge External
External
Memory
Memory Facility
Facility Base
Base Programs
Programs
User
User Developer
Developer
Interface
Interface Interface
Interface
Knowledge
User Engineer 45
ADVANTAGES OF RULE-
BASED ES
Use of Relevant Knowledge – system will use only the rules that
are relevant to the problem.
Derivation of Explanations from Rigid Syntax – explain the
user how it reaches the conclusion.
Consistency Checking – to assure that the same situations do
not lead to different actions.
Exp:
IF hungry THEN eat…
IF hungry THEN drink…
IF B
THEN C
IF A
THEN B 49
DISADVANTAGES OF
RULE-BASED ES
Can be Slow – systems with a large set of rules can
be slow.
Are Inappropriate for Some Problems – shortcoming
of the rule-based system occurs when rules do not
efficiently or naturally capture the representation of
the domain’s knowledge.
50
DISADVANTAGES OF
RULE-BASED ES
Inability to learn - In general, rule-based expert systems
do not have an ability to learn from the experience.
Unlike a human expert, who knows when to “break the
rules”, an expert system cannot automatically modify its
knowledge base, or adjust existing rules or add new ones.
The knowledge engineer is still responsible for revising
and maintaining the system.
51
SUMMARY
https://youtu.be/fXGJcd28SM8
52
EXERCISES
All cars have 4 wheels and 4 doors. A car is differentiated by its
engine capacity. A Proton Saga has a 1.5L and a 1.3L engine type
while a Proton Wira has a 1.3L, 1.5L, 1.6L, 1.8L and 2.0L engine
type. All Proton cars run on petrol. All car engines are built based
on the same principal of using pistons and cylinders. Draw:
semantic net & frame.
ABC hotel consists of two types of rooms, that are, standard and
superior rooms. A standard room is equipped with a queen bed
while a superior room is equipped with two queen beds. All rooms
have a telephone, television and hot kettle. Draw: semantic &
frame.
53
EXERCISES
Mini is a robin; it lives in a nest, which is on a pine tree in Mr. Ali’s
backyard. Robins are birds; they can fly and have wings. They are
endangered species, and they are protected by government
regulations. Draw: semantic & frame.
Chevette is a courier. Rydell is a policeman. Couriers are a kind of
person. Policeman are a kind of person. People have two legs.
People walk. Chevette is a friend of Rydell. Chevette likes
chocolate. Draw: semantic net & frame.
54
REFER 1
Semantic Network Wings
has Wings
is-a
is-a
Parrot
Parrot Bird
Bird Animal Air
Air
Animal
breathe
travel
Fly
Fly
Ostrich
Ostrich
travel Walk
Walk
55
REFER 2
Frame
56
ANSWER 1
Semantic Network
57
ANSWER 1
Frame
58
ANSWER 1
Semantic Network
59
Pistons
has
4
wheels has
Engine
has Cylinders
has
has
Car
is a
Engine
has Capacity is
4 Proton
Saga
doors is
is is is
has 1.8L 2.0L
has
is a 1.6L
1.5L
has
1.3L has
has
has
has
Proton
Wira
60