___________________________________________ Knowledge-Based Systems (KBSs) ___________________________________________ Fou...
INTRODUCTION TO CLIPS
<ul><li>CLIPS is a decent example of an expert system shell </li></ul><ul><ul><li>rule-based ,  forward-chaining system </...
<ul><li>be familiar with the important concepts and methods used in rule-based ES shells  </li></ul><ul><ul><li>facts, rul...
Introduction <ul><li>CLIPS  C   L anguage  I mplementation  P roduction  S ystem </li></ul><ul><li>forward-chaining  </li...
The CLIPS Programming Tool <ul><li>history of CLIPS </li></ul><ul><ul><li>implemented in C for efficiency and portability ...
Components of CLIPS <ul><li>rule-based language </li></ul><ul><ul><li>can create a  fact  list </li></ul></ul><ul><ul><li>...
Notation <ul><li>symbols, characters, keywords  </li></ul><ul><ul><li>entered exactly as shown:  (example) </li></ul></ul>...
Tokens and Fields <ul><li>Tokens  </li></ul><ul><ul><li>groups of characters with special meaning for CLIPS, </li></ul></u...
CLIPS Primitive Data Types <ul><ul><li>float : decimal point ( 1.5 ) or exponential notation ( 3.7e10 ) </li></ul></ul><ul...
<ul><li>Ex.:    “”three-tokens“” </li></ul><ul><li>in clips </li></ul><ul><li>“” </li></ul><ul><li>three-tokens </li></ul>...
<ul><ul><li>external address </li></ul></ul><ul><ul><ul><li>address of external data structure returned by user-defined fu...
Invoke / Exit CLIPS <ul><li>entering CLIPS  </li></ul><ul><ul><li>double-click on icon, or type program name (CLIPS) </li>...
<ul><ul><li>A:>CLIPSDOS  </li></ul></ul><ul><ul><li>CLIPS (V6.22 06/15/04) CLIPS> exit  </li></ul></ul><ul><ul><li>exit ...
Facts <ul><li>elementary information items (“chunks”) </li></ul><ul><li>Facts  is A &quot;chunk&quot; of information  </li...
Example of a fact <ul><li>(person (name &quot;John Q. Public&quot;) </li></ul><ul><li>(age 23) </li></ul><ul><li>(eye-colo...
deftemplate fact <ul><li>(deftemplate <relation-name> [<optional-comment>] </li></ul><ul><li>  <slot-definition>*) </li></...
ordered fact <ul><li>deftemplate facts  are Facts with a relation name   that has a corresponding deftemplate .  </li></ul...
Defining Facts <ul><li>Facts representing information can be added and removed from the fact list. </li></ul><ul><li>New f...
retract  command  <ul><li>Removing facts from the fact list is called  retraction  and is done with the retract command.  ...
MODIFYING AND DUPLICATING FACTS   <ul><li>Slot values of deftemplate facts can be modified using the modify command.  </li...
The duplicate command  <ul><li>CLIPS>  (duplicate 2 (name “Jack S. Public”) </li></ul><ul><li><Fact-3> </li></ul><ul><li>C...
WATCH COMMAND   <ul><li>(watch <watch-item>) </li></ul><ul><li>where <watch-item> is one of the symbols  facts, rules, act...
Initial Facts <ul><li>(deffacts kurfesses &quot;some members of the Kurfess family&quot; </li></ul><ul><li>(person (name &...
Usage of Facts <ul><li>adding facts  </li></ul><ul><ul><li>(assert <fact>+) </li></ul></ul><ul><li>deleting facts  </li></...
Rules <ul><li>general format </li></ul><ul><ul><li>(defrule <rule name> [&quot;comment&quot;] </li></ul></ul><ul><ul><li><...
Rule Components <ul><li>rule header  </li></ul><ul><ul><li>defrule keyword, name of the rule, optional comment string </li...
Example <ul><li>industrial plant monitoring expert system  </li></ul><ul><li>>>>> IF the emergency is a fire </li></ul><ul...
Examples of Rules <ul><li>simple rule  </li></ul><ul><ul><li>(defrule birthday-FJK </li></ul></ul><ul><ul><li>(person  (na...
Properties of Simple Rules <ul><li>very limited: </li></ul><ul><ul><li>LHS must match facts exactly </li></ul></ul><ul><ul...
THE AGENDA AND EXECUTION <ul><li>A CLIPS program can be made to run with the  run  command.  </li></ul><ul><li>(run [<limi...
Program Execution <ul><li>agenda  </li></ul><ul><ul><li>if all patterns of a rule match with facts, it is put on the agend...
Execution of a Program  <ul><li>(reset) prepares (re)start of a program:  </li></ul><ul><ul><li>all previous facts are del...
Upcoming SlideShare
Loading in …5
×

Lecture2

1,702 views
1,659 views

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,702
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
78
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Lecture2

  1. 1. ___________________________________________ Knowledge-Based Systems (KBSs) ___________________________________________ Fourth Year (First Semester) CS (CS471) & IT (College Ellective -2) Dr. Hamdy M. Mousa MENOUFIA UNIVERSITY FACULTY OF COMPUTERS AND INFORMATION Lecture two
  2. 2. INTRODUCTION TO CLIPS
  3. 3. <ul><li>CLIPS is a decent example of an expert system shell </li></ul><ul><ul><li>rule-based , forward-chaining system </li></ul></ul><ul><li>it illustrates many of the concepts and methods used in other ES shells </li></ul><ul><li>it allows the representation of knowledge, and its use for solving suitable problems </li></ul>Motivation
  4. 4. <ul><li>be familiar with the important concepts and methods used in rule-based ES shells </li></ul><ul><ul><li>facts, rules, pattern matching, agenda, working memory, forward chaining </li></ul></ul><ul><li>understand the fundamental workings of an ES shell </li></ul><ul><ul><li>knowledge representation </li></ul></ul><ul><ul><li>reasoning </li></ul></ul><ul><li>apply rule-based techniques to simple examples </li></ul><ul><li>evaluate the suitability of rule-based systems for specific tasks dealing with knowledge </li></ul>Objectives
  5. 5. Introduction <ul><li>CLIPS  C L anguage I mplementation P roduction S ystem </li></ul><ul><li>forward-chaining </li></ul><ul><ul><li>starting from the facts, a solution is developed </li></ul></ul><ul><li>pattern-matching </li></ul><ul><ul><li>Rete matching algorithm: find ``fitting'' rules and facts </li></ul></ul><ul><li>knowledge-based system shell </li></ul><ul><ul><li>empty tool, to be filled with knowledge </li></ul></ul><ul><li>multi-paradigm programming language </li></ul><ul><ul><li>rule-based, object-oriented (Cool) and procedural </li></ul></ul>
  6. 6. The CLIPS Programming Tool <ul><li>history of CLIPS </li></ul><ul><ul><li>implemented in C for efficiency and portability </li></ul></ul><ul><ul><li>developed by NASA, distributed & supported by COSMIC </li></ul></ul><ul><ul><li>runs on PC, Mac, UNIX, VAX VMS </li></ul></ul><ul><li>CLIPS provides mechanisms for expert systems </li></ul><ul><ul><li>a top-level interpreter </li></ul></ul><ul><ul><li>production rule interpreter </li></ul></ul><ul><ul><li>object oriented programming language </li></ul></ul><ul><ul><li>LISP-like procedural language </li></ul></ul>
  7. 7. Components of CLIPS <ul><li>rule-based language </li></ul><ul><ul><li>can create a fact list </li></ul></ul><ul><ul><li>can create a rule set </li></ul></ul><ul><ul><li>an inference engine matches facts against rules </li></ul></ul><ul><li>object-oriented language (COOL) </li></ul><ul><ul><li>can define classes </li></ul></ul><ul><ul><li>can create different sets of instances </li></ul></ul><ul><ul><li>special forms allow you to interface rules and objects </li></ul></ul>
  8. 8. Notation <ul><li>symbols, characters, keywords </li></ul><ul><ul><li>entered exactly as shown: (example) </li></ul></ul><ul><li>square brackets [...] </li></ul><ul><ul><li>contents are optional: (example [test]) </li></ul></ul><ul><li>pointed brackets (less than / greater than signs) < ... > </li></ul><ul><ul><li>replace contents by an instance of that type </li></ul></ul><ul><ul><li>(example <char>) >>>>>>> (example 1) </li></ul></ul><ul><li>star * </li></ul><ul><ul><li>replace with zero or more instances of the type </li></ul></ul><ul><ul><li><char>* >>>>>>> 1 or 1 2 or 1 2 3 or </li></ul></ul><ul><ul><li> </li></ul></ul><ul><li>plus + </li></ul><ul><ul><li>replace with one or more instances of the type </li></ul></ul><ul><ul><li><char>+ (is equivalent to <char> <char>* ) </li></ul></ul><ul><li>vertical bar | </li></ul><ul><ul><li>choice among a set of items: </li></ul></ul><ul><ul><li>true | false </li></ul></ul>
  9. 9. Tokens and Fields <ul><li>Tokens </li></ul><ul><ul><li>groups of characters with special meaning for CLIPS, </li></ul></ul><ul><ul><li>e.g. ( ) separated by delimiters </li></ul></ul><ul><ul><ul><li>( space, tab, Carriage Return , ...) </li></ul></ul></ul><ul><li>Fields </li></ul><ul><ul><li>particularly important group of tokens </li></ul></ul><ul><ul><li>CLIPS primitive data types </li></ul></ul><ul><ul><ul><li>float, integer, symbol, string, external address, instance name, instance address </li></ul></ul></ul>
  10. 10. CLIPS Primitive Data Types <ul><ul><li>float : decimal point ( 1.5 ) or exponential notation ( 3.7e10 ) </li></ul></ul><ul><ul><li>integer : [sign] <digit>+ </li></ul></ul><ul><ul><li>symbol : <printable ASCII character>+ </li></ul></ul><ul><ul><ul><li>e.g. this-is-a-symbol, wrzlbrmft, !?@*+ </li></ul></ul></ul><ul><ul><ul><li>NOTE : CLIPS is case-sensitive </li></ul></ul></ul><ul><ul><li>string : delimited by double quotes </li></ul></ul><ul><ul><ul><li>e.g. &quot;This is a string“ </li></ul></ul></ul><ul><li>There can be zero or more characters of any kind between the double quotes, including characters normally used by CLIPS as delimiters. i.e. </li></ul><ul><ul><li>&quot;CLIPS&quot; </li></ul></ul>
  11. 11. <ul><li>Ex.: “”three-tokens“” </li></ul><ul><li>in clips </li></ul><ul><li>“” </li></ul><ul><li>three-tokens </li></ul><ul><li>“” </li></ul><ul><li>Within a string, double quotes can be included by using the backslash operator, . </li></ul><ul><li>Ex.: “ ”single-token“” </li></ul>CLIPS Primitive Data Types
  12. 12. <ul><ul><li>external address </li></ul></ul><ul><ul><ul><li>address of external data structure returned by user-defined functions </li></ul></ul></ul><ul><ul><li>instance name (used with Cool) </li></ul></ul><ul><ul><ul><li>delimited by square brackets </li></ul></ul></ul><ul><ul><li>instance address (used with Cool) </li></ul></ul><ul><ul><ul><li>return values from functions </li></ul></ul></ul><ul><li>multi-field value is A series of zero or more fields contained together. Multifield values are usually created by calling a function or when specifying initial values for facts. </li></ul><ul><li>For example, the zero length multifield: </li></ul><ul><li>( ) </li></ul><ul><li>the multifield containing the symbols this and that : </li></ul><ul><li>(this that) </li></ul>CLIPS Primitive Data Types
  13. 13. Invoke / Exit CLIPS <ul><li>entering CLIPS </li></ul><ul><ul><li>double-click on icon, or type program name (CLIPS) </li></ul></ul><ul><ul><li>system prompt appears: </li></ul></ul><ul><ul><li>CLIPS> </li></ul></ul><ul><li>exiting CLIPS </li></ul><ul><ul><li>at the system prompt </li></ul></ul><ul><ul><li>CLIPS> </li></ul></ul><ul><ul><li>type (exit) </li></ul></ul><ul><ul><li>Note: enclosing parentheses are important ; they indicate a command to be executed, not just a symbol </li></ul></ul>
  14. 14. <ul><ul><li>A:>CLIPSDOS  </li></ul></ul><ul><ul><li>CLIPS (V6.22 06/15/04) CLIPS> exit  </li></ul></ul><ul><ul><li>exit </li></ul></ul><ul><ul><li>CLIPS> (+ 3 4)  </li></ul></ul><ul><ul><li>7 </li></ul></ul><ul><ul><li>CLIPS> ( exit)  </li></ul></ul><ul><ul><li>A:> </li></ul></ul>Invoke / Exit CLIPS
  15. 15. Facts <ul><li>elementary information items (“chunks”) </li></ul><ul><li>Facts is A &quot;chunk&quot; of information </li></ul><ul><li>Facts consist of a relation name (a symbolic field) followed by zero or more slots (also symbolic fields) and their associated values. </li></ul><ul><li>relation name </li></ul><ul><ul><li>symbolic field used to access the information </li></ul></ul><ul><ul><li>often serves as identifier for the fact </li></ul></ul><ul><li>slots (zero or more) </li></ul><ul><ul><li>symbolic fields with associated values </li></ul></ul><ul><li>deftemplate construct </li></ul><ul><ul><li>used to define the structure of a fact </li></ul></ul><ul><ul><ul><li>names and number of slots </li></ul></ul></ul><ul><li>deffacts </li></ul><ul><ul><li>used to define initial groups of facts </li></ul></ul>
  16. 16. Example of a fact <ul><li>(person (name &quot;John Q. Public&quot;) </li></ul><ul><li>(age 23) </li></ul><ul><li>(eye-color blue) </li></ul><ul><li>(hair-color black)) </li></ul>
  17. 17. deftemplate fact <ul><li>(deftemplate <relation-name> [<optional-comment>] </li></ul><ul><li> <slot-definition>*) </li></ul><ul><li>deftemplate fact </li></ul><ul><ul><li>(deftemplate person &quot;deftemplate example” </li></ul></ul><ul><ul><li>(slot name) </li></ul></ul><ul><ul><li>(slot age) </li></ul></ul><ul><ul><li>(slot eye-color) </li></ul></ul><ul><ul><li>(slot hair-color)) </li></ul></ul>
  18. 18. ordered fact <ul><li>deftemplate facts are Facts with a relation name that has a corresponding deftemplate . </li></ul><ul><li>ordered facts are Facts with a relation name that does not have a corresponding deftemplate </li></ul><ul><li>ordered fact </li></ul><ul><ul><li>(person-name Franz J. Kurfess) </li></ul></ul><ul><ul><li>Ex.: </li></ul></ul><ul><ul><li>(number-list 7 9 3 4 20) </li></ul></ul><ul><ul><li>equivalent to defining the following deftemplate: </li></ul></ul><ul><ul><li>(deftemplate number-list (multislot values)) </li></ul></ul><ul><ul><li>then defining the fact as follows: </li></ul></ul><ul><ul><li>(number-list (values 7 9 3 4 20)) </li></ul></ul>
  19. 19. Defining Facts <ul><li>Facts representing information can be added and removed from the fact list. </li></ul><ul><li>New facts can be added to the fact list using the assert command. The syntax of the assert command is </li></ul><ul><li>(assert <fact>+) </li></ul><ul><li>Facts can be asserted. </li></ul><ul><ul><li>CLIPS> (assert (parson (name &quot;John Q. Public&quot;) </li></ul></ul><ul><ul><li> (age 23) </li></ul></ul><ul><ul><li> (eye-color blue) </li></ul></ul><ul><ul><li>(hair-color black)))  </li></ul></ul><ul><ul><li><Fact-0> </li></ul></ul><ul><ul><li>CLIPS> </li></ul></ul><ul><li>Facts can be listed </li></ul><ul><ul><li>CLIPS> (facts)  </li></ul></ul><ul><ul><li>f-0 (person (name &quot;John Q. Public&quot;) </li></ul></ul><ul><ul><li>(age 23) </li></ul></ul><ul><ul><li>(eye-color blue) </li></ul></ul><ul><ul><li>(hair-color black)) </li></ul></ul><ul><ul><li>For a total of 1 fact. </li></ul></ul><ul><ul><li>CLIPS> </li></ul></ul>
  20. 20. retract command <ul><li>Removing facts from the fact list is called retraction and is done with the retract command. </li></ul><ul><ul><ul><li> (retract <fact-index>+) </li></ul></ul></ul><ul><li>Facts can be retracted </li></ul><ul><ul><li>CLIPS> (retract 0) </li></ul></ul><ul><ul><li>CLIPS> (facts) </li></ul></ul><ul><li>an instance of a fact is created by </li></ul><ul><ul><li>(assert (person (name &quot;Franz J. Kurfess&quot;) </li></ul></ul><ul><ul><li>(age 46) </li></ul></ul><ul><ul><li>(eye-color brown) </li></ul></ul><ul><ul><li>(hair-color brown)) </li></ul></ul><ul><ul><li>) </li></ul></ul>
  21. 21. MODIFYING AND DUPLICATING FACTS <ul><li>Slot values of deftemplate facts can be modified using the modify command. </li></ul><ul><li>(modify <fact-index> <slot-modifier>+) </li></ul><ul><li>where <slot-modifier> is </li></ul><ul><li>(<slot-name> <slot-value>) </li></ul><ul><li>Ex.: </li></ul><ul><li>CLIPS> (modify 0 (age 24))  </li></ul><ul><li><Fact-1> </li></ul><ul><li>CLIPS> (Facts)  </li></ul><ul><li>f-1 (person (name &quot;John Q. Public&quot;) </li></ul><ul><li> (age 24) </li></ul><ul><li> (eye-color blue) </li></ul><ul><li> (hair-color black)) </li></ul><ul><li>For a total of 1 fact, </li></ul><ul><li>CLIPS> </li></ul>
  22. 22. The duplicate command <ul><li>CLIPS> (duplicate 2 (name “Jack S. Public”) </li></ul><ul><li><Fact-3> </li></ul><ul><li>CLIPS> (Facts)  </li></ul><ul><li>f-2 (person (name &quot;John Q. Public&quot;) </li></ul><ul><li> (age 24) </li></ul><ul><li> (eye-color blue) </li></ul><ul><li> (hair-color black)) </li></ul><ul><li>f-3 (person (name &quot;Jack Q. Public&quot;) </li></ul><ul><li> (age 24) </li></ul><ul><li> (eye-color blue) </li></ul><ul><li> (hair-color black)) </li></ul><ul><li>For a total of 2 fact, </li></ul><ul><li>CLIPS> </li></ul>
  23. 23. WATCH COMMAND <ul><li>(watch <watch-item>) </li></ul><ul><li>where <watch-item> is one of the symbols facts, rules, activations, statistics, compilations, focus, deffunction, global, generic-function, methods, instances, slots, messages, message-handler or all. </li></ul><ul><li>CLIPS> (facts 3 3)  </li></ul><ul><li>f-3 (person (name &quot;Jack S. Public&quot;) </li></ul><ul><li> (age 24) </li></ul><ul><li>(eye-color blue) </li></ul><ul><li> (hair-color black)) </li></ul><ul><li>For a total of 1 fact, </li></ul><ul><li>CLIPS> (watch facts)  </li></ul><ul><li>CLIPS> (modify 3 (age 25))  <= = f-3 (person (name &quot;Jack S. Public&quot;) </li></ul><ul><li>(age 24) </li></ul><ul><li>(eye-color blue) </li></ul><ul><li>(hair-color black)) </li></ul><ul><li>==> f-4 (person (name &quot;Jack S. Public&quot;) </li></ul><ul><li>(age 25) </li></ul><ul><li>(eye-color blue) </li></ul><ul><li>(hair-color black)) </li></ul><ul><li><Fact-4> </li></ul><ul><li>CLIPS> </li></ul>
  24. 24. Initial Facts <ul><li>(deffacts kurfesses &quot;some members of the Kurfess family&quot; </li></ul><ul><li>(person (name &quot;Franz J. Kurfess&quot;) (age 46) </li></ul><ul><li>(eye-color brown) (hair-color brown)) </li></ul><ul><li>(person (name &quot;Hubert Kurfess&quot;) (age 44) </li></ul><ul><li>(eye-color blue) (hair-color blond)) </li></ul><ul><li>(person (name &quot;Bernhard Kurfess&quot;) (age 41) </li></ul><ul><li>(eye-color blue) (hair-color blond)) </li></ul><ul><li>(person (name &quot;Heinrich Kurfess&quot;) (age 38) </li></ul><ul><li>(eye-color brown) (hair-color blond)) </li></ul><ul><li>(person (name &quot;Irmgard Kurfess&quot;) (age 37) </li></ul><ul><li>(eye-color green) (hair-color blond)) </li></ul><ul><li>) </li></ul>
  25. 25. Usage of Facts <ul><li>adding facts </li></ul><ul><ul><li>(assert <fact>+) </li></ul></ul><ul><li>deleting facts </li></ul><ul><ul><li>(retract <fact-index>+) </li></ul></ul><ul><li>modifying facts </li></ul><ul><ul><li>(modify <fact-index> (<slot-name> <slot-value>)+ ) </li></ul></ul><ul><ul><ul><li>retracts the original fact and asserts a new, modified fact </li></ul></ul></ul><ul><li>duplicating facts </li></ul><ul><ul><li>(duplicate <fact-index> (<slot-name> <slot-value>)+ ) </li></ul></ul><ul><ul><ul><li>adds a new, possibly modified fact </li></ul></ul></ul><ul><li>inspection of facts </li></ul><ul><ul><li>(facts) </li></ul></ul><ul><ul><ul><li>prints the list of facts </li></ul></ul></ul><ul><ul><li>(watch facts) </li></ul></ul><ul><ul><ul><li>automatically displays changes to the fact list </li></ul></ul></ul>
  26. 26. Rules <ul><li>general format </li></ul><ul><ul><li>(defrule <rule name> [&quot;comment&quot;] </li></ul></ul><ul><ul><li><patterns>* ; left-hand side (LHS) </li></ul></ul><ul><ul><li> ; or antecedent of the rule </li></ul></ul><ul><ul><li>=> </li></ul></ul><ul><ul><li><actions>*) ; right-hand side (RHS) </li></ul></ul><ul><ul><li> ; or consequent of the rule </li></ul></ul>
  27. 27. Rule Components <ul><li>rule header </li></ul><ul><ul><li>defrule keyword, name of the rule, optional comment string </li></ul></ul><ul><li>rule antecedent (LHS) </li></ul><ul><ul><li>patterns to be matched against facts </li></ul></ul><ul><li>rule arrow </li></ul><ul><ul><li>separates antecedent and consequent </li></ul></ul><ul><li>rule consequent (RHS) </li></ul><ul><ul><li>actions to be performed when the rule fires </li></ul></ul>
  28. 28. Example <ul><li>industrial plant monitoring expert system </li></ul><ul><li>>>>> IF the emergency is a fire </li></ul><ul><li> THEN the response is to activate the sprinkler system </li></ul><ul><li>CLIPS Rules: </li></ul><ul><li>(deftemplate emergency {slot type)) </li></ul><ul><li>(deftemplate response (slot action)) </li></ul><ul><li>; Rule header </li></ul><ul><li>(defrule fire-emergency &quot;An example rule&quot; </li></ul><ul><li>; Patterns </li></ul><ul><li>(emergency (type fire)) </li></ul><ul><li>; THEN arrow </li></ul><ul><li>=> </li></ul><ul><li>; Actions </li></ul><ul><li>(assert </li></ul><ul><li>(response </li></ul><ul><li>(action activate-sprinkler-system)))) </li></ul>
  29. 29. Examples of Rules <ul><li>simple rule </li></ul><ul><ul><li>(defrule birthday-FJK </li></ul></ul><ul><ul><li>(person (name &quot;Franz J. Kurfess&quot;) </li></ul></ul><ul><ul><li>(age 46) </li></ul></ul><ul><ul><li>(eye-color brown) </li></ul></ul><ul><ul><li>(hair-color brown)) </li></ul></ul><ul><ul><li>(date-today April-13-02) </li></ul></ul><ul><ul><li>=> </li></ul></ul><ul><ul><li>(printout t &quot;Happy birthday, Franz!&quot;) </li></ul></ul><ul><ul><li>(modify 1 (age 47)) </li></ul></ul><ul><ul><li>) </li></ul></ul>
  30. 30. Properties of Simple Rules <ul><li>very limited: </li></ul><ul><ul><li>LHS must match facts exactly </li></ul></ul><ul><ul><li>facts must be accessed through their index number </li></ul></ul><ul><ul><li>changes must be stated explicitly </li></ul></ul><ul><li>can be enhanced through the use of variables </li></ul>
  31. 31. THE AGENDA AND EXECUTION <ul><li>A CLIPS program can be made to run with the run command. </li></ul><ul><li>(run [<limit>] ) </li></ul><ul><li>where the optional argument <limit> is the maximum number of rules to be fired. </li></ul><ul><li>The list of rules on the agenda can be displayed with the agenda command. </li></ul><ul><li>(agenda) </li></ul><ul><li>EX.: </li></ul><ul><li>CLIPS> (reset)  </li></ul><ul><li>CLIPS> ( assert (emergency (type fire)))  </li></ul><ul><li><Fact-1> </li></ul><ul><li>CLIPS> (agenda)  </li></ul><ul><li>0 fire-emergency: f-1 </li></ul><ul><li>For a total of 1 activation. </li></ul><ul><li>CLIPS> </li></ul><ul><li>The 0 indicates the salience of the rule on the agenda. </li></ul>
  32. 32. Program Execution <ul><li>agenda </li></ul><ul><ul><li>if all patterns of a rule match with facts, it is put on the agenda </li></ul></ul><ul><ul><li>(agenda) displays all activated rules </li></ul></ul><ul><li>salience </li></ul><ul><ul><li>indicates priority of rules </li></ul></ul><ul><li>refraction </li></ul><ul><ul><li>rules fire only once for a specific set of facts </li></ul></ul><ul><ul><ul><li>prevents infinite loops </li></ul></ul></ul><ul><ul><li>(refresh <rule-name>) </li></ul></ul><ul><ul><ul><li>reactivates rules </li></ul></ul></ul>
  33. 33. Execution of a Program <ul><li>(reset) prepares (re)start of a program: </li></ul><ul><ul><li>all previous facts are deleted </li></ul></ul><ul><ul><li>initial facts are asserted </li></ul></ul><ul><ul><li>rules matching these facts are put on the agenda </li></ul></ul><ul><li>(run [<limit>]) starts the execution </li></ul><ul><li>breakpoints </li></ul><ul><ul><li>(set-break [<rule-name>]) </li></ul></ul><ul><ul><ul><li>stops the execution before the rule fires, </li></ul></ul></ul><ul><ul><ul><li>continue with (run) </li></ul></ul></ul><ul><ul><li>(remove-break [<rule-name>]) </li></ul></ul><ul><ul><li>(show-breaks) </li></ul></ul>

×