Professional Documents
Culture Documents
Expert Systems
Expert Systems
2
What is CLIPS?
CLIPS is a type of computer language designed for
writing applications called expert systems
CLIPS is a tool for building expert systems.
CLIPS Rule Based Programming Language - Browse
/CLIPS/6.30 at SourceForge.net
3
The basic elements of an expert system:
1. fact-list: Global memory for data
2. knowledge-base: Contains all the rules, the rule-
base
3. inference engine: Controls overall execution of rules
A program in CLIPS consists of
Facts
Rules
4
What is CLIPS?
Each CLIPS command must have a matching number of
left and right parentheses
The normal mode of leaving CLIPS is with the exit
command. Just type
(exit)
5
Fields(Data Types)
There are eight types of fields, also called the CLIPS primitive
data types:
float
integer
symbol
string
external address
fact address
instance name
instance address.
6
Integer & Float
Examples of integers are
7
String Field
A string must begin and end with double quotation
marks, which are part of the field.
E.g.
“Active the sprinkler system “
"a\"quote"
8
Symbol Field
A symbol in CLIPS is any sequence of characters that
starts with any printable ASCII character and is
followed by zero or more printable ASCII characters.
When a delimiter is found, the symbol is ended.
Delimiters include any nonprintable ASCII character.
(spaces, tabs, returns, line feeds) and “ ( ) & | < ~ ;
Symbols cannot contain delimiters
9
Symbol Field
E.g.
Space-Station
127A
456-93-039
@+=-%
2each
10
Fields
The primitive data types are referred to as single-field
values
A multifield value is a sequence of zero or more single
field values.
(number 1 2 5 )
(this that)
11
Facts
Ordered facts
consist of a symbol followed by a sequence of zero or
more fields separated by spaces and delimited by an
opening parenthesis on the left and a closing parenthesis
on the right.
For example,
(father-of jack bill) states that bill is the father of jack.
(the pump is on)
(altitude is 10000 feet)
(grocery-list bread milk eggs)
12
Facts
Non-ordered (or deftemplate) facts.
(deftemplate person "An example deftemplate"
(slot name) "An example deftemplate" --> comment(optional)
(slot age)
(slot eye-color)
(slot hair-color)
13
Non-ordered (or deftemplate) facts
The following is an example of a fact:
(person (name "John Q. Public")
(age 23)
(eye-color blue)
(hair-color black))
14
Manipulation of Facts -- assert
Basic commands to operate on facts:
assert, retract, modify, duplicate, facts
Adding Facts
New facts can be added to the fact list using the assert command.
(assert <fact>+)
As an example,
CLIPS>(deftemplate person
(slot name)
(slot age)
(slot eye-color)
(slot hair-color))
CLIPS>(assert (person (name "John Q. Public")
(age 23)
(eye-color blue)
(hair-color black)))
<Fact-0>
CLIPS
15
Manipulation of Facts -- assert
More than one fact can be asserted using a single assert
command. For
example, the command:
(assert (person (name "John Q. Public")
(age 23)
(eye-color blue)
(hair-color black))
(person (name "Jane Q. Public")
(age 36)
(eye-color green)
(hair-color red))
16