Artificial Intelligence CLIPS Language Tutorial - PowerPoint PPT Presentation

About This Presentation
Title:

Artificial Intelligence CLIPS Language Tutorial

Description:

Artificial Intelligence CLIPS Language Tutorial Michael Scherger Department of Computer Science Kent State University Introduction CLIPS is a tool for building expert ... – PowerPoint PPT presentation

Number of Views:380
Avg rating:3.0/5.0
Slides: 31
Provided by: MichaelS146
Learn more at: https://www.cs.kent.edu
Category:

less

Transcript and Presenter's Notes

Title: Artificial Intelligence CLIPS Language Tutorial


1
Artificial IntelligenceCLIPS Language Tutorial
  • Michael Scherger
  • Department of Computer Science
  • Kent State University

2
Introduction
  • CLIPS is a tool for building expert systems
  • Originally developed by the Software Technology
    Branch (STB) at NASA Johnson Space Center
  • First release in 1986
  • Web location
  • http//www.ghg.net/clips/CLIPS.html

3
Introduction
  • CLIPS was designed to facilitate the development
    of software to model human knowledge
  • Facts
  • Rules
  • Deffunctions and generic functions
  • Object oriented programming

4
Starting / Exiting CLIPS
  • To start CLIPS (Windows)just double click the
    CLIPSWin.exe icon
  • To exit CLIPS type (exit) at the CLIPSgt prompt.

5
Facts
  • Fact Assertion
  • (assert (play Ivan tennis))
  • (assert (duck))
  • (assert (chair red))
  • As facts are entered into the KB, they are
    assigned a Fact Index
  • (retract 1)
  • Removes fact 1 from the KB
  • (clear)
  • Removes all facts from the fact base and KB

6
Facts
  • Fact Assertion
  • (facts)
  • Dump the fact base
  • Fact identifier time tag
  • f-0
  • f-1
  • Special fact
  • (initial-fact)
  • Is always F0 and is used to match the first/start
    rules

7
Facts
  • deffacts is a way of initializing the fact base
    (group of facts)
  • Example
  • (deffacts tennis-players people who play
    tennis
  • (athelete Ivan very-good)
  • (play Ivan tennis)
  • (athelete Martina very-good)
  • (play Martina tennis))
  • Will cause the fact base to be initialized with
    the facts (initial-fact)

8
Facts
  • When (reset) is entered, the result is
  • f-0 (initial-fact)
  • f-1 (athelete Ivan very-good)
  • f-2 (play Ivan tennis)
  • f-3 (athelete Martina very-good)
  • f-4 (play Martina tennis)

9
Rules
  • Syntax
  • (defrule r-name comment
  • pattern-1
  • pattern-n
  • gt
  • action-1
  • action-m)

10
Rules
  • r-name is the rule name
  • comment must be surrounded by quotes
  • pattern-i is the antecedent pattern
  • action-j is the consequent pattern

11
Rules
  • The agenda is the list of rules that have been
    matched and are waiting execution
  • (agenda) will print out the rules
  • The agenda is prioritized by salience value
  • Salience is specified by the programmer and is
    from -10000 to 10000
  • Default is 0 if (declare (salience 25)) is not in
    rule e.g.
  • Rules are selected for firing by salience
  • Two rules of same salience use LIFO to fire

12
Rules
  • (pprule r-name) will pretty print out the rule
  • (excise r-name) will remove a rule from the system

13
Variables
  • Variables start with a ?
  • E.g. ?age
  • Bindings are valid within a rule only

14
Fact Base Updates
  • (retract fact-id)
  • requires fact to be the index number which is
    sometime difficult to determine
  • Therefore use
  • variable with lt- notation which binds the fact
    index number to the variable

15
Fact Base Updates
  • Example
  • (defrule become-adult
  • ?child lt- (child harry)
  • (birthday harry August-15)
  • ?age lt- (age harry 17)
  • (date today August-15)
  • gt
  • (assert (adult harry))
  • (retract ?child)
  • (retract ?age)
  • (assert (age harry 18))
  • (printout t harry is now an adult crlf))
  • What facts are retracted?
  • What facts are kept?
  • What facts are generated?
  • Changing harry to ?person and August-15 to ?date
    will generalize this rule

16
Firing Rules
17
Firing Rules
18
Firing Rules (Matching)
19
Firing Rules (Matching)
20
Wildcard Matching
  • ?
  • matches one
  • ?
  • matches any number
  • ?name
  • match and bind

21
Variables, Variables, Variables
  • Variables start with a ?
  • Examples
  • ?x ?sensor ?color
  • ?location ?room ?size

22
Variables, Variables, Variables
23
Wildcard Matching
  • Example
  • (name ? ?Kennedy)
  • will match
  • (name John Fitzgerald Kennedy)
  • (name ? ? SMITH)
  • will match
  • (name John SMITH)
  • (name Suzie Jane SMITH)
  • (name John James Jones SMITH)
  • but would not match
  • (name SMITH)
  • (name John Jones SMITH Rogers)
  • ?name is the same as the previous but the
    matches are bound to ?name

24
Wildcard Matching
25
Field Constraints
  • Negation
  • (defrule apply-heat
  • (temperature water boil)
  • gt
  • (adjust heat maximum) a function call
  • (printout t Turn the heat to the maximum
    setting crlf))

26
Field Constraints
  • OR
  • (defrule apply-heat
  • (temperature water coldcoolwarm)
  • gt
  • (adjust heat maximum) a function call
  • (printout t Turn the heat to a medium setting
    crlf))

27
Field Constraints
  • AND
  • (temperature water ?temphotboil)
  • will match either of the following facts
  • (temperature water hot)
  • (temperature water boil)

28
Mathematical Operators
  • Uses prefix notation as in Lisp
  • ( 3 4)
  • ( ( 3 4) ( 5 6))
  • Use as assignment for fact assertion on left
    hand side
  • (assert (answer ( 3 4 ) ) )
  • put
  • (answer 12)
  • in the fact list

29
Systematic Manner
30
Templates
Write a Comment
User Comments (0)
About PowerShow.com