Professional Documents
Culture Documents
Week8 ExpertSystems Programming Part1
Week8 ExpertSystems Programming Part1
Lectures of Week 8:
Expert Systems Programming and Shells – Part 1
RECAP
• Defining the nature and scope of the
problem
– Rule-based ES are appropriate when the nature
of the problem is qualitative, knowledge is
explicit, and experts are available to solve the
problem effectively and provide their knowledge
• CLIPS is portable.
http://www.clipsrules.net/Downloads.html
Components of CLIPS
• Rule-Based Language
– Can create a fact list
– Can create a rule set
– An inference engine matches facts against rules
• Object-Oriented Language
– Can define classes
– Can create different sets of instances
– Special forms allow you to interface rules and
objects
Defining Facts
• Facts can be asserted
CLIPS> (assert (today is sunday))
<Fact-0>
• CLIPS>(retract 0)
CLIPS>(facts)
f-1 (colour red)
For a total of 1 fact.
Facts
1. Relation name or Ordered fact
– symbolic field used to access the information
– often serves as identifier for the fact
– (example: (today is Sunday), (color green))
2. deffacts
– used to define groups of facts
– (example on slide 15)
3. deftemplate construct
– used to define the structure of a fact
» names and number of slots (zero or more)
• The rule consists of three parts. The first part, (defrule duck,
simply gives the rule a unique name.
(defrule is-it-a-duck
(animal-has webbed-feet)
(animal-has feathers)
=>
(assert (animal-is duck)))
(defrule duck
(declare (salience 20))
; salience in the interval [-10000, 10000] to set priority of rules
(animal-is duck)
=> (assert (sound-is quack))
(printout t "it’s a duck" crlf))
(defrule start
(initial-fact)
=>
(printout t "hello there " crlf) )
Tracing & Recording Things
• Watch command can watch facts (and rules)
CLIPS> (watch facts)
CLIPS> (reset)
==> f-0 (initial-fact)
CLIPS> (retract 0)
<== f-0 (initial-fact)