seyed hashem davarpanah [email protected] university of science and culture expert systems clips

62
Seyed Hashem Davarpanah [email protected] University of Science and Culture Expert systems CLIPS

Upload: hayden-fagan

Post on 26-Mar-2015

229 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Seyed Hashem [email protected]

University of Science and Culture

Expert systemsCLIPS

Page 2: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Motivation

• CLIPS is a decent example of an expert system shell– rule-based, forward-chaining system

• it illustrates many of the concepts and methods used in other XPS shells

• it allows the representation of knowledge, and its use for solving suitable problems

Page 3: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Introduction• CLIPS stands for

– C Language Implementation Production System• forward-chaining

– starting from the facts, a solution is developed• pattern-matching

– Rete matching algorithm: find ``fitting'' rules and facts• knowledge-based system shell

– empty tool, to be filled with knowledge• multi-paradigm programming language

– rule-based, object-oriented (Cool) and procedural

Page 4: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Rete Matching Algorithm• An expert system might check each rule against the known facts in

the knowledge base, firing that rule if necessary, then moving on to the next rule.

• For even moderate sized rules and facts knowledge-bases, this approach performs far too slowly.

• The Rete algorithm provides the basis for a more efficient implementation.

• A Rete-based expert system builds a network of nodes, where each node (except the root) corresponds to a pattern occurring in the left-hand-side (the condition part) of a rule.

• The path from the root node to a leaf node defines a complete rule left-hand-side. Each node has a memory of facts which satisfy that pattern. As new facts are asserted or modified, they propagate along the network, causing nodes to be annotated when that fact matches that pattern. When a fact or combination of facts causes all of the patterns for a given rule to be satisfied, a leaf node is reached and the corresponding rule is triggered.

Page 5: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

The CLIPS Programming Tool• history of CLIPS

– influenced by OPS5 and ART– implemented in C for efficiency and portability– developed by NASA, distributed & supported by

COSMIC– runs on PC, Mac, UNIX, VAX VMS

• CLIPS provides mechanisms for expert systems– a top-level interpreter– production rule interpreter– object oriented programming language– LISP-like procedural language

Page 6: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

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 (COOL)– can define classes– can create different sets of instances– special forms allow you to interface rules and

objects

[Jackson 1999]

Page 7: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Notation• symbols, characters, keywords

– entered exactly as shown: – (example)

• square brackets [...] – contents are optional:– (example [test])

• pointed brackets (less than / greater than signs) < ... >– replace contents by an instance of that type– (example <char>)

• star * – replace with zero or more instances of the type– <char>*

• plus + – replace with one or more instances of the type– <char>+ (is equivalent to <char> <char>* )

• vertical bar | – choice among a set of items:– true | false

Page 8: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Invoke / Exit CLIPS

• entering CLIPS double-click on icon, or type program name (CLIPS)system prompt appears: CLIPS>

• exiting CLIPS at the system prompt CLIPS> type (exit)– Note: enclosing parentheses are important; they

indicate a command to be executed, not just a symbol

Page 9: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Fields - Examples

Fields (data types)• float 4.00, 2.0e+2, 2e-2• integer 4, 2, 22• symbol Alpha24*, !?@*$• string “Johnny B. Good”• instance name [titanic], [PPK]

Variables?var, ?x, ?day variables for single field value$?names variable for multi-field value

Page 10: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

CLIPS –Facts

Facts• a relation-name,• an ordered sequence of values (ordered facts), or • a set of (slot-name slot-value)-pairs (i.e. deftemplate-

facts)

examples:

(today is Thursday)(person (name “Johnny B. Good”) (age 25))

Page 11: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Ordered Facts

Ordered facts• are facts defined without (explicit) template; • the field-values are ordered.

Examples:(number-list 1 2 55 6 7 42)(today is Sunday)

Page 12: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Deftemplate Facts

Deftemplate-facts • are facts defined based on a template; • slots can be arranged arbitrarily, there is no

specific order.

• Define a template for describing a set of facts using deftemplate (record structure) .

• Use deffacts to create a list of facts based on a template.

