Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 25

Kingdom of Saudi Arabia

Ministry of Higher Education ‫المملكة العربية السعودية‬


Taibah University ‫وزارة التعليم العالي‬
College of Computer Science and ‫جامعة طيبة‬
Engineering ‫كلية علوم و هندسة الحاسبات‬

MSCS822 – Expert Systems and


Knowledge
Engineering Applications

Lectures of Week 10:


Reasoning
Introduction
• Real knowledge representation and reasoning systems come
in several major varieties.
• These differ in their intended use, expressivity, features,…
• Some major families are
– Logic programming languages
– Theorem provers
– Rule-based or production systems
– Semantic networks
– Frame-based representation languages
– Databases (deductive, relational, object-oriented, etc.)
– Constraint reasoning systems
– Description logics
– Bayesian networks
– Evidential reasoning
2
Forward-chaining Production Systems
• The notion of a “production system” was invented in 1943
by Post
• Used as the basis for many rule-based expert systems
• Used as a model of human cognition in psychology
• A production is a rule of the form:

C1, C2, … Cn => A1 A2 …Am

Left hand side (LHS) Right hand side (RHS)


Condition which must Actions to be performed
hold before the rule or conclusions to be drawn
can be applied when the rule is applied
3
Production Systems: Basic components
• Rules -- Unordered set of user-defined “if-then” rules.
– Form: if P1  ...  Pm then A1, ..., An
– The Pi are facts that determine the conditions when a rule is
applicable.
– Actions can add or delete facts from the working memory.

• Working Memory -- A set of “facts” consisting of positive


literals defining what’s known to be true about the world
– Usually “flat tuples” like (location taibahU madinah).

• Inference Engine -- Procedure for inferring changes


(additions and deletions) to working memory.
– Typically uses forward chaining to make inferences

4
Typical CLIPS Rules
(defrule determine-gas-level ""
(working-state engine does-not-start)
(rotation-state engine rotates)
(not (repair ?)) (defrule normal-engine-state-conclusions
(not (gas-in-tank yes)) ""
=> (declare (salience 10))
(assert (repair "Add gas."))) (working-state engine normal)
=>
(defrule print-repair "" (assert (repair "No repair needed."))
(declare (salience 10)) (assert (spark-state engine normal))
(repair ?item) (assert (charge-state battery charged))
=> (assert (rotation-state engine rotates)))
(printout t crlf crlf)
(printout t "Suggested Repair:")
(printout t crlf crlf)
(format t " %s%n%n%n" ?item))
5
Typical CLIPS facts
• Facts in most production systems
are basically flat tuples.

(initial-fact)
(deftemplate engine
(working-state engine unsatisfactory)
(slot horsepower)
(slot displacement) (charge-state battery charged)
(slot manufacturer) (rotation-state engine rotates)
(slot year)) (repair "Clean the fuel line.")
• Matching slots in a template is (engine (horsepower 250)
order insensitive, as in: (displacement 409)
(engine (year 1998) (horsepower ?x)) (manufacturer ford))
(engine (horsepower 250)
(displacement 500) (year 1998))

6
Basic Procedure
While changes are made to Working Memory do:
• Match: Construct the Conflict Set -- the set of all possible
(R, F) pairs such that R is one of the rules and F is a subset
of facts in WM that unify with the antecedent (left-hand
side) of R.

• Conflict Resolution: for execution. Select one pair from


the Conflict Set

• Act: Execute the actions associated with the consequent


(right-hand side) of R, after making the substitutions used
during unification of the antecedent part with F.

7
Rete Algorithm
• The Rete Algorithm (Greek for “net”) is the most widely used,
efficient algorithm for the implementation of production systems.
• Developed by Charles Forgy at Carnegie Mellon University in
1979.
– Charles L. Forgy, "Rete: A Fast Algorithm for the Many Pattern/Many
Object Pattern Match Problem", Artificial Intelligence,19, pp 17-37, 1982.
• Rete is the only algorithm for production systems whose
efficiency is asymptotically independent of the number of rules.
• The basis for a whole generation of fast expert system shells:
OPS5, ART, CLIPS and Jess.

8
Match Phase
RULES
(defrule R1 “rule one” WORKING MEMORY
(a ?x)(b ?x)(c ?y) (a 1) (a 2)
=> (assert (d ?x))) (b 2) (b 3)
(defrule R2 “rule two” (b 4) (c 5)
(a ?x)(b ?y)(d ?x)
=> (assert (e ?x)))
(defrule R3 “rule three”
?fact <- (a ?x) (b ?x) (e ?x)
=> (remove ?fact))

9
Conflict Resolution Strategy Components
• Refraction
– A rule can only be used once with the same set of facts in WM.
Whenever WM is modified, all rules can again be used. This
strategy prevents a single rule and list of facts from being used
repeatedly, resulting in an infinite loop of reasoning.
• Recency
– Use rules that match the facts that were added most recently to WM,
providing a kind of “focus of attention” strategy.
• Specificity
– Use the most specific rule: if both R1 and R2 match, and R1’s LHS
logically implies R2’s LHS, use R2.
• Explicit priorities
– E.g., numeric salience attribute for rules

