CLIPS 1 Expert Systems Dr. Samy Abu Nasser. CLIPS 2 Course Overview u Introduction u CLIPS Overview u Concepts, Notation, Usage u Knowledge Representation.

Slides:



Advertisements
Similar presentations
Expert systems CLIPS Seyed Hashem Davarpanah
Advertisements

Introduction to CLIPS COMP 474/674 FALL 2003 Michelle Khalifé.
The CLIPS Programming Tool History of CLIPS –Influenced by OPS5 and ART –Implemented in C for efficiency and portability –Developed by NASA, distributed.
November 2, 2004AI: CLIPS Language Tutorial1 CLIPS Michael Scherger Department of Computer Science Kent State University.
The Web Warrior Guide to Web Design Technologies
Expert System Shells - Examples
Samad Paydar Ferdowsi University of Mashhad.  C Language Integrated Production System (CLIPS)  A tool for building expert systems  An expert system.
1 01/12/2011Knowledge-Based Systems, Paula Matuszek Intro to CLIPS Paula Matuszek CSC 9010, Spring, 2011.
November 2, 2004AI: CLIPS Language Tutorial1 Artificial Intelligence CLIPS Language Tutorial Michael Scherger Department of Computer Science Kent State.
Chapter 8 Pattern Matching
Introduction to CLIPS (Lecture Note #17)
Chapter 7: Introduction to CLIPS
CLIPS C Language Integrated Production System Note: Some slides and/or pictures are adapted from Lecture slides / Books of Dr Zafar Alvi.
Artificial Intelligence Lecture No. 18 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
1 Computer Science Department California Polytechnic State University San Luis Obispo, CA, U.S.A. CPE/CSC 481: Knowledge-Based Systems Franz J. Kurfess.
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Introduction to C Programming
Rule Based Systems Michael J. Watts
Chapter 12: Expert Systems Design Examples
Introduction to CLIPS (Chapter 7) Fact List (contains data) Knowledge Base (contains rules) Inference Engine (controls execution)
© Franz J. Kurfess CLIPS 1 CPE/CSC 481: Knowledge-Based Systems Dr. Franz J. Kurfess Computer Science Department Cal Poly.
© 2002 Franz J. Kurfess Introduction 1 CPE/CSC 481: Knowledge-Based Systems Dr. Franz J. Kurfess Computer Science Department Cal Poly.
© C. Kemke CLIPS 1 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba.
Chapter 8: Advanced Pattern Matching Expert Systems: Principles and Programming, Fourth Edition.
Chapter 9: Modular Design, Execution Control, and Rule Efficiency Expert Systems: Principles and Programming, Fourth Edition.
Introduction to Jess.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
JavaScript, Third Edition
Guide To UNIX Using Linux Third Edition
Introduction to C Programming
CS 561, Session 25 1 Introduction to CLIPS Overview of CLIPS Facts Rules Rule firing Control techniques Example.
Chapter 2: Algorithm Discovery and Design
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
1 01/12/2011Knowledge-Based Systems, Paula Matuszek More Intro to CLIPS Paula Matuszek CSC 9010, Spring, 2011.
Chapter 9: Modular Design, Execution Control, and Rule Efficiency Expert Systems: Principles and Programming, Fourth Edition.
Expert System Topic 2.
Chapter 7: Introduction to CLIPS Expert Systems: Principles and Programming, Fourth Edition.
Artificial Intelligence Lecture No. 17 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Chapter 10: Procedural Programming Expert Systems: Principles and Programming, Fourth Edition.
Input, Output, and Processing
Jess: A Rule-Based Programming Environment Reporter: Yu Lun Kuo Date: April 10, 2006 Expert System.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Introduction to Programming with RAPTOR
Chapter 7: Introduction to CLIPS Presented By: Farnaz Ronaghi.
IMSS013 CLIPS. 2 Background CLIPS is an expert system tool developed by the Software Technology Branch (STB), NASA/Lyndon B. Johnson Space Center. First.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Computer Science Department California Polytechnic State University San Luis Obispo, CA, U.S.A. Franz J. Kurfess CPE/CSC 481: Knowledge-Based Systems.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Expert Systems Chapter 7 Introduction to CLIPS Entering and Exiting CLIPS A> CLIPS  CLIPS (V6.5 09/01/97) CLIPS> exit exit CLIPS> (+ 3 4)  7 CLIPS>
Artificial Intelligence Lecture No. 26 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Introduction to CLIPS. Expert Systems: Principles and Programming, Fourth Edition2 What is CLIPS? CLIPS is a multiparadigm programming language that provides.
1 Knowledge Based Systems (CM0377) Lecture 10 (Last modified 19th March 2001)
Artificial Intelligence Lecture No. 19 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Mostly adopted from Jason Morris notes (Morris Technical Solutions)
Artificial Intelligence Lecture No. 22 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Expert System Seyed Hashem Davarpanah University of Science and Culture.
The CLIPS Expert System Shell Dr Nicholas Gibbins
Summary for final exam Agent System..
Introduction to CLIPS 2 Session 13 Course: T0273 – EXPERT SYSTEMS Year: 2014.
Jörg Kewisch, June 10, 2013, LILUG Meeting CLIPS C Language Integrated Production System Developed at the Software Development Branch, NASA Lyndon B. Johnson.
Topics Designing a Program Input, Processing, and Output
Intelligent Systems JESS constructs.
Chapter 7: Introduction to CLIPS
Chapter 8: Advanced Pattern Matching
بسم الله الرحمن الرحیم آموزش نرم افزار CLIPS
Chapter 11: Classes, Instances, and Message-Handlers
CPE/CSC 481: Knowledge-Based Systems
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Presentation transcript:

CLIPS 1 Expert Systems Dr. Samy Abu Nasser

CLIPS 2 Course Overview u Introduction u CLIPS Overview u Concepts, Notation, Usage u Knowledge Representation u Semantic Nets, Frames, Logic u Reasoning and Inference u Predicate Logic, Inference Methods, Resolution u Reasoning with Uncertainty u Probability, Bayesian Decision Making u Pattern Matching u Variables, Functions, Expressions, Constraints u Expert System Design u ES Life Cycle u Expert System Implementation u Salience, Rete Algorithm u Expert System Examples u Conclusions and Outlook

CLIPS 3 Overview CLIPS u Motivation u Objectives u CLIPS Background u History u Main ideas u Terminology u Facts and Rules u Formats u Using Facts and Rules u Variables and Pattern Matching u Variables u Pattern Matching u Execution of Programs u Invoking and leaving CLIPS u Watching u Important Concepts and Terms u Chapter Summary

CLIPS 4 Logistics u Introductions u Course Materials u textbooks (see below) u lecture notes u PowerPoint Slides u handouts u Term Project u Lab and Homework Assignments u Exams u Grading

CLIPS 5 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 ES shells  it allows the representation of knowledge, and its use for solving suitable problems

CLIPS 6 Objectives  be familiar with the important concepts and methods used in rule-based ES shells  facts, rules, pattern matching, agenda, working memory, forward chaining  understand the fundamental workings of an ES shell  knowledge representation  reasoning  apply rule-based techniques to simple examples  evaluate the suitability of rule-based systems for specific tasks dealing with knowledge

CLIPS 7 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

CLIPS 8 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 [Jackson 1999]

CLIPS 9 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]

