L13 Clips Tut
L13 Clips Tut
L13 Clips Tut
January 2010
We will use CLIPS to illustrate many of the concepts and methods Suggest to download the latest version of Application Installer on Windows Platform
apply rule-based techniques to simple examples evaluate the suitability of rule-based systems for specific tasks dealing with knowledge
241-320 Design Architecture & Engineering for Intelligent System
CLIPS is a multi-paradigm programming language that provides support for rule-based, object-oriented, and procedural programming. You can download it from:
http://clipsrules.sourceforge.net/index.html Download Installer version on Windows Platform
CLIPS in PC
Double click from the shortcuts
CLIPS Tutorial
We will take the tutorial given in the CLIPS main page to study in our class.
10
11
12
13
14
Example: Rules
Rules: IF <antecedent> THEN <consequent> The rule name The IF part The THEN part Q: Can you explain the rule above?
241-320 Design Architecture & Engineering for Intelligent System
15
Q: Explain why a new fact is occurred after running the duck rule? A: It is inferred by the rule.
241-320 Design Architecture & Engineering for Intelligent System
16
Clear all facts, but the rules will be untouched Q: Can you explain the rule above?
241-320 Design Architecture & Engineering for Intelligent System
17
Adding 2 rules
18
19
20
CLIPS Tutorial
We will take the tutorial given in the CLIPS main page to study in our class.
21
22
23
No fact at this moment But scripts is in action after this reset command
24
From the facts and rule above, this results is produced. Q: What animal are represented are on each line?
241-320 Design Architecture & Engineering for Intelligent System
25
26
27
28
29
CLIPS Tutorial
We will take the tutorial given in the CLIPS main page to study in our class.
30
31
(assert (personal-data (name Andrew) (age 20) (weight 80) (height 188) (blood-pressure 130 80))) You don't have to specify all the information; (assert (personal-data (weight 150) (age 23) (name Brenda)))
241-320 Design Architecture & Engineering for Intelligent System
32
(deffacts people (personal-data (name Andrew) (age 20) (weight 80) (height 188) (blood-pressure 130 80)) (personal-data (name Cyril) (age 63) (weight 70) (height 1678) (blood-pressure 180 90)))
33
(defrule birthday ?birthday <- (birthday ?name) ?data-fact <- (personal-data (name ?name) (age ?age)) => (modify ?data-fact (age (+ ?age 1))) (retract ?birthday) )
Delete the birthday facts, since it is only once a year. Another reasons is that every time any part of Andrew's personal data (e.g. weight) was changed,Design Architecture & rule would Knowledge Representation and rapid ageing! the birthday be fired again, causing 241-320
Engineering for Intelligent System
34
(defrule birthday ?birthday <- (birthday ?name) ?data-fact <- (personal-data (name ?name) (age ?age)) => (modify ?data-fact (age (+ ?age 1))) (retract ?birthday) )
Delete the birthday facts, since it is only once a year. Another reasons is that every time any part of Andrew's personal data (e.g. weight) was changed,Design Architecture & rule would Knowledge Representation and rapid ageing! the birthday be fired again, causing 241-320
Engineering for Intelligent System
35
CLIPS Tutorial
You may proceed to the other tutorials on your own!
36
37
Exercise:
You are about to develop an expert system that can have the diagnosis of a cars failure
The decision tree given here can be used as a guideline Interaction with user is preferred
38