Professional Documents
Culture Documents
Week10 Reasoning
Week10 Reasoning
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.
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
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
giver john
give
recipient object
mary book32
14
Individuals and Classes
Genus
17
From Semantic Nets to Frames
• Semantic networks morphed into Frame
Representation Languages in the ‘70s and ‘80s.
19
20
Description Logics
• Description logics provide a family of frame-like KR
systems with a formal semantics.
– E.g., KL-ONE, LOOM, Classic, …
–)
– 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).
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