# CSC463-Fundamentals of AI

(UiTM Trg MP Jul 2009) 1
Rule-based Expert System
Structure of rule-based
Characteristics of rule-based
Forward Chaining
Backward Chaining
Predicate Calculus
 Knowledge?
◦ “Know-how”, in some domain
◦ Theoretical or practical understanding of a domain / subject
/ area
◦ Data  Information  Knowledge  Meta-knowledge
◦ It consists of relationship between information

 Categories of knowledge
◦ Priori knowledge
 universally true and cannot be denied without contradiction
◦ Posterior knowledge
 the truth or false of the knowledge can be verified using sense
experience

CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 2
 Categories of knowledge - continue
◦ Procedural Knowledge
 Describe how to solve the problem
 Provide direction on how to do something
◦ Declarative Knowledge
 Describe what is known about a problem
 Know something is true and false
◦ Meta-Knowledge
 Describe knowledge about another knowledge
◦ Heuristics Knowledge
 Describe rules of thumb that guides the reasoning process
◦ Structural Knowledge
 Describe an expert overall mental model of the problem
◦ Tacit Knowledge
 Unconscious knowledge, can not be expressed by language
 Unconsciously know how to do something

CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 3
 Two ways to represent knowledge:
◦ Formal
 Predicate Calculus
 Propositional logic
 Resolution

◦ Informal
 Object-Attribute Value (OAV)
 Semantic Network
 Production Rules
 Frames

CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 4
 3 common knowledge representation
schemes
 Logic –
 Propositional Logic, Predicate Calculus
something
 Eg:
 Representation:
 Regular sentence: Abu makan nasi
 Logical sentence: abu_makan_nasi or makan (Abu, nasi)

CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 5
 3 common knowledge representation
schemes
◦ Object (Frames)
 There are a few methods in object-based
representation
 teknik OAV,
 rangkaian semantic,
 Kerangka,
 pohon keputusan
 skrip.

CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 6
 3 common knowledge representation
schemes
 Rules
 Use IF condition THEN action

CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 7
◦ What to Represent?
 Objects: facts about object in our world domain – Ex. Guitars
have single strings, trumpets are brass instruments

 Events: actions that occur in our world – Steve Vai played the
guitar in Frank Zappa‟s Band

 Performance: a behavior like playing the guitar involves
knowledge about how to do things.

 Meta-knowledge: knowledge about what we know.

CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 8

 Expert?

◦ Those who possess knowledge are called experts
◦ Most powerful or important people in an organization
◦ Has deep knowledge (facts and rules) and strong practical
experience in a particular domain
◦ Human mental process is internal and it‟s too complex to be
represented as an algorithm
◦ Most experts are capable of expressing their knowledge in
the form of rules for problem solving

CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 9

 Statements represented in the IF-THEN
form are called production rules or just
rules
 A rule provides some description of how to
solve problem
 Term “rule” in AI that is the most commonly
used type of knowledge representation
 Rule is defined as a IF-THEN structure
where given information or facts in IF part
and actions in THEN part

CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 10

 Statements represented in the IF-THEN
form are called production rules or just
rules
 A rule provides some description of how to
solve problem
 Term “rule” in AI that is the most commonly
used type of knowledge representation
 Rule is defined as a IF-THEN structure
where given information or facts in IF part
and actions in THEN part

CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 11

Example of rules from expert
Knowledge / Rules
IF the „traffic light‟ is green
THEN the action is go

IF the „traffic light‟ is red
THEN the action is stop
CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 12
 Rules as knowledge representation scheme
◦ Rules contain two parts:
 IF part – antecedent (premise of condition)
 THEN part – consequent (conclusion or action)

◦ In general, rules can contain multiple antecedents joint by
AND (conjunction), OR (disjunction) or combination of
both
◦ Good habit to avoid mixing conjunctions and disjunctions in
the same rule
◦ The consequent of rule can also have multiple clauses

CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 13
Examples of Rules
Single:
IF <antecedent>
THEN <consequent>

Conjuctions
IF <antecedent 1>
AND <antecedent 2>
:
AND <antecedent n>
THEN <consequent>
CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 14
Disjuctions
IF <antecedent 1>
OR <antecedent 2>
:
OR <antecedent n>
THEN <consequent>

Consequent with multiple clauses
IF <antecedent>
THEN <consequent 1>
<consequent 2>
:
<consequent n>
CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 15
 Antecedent
◦ Two parts:
 Object (linguistic part) eg. „traffic light‟
 Value eg. red
 Object and value are linked by an operator
eg. Is, are, is not, are not
 Operator identifies the object and assigns the value
 Operator assign a symbolic value to a linguistic object
 Mathematical operator define object as numerical and
assign it a numerical value
eg IF „age of a customer‟ < 18
AND „cash withdrawal‟ > 1000
THEN „signature of parent‟ is required
CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 16
 Consequent
 Combines an object and a value connected by an operator
 Operator assigns the value to the linguistic object