10
Semantic Networks
• A semantic network is a simple representation scheme that
uses a graph of labeled nodes and labeled, directed arcs to
encode knowledge.
– Usually used to represent static, taxonomic, concept dictionaries
• Semantic networks are typically used with a special set of
accessing procedures that perform “reasoning”.
– e.g., inheritance of values and relationships
• Semantic networks were very popular in the ‘60s and ‘70s
but are less frequently used today.
– Often much less expressive than other KR formalisms
• The graphical depiction associated with a semantic
network is a significant reason for their popularity.
11
Nodes and Arcs

• Arcs define binary relationships that hold between objects


denoted by the nodes.

mother age
Sue john 5
wi
age fe
hus father
ba nd mother(sue.john)
34 Max age(john,5)
age wife(sue,max)
age(max,34)
...
12
Semantic Networks
• The ISA (is-a) or AKO (a-
kind-of) relation is often
used to link instances to Animal
classes, classes to
isa
superclasses
hasPart
• Some links (e.g. hasPart) Bird
are inherited along ISA
isa Wing
paths.
• The semantics of a semantic Robin
net can be relatively isa isa
informal or very formal
– often defined at the
implementation level
Rusty Red
13
Reification

• Non-binary relationships can be represented by “turning the


relationship into an object”
• This is an example of what logicians call “reification”
– reify v : consider an abstract concept to be real
• We might want to represent the generic give event as a
relation involving three things: a giver, a recipient and an
object, give(john,mary,book32)

giver john
give
recipient object
mary book32
14
Individuals and Classes
Genus

• Many semantic networks Animal


distinguish:
subclass instance
hasPart
–nodes representing Bird
individuals and those
representing classes. subclass Wing
Robin
–the “subclass” relation instance instance
from the “instance-of”
relation
Rusty Red
15
Inference by Inheritance
• One of the main kinds of reasoning done in a
semantic net is the inheritance of values along
the subclass and instance links.

• Semantic networks differ in how they handle


the case of inheriting multiple different values.
– All possible values are inherited, or
– Only the “lowest” value or values are
inherited
16
Conflicting Inherited Values

17
From Semantic Nets to Frames
• Semantic networks morphed into Frame
Representation Languages in the ‘70s and ‘80s.

• A frame is a lot like the notion of an object in OOP,


• A frame has a set of slots.

• A slot represents a relation to another frame (or


value). A slot has one or more facets.

• A facet represents some aspect of the relation.


18
Facets
• A slot in a frame holds more than a value.
• Other facets might include:
– current fillers (e.g., values)
– default fillers
– minimum and maximum number of fillers
– type restriction on fillers (usually expressed as another
frame object)
– attached procedures (if-needed, if-added, if-removed)
– salience measure
– attached constraints or axioms
• In some systems, the slots themselves are instances of frames.

19
20
Description Logics
• Description logics provide a family of frame-like KR
systems with a formal semantics.
– E.g., KL-ONE, LOOM, Classic, …

• An additional kind of inference done by these systems is


automatic classification
– finding the right place in a hierarchy of objects for a
new description.

• Current systems take care to keep the languages simple, so


that all inference can be done in polynomial time (in the
number of objects).
21
Abduction
• Abduction is a reasoning process that tries to form plausible
explanations for abnormal observations.
– Abduction is distinctly different from deduction and induction
– Abduction is inherently uncertain

• Uncertainty is an important issue in abductive reasoning


• Some major formalisms for representing and reasoning about
uncertainty:

–)
– Probability theory (esp. Certainty factors (an early representative
Bayesian belief networks)
– Dempster-Shafer theory
– Fuzzy logic 22
Abduction
• Definition (Encyclopedia Britannica): reasoning that derives an
explanatory hypothesis from a given set of facts
– The inference result is a hypothesis that, if true, could explain
the occurrence of the given facts

• Examples
– DENDRAL: An expert system to construct 3D structure of
chemical compounds.
• Fact: mass spectrometer data of the compound and its
chemical formula.
• KB: chemistry, esp. strength of different types of bounds
• Reasoning: form a hypothetical 3D structure that satisfies the
chemical formula, and that would most likely produce the
given mass spectrum.
23
Abduction examples (cont.)
– Medical diagnosis:
• Facts: symptoms, lab test results, and other observed
findings (called manifestations).

• KB: causal associations between diseases and


manifestations.

• Reasoning: one or more diseases whose presence would


causally explain the occurrence of the given manifestations.

24
Abduction, Deduction and Induction
A => B
Deduction: major premise: All balls in the box are black
minor premise: These balls are from the box A
---------
conclusion: These balls are black B

Abduction: rule: All balls in the box are black A => B


B
observation: These balls are black -------------
Possibly A
explanation: These balls are from the box

Induction: case: These balls are from the box Whenever


A then B
observation: These balls are black -------------
hypothesized rule: All ball in the box are black Possibly
A => B
Deduction reasons from causes to effects
Abduction reasons from effects to causes
Induction reasons from specific cases to general rules
25

You might also like