3. 4/25/2023 3
Introduction
• Will look at techniques for encoding knowledge in
an expert system
• An expert system must encode knowledge, not data
• Knowledge is represented in some symbolic form
• Knowledge must be able to be manipulated by the
expert system
• No one technique is suited for every application
4. 4/25/2023 4
Overview
Knowledge - Understanding of a subject area
Domain - A well-focused subject area
Knowledge Representation - The method used to encode
knowledge in an expert system’s knowledge base
KNOWLEDGE IS POWER
5. 4/25/2023 5
Knowledge in AI
• Cognitive psychologists have formed a number of
theories to explain how humans solve problems
• Theories have uncovered:
– Types of knowledge humans commonly use
– How humans mentally organize this knowledge
– How humans use it efficiently to solve a problem
• Researchers in AI have used the results to develop
techniques to best represent these different
knowledge types in the computer
• A knowledge engineers’ responsibility is to choose
the knowledge representation technique best suited
for the given application
6. 4/25/2023 6
Approaches to Knowledge
Representation
A good system for the representation of knowledge should possess
The following properties:
1. Representational Adequacy - the ability to represent all of the
kinds of knowledge that are needed in that domain.
2. Inferential Adequacy - the ability to manipulate the representational
structures in such a way as to derive new structures corresponding
to new knowledge inferred from old
3. Inferential Efficiency - the ability to incorporate into the know-
ledge structure additional information
4. Acquisitional Efficiency - the ability to acquire new information
easily
7. 4/25/2023 7
Types of Knowledge
1. Procedural Knowledge - describes how a problem is solved
• provides direction on how to do something
• Ex: rules, strategies, agendas and procedures
2. Declarative Knowledge - describes what is known about a problem
• includes simple statements that are asserted to be true or false
• includes a list of statements that more fully describe some concept
3. Meta-Knowledge - describes knowledge about knowledge
• used to pick other knowledge best suited for solving a problem
• experts use to enhance the efficiency of problem solving by
directing their reasoning into the most promising areas
8. 4/25/2023 8
Types of Knowledge - cont.
4. Heuristic Knowledge - describes a rule-of-thumb that guides the
reasoning process.
• represents the knowledge compiled by an expert through the
experience of solving past problems
• experts will take fundamental knowledge and compile it into
simple heuristics to aid problem solving
5. Structural Knowledge - describes knowledge structures
• describes the expert’s overall mental model of the problem
• concepts, sub-concepts, and objects are typical examples
9. 4/25/2023 9
Summary of Knowledge Types
Types of Knowledge
Procedural Knowledge
Declarative Knowledge
Meta-Knowledge
Heuristic Knowledge
Structural Knowledge
Rules; Strategies
Agendas; Procedures
Concepts; Objects
Facts
Knowledge about the other types of
knowledge and how to use them
Rules of Thumb
Rule Sets; Concept Relationships
Concept to Object Relationships
10. 4/25/2023 10
Knowledge Representation
Techniques
• Five most common Techniques:
– Object-attribute-value triplets
– Rules
– Semantic Networks
– Frames
– Logic
• Each technique emphasizes certain information about
a problem while ignoring other information
• Each technique has advantages and disadvantages for
capturing efficiently the different types of knowledge
• Choosing the correct representation for a given
application supports effective problem solving
11. 4/25/2023 11
Facts
• All cognitive theories of human knowledge organization use
facts as basic building blocks
• A fact is a form of declarative knowledge that provides some
understanding of an event or problem
• In expert systems, facts are used to help describe parts of frames
semantic networks, or rules
DEFINITION: A proposition (i.e. fact) is a statement that is
either true or false
12. 4/25/2023 12
Object-Attribute-Value Triplets
(O-A-V Triplets)
• In an expert system we assert into the working memory the
Boolean truth statement (TRUE OR FALSE), and use this
assertion in processing other knowledge
• Simple proposition: It is raining
• Fact is also used to assert a particular property value of some object
• “The ball is red” assigns the value “red” to the ball’s color
• This is known as an object-attribute-value (O-A-V) triplet
13. 4/25/2023 13
O-A-V Triplets Cont.
O-A-V triplets divides a given statement into three distinct
parts:
– Object
– Attribute
– Attribute Value
Consider: “The chair’s color is brown”
Can represent as an O-A-V triplet as follows:
Object = “chair”
Attribute = “color”
Value = “brown”
14. 4/25/2023 14
O-A-V Triplets Cont.
For most problems addressed by an expert system, objects
have more than one important feature:
Diameter
1 Foot
Color Red
Weight
1 Pound
Ball
Object Attribute Value
Object with multiple attributes
15. 4/25/2023 15
Single-Valued and Multi-Valued Facts
If only one answer makes sense, the O-A-V is single-valued:
Expert System Question: Please tell me if the barometric (object)
pressure (attribute) is
Falling (attribute values)
Steady
Rising
A: Falling
If multiple values make sense then the O-A-V is multi-valued:
Q: Please select the level of your education (attribute)
High School (attribute values)
College
Graduate School
A: High School
College
note: object “person” is implied
17. 4/25/2023 17
Rules
• Facts allow the system to understand the state of the world
• System must have additional knowledge for it to work
intelligently with the facts
• Most expert systems use rules to provide additional
knowledge
DEFINITION: Rule - A knowledge structure that relates
some known information to other information that can be
concluded or inferred to be known
18. 4/25/2023 18
Rules Cont.
• A rule is a form of procedural knowledge
• It associates given information to some action
• Action may be the assertion of new information or
some procedure to perform
• A rule describes how to solve a problem
19. 4/25/2023 19
Structure of a Rule
The rules structure logically connects one or more antecedents
also called premises contained in the IF part, to one or more
consequents also called conclusions contained in the THEN part.
IF The ball’s color is red
THEN I like the ball
If the balls color is red then we can infer that I like the ball
20. 4/25/2023 20
Structure of a Rule - Cont.
A rule can have multiple premises joined with AND statements
(conjunctions), OR statements (disjunctions), or a combination of both.
Its conclusion can contain a single statement or a combination joined
with an AND.
The rule can also contain an ELSE statement, that is inferred to be
TRUE if one or more of its premises are FALSE
21. 4/25/2023 21
Rule Example
IF Today’s time is after 10am
AND Today is a weekday
AND I am at home
OR My boss called and said that I am late for work
THEN I am late for work
ELSE I am not late for work
RECOMMENDATION: Avoid the use of the OR
operator and ELSE statements
22. 4/25/2023 22
Avoid ORs and ELSEs
Rule 1: IF A = X Rule 2: IF A = X
OR B = Y THEN D = XX
THEN D = XX ELSE D = YY
should be rewritten as: should be rewritten as:
Rule 1a: IF A = X Rule 2a: IF A = X
THEN D = XX THEN D = XX
Rule 1b: IF B = Y Rule 2b: IF A NOT = X
THEN D = XX THEN D = YY
Why: Easier to follow the inference process.
Easier to debug.
Clearer presentation
Validation of such rules more difficult
Not all expert system shells allow ORs or ELSEs.
.
23. 4/25/2023 23
Examples of Bad Rules
IF (engine_type==”Jet”)
IF(Wing_Position==”Low”
Is B747
IF(engine_type==”High”)
IF(Bulges==”None”)
IS C5A
IF(Bulges==”Aft Wing”)
IS C141
IF(engine_type==”Prop”)
IS C141
24. 4/25/2023 24
Example 2
IF Item Type is Tool THEN put on Peg Board ELSE
IF Item Type is Toy THEN
IF Toy Type is Indoor THEN put in Box in Back
ELSE put Along Wall
IF Item Type is Supply THEN
IF Size is Small THEN put in Drawer
ELSE put Under Bench
IF Item Type is Miscellaneous THEN
IF Need Again is No THEN put in Trash
ELSE put in Box in Back
25. 4/25/2023 25
Example 3
If weight is less than 10 lbs and is not a tool
Then put on top shelf
Else if it is for yard work
Then put in shed
Else hang above tool bench
26. 4/25/2023 26
Working Memory
• Expert systems employing rules are called rule-based
expert systems
• System matches the IF portion of the rules with facts
contained in the working memory
• When a match is confirmed, the rule fires and its THEN
statements are added to the working memory
• The new statements added to the working memory can
also cause other rules to fire
27. 4/25/2023 27
The Inference Engine
IF ball’s color is Red
THEN I like the ball
If I like the ball
THEN I will buy the ball
Knowledge Base
Working Memory
Ball’s color is red
I like the ball
I will buy the ball
Q: Ball’s color?
A: Red Step 1 Step 2
Step 4
Step 3
Step 5
28. 4/25/2023 28
Executing a Procedure
Simple calculation: IF the area of the square is needed
THEN AREA = LENGTH*WIDTH
Procedural Program to call an external routine:
IF The design requires a new box
AND NUMBER = Number of items to pack
AND SIZE = Size of item
THEN CALL COMPUTE_BOX_VOLUME
AND SEND NUMBER, SIZE
AND RETURN VOLUME
29. 4/25/2023 29
Other examples of Procedures
SPREADSHEET:
IF January sales needed
THEN OPEN SALES
AND JANUARY_SALES = B7
DATABASE:
IF There is a plant emergency
AND NAME = Smith
THEN OPEN TELEPHONE
AND FIND NAME, NAME-FIELD
AND TELEPHONE = TELEPHONE-FIELD
30. 4/25/2023 30
Variable Rules
In some applications, you will need to perform the same
operation on a set of similar objects.
Ex: IF John Smith is an employee
AND John Smith’s age is greater than 65
THEN John Smith can retire
Rule checks if John Smith is an employee of the company and
is over 65 before concluding he can retire.
What if you wanted the system to perform the same check for
other individuals?
31. 4/25/2023 31
Pattern-Matching
Most shells offer pattern-matching that include variables
that you can use to match similar problem statements.
IF ?X is EMPLOYEE
AND ?X AGE > 65
THEN ?X can retire
Rule scans working memory looking for matches, if
matches are found, the rule concludes that the person
can retire
32. 4/25/2023 32
Advantages to Using Variables
• Designer only has to write one rule for many employees
• Designer only has to change one rule to make a variable
change instead of many
• Offers an efficient way to process information
• Can directly capture general directions obtained from
an expert
34. 4/25/2023 34
Meta Rules Cont.
• A meta-rule establishes strategies for the use of
domain specific rules, instead of concluding new
information
• Meta-rules provide direction to the expert system during
the session
Ex: IF The car will not start
AND The electrical system is operating normally
THEN Use rules concerning the fuel system
35. 4/25/2023 35
Semantic Networks
DEFINITION: Semantic Network - A method of knowledge
representation using a graph made up of nodes and arcs where the nodes
represent objects and the arcs the relationships between the objects
Canary
Wings
Bird
Fly
IS-A
HAS
TRAVEL
Semantic network of a bird
IS-A (Canary, Bird)
36. 4/25/2023 36
Expanding the Network
You can add a new object node by 1) a similar object, 2) a more
specific object, or (3) a more general object.
Canary
Wings
Bird
Fly
IS-A
HAS
TRAVEL
IS-A
IS-A
TRAVEL
IS-A
BREATHE
Tweety
Penguin
Walk
Air
Animal
37. 4/25/2023 37
Inheritance
• Nodes added to a semantic network automatically
inherit information from the network
• “Tweety” breathes air because it is an “Animal”
• Inheritance eases the task of coding knowledge
• To support, objects must be organized into classes;
classes must be arranged in a generalization hierarchy
Canary Bird
IS-A
IS-A IS-A
Tweety Animal
Air
BREATHE
BREATHE (Tweety, Air)
38. 4/25/2023 38
Inheritable Knowledge
Fielder .262
.106
Three-Finger-
Brown
Pee-Wee-
Reese
Brooklyn-
Dodgers
Chicago-
Cubs
Baseball
Player
Adult-
Male
Person Right
5-10
6-1
.252
Pitcher
team
team
instance instance
Batting-average
Batting-average
isa isa
Batting-average
height
bats
isa
height
isa
handed
Equal
handed
isa shows class inclusion; instance shows class membership
40. 4/25/2023 40
Frames
DEFINITION: Frame - A data structure for representing
stereotypical knowledge of some concept
Minsky (first proposed frames) describes a frame as follows:
“When one encounters a new situation (or makes a substantial change
in one’s view of a problem) one selects from memory a structure called
a “frame.” This is a remembered framework to be adapted to fit reality
by changing details as necessary.”
41. 4/25/2023 41
Structure of a Frame
The basic structure of a frame is similar to many forms
such as a “report card”
REPORT CARD GENERAL FRAME STRUCTURE
Student Name:
Address:
Course Grades
Chemistry
Math
English
...
Frame Name: Object1
Class: Object2
Properties: Property1
Property2
Property3
...
Value1
Value2
Value3
...
ISA(OBJECT1, OBJECT2)
42. 4/25/2023 42
Class Frame
A class frame represents the general characteristics
of some set of common objects.
Frame Name:
Properties:
Bird
Color Unknown
Eats Worms
No._Wings 2
Flies True
Hungry Unknown
Activity Unknown
43. 4/25/2023 43
Instance Frame
Instance Frame describes a specific instance of a
class frame. The frame inherits both properties and
property values from the class.
Frame Name:
Class:
Properties:
Bird
Color Yellow
Eats Worms
No._Wings 1
Flies False
Hungry Unknown
Activity Unknown
Tweety
Lives Cage
44. 4/25/2023 44
Hierarchical Structure
You can create complex frame structures organizing
by different levels of abstraction. Each level inherits
from the previous level.
Birds
Robins Canaries
Sparrows
Bird1 Bird2 Bird3 Bird4 Bird5
45. 4/25/2023 45
Facets
• Provide you with additional control over property values
• Can define a constraint on a property value - i.e.
– Limit a numeric property value to some set range
– limit a string value to one of a few possible values
– restrict the type of data that can be stored in a
property value, i.e. string, numeric, or boolean
• Can instruct a property how to obtain its value or what to
do if its value changes
– IF-NEEDED facets
– IF-CHANGED facets
46. 4/25/2023 46
Methods
A method is a procedure that executes whenever a
property value is needed.
Property value can be obtained through a series of
computations, or from an external database or spreadsheet
Method is typically written in the procedural language of the
chosen shell and attached to the property’s IF-NEEDED facet
47. 4/25/2023 47
Example
1. Assume property value “Flies” in the “Tweety” frame is “Unknown”.
2. You want the system to determine if tweety can fly.
Method: IF Tweety has less than two wings
THEN Tweety can’t fly
IF Tweety has two wings
THEN Tweety can fly
To implement method, we need the property value of “No._Wings”
from the “Tweety” frame.
48. 4/25/2023 48
Example Con’t
Shells differ but one example is
Frame:Property
Using the code on the previous “Tweety frame, we have
Tweety:No._Wings = 1
Now we need to assert a value of True or False to the “Flies”
property depending on Tweety’s wing count.
49. 4/25/2023 49
Example Con’t
Frame:Property = Value
IF Tweety:No._Wings < 2
THEN Tweety:Flies = False
IF Tweety:No._Wings = 2
THEN Tweety:Flies = True
This method is attached to the IF-NEEDED facet of property
“Flies” of the frame “Tweety”
50. 4/25/2023 50
Logic
• Logic is the oldest form of knowledge representation
in a computer
• One most often linked to intelligent systems are
propositional logic and predicate calculus
• Techniques use symbols to represent knowledge
• Operators applied to the symbols produce logical
reasoning