Page 13: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Examples of Facts

• ordered fact(person-name Franz J. Kurfess)

• deftemplate fact(deftemplate person "deftemplate example”

(slot name) (slot age) (slot eye-color) (slot hair-color))

Page 14: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Defining Facts• Facts can be asserted

CLIPS> (assert (today is sunday))<Fact-0>

• Facts can be listedCLIPS> (facts)f-0 (today is sunday)

• Facts can be retractedCLIPS> (retract 0)CLIPS> (facts)

[Jackson 1999]

Page 15: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Instances

• an instance of a fact is created by (assert (person (name "Franz J. Kurfess")

(age 46)

(eye-color brown)

(hair-color brown))

)

Page 16: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Initial Facts(deffacts kurfesses "some members of the Kurfess

family"(person (name "Franz J. Kurfess") (age 46)

(eye-color brown) (hair-color brown))(person (name "Hubert Kurfess") (age 44)

(eye-color blue) (hair-color blond))(person (name "Bernhard Kurfess") (age 41)

(eye-color blue) (hair-color blond))(person (name "Heinrich Kurfess") (age 38)

(eye-color brown) (hair-color blond))(person (name "Irmgard Kurfess") (age 37)

(eye-color green) (hair-color blond))

)

Page 17: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Usage of Facts• adding facts

– (assert <fact>+)

• deleting facts – (retract <fact-index>+)

• modifying facts – (modify <fact-index> (<slot-name> <slot-value>)+ )

• retracts the original fact and asserts a new, modified fact

• duplicating facts – (duplicate <fact-index> (<slot-name> <slot-value>)+ )

• adds a new, possibly modified fact

• inspection of facts – (facts)

• prints the list of facts– (watch facts)

• automatically displays changes to the fact list

Page 18: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Rules

• general format(defrule <rule name> ["comment"] <patterns>* ; left-hand side (LHS) ; or antecedent of the rule

=> <actions>*) ; right-hand side (RHS)

; or consequent of the rule

Page 19: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Rule Components

• rule header – defrule keyword, name of the rule, optional

comment string• rule antecedent (LHS)

– patterns to be matched against facts• rule arrow

– separates antecedent and consequent• rule consequent (RHS)

– actions to be performed when the rule fires

Page 20: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Rule - Example

(defrule birthday “A person’s birthday”(person (name ?name) (age ?

age))(has-birthday ?name ?age)

=>

(printout t “Happy Birthday, ” ?name))

templatefact

ordered fact

terminal

rule name comment

variables

variabletextfunction

Page 21: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Examples of Rules• simple rule

(defrule birthday-FJK (person (name "Franz J. Kurfess")

(age 46) (eye-color brown) (hair-color brown)) (date-today April-13-02)=> (printout t "Happy birthday, Franz!")

(modify 1 (age 47)))

Page 22: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Wildcards

• question mark ?– matches any single field within a fact

• multi-field wildcard $? – matches zero or more fields in a fact

Page 23: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Salience

• We can use salience measures to prioritize rules.

• CLIPS provides a built-in method for prioritizing rules:

(declare (salience value))

• Salience values can range from -10000 to +10000. Default is 0.

• We can thus force the execution of one rule over another. We can implement sequencing of rules.

Page 24: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Rule Prioritization in Clips

• for example, consider the following rules... (forced order of execution)

Page 25: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Two Nifty Rules

(defrule fire-first(declare (salience 30))(priority first)

=> (printout t "Print First" crlf) )

(defrule fire-second(declare (salience 20))(priority second)

=>(printout t "Print Second" crlf) )

Page 26: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Field Constraints

• not constraint ~– the field can take any value except the one specified

• or constraint |– specifies alternative values, one of which must match

• and constraint &– the value of the field must match all specified values

– mostly used to place constraints on the binding of a variable

Page 27: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Mathematical Operators • basic operators (+,-,*,/) and many functions (trigonometric,

logarithmic, exponential) are supported• prefix notation• no built-in precedence, only left-to-right and parentheses• test feature

