csnb234 artificial intelligence
DESCRIPTION
CSNB234 ARTIFICIAL INTELLIGENCE. Chapter 6 Knowledge Representation. (Chapter 7, pp. 223-258, Textbook) (Chapter 5, pp. 167-197, Ref. #1). Instructor: Alicia Tang Y. C. Knowledge Representation. Knowledge representation is certainly one of the most important topics - PowerPoint PPT PresentationTRANSCRIPT
CSNB234ARTIFICIAL INTELLIGENCE
Chapter 6Knowledge Representation
Chapter 6Knowledge Representation
Instructor: Alicia Tang Y. C.
(Chapter 7, pp. 223-258, Textbook)(Chapter 5, pp. 167-197, Ref. #1)
2
Knowledge Representation
• Knowledge representation is certainly one of the most important topics
• Predicate logic based representations (We do this with an historical focus)
• Schemes in an "evolutionary order" (This allows the reader to see how the strengths of one representation find their way into succeeding approaches)
3
Knowledge RepresentationKnowledge Representation
• Representational schemes can be divided into four rough categories.
• These categories are not intended to be definitive but rather to assist the students (you) in getting a general perspective.
• Over the past 25 years, numerous representational schemes have been proposed and implemented, each of them having its own strengths and weaknesses.
• Representational schemes can be divided into four rough categories.
• These categories are not intended to be definitive but rather to assist the students (you) in getting a general perspective.
• Over the past 25 years, numerous representational schemes have been proposed and implemented, each of them having its own strengths and weaknesses.
4
1. Logical representation schemes. – This class of representations uses expressions in formal logic to represent a knowledge base. Inference rules and proof procedures apply this knowledge to problem instances.
2. Network representation schemes.– Network representations capture knowledge as a graph in which the nodes represent objects or concepts in the problem domain and the arcs represent relations or associations between them. Semantic network and conceptual graph.
Mylopoulos and Levesque (1984) have classified these into four categories
Mylopoulos and Levesque (1984) have classified these into four categories
5
3. Structured representation schemes.– Structured representation languages extend networks by allowing each node to be a complex data structure consisting of named slots with attached values. Scripts and frames.
4. Procedural representation schemes.– Procedural schemes represent knowledge as a set of instructions for solving a problem. This contrasts with the declarative representations
provided by logic and semantic networks. – A production rule system is an example of this approach.
6
Before we begin the four methods.. Let’s see this
• There is a common method used for many non-AI (databases) representation, namely– Object-Attribute-Value (O-A-V) Triplets
• An O-A-V is a more complex type of proposition (fact).
• It divides statement into three (3) parts as shown:
shirtprice
RM39
object attribute value
7
There can be single or multiple attribute facts
There can also be single or multiple value facts .
e.g. Is the barometer pressure rising, falling or steady?
shirt
bluecolor
cost
rm39
sizeXL
8
Semantic Networks (I)
• A semantic net has a binary relation• Concepts are represented by nodes• Links between nodes represent the relationships
• Drawbacks: – Disjunctive and conjunctive information cannot be included into semantic nets• E.g. apple can be either green or red• E.g. panda has color black and white
9
Semantic Networks (II)
• Examples of relationship labeled on arcs (notice that there is an underscore)– is_a– has_a– has_part
• Examples of concepts (nodes)– bird– person– book– famous– intelligent
10
A semantic net that represents a bird’s property
feathers bird flies
small bluebird blue
is_a
size
has_propertyhas_covering
has_color
11
has_a DOOR LAB is_a ROOM in has COMPUTERS PRINTERS is_a LASER_PRINTER
Exercise:Draw a semantic network for the following description:
Lab is a room. Lab has a door. Lab has many computers. Printer is in lab. Laser printer is a Printer.
12
CONCEPTUAL GRAPHSCONCEPTUAL GRAPHS
• Developed in 1984• Conceptual graphs (networks)
overcome the restriction to binary relation
• Simply makes all links unlabelled
• Developed in 1984• Conceptual graphs (networks)
overcome the restriction to binary relation
• Simply makes all links unlabelled
13
A Disjunctive Net for Red or Green Apple
Apple Green
Red
A Conceptual Net that represents “OR”
Color
15
A Conjunctive Net for black and white panda
PANDA
WHITE
BLACK
A Conceptual Net that represents “AND”
Color
Color
16
Semantic Nets
• It can capture and show inheritance– a very good feature (that not found in
other schemes)
• Can be used to combine with other representation methods
• See next slide for “inheritance” power of semantic nets
17
Inheritance in Semantics Nets
BreatheAnimal
Move
FlyBird
Wings
Feathers
Canary Sing
Yellowis
can
can
has
has
can
can
Animal’s properties are inherited to Bird and
Bird’s properties areinherited to a bird
species called canary
Penguin
We shall see this later
18
Exception Handling (for addressing the problem caused by its inheritance property)
Sometimes, inheritance may cause problems.
Penguin through inheritance gets the property “fly”. (in practice it cannot)
To avoid this situation, all the specific properties of a nodemust be attached to it through local nodes, so that when an answer is needed, it will search all the local nodes first. If the answer is not available in the local nodes then the general nodes will be used.
For example if we ask “how does penguin travel?” the reply will be “it walks” (supposed that already stored in local node)
19
Frames
• The idea behind frames is to store information in meaningful chunks.
• This frame has 4 slots:
BOOK
Title : Qualitative Reasoning Author : Ken D. ForbusPublisher : Prentice-HallYear : 2000
20
Converting from Frames to Semantics Nets
date
author
ForbusQPT
novel
bookpublisher
encyclopedia
editor
has_a has_a
is_ais_a
has_a
has_a
is_ais_a
21
Frame Description
Hotel Roomspecialisation of: room
location: the hotelcontains: bed, chair & phone
Hotel Bedsuperclass: bed
size: kingcontains: mattress, pillow, etc. ::
Hotel Phonespecialisation of: phone
use: calling room servicebilling: through room
(Source: Luger’s AI book)
22
Frames
• You should be able to see now :– that a frame describes an object by embedding
all the information about that object in “slots”– that slots are commonly known in programming
terms as fields or attributes with associated value
• this is an advantage (discuss in later part)
– that a frame is similar to a database record– that a frame describes typical instances of the
concepts they represent
23
SCRIPTS
• Similar to frames except that scripts describe a sequence of events rather than just an object.
• Like frames, scripts portray a stereotyped situation.
• Components:– Entry-condition– Results– Props– Roles – Scenes/episodes
24
Components in Scripts (I)
– Entry-conditions• must be true for the scripts• also called descriptors
– Results• facts that are true once the scripts has
ended
– Props• things or objects that support a given
script
25
Components in Scripts (II)
– Roles • are actions (hence role) that the individual
actors perform or execute
– Scenes/episodes•Schank breaks a script into a series
of “episodes” called scenes– e.g. entering, ordering, … billing, exiting
(for restaurant scenario)• a scene is a temporal aspect of the script
26
Production Rules (I)• Most Expert Systems are rule-based
– i.e. the knowledge-base of the ES consists of a huge set of production rules (or just “rules”)
• Facts, rules and inference engines are required to execute a rule-based expert system
• Production-rules system captures knowledge in simple “if-then” format.
27
Production Rules (II)
• The human mental process is too complex to be represented as an algorithm
• However, most experts are capable of expressing their knowledge in the form of rules for their problem solving
• e.g.• IF the traffic-light is green THEN the action is go• IF the traffic-light is red THEN the action is stop
28
Production Rules (III)• A production rule model consists of
two parts:– the IF part, called antecedent or premise
or condition, and– the THEN part, called consequent or
conclusion or action• In our earlier example:
• IF <the traffic-light is green> THEN <go>
• IF <the traffic-light is red> THEN <stop>
condition
action
29
Production Rules (IV)
• Multiple conditions are joined by the keywords AND (conjunction), OR (disjunction) or a combination of both.
• Example:
IF <condition-1>AND <condition-2> :AND <condition-n>THEN <action>
IF <condition-1>OR <condition-2> :OR <condition-n>THEN <action>
30
Production Rules (V)
• Rule-based ES also use mathematical operators to define an object as numerical and assign it to the numerical value
IF Age of the student < 21AND SPM no. of A’s >= 8THEN Admit the student to BIT
31
Production Rules (VI)• Rules can represent relations, recommendations,
directives and heuristics as follows:
Relations:
IF the fuel tank is emptyTHEN the the car will not start
Recommendation:
IF you study hardAND you study smartAND you never absentTHEN you will get an “A”
32
Production Rules (VII)Strategy:
IF the car is deadTHEN check fuel tank
step 1 is complete
IF step 1 is completeAND the fuel tank is fullTHEN check battery
step 2 is complete
IF step 2 is completeAND the battery is replaced THEN check electrical fuel lines
:
:
Heuristics:
IF the spill is liquidAND the spill pH is < 6AND the smell is vinegarTHEN the spill material is acetic acid
Directive:
IF the fuel tank is emptyTHEN refuel the car
33
Production System Model
Production RulesProduction Rules
Long term memory
FactsFacts
Short term memory
Reasoning
Conclusion
Question: why are the rules as long term memory?
34
Basic structure of a Production system
Production Rules
Production Rules
Knowledge-base
FactsFacts
Database
User
Inference Engine
Explanation Facility
User Interface
35
“Firing” of Rules • When the condition part of a rule is
satisfied, the rule is said to fire and the action part is executed.
• The inference engine carries out the reasoning whereby the expert system reaches a solution. It links the rules given in the knowledge base with the facts provided in the database.
• The explanation facility enables the user to ask questions such as “why” & “how”.
36
Reasoning Methods in Production Rule Systems
•There are two reasoning methods often use in rule-based ES:(1) Forward chaining(2) Backward chaining
(the design of the reference engine)
37
Forward Chaining
• This is the data-driven reasoning.• The reasoning starts from the known fact or data
and proceeds forward with the data.• Each time only the topmost rule is executed.• When fired, the rule adds a new fact in the
database.• Any rule can be executed only once.• The match-fire cycle stops when no further rules
can be fired.
Powerful mechanism
38
Rule-based system (Forward reasoning example)
Rule 1: IF Y is true AND D is true THEN Z is true
Rule 2: IF X is true AND B is true
AND E is true THEN Y is true
Rule 3: IF A is true THEN X is true
A X
B
D
Y
ZE
39
• Given the facts that – A, B and E are true
• In a Forward Chaining system– what type of answer/conclusion the
system will return?– How do you justify it?
Or, Fact 1: AFact 2: BFact 3: E
Question 1
40
Question 2
What if ‘D’ is also true?
(i.e. as a fact in the KB)
Give the conclusion of the reasoning process.
41
Backward Chaining (I)
• Backward chaining is the goal-driven
• In this reasoning method, the expert system is trying to satisfy a goal (i.e. there is a hypothetical solution) and the inference engine move attempts to find the evidence to prove it.
• If evidences are found, the goal is proved.
• If not, backtracking is initiated.
42
Backward Chaining (II)
• Thus the inference engine puts the rule it is working with (the rule is said to stack on) and sets up a new goal (i.e. subgoal), to prove the IF-part of this rule.
• Then the knowledge base is searched again for rules that can prove the subgoal.
• The inference engine repeats the process of stacking the rules until no rules are found in the knowledge base to prove the current subgoal.
Backtrackingis done here
43
Backward Chaining (III)
• In the simplest sense, in backward chaining, to prove a goal G, it is to check:– If G is a fact then it is proven & stop.– Otherwise, find a rule which can be used to
conclude G.•In proving G, try to prove each premise (preconditions) of the rule that infers G.
•G is said to be proven (i.e. it is TRUE) if all the premises are true (valid/hold).
45
Formal Logic
• Advantages– Facts asserted
independently of use– completeness
• Disadvantages– Separation of
representation and processing
– Inefficient with large data sets
– Very slow with large knowledge bases
46
Production Rules
• Advantages– Simple syntax– Easy to understand– Simple interpreter– Flexible (easy to add
or modify)
• Disadvantages– Hard to follow hierarchies– Poor at representing
structured descriptive knowledge
– Ineffective search strategy
– Not all knowledge can be expressed as rules
47
Semantic Networks
• Advantages– Easy to follow
hierarchy– Easy to trace
association– flexible
• Disadvantages• Meaning attached to
nodes might be ambiguous
• Exception handling is difficult
• Difficult to program
48
Frames
• Advantages– Expressive power– Easy to set up
slots for new properties and relations
– Easy to include default information
• Disadvantages– Difficult to
program– Difficult for
inference– Lack of
inexpensive software
50
Homework #2
Give Two advantages and Two disadvantages of Rule-based ES
that are NOT listed in this handouts
52
Conflict Resolution• Earlier we saw two rules for crossing the road.
Let’s add another rule to the knowledge base
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
New rule
53
• Now, we have 2 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 I. E 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 is called conflict resolution.
54
How do we deal with it?• In forward chaining, both rules would be
fired.
• Rule 2 is fired first as the topmost one, as a result, its THEN-part is executed. Value stop is returned.
• 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 result the object action takes new value go.