eg. IF „traffic light‟ is green
THEN action is go

 Numerical objects and simple arithmetic expression can be
used in rule consequent
eg IF „income‟ > 16283
THEN „discount‟ = „income‟ * 1.5 / 100
CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 17
 Rules can represent
◦ Relations
◦ Recommendations
◦ Directives
◦ Strategies
◦ Heuristics

CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 18
 Examples
◦ Relations
IF the „fuel tank‟ is empty

◦ Recommendations
IF the season is autumn
AND the sky is cloudy
AND the forecast is drizzle
THEN the advice is „take an umbrella‟

CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 19
◦ Directives
AND the „fuel tank‟ is empty
THEN the action is „refuel the car‟

◦ Strategies
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 id complete

CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 20

◦ Heuristics
IF the spill is liquid
AND the „spill pH‟ < 6
AND the „spill smell‟ is vinegar
THEN the „spill material‟ is „acetic acid‟

CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 21
CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 22
◦ Expert system – a computer program capable of
performing at the level of human expert in a narrow
problem area

◦ Use computer to
 Act as an intelligent assistant in some domain to solve
problem
 Be able to integrate new knowledge and show
knowledge in a form that is easy to read and
understand
 Able to explain / show how it reaches a particular
conclusion

CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 23
◦ Expert system shell can be considered as an expert
with knowledge removed

◦ Users has to add knowledge in the form of rules and
provide relevent data to solve problem

◦ Five members in Expert System Development

CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 24
◦ Expert System development team
CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 25
◦ Production system
CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 26
◦ Basic Structure
CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 27
◦ Complete Structure
 Comparison of human experts, expert system and conventional program
CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 28
 The inference engine compares each rule in
knowledge base with facts contain in the database

CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 29
 The matching of rule IF parts to the facts produce
inference chains
 The inference chains indicates how an expert system
applies the rules to reach a conclusion

 Example of chaining inference techniques
Suppose
Database contains facts A, B, C, D and E
Knowledge base contains three rules
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
CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 30

 Inference chain
CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 31

A X
B
E
Y
D
Z
 Diagram indicates how the expert system applies the
rules to infer fact Z
 The inference engine must decide when the rules
have to be fired (executed)
 Two principal ways are Forward Chaining and
Backward Chaining (Waterman & Hayes Roth 1978)

Rule 3
Rule 2
Rule 1
 Forward chaining  data driven
◦ Premise clause match situation then assert
conclusion
 Inference strategy that begins with a set of
known facts, derives new facts using rules
whose premises match the known facts,
continues until goal reached or no more rules
matches.
 Example:-
◦ As given in slides 26 & 27

CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 32

 Example
◦ Page 37 of (Negnevitsky, 2005)
CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 33

 Example:-
◦ Patient visit a doctor to complaint about certain ailments.

 Rules :-
◦ Rule 1:
IF patient has sore throat
AND suspect bacterial infection
THEN believe patient has strep throat
◦ Rule 2:
IF patient temperature > 100
THEN patient has fever
◦ Rule 3
IF patient sick over a month
AND patient has a fever
THEN suspect a bacterial infections

Assert the following facts (from user):-
1. Patient temperature > 102
2. Patient has been sick for 12 months
3. Patient has sore throat
CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 34

 Backward Chaining  goal driven
◦ Determine facts in the conclusion to prove the
conclusion is true
 An inference strategy that attempts to prove
a hypothesis by gathering supporting
information
 Example:-
◦ A patient visit a doctor and after listening, the
doctor believe patient has strep throat thus doctor
have to prove his assumption
CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 35

 Rule 1:
IF there are signs of throat infection
AND there is evidence that organism is streptococcus
THEN patient has strep throat
 Rule 2:
IF patient throat is red
THEN there are signs of throat infections
 Rule 3:
IF stains of organisms is grampos
AND morphology of the organism is cossus
AND growth of the organism is chains
THEN there is evidence that the organism is streptococcus

OBJECTIVE:- to prove that „The patient have strep throat‟
CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 36

 Example: Page 39 of (Negnevitsky, 2005)
CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 37

 To study how domain expert solves problem
◦ Choose forward chaining if the expert needs to gather information and infers
from it
◦ Choose backward chaining if the expert begins with hypothetical solution and
find facts to prove it

 In expert system, it is a natural way to use forward chaining for
analysis and interpretation
eg DENDRAL – determine the molecular structure of unknown soil based on its
mass spectral data (Feigenbaum et al. 1971)

 For diagnostic purposes, usually backward chaining is used
eg MYCIN – a medical expert system for diagnosing infectious blood diseases
(Shortliffe, 1976)

CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 38

 Many expert system shells use a combination of forward and
backward chaining inference techniques

 The basic inference mechanism is usually backward chaining.
Only when a new fact is establish, forward chaining is employed
to maximise the use of the new data
CSC463-Fundamentals of AI
(UiTM Trg MP Jul 2009) 39