– evaluates an expression in the LHS instead of matching a pattern against a fact

• pattern connectives – multiple patterns in the LHS are implicitly AND-connected– patterns can also be explicitly connected via AND, OR, NOT

• user-defined functions – external functions written in C or other languages can be integrated– Jess is tightly integrated with Java

Page 28: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Examples of Rules

• more complex rule (defrule find-blue-eyes (person (name ?name) (eye-color blue)) => (printout t ?name " has blue eyes."

crlf))

Page 29: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Example Rule with Field Constraints

(defrule silly-eye-hair-match(person (name ?name1)

(eye-color ?eyes1&blue|green)(hair-color ?hair1&~black))

(person (name ?name2&~?name1)(eye-color ?eyes2&~?eyes1)(hair-color ?hair2&red|?hair1))

=>

(printout t ?name1 " has "?eyes1 " eyes and " ?hair1 " hair." crlf)

(printout t ?name2 " has "?eyes2 " eyes and " ?hair2 " hair." crlf))

Page 30: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Using Templates(deftemplate student “a student record”(slot name (type STRING))(slot age (type NUMBER) (default 18)))

CLIPS> (assert (student (name fred)))

(defrule print-a-student(student (name ?name) (age ?age))=>(printout t ?name “ is “ ?age)

)

[Jackson 1999]

Page 31: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

An Example CLIPS Rule

(defrule sunday “Things to do on Sunday”

(salience 0) ; salience in the interval [-10000, 10000]

(today is Sunday)

(weather is sunny)

=>

(assert (chore wash car))

(assert (chore chop wood)))

[Jackson 1999]

Page 32: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Variables & Pattern Matching

• Variables make rules more applicable

(defrule pick-a-chore(today is ?day)(chore is ?job)=>(assert (do ?job on ?day))

)

• if conditions are matched, then bindings are used

[Jackson 1999]

Page 33: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Retracting Facts from a Rule(defrule do-a-chore

(today is ?day); ?day must have a consistent binding

?chore <- (do ?job on ?day)=>(printout t ?job “ done”)(retract ?chore)

)

• a variable must be assigned to the item for retraction

[Jackson 1999]

Page 34: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Procedural Control in Actions

• Procedural Control Elements can appear on the RHS of a rule or in message-handlers of classes.

(if <predicate-expression>

then <expression>+

[else <expression>+ ]) ;;else-part optional

(while <predicate-expression>

[do] <expression>* ]) ;;‘do’ not mandatory

Page 35: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Example – if-then-else

