Samad Paydar Ferdowsi University of Mashhad.  C Language Integrated Production System (CLIPS)  A tool for building expert systems  An expert system.

Slides:



Advertisements
Similar presentations
10/4/2003COMP 474/674 Fall 2003 Michelle Khalife1 Conflict Resolution in CLIPS COMP 474/674 FALL 2003 Michelle Khalifé.
Advertisements

The CLIPS Programming Tool History of CLIPS –Influenced by OPS5 and ART –Implemented in C for efficiency and portability –Developed by NASA, distributed.
CLIPS 1 Expert Systems Dr. Samy Abu Nasser. CLIPS 2 Course Overview u Introduction u CLIPS Overview u Concepts, Notation, Usage u Knowledge Representation.
Expert System Shells - Examples
Conflict Resolution  what to do if there is more than 1 matching rule in each inference cycle? match WM with LHS of rules select one rule (conflict resolution)
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.
Introduction to C Programming
Introduction to CLIPS (Chapter 7) Fact List (contains data) Knowledge Base (contains rules) Inference Engine (controls execution)
Mary Lou Maher MIT Fall 2002 Jess: A Production System Language Agent-Based Virtual Worlds.
© C. Kemke CLIPS 1 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
© C. Kemke Control 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.
EXPERT SYSTEMS Part I.
Introduction to Jess.
Introduction to a Programming Environment
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
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.
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.
Chapter 1: A First Program Using C#. Programming Computer program – A set of instructions that tells a computer what to do – Also called software Software.
Chapter 7: Introduction to CLIPS Expert Systems: Principles and Programming, Fourth Edition.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
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
Programming Fundamentals. Today’s Lecture Why do we need Object Oriented Language C++ and C Basics of a typical C++ Environment Basic Program Construction.
Jess: A Rule-Based Programming Environment Reporter: Yu Lun Kuo Date: April 10, 2006 Expert System.
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.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
Asking the USER for values to use in a software 1 Input.
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>
1 Debugging and Syntax Errors in C++. 2 Debugging – a process of finding and fixing bugs (errors or mistakes) in a computer program.
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)
Asking the USER for values to use in a software 1 Input.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Artificial Intelligence Lecture No. 19 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Artificial Intelligence Lecture No. 23 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.
The CLIPS Expert System Shell Dr Nicholas Gibbins
Summary for final exam Agent System..
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
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.
Intelligent Systems JESS constructs.
Introduction to the C Language
Chapter 7: Introduction to CLIPS
Chapter 2 part #3 C++ Input / Output
Chapter 8: Advanced Pattern Matching
بسم الله الرحمن الرحیم آموزش نرم افزار CLIPS
Chapter 11: Classes, Instances, and Message-Handlers
Chapter 2 part #3 C++ Input / Output
Introduction to C Programming
Chapter 1 c++ structure C++ Input / Output
Presentation transcript:

Samad Paydar Ferdowsi University of Mashhad

 C Language Integrated Production System (CLIPS)  A tool for building expert systems  An expert system is a program which is specifically intended to model human expertise or knowledge  Created in 1985 at NASA’s Johnson Space Center 2

 Written in C for portability and speed  Has been installed on many different operating systems  Widely used in industry, academia and government 3

 Can be integrated with languages such as C, Java, Visual Basic  Different extensions are available:  FuzzyCLIPS: an extension of CLIPS incorporating fuzzy logic  PHLIPS is a PHP extension that provides a basic interface to the CLIPS environment  CLIPSNet, a.Net wrapper for CLIPS 4

 Three ways to represent knowledge in CLIPS  Rules ▪ For heuristic knowledge base on experience  Deffunctions and generic functions ▪ For procedural knowledge  Object Oriented Programming ▪ For better (i.e. Modular) representation 5

 CLIPS supports developing expert systems by providing some facilities  An integrated editor  Debugging tool  Shell ▪ Portion of CLIPS which performs inferences or reasoning 6

 The CLIPS shell provides the basic elements of an expert system:  Fact-list, and instance-list: Global memory for data  Knowledge-base: Contains all the rules, the rule- base  Inference engine: Controls overall execution of rules 7

 CLIPS has a LISP-like syntax  Extensive use of parentheses ▪ E.g. as delimiters  It is case-sensitive 8

 assert command for adding facts to the fact- list  (assert (argument) )  Some example ▪ (assert(is-a-country “Iran” )) ▪ (assert (is-a-city “Tehran”)) ▪ (assert (has-population “Tehran” )) 9

 facts command for listing current facts  (facts)  Each fact has an identifier of the form ▪ f-{fact-index}  Duplicate facts are not allowed by default ▪ set-fact-duplication allows duplicate fact entry. 10

 Removing facts from the fact-list is called retraction and is done with the retract command.  To retract a fact, you must specify the fact index as the argument of retract  (retract (facts indices) 11

 Example ▪ (retract 2)  It is possible to retract multiple facts simultaneously ▪ (retract )  It is possible to retract all the facts ▪ (retract*) 12

 Retract does not change indices of remaining facts 13

 reset command to clear all the facts  It insert a fact (initial-fact) as f-0  This fact is often used for convenience to initially activate rules 14

 clear command for removing all facts from memory  It actually does more than just removing facts  Also removes all the rules 15

 A fact such as (Tuesday) or (“Bahman”) is said to consist of a single field.  A field is a placeholder (named or unnamed) that may have a value associated with it.  The (Tuesday) fact has a single, unnamed field  Multi-field fact ▪ (Country Iran)  The order of unnamed fields is significant. ▪ (Country Iran) vs. (Iran Country) 16

 Symbol nil, which means "nothing" may be used for an empty field as a placeholder. ▪ (basket-content nil)  The basket yet contains nothing 17

 Different types of fields:  float  integer  symbol  string  … 18

 A symbol is one type of field that starts with a printable ASCII character and is followed optionally by zero or more printable characters. 19

 The semicolon acts as the start of a comment in CLIPS 20

 A string must begin and end with double quotes.  The double quotes are part of the field.  Zero or more characters of any kind can appear between the double quotes. 21

 All numbers in CLIPS are treated as long integers or double-precision floats  (assert (x 1.5))  (assert (y -1)) 22

 It is good rule-based programming style to use the first field of a fact to describe the  relationship of the following fields. When used this way, the first field is called a relation.  (basket-contents apple orange banana) 23

 CLIPS provides several commands to help you debug programs  One command allows you to continuously watch facts being asserted and retracted  This is more convenient than having to type in a (facts) command over and over again and trying to figure out what's changed in the fact-list. 24

 To start watching facts, enter the command (watch facts)  The right double arrow, ==>, means that a fact is entering memory  The left double arrow, <==, indicates a fact is leaving memory 25

 To turn off watching facts enter  (unwatch facts) 26

 A rule is similar to an IF THEN statement in traditional programming languages  Rules are defined by defrule construct 27

 General syntax of a rule (defrulerule_name "optional_comment" (pattern_1) ;Left-Hand Side (LHS) (pattern_2) ;of the rule consisting of elements ;before the "=>" (pattern_N) => (action_1) ;Right-Hand Side (RHS) (action_2) ;of the rule consisting of elements ;after the "=>" (action_M)) ;the last ")" balances the opening ; "(" to the left of "defrule". Be ; sure all your parentheses balance ; or you will get error messages 28

 An action is actually a function which performs some useful action  Typically has no return value  such as an (assert) or (retract) 29

(defrule capital-rule “simple rule about capitals" (is-a-country ?country) ;Pattern1 (has-capital ?country ?capital) ;Pattern2 => (assert (is-a-city ?capital)) ;Action1 (assert (has-city ?country ?capital)) ;Action2 ) ;end of defrule 30

 The name of a variable, or variable identifier, is always written by a question mark followed by a symbol that is the name of the variable. 31

 CLIPS attempts to match the patterns of rules against facts in the fact-list.  If all the patterns of a rule match facts, the rule is activated and put on the agenda.  The agenda is a collection of activations which are those rules which match pattern entities.  Zero or more activations may be on the agenda. 32

 The last part of a rule is the list of zero or more actions that will be executed when the rule fires.  The term fires means that CLIPS has selected a certain rule for execution from the agenda 33

 A program will cease execution when no activations are on the agenda 34

 When multiple activations are on the agenda, CLIPS automatically determines which activation is appropriate to fire  CLIPS orders the activations on the agenda in terms of increasing priority or salience 35

 CLIPS always executes the actions on the RHS of the highest priority rule on the agenda.  This rule is then removed from the agenda and the actions of the new highest salience rule is executed.  This process continues until there are no more activations or a command to stop is encountered. 36

 To see a rule, use the ppdefrule command  pretty print rule  To see a rule, specify the rule name as an argument to ppdefrule  To list all the current rules, use the rules command 37

 You can check what's on the agenda with the agenda command 38

 To make a program run, just enter the run command 39

 Use printout function to print something in the output  (printout t “Hello World!“ crlf))  letter "t” tells CLIPS to send the output to the standard output device of your computer, i.e. the terminal 40

 Besides asserting facts in the RHS of rules, you also can print out information using the printout function (defrule good_rule (today “Friday”) => (printout t “No Study! No Work!“ crlf)) ) 41

 CLIPS can read the information from the keyboard using the read function (defrule simple-rule (initial-fact) => (printout t “Enter your name:" crlf) (assert (Person (read) )) ) 42

 The Inference Engine sorts the activations according to their salience.  This sorting process is called conflict resolution because it eliminates the conflict of deciding which rule should fired next. 43

 CLIPS offers seven different modes of conflict resolution: depth, breadth, LEX, MEA, complexity, simplicity, and random.  It's difficult to say that one is clearly better than another without considering the specific application.  Even then, it may be difficult to judge which is "best." 44

 The depth strategy is the standard default strategy of CLIPS.  In this strategy, is ordered from highest to lowest salience 45

 Can help in writing rules whose patterns have a well-defined structure.  Templates are defined by the deftemplate construct  Analogous to a record structure in Pascal, or Class in C++  Defines a group of related fields in a pattern 46

 A deftemplate is a list of named fields called slots  Allows access by name rather than by specifying the order of fields  Contributes to good style in expert systems programs and is a valuable tool  A slot is a named single-slot or multi-slot. 47

(deftemplate person (slot name) (slot age) (slot eye-color) (slot hair-color) ) 48

(deftemplate Person “This is a sample template for the concept of person" ;optional comment (slot name (type STRING) (default “”)) (slot gender (type SYMBOL) (default male)) ) 49