L11_KR_p3
-
Upload
bomezzz-enterprises -
Category
Documents
-
view
217 -
download
0
Transcript of L11_KR_p3
-
8/3/2019 L11_KR_p3
1/30
241-320 Design Architecture and Engineeringfor Intelligent System
Suntorn Witosurapot
Contact Address:Phone: 074 287369 or
Email: [email protected]
December 2010
-
8/3/2019 L11_KR_p3
2/30
Lecture 12:
Knowledge Representation
and Reasoning Part 3
(Rule based Systems)
-
8/3/2019 L11_KR_p3
3/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 3
Preview:
KR can be classified into 3 categories :
1. Logic-based representation () Propositional Logic
2. Object-based representation () Semantic Networks, Frames
3. Rule-based representation ()
So far, we have learned how to represent knowledgein a relatively declarative, static way (as a bunch ofthings that are true)via PL, Semantic Nets or Frames.
Here, we will learn how to represent knowledge interms of a bunch of rules that tell you what you shoulddo or what you could conclude in different situations.
This lecture
-
8/3/2019 L11_KR_p3
4/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 4
Preview: (cont.)
These rules can be called Production Rules
Expert systems that use a knowledge base consistingof production rules are called rule-based systemsthat
1) can express heuristic knowledge
Heuristics vs. rigid rules
Heuristic: A rule of thumb; a guideline.
Most domain knowledge is in the form of heuristics,rather than rigid rules
Ex: ,rather than: > 10 =
-
8/3/2019 L11_KR_p3
5/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 5
Preview: (cont.)
2) Can capture a domain experts knowledge inpropositional, qualitative form
Procedural vs. propositional
Most programming languages are procedural:first do this, then this, then this
Most human expert knowledge is propositional:If A is true, then B is true
So, conventional programming languages are notnecessarily the most intuitive way to representdomain knowledge.
-
8/3/2019 L11_KR_p3
6/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 6
Preview: (cont.)
3) Can capture a domain experts knowledge inpropositional, qualitative form
Quantitative vs. qualitative
Humans tend to represent their knowledge qualitatively,e.g. John is tall, but Jim is taller.
As opposed to quantitative:
Johns height is 65. Jims height is 68.
So, probably a good idea to represent expert knowledgethat way.
-
8/3/2019 L11_KR_p3
7/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 7
Preview: (cont.)
4) Can separate the knowledge from the reasoning(inference) and from the specific facts
5) easy to understand (i.e. `knowledge' is visible).
Reasoning + knowledge + facts
Human expertise typically breaks down into: Ability to reason Knowledge about the domain (e.g. migraines)
Facts about the particular situation (e.g. this patientssymptoms)
=> Able to Explan the reasoning(e.g.Why do you think I have amigraine? Well, because you have a frequent, intense pain in ..)
-
8/3/2019 L11_KR_p3
8/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 8
Outline
Rule-Based Systems
Production Rules vs. Logic
Advantages & disadvantages
Visualising the rule base
Reasoning with a rule base
Forward chaining
Backward chaining
-
8/3/2019 L11_KR_p3
9/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 9
Rule-Based Systems
In Logic (and semantic nets) we represent knowledgein a declarative, static way - as some facts and rulesthat are true.
Rules in Logic say what is TRUE when someconditions are given.
Rule-based systems are based on rules that saywhat to do, given various conditions.
IF THEN
A special engine will take control when rules areinvoked.
-
8/3/2019 L11_KR_p3
10/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 10
Production Rules vs Logic
In simple examples, rules are very similar to the relationsyntax ( ) in logic (meaning imply), but less formal
IF THEN
E.g. IF fish is floating THEN fish is dead
Alternate syntax: Fish is floating fish is dead
Less concern about precise semantics & sound inference
More about programmed operations based onthe knowledge
-
8/3/2019 L11_KR_p3
11/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 11
Production Rules vs Logic (cont.)
The antecedent part can be multiple in rules
Rules: IF THEN
A rule that contains two clauses in the antecedentconnected by logical OR can re-written as two rules
IF weather is hot OR temperature is high THENice-cream sales are high
could be re-written asIF weather is hot THEN ice-cream sales are high
IF temperature is high THEN ice-cream sales are high
-
8/3/2019 L11_KR_p3
12/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 12
Check your understanding
Q: Can you explain how the if then pattern in theproduction rules and in the conditional statementsfound in conventional programming languages are
different?A: Rules in programming language tell you what is TRUE
when some conditions are given, but
Rules in the production rules tell you what TO DO,
given various conditions, since they are just simplyrepresent the knowledgebased on heuristics orexperiential reasoning.
-
8/3/2019 L11_KR_p3
13/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 13
Simple Example: Small KBS for weather prediction
R1 IF the ambient temperature is above 35 C
THEN the weather is hot
R2 IF the relative humidity is greater than 65%
THEN the atmosphere is humidR3 IF the weather is hot AND the atmosphere is humid
THEN thunderstorms are likely to happen
An alternative is to write one rule (R1 & R2 are placed
directly in the premise of R3). However we may wish to use the statements, the weather is
hot and the atmosphere is humid, for other purposes in theknowledge base.
-
8/3/2019 L11_KR_p3
14/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 14
Advantages & disadvantages
Advantages
easy to understand the knowledge `content'.
explanation for the reasoning is easily shown i.e. a list ofwhich rules fired (and in which order) during reasoning.
maintenance (or modification) is easy, provided the rulebase structured well.
uncertainty can incorporated into the knowledge base.
Disadvantages (or limitations) rule bases can be very large (thousands of rules)
rules may not reflect the actual decision making
the only structure in the KB is through the rule chaining
-
8/3/2019 L11_KR_p3
15/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 15
Outline
Rule-Based Systems
Production Rules vs. Logic
Advantages & disadvantages
Visualising the rule base
Reasoning with a rule base
Forward chaining
Backward chaining
-
8/3/2019 L11_KR_p3
16/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 16
Visualising the rule base
An and/or graphvisualises the rule base as a treestructure
The nodesare facts [as expressed by the rule clauses]and the lines (or arcs) represent condition-actionpairs [i.e. where one node appears in the antecedent (LHS)and the other in the consequent (RHS) of a rule].
A logical AND between any two or more ruleclauses is shown byjoining the arcs. If there is no
join then a logical OR is assumed.
To simplify the structure of the graph, the nodes willbe represented abstractly [using letters etc].
-
8/3/2019 L11_KR_p3
17/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 17
Visualising the rule base: Example 1
The and/or graph for the following rule base(1) IF A and B and C THEN E
(2) IF D THEN F
(3) IF E and F and G THEN H
goal
-
8/3/2019 L11_KR_p3
18/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 18
Visualising the rule base: Example 2
(1) IF A and B and C THEN D
(2) IF A1 and A2 and A3 THEN A
(3) IF A11 and A12 THEN A1
(4) IF A21 and A22 THEN A2(5) IF C1 and C2 and C3 THEN C
(6) IF B1 and B2 THEN B
(7) IF C21 and C22 THEN C2
Goal D
-
8/3/2019 L11_KR_p3
19/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 19
Outline
Rule-Based Systems
Production Rules vs. Logic
Advantages & disadvantages
Visualising the rule base
Reasoning with a rule base
Forward chaining
Backward chaining
-
8/3/2019 L11_KR_p3
20/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 20
Reasoning with a rule base
How are the rules processed? In general, the pattern-matching cycles is performed
For each cycle ....
the left-hand side(s) of the rules are compared with
the current facts. when all conditions of a rule is met, (called it is
'fired) and the value of the conclusion (action part)is added to working memory.
on the next cycle, further rules may fire and so theprocess goes on.
The issue becomes What strategies and controlsshould be in place to guide rule selection?
-
8/3/2019 L11_KR_p3
21/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 21
Reasoning with a rule base (cont.)
Two main control strategies:
Forward chaining () Data Driven Search
starts with the facts, and sees what rules apply(and hence what should be done) given the facts.
Backward chaining ()
Goal Driven Search starts with something to find out, and looks for
rules that will help in answering it given currentfact (or requiring new inputs, eg. Diagnostic tests).
-
8/3/2019 L11_KR_p3
22/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 22
Forward chaining: Example visualization
An example
(1) IF A THEN C
(2) IF A and B THEN D
(3) IF D and B THEN G
(4) IF D and C THEN F(5) IF C THEN E
(6) IF E and F THEN H
(7) IF F and G and K THEN J
(8) IF F and G THEN I
Note:
H, I and J are root nodes
A, B and K are `inputs'
A
D
E
H
I
J
F
GB
K
C
-
8/3/2019 L11_KR_p3
23/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 23
Forward chaining:Advantages & DisAdvantage
Good for answering What is the situation?kind of questions (e.g. What kind of animal is this?)
Fires a lot of rules, and generates a lot of facts that
might be irrelevant to the problem
-
8/3/2019 L11_KR_p3
24/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 24
Backward Chaining (goal driven search)
Same rules/facts may be processed differently, usingbackward chainingengine.
Start with possible hypothesis (e.g. The patient has
type I diabetes) and tries to prove it Find rules that consequents that match the goal.
If antecedents match the facts, stop.
If not, make the antecedents the new subgoals,
and repeat.
-
8/3/2019 L11_KR_p3
25/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 25
Backward chaining: Example visualization
Using example 2
(1) IF A and B and C THEN D
(2) IF A1 and A2 and A3 THEN A
(3) IF A11 and A12 THEN A1
(4) IF A21 and A22 THEN A2
(5) IF C1 and C2 and C3 THEN C
(6) IF B1 and B2 THEN B(7) IF C21 and C22 THEN C2
The graph clearly shows that fact D isroot of the tree. Hence, the objective isto determine this fact.
Note also that the leaf nodes (A11, A12,A21, A22, A3, B1, B2, C1, C21, C22, C3)represent `facts' that cannot be inferredfrom the rule base but instead have to be'asked for' (in other words they are inputs)
-
8/3/2019 L11_KR_p3
26/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 26
Applications
Backward chaining systems have been fairly widelyused in E.g., medical expert systems, where
start with set of hypotheses on possible diseases
- try to prove each one,
asking additional diagnostic questions when fact isunknown.
-
8/3/2019 L11_KR_p3
27/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 27
Backward chaining:Advantages & DisAdvantage
Efficient way to prove or disprove a particularhypothesis.
Sometimesmore efficient with a small set of
hypotheses Less efficient than forward chaining if large number of
hypotheses
-
8/3/2019 L11_KR_p3
28/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 28
Forward vs. backward chaining
Forward chaining best for analysis andinterpretation (e.g. Determination ofmolecular structure of soil sample).
Backward chaining best for diagnosis (e.g.Diagnoses of infectious blood diseases).
-
8/3/2019 L11_KR_p3
29/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning - part 3 (Rule-based) 29
Forward + backward chaining
Most real expert systems use both
Primary inference is backward chaining, and switchesto forward chaining when new data is added
This aims to minimizes pointless queries to user(backward chaining), but exploits any facts that areacquired
-
8/3/2019 L11_KR_p3
30/30
241-320 Design Architecture &Engineering for Intelligent System Knowledge Representation andReasoning part 3 (Rule based) 30
Reading
6 (Resoning andInference)
6.2