(defrule special-age “18, 21, 100”(or (person (name ?name) (age ?age&18))

(person (name ?name) (age ?age&21)) (person (name ?name) (age ?age&100)))

=>(if (= ?age 18) then (printout t ?name “ can buy beer in Canada.”)

else (if (= ?age 21) then (printout t ?name “ can

buy beer in the USA.”) else

(if (= ?age 100) then (printout t “The major will visit ” ?name ))...)

Page 36: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Condition Patterns with Logical Connectives

Complex Conditions with logical connectives:

(or (pattern1) (pattern2))Rule becomes active if one of the patterns matches.

example: (or (birthday) (anniversary))matches fact base with facts (birthday) or (anniversary)

Equivalent for:

and (is default)notexists to be fulfilled for one matching fact forall to be fulfilled for all facts which match

based on first fact and variable binding

Page 37: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Complex Condition Elements - or

(defrule report-emergency

(or (emergency (emergency-type fire) (location ?building))

(emergency (emergency-type bomb) (location ?building))

)

=>

(printout t “evacuate “ ?building)

)

reports a building if there is a fire or bomb emergency in this building

Page 38: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Complex Condition Elements – exists

(defrule emergency-report (exists

(or (emergency (emergency-type fire)) (emergency (emergency-type bomb)))

) =>

(printout t “There is an emergency.“ crlf ))

prints one emergency-message if there is a fire or bomb emergency. (no further matching, firing, or printout)

Page 39: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Complex Condition Elements – forall

(defrule evacuated-all-buildings (forall (emergency (emergency-type fire | bomb)

(location ?building) )

(evacuated (building ?building)))=>

(printout t “All buildings with emergency are evacuated “ crlf))

prints evacuated-message if for all buildings, which have a fire or bomb emergency, the building is evacuated.

Page 40: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Salience

• We can use salience measures to prioritize rules.

• CLIPS provides a built-in method for prioritizing rules:

(declare (salience value))

• Salience values can range from -10000 to +10000. Default is 0.

• We can thus force the execution of one rule over another. We can implement sequencing of rules.

Page 41: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Rule Prioritization in Clips

• for example, consider the following rules... (forced order of execution)

Page 42: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Two Nifty Rules

(defrule fire-first(declare (salience 30))(priority first)

=> (printout t "Print First" crlf) )

(defrule fire-second(declare (salience 20))(priority second)

=>(printout t "Print Second" crlf) )

Page 43: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Manipulation of Constructs• show list of constructs

(list-defrules), (list-deftemplates), (list-deffacts)

• prints a list of the respective constructs• show text of constructs

(ppdefrule <defrule-name>), (ppdeftemplate <deftemplate-name>), (ppdeffacts <deffacts-name>)

• displays the text of the construct (``pretty print'')• deleting constructs

(undefrule <defrule-name>), (undeftemplate <deftemplate-name>), (undeffacts <deffacts-name>)

• deletes the construct (if it is not in use)• clearing the CLIPS environment

(clear) • removes all constructs and adds the initial facts to the CLIPS environment

Page 44: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

bind-functionbind-function – explicitly binds value to variable

(bind ?age (read)) stores value of single field which is read into single-field variable ?age

(bind ?name (readline))stores line which is read as STRING into single-field STRING-variable ?address

(bind ?address (explode$ (readline)))explode$ splits line which is read as STRING into multifield-value which is stored in multislot-variable ?address

Page 45: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Open, Close FileOpen file for read/write:

(open “<file-name>” <logical-name> “r”)– <file-name> is physical file-name (path)– <logical-name> is name used in program– “r” indicates read-access (“w”, “r+”)

example: (open “example.dat” my-file “r”)(read my-file)

Close file:(close <logical-name>)

Page 46: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Input – read, readlineread – input of single fieldreadline – input of complete (line as string)

general: (read <logical name>)<logical name> refers to file-name in program(read) keyboard is default

read with bind-function to bind input to variable:(bind ?input (read))(bind $?input (readline))

Page 47: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Input – read, readline (read / readline <logical name>)

– default is keyboard/terminal– file has to be opened using

(open “<file-name>” <logical-name> “r”)• <file-name> is physical file-name (can include path)• <logical-name> is name used in read command• “r” indicates read-access

example: (open “example.dat” example “r”)(read example)

use with bind-function to bind input to variable

Page 48: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Output - printout(printout <logical-name> ... ) t terminal is standard otherwise <logical-name> refers to a file-name

file has to be opened using (open “<file-name>” <logical-name> “w” )

– <file-name> is physical file-name (can include path)– <logical-name> is name used in printout command “w” indicates write-access

example: (open “example.dat” my-output “w” )(printout my-output ?name crlf)

Page 49: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Program Execution• agenda

– if all patterns of a rule match with facts, it is put on the agenda

– (agenda) displays all activated rules• salience

– indicates priority of rules• refraction

– rules fire only once for a specific set of facts• prevents infinite loops

– (refresh <rule-name>) • reactivates rules

Page 50: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Execution of a Program • (reset) prepares (re)start of a program:

– all previous facts are deleted– initial facts are asserted– rules matching these facts are put on the agenda

• (run [<limit>]) starts the execution• breakpoints

– (set-break [<rule-name>])• stops the execution before the rule fires,• continue with (run)

– (remove-break [<rule-name>])– (show-breaks)

Page 51: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Watching

• watching the execution – (watch <watch-item>) prints messages

about activities concerning a <watch-item>• (facts, rules, activations, statistics, compilation, focus, all)

– (unwatch <watch-item>) • turns the messages off

Page 52: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Watching Facts, Rules and Activations

• facts – assertions (add) and retractions (delete) – of facts

• rules – message for each rule that is fired

• activations – activated rules: matching antecedents – these rules are on the agenda

Page 53: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

More Watching ...• statistics

– information about the program execution– (number of rules fired, run time, ... )

• compilation (default)– shows information for constructs loaded by (load)

• Defining deftemplate: ...• Defining defrule: ... +j=j

– +j, =j indicates the internal structure of the compiled rules» +j join added» =j join shared

– important for the efficiency of the Rete pattern matching network

• focus – used with modules– indicates which module is currently active

Page 54: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Defining Functions in CLIPS• Uses a LISP or Scheme-like syntax

(deffunction function-name (arg ... arg)action ... action)

(deffunction hypotenuse (?a ?b)(sqrt (+ (* ?a ?a) (* ?b ?b))))

(deffunction initialize ()(clear)(assert (today is sunday)))

[Jackson 1999]

Page 55: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Defining Classes & Instances• defining the class CAR(defclass car

(is-a user)

(name)

(made-by))

• defining an instance of CAR(make-instance corvette of car

(made-by chevrolet))

[Jackson 1999]

Page 56: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Managing Instances• Commands to display instances

CLIPS> (instances)[corvette] of carCLIPS> (send [corvette] print)[corvette] of car(made-by chevrolet)

• Command to group instances (in a file)(definstances

(corvette of car (made-by chevrolet))(thunderbird of car (made-by ford)))

[Jackson 1999]

Page 57: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Clearing & Resetting Instances• deleting an instance

CLIPS> (send [corvette] delete)

• deleting all instancesCLIPS> (unmake-instance *)

• resetting creates an initial objectCLIPS> (reset)CLIPS> (instances)[initial-object] of INITIAL-OBJECT

[Jackson 1999]

Page 58: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Limitations of CLIPS

• single level rule sets– in LOOPS, you could arrange rule sets in a hierarchy,

embedding one rule set inside another, etc• loose coupling of rules and objects

– rules can communicate with objects via message passing– rules cannot easily be embedded in objects, as in Centaur

• CLIPS has no explicit agenda mechanism– the basic control flow is forward chaining– to implement other kinds of reasoning you have to

manipulate tokens in working memory

[Jackson 1999]

Page 59: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Alternatives to CLIPS• JESS

– see below• Eclipse

– enhanced, commercial variant of CLIPS– has same syntax as CLIPS (both are based on ART)– supports goal-driven (i.e., backwards) reasoning– has a truth maintenance facility for checking consistency– can be integrated with C++ and dBase– new extension RETE++ can generate C++ header files– not related to the (newer) IBM Eclipse environment

• NEXPERT OBJECT– another rule- and object-based system– has facilities for designing graphical interfaces– has a ‘script language’ for designing user front-end– written in C, runs on many platforms, highly portable

[Jackson 1999]

Page 60: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

JESS• JESS stands for Java Expert System Shell• it uses the same syntax and a large majority of

the features of CLIPS• tight integration with Java

– can be invoked easily from Java programs– can utilize object-oriented aspects of Java

• some incompatibilities with CLIPS– COOL replaced by Java classes– a few missing constructs

• more and more added as new versions of JESS are released

Page 61: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

CLIPS Summary• notation

– similar to Lisp, regular expressions• facts

– (deftemplate), (deffacts), assert / retract• rules

– (defrule ...), agenda• variables, operators, functions

– advanced pattern matching• input/output

– (printout ...), (read ...), (load ...)• program execution

– (reset), (run), breakpoints• user interface

– command line or GUI

Page 62: Seyed Hashem Davarpanah Davarpanah@usc.ac.ir University of Science and Culture Expert systems CLIPS

Important Concepts and Terms– agenda– antecedent– assert– backward chaining– consequent– CLIPS– expert system shell– fact– field– forward chaining– function– inference– inference mechanism– instance– If-Then rules– JESS

– knowledge base– knowledge representation– pattern matching– refraction– retract– rule– rule header– salience– template– variable– wild card