CLIPS 10 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 )  star *  replace with zero or more instances of the type  *  plus +  replace with one or more instances of the type  + (is equivalent to * )  vertical bar |  choice among a set of items:  true | false

CLIPS 11 Tokens and Fields  tokens  groups of characters with special meaning for CLIPS,  e.g. ( ) \ separated by delimiters  ( space, tab, Carriage Return,...)  fields  particularly important group of tokens  CLIPS primitive data types  float, integer, symbol, string, external address, instance name, instance address

CLIPS 12 CLIPS Primitive Data Types  float: decimal point ( 1.5 ) or exponential notation ( 3.7e10 )  integer: [sign] +  symbol: +  e.g. this-is-a-symbol, wtt,  string: delimited by double quotes  e.g. "This is a string"  external address  address of external data structure returned by user-defined functions  instance name (used with Cool)  delimited by square brackets  instance address (used with Cool)  return values from functions

CLIPS 13 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

CLIPS 14 Facts  elementary information items (“chunks”)  relation name  symbolic field used to access the information  often serves as identifier for the fact  slots (zero or more)  symbolic fields with associated values  deftemplate construct  used to define the structure of a fact  names and number of slots  deffacts  used to define initial groups of facts

CLIPS 15 Examples of Facts  ordered fact (person-name Beesan Samy)  deftemplate fact (deftemplate person "deftemplate example” (slot name) (slot age) (slot eye-color) (slot hair-color))

CLIPS 16 Defining Facts  Facts can be asserted CLIPS> (assert (today is sunday))  Facts can be listed CLIPS> (facts) f-0 (today is sunday)  Facts can be retracted CLIPS> (retract 0) CLIPS> (facts) [Jackson 1999]

CLIPS 17 Instances  an instance of a fact is created by (assert (person (name “Beesan Samy") (age 5) (eye-color blue) (hair-color blond)) )

CLIPS 18 Initial Facts (deffacts samy "some members of the Samys family" (person (name “Beesan Samy") (age 5) (eye-color blue)(hair-color blond)) (person (name “Basma Samy") (age 8) (eye-color blue)(hair-color blond)) (person (name “Batool Samy") (age 4) (eye-color blue)(hair-color blond)) (person (name “Basem Samy") (age 12) (eye-color brown)(hair-color black)) (person (name “Basel Samy") (age 10) (eye-color green)(hair-color black)) )

CLIPS 19 Usage of Facts  adding facts  (assert +)  deleting facts  (retract +)  modifying facts  (modify ( )+ )  retracts the original fact and asserts a new, modified fact  duplicating facts  (duplicate ( )+ )  adds a new, possibly modified fact  inspection of facts  (facts)  prints the list of facts  (watch facts)  automatically displays changes to the fact list

CLIPS 20 Rules  general format (defrule ["comment"] * ; left-hand side (LHS) ; or antecedent of the rule => *) ; right-hand side (RHS) ; or consequent of the rule

CLIPS 21 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

CLIPS 22 Examples of Rules  simple rule (defrule birthday-Beesan (person (name “Beesan Samy") (age 5) (eye-color blue) (hair-color blond)) (date-today September ) => (printout t "Happy birthday, Beesan!") (modify 1 (age 6)) )

CLIPS 23 Properties of Simple Rules  very limited:  LHS must match facts exactly  facts must be accessed through their index number  changes must be stated explicitly  can be enhanced through the use of variables

CLIPS 24 Variables, Operators, Functions  variables  symbolic name beginning with a question mark " ? "  variable bindings  variables in a rule pattern (LHS) are bound to the corresponding values in the fact, and then can be used on the RHS  all occurrences of a variable in a rule have the same value  the left-most occurrence in the LHS determines the value  bindings are valid only within one rule  access to facts  variables can be used to make access to facts more convenient: ?age <- (age harry 17)

CLIPS 25 Wildcards  question mark ?  matches any single field within a fact  multi-field wildcard $?  matches zero or more fields in a fact

CLIPS 26 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

CLIPS 27 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

CLIPS 28 Examples of Rules  more complex rule (defrule find-blue-eyes (person (name ?name) (eye-color blue)) => (printout t ?name " has blue eyes." crlf))

CLIPS 29 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))

CLIPS 30 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]

CLIPS 31 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]

CLIPS 32 [Jackson 1999] Getting the Rules Started  The reset command creates a special fact CLIPS> (load “today.clp”) CLIPS> (facts) CLIPS> (reset) CLIPS> (facts) f-0 (initial-fact)... (defrule start (initial-fact) => (printout t “hello”) )

CLIPS 33 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]

CLIPS 34 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]

CLIPS 35 Pattern Matching Details  one-to-one matching (do ?job on ?day) (do washing on monday)  use of wild cards (do ? ? monday) (do ? on ?) (do ? ? ?day) (do $?) (do $? monday) (do ?chore $?when) [Jackson 1999]

CLIPS 36 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]

CLIPS 37 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]

CLIPS 38 Concrete & Abstract Classes  some classes only exist for inheritance purposes Person ManWoman JackJill [Jackson 1999]

CLIPS 39 Managing Instances  Commands to display instances CLIPS> (instances) [corvette] of car CLIPS> (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]

CLIPS 40 Clearing & Resetting Instances  deleting an instance CLIPS> (send [corvette] delete)  deleting all instances CLIPS> (unmake-instance *)  resetting creates an initial object CLIPS> (reset) CLIPS> (instances) [initial-object] of INITIAL-OBJECT [Jackson 1999]

CLIPS 41 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 ), (ppdeftemplate ), (ppdeffacts )  displays the text of the construct (``pretty print'')  deleting constructs (undefrule ), (undeftemplate ), (undeffacts )  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

CLIPS 42 Input / Output  print information (printout *)  logical device frequently is the standard output device t (terminal)  terminal input (read [ ]), (readline [ ])  read an atom or string from a logical device  the logical device can be a file which must be open  open / close file (open [ ]), (close [ ])  open /close file with as internal name  load / save constructs from / to file (load ), (save )  backslash \ is a special character and must be ``quoted'' (preceded by a backslash \)  e.g. (load “c:\\clips\\example.clp")

CLIPS 43 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 )  reactivates rules

CLIPS 44 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 [ ]) starts the execution  breakpoints  (set-break [ ])  stops the execution before the rule fires,  continue with ( run )  (remove-break [ ])  (show-breaks)

CLIPS 45 Watching  watching the execution  (watch ) prints messages about activities concerning a  (facts, rules, activations, statistics, compilation, focus, all)  (unwatch )  turns the messages off

CLIPS 46 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

CLIPS 47 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 »+jjoin added »=j join shared  important for the efficiency of the Rete pattern matching network  focus  used with modules  indicates which module is currently active

CLIPS 48 User Interface  menu-based version  most relevant commands are available through windows and menus  command-line interface  all commands must be entered at the prompt  (don’t forget enclosing parentheses)

CLIPS 49 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]

CLIPS 50 Alternatives to CLIPS  JESS  see below  Eclipse  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  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]

CLIPS 51 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

CLIPS 52 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

CLIPS 53 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