© C. Kemke CLIPS 1 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba.

Slides:



Advertisements
Similar presentations
Expert systems CLIPS Seyed Hashem Davarpanah
Advertisements

Chapter 7 Introduction to Procedures. So far, all programs written in such way that all subtasks are integrated in one single large program. There is.
10/4/2003COMP 474/674 Fall 2003 Michelle Khalife1 Conflict Resolution in CLIPS COMP 474/674 FALL 2003 Michelle Khalifé.
P1PMF Split1 QBASIC. P1PMF Split2QBasic Command Prompt Will launch the emulator DOS operating system? Press Alt + Enter to display the widescreen.
© C. Kemke XPS Implementation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba.
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.
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.
Chapter 11: Classes, Instances, and Message- Handlers Expert Systems: Principles and Programming, Fourth Edition.
Introduction to CLIPS (Chapter 7) Fact List (contains data) Knowledge Base (contains rules) Inference Engine (controls execution)
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Expert Systems 3 1 Rewriting Rules, CLIPS Content of this lecture: 1.Interpretation of rules 2.Example: CLIPS Sorting 3.Non-determinism 4.Control regimes:
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.
© C. Kemke1Reasoning - Introduction COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba.
By: Dr. Christel Kemke Department of Computer Science University of Manitoba.
© 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.
Introduction to Jess.
Jess Presentation by Chun Ping Wang. What is Jess? Jess is an expert system shell made for java. Rete pattern algorithm. Purpose. –Jess is best use for.
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.
Review Topics Test 1. Background Topics Definitions of Artificial Intelligence & Turing Test Physical symbol system hypothesis vs connectionist approaches.
Expert System Topic 2.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
Introduction to Python
The UNIX Shell. The Shell Program that constantly runs at terminal after a user has logged in. Prompts the user and waits for user input. Interprets command.
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.
Floating point numerical information. Previously discussed Recall that: A byte is a memory cell consisting of 8 switches and can store a binary number.
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.
COMP 171: Data Types John Barr. Review - What is Computer Science? Problem Solving  Recognizing Patterns  If you can find a pattern in the way you solve.
I Power Higher Computing Software Development Development Languages and Environments.
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>
Advanced Pattern Matching. Field constraints Used to restrict the values of a field on LHS of a rule Used to restrict the values of a field on LHS of.
Artificial Intelligence Lecture No. 26 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Artificial Intelligence Lecture No. 24 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.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
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
Linux Administration Working with the BASH Shell.
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.
Intelligent Systems JESS constructs.
Chapter 7: Introduction to CLIPS
Chapter 8: Advanced Pattern Matching
بسم الله الرحمن الرحیم آموزش نرم افزار CLIPS
Chapter 11: Classes, Instances, and Message-Handlers
JESS (Java Expert System Shall)
Expert System Implementation
CPE/CSC 481: Knowledge-Based Systems
Computer Based Tutoring
Presentation transcript:

© C. Kemke CLIPS 1 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke CLIPS 1 2 CLIPS Introduction 2 Review and Introduction 2  CLIPS Programming System  Basic CLIPS Constructs and Syntax  Fields and Templates  Complex Condition Patterns  Input and Output  Salience

© C. Kemke CLIPS 1 3 CLIPS – Programming Systems CLIPS Interpreter  enter commands, direct modification of fact base... CLIPS File-Menu  load, save and edit CLIPS program files CLIPS Edit-Menu  Balance (ctrl B), Comment CLIPS Execution-Menu  set execution parameters (e.g. reset, run, clear, watch, constraint checking, halt) CLIPS Browse-Menu  manage and info about constructs CLIPS Window-Menu  current status info, e.g. Facts, Activations, …

© C. Kemke CLIPS 1 4 Working with Facts Changing fact base  Adding facts(assert )  Deleting facts(retract )  Modifying facts(modify (deftemplate facts) ( ))  Duplicating facts(duplicate (deftemplate facts) ( )) Monitoring program execution  Print all facts(facts)  Displays changes(watch facts), also for rules...  Dribblerecord trace into file

© C. Kemke CLIPS 1 5 CLIPS – Basic Constructs Basic Language Elements:  Fields(basic Data Types; slot fillers)  Facts(used in condition patterns)  Rules(condition-action rules)  Templates(like records; define facts)  Classes (like objects; define facts)  Messagehandlers (like methods defined for classes; used in condition patterns and actions)

© C. Kemke CLIPS 1 6 Fields - Examples Fields (data types)  float4.00, 2.0e+2, 2e-2  integer4, 2, 22  symbolAlpha24*,  string“Johnny B. Good”  instance name[titanic], [PPK] Variables ?var, ?x, ?dayvariables for single field value $?namesvariable for multi-field value

© C. Kemke CLIPS 1 7 Template and Fact with Single Field Single value in a slot: (person (name "Johnny B. Good" ) (age 42)) Defined based on: (deftemplate person (slot name) (slot age)) A single field slot stores one single field value, e.g. the string "Johnny B. Good" or the integer / number 42 in the example above.

© C. Kemke CLIPS 1 8 Multislots and Multifields More than one value in a slot: (person (name Johnny B. Good) (age 42)) Defined based on: (deftemplate person (multislot name) (slot age)) A multi-slot allows several field values to be stored in one slot, e.g. the 3 field values Johnny, B. and Good in the example above.

© C. Kemke CLIPS 1 9 Slot Restrictions Defined Template with Slot-Restrictions (Constraint-Attributes): (deftemplate person (slot name (type STRING)) (slot age (type INTEGER)) (slot gender (allowed-symbols male female)) )

© C. Kemke CLIPS 1 10 Slot Constraint-Attributes ::= | | ::= (type ) ::= + | ?VARIABLE ::= SYMBOL | STRING | LEXEME | INTEGER | FLOAT | NUMBER | INSTANCE-NAME | INSTANCE-ADDRESS | INSTANCE | FACT-ADDRESS | EXTERNAL-ADDRESS

© C. Kemke CLIPS 1 11 Slot Constraint-Attributes Type + Allowed Values (Enumeration, Collection) ::= (allowedsymbols ) | (allowedstrings ) | (allowed-lexemes ) | (allowedintegers ) | (allowedfloats ) | (allowednumbers ) | (allowed-instance-names ) | (allowedvalues )

© C. Kemke CLIPS 1 12 Slot Constraint-Attributes Range of Values (min and max value) ::= (range ) ::= | ?VARIABLE Number of Fillers (min and max) ::= (cardinality ) ::= | ?VARIABLE

© C. Kemke CLIPS 1 13 Variables and Wildcards single-field variablebinds single value ? e.g.?age, ?x, ?address ?fact-variable multi-field variable accepts multiple values; $? can bind multi-field value single-field wildcardmatches any single-field value ? multi-field wildcardmatches any multi-field value $?

© C. Kemke CLIPS 1 14 All Kinds of Variables (defrule birthday “A person’s birthday” ?f1 <- (person (name $?name) (age ?age)) ?f2 <- (has-birthday $?name) => (printout t “Happy Birthday,” $?name) (retract ?f1) (retract ?f2) (assert (person (name $?name) (age (+ ?age 1))))) Q: With which patterns does the Condition match? A: e.g. (person (name Johnny B. Good) (age 42))

© C. Kemke CLIPS 1 15 All Kinds of Variables 2 (defrule birthday “A person’s birthday” ?f1 <- (person (name ?name $?) (age ?age)) ?f2 <- (has-birthday ?name) => (printout t “Happy Birthday,” ?name) (retract ?f2) (modify ?f1 (age (+ ?age 1)))) Q1: What is $? matching with? Q2: What is the rule doing?

© C. Kemke CLIPS 1 16 Complex Condition Elements  logical connectives and, or, not to combine patterns  forall and exists – consider all matches/ only one match in further evaluation  logical – connects condition element and asserted fact in action (Truth Maintenance)  use test-condition (test )  field-constraints &, |, and &: attached to slot of (deftemplate) condition pattern

© C. Kemke CLIPS 1 17 Field Constraints (Connected Pattern Constraints) not ~ not this value (name ~Simpson) (age ~40) or | could be one of these values (name Simpson|Oswald) (age 30|40|50) and &attaches constraint to variable (name ?name&~Simpson) (name ?name&Harvey) expr. : adds expression as constraint (age ?age&:(> ?age 20)) (name ?name&:(eq (sub-string 1 1 ?name) "S") checks whether the sub- string from 1 to 1 (first letter) of the name is "S" checks whether the age is above 20

© C. Kemke CLIPS 1 18 Field Constraint (defrule you-wish “something with people and age” (person (name ?name) (age ?age&:(> ?age 20)) => (printout t ?name “is over twenty.” crlf) (printout t ?name “is “ ?age “years old.” crlf)) Q1: Which patterns match this Condition? Q2: What is the rule doing?

© C. Kemke CLIPS 1 19 Condition Patterns with Logical Connectives Complex Conditions with logical connectives: (or (pattern1) (pattern2)) Rule becomes active if one of the patterns matches. example: (or (birthday) (anniversary)) matches fact base with facts (birthday) or (anniversary) Equivalent for: and(is default) not existsto be fulfilled for one matching fact forallto be fulfilled for all facts which match based on first fact and variable binding

© C. Kemke CLIPS 1 20 Complex Condition Elements - or (defrule report-emergency (or (emergency (emergency-type fire) (location ?building)) (emergency (emergency-type bomb) (location ?building)) ) => (printout t “evacuate “ ?building) ) reports a building if there is a fire or bomb emergency in this building

© C. Kemke CLIPS 1 21 Complex Condition Elements – exists (defrule emergency-report (exists (or (emergency (emergency-type fire)) (emergency (emergency-type bomb))) ) => (printout t “There is an emergency.“ crlf ) ) prints one emergency-message if there is a fire or bomb emergency. (no further matching, firing, or printout)

© C. Kemke CLIPS 1 22 Complex Condition Elements – forall (defrule evacuated-all-buildings (forall (emergency (emergency-type fire | bomb) (location ?building) ) (evacuated (building ?building))) => (printout t “All buildings with emergency are evacuated “ crlf)) prints evacuated-message if for all buildings, which have a fire or bomb emergency, the building is evacuated.

© C. Kemke CLIPS 1 23 Exercise (defrule special-age “18, 21, 100” (or (person (name ?name) (age 18)) (person (name ?name) (age 21)) (person (name ?name) (age 100))) => (printout t ?name “ has a special age.”)) Task: Modify the condition pattern so that you use a variable for age, and field constraints for the values, and printout the name and age of any matching person.

© C. Kemke CLIPS 1 24 (deftemplate person (slot age (type INTEGER)) (multislot name (type STRING)) (slot gender (allowed-values f m)) ) (deffacts people (person (age 20) (name "Mike" "M." "Moore") (gender m)) (person (age 40) (name "James" "J." "James" ) (gender m)) (person (age 42) (name "Susan" "D." "More") (gender f)) (person (age 28) (name "John" "J." "Jones") (gender m)) ) (defrule what-am-I-doing (or (person (name ?first ?middle ?last&:(eq ?last "Moore"))) (person (name ?first ?middle ?last&:(eq ?last "More"))) ) => (printout t "Found " ?first " " ?last crlf) ) Q2: Can you simplify the Condition Element? Do it! Q1: What is the rule doing?

© C. Kemke CLIPS 1 25 bind-function bind-function – explicitly binds value to variable (bind ?age (read)) stores value of single field which is read into single-field variable ?age (bind ?name (readline)) stores line which is read as STRING into single-field STRING-variable ?address (bind ?address (explode$ (readline))) explode$ splits line which is read as STRING into multifield-value which is stored in multislot-variable ?address

© C. Kemke CLIPS 1 26 Open, Close File Open file for read/write: (open “ ” “r”)  is physical file-name (path)  is name used in program  “r” indicates read-access (“w”, “r+”) example: (open “example.dat” my-file “r”) (read my-file) Close file: (close )

© C. Kemke CLIPS 1 27 Input – read, readline read – input of single field readline – input of complete (line as string) general: (read ) refers to file-name in program (read) keyboard is default read with bind-function to bind input to variable: (bind ?input (read)) (bind $?input (readline))

© C. Kemke CLIPS 1 28 Input – read, readline (read / readline )  default is keyboard/terminal  file has to be opened using (open “ ” “r”)  is physical file-name (can include path)  is name used in read command  “r” indicates read-access example: (open “example.dat” example “r”) (read example) use with bind-function to bind input to variable

© C. Kemke CLIPS 1 29 Output - printout (printout... ) u t terminal is standard u otherwise refers to a file-name file has to be opened using (open “ ” “w” )  is physical file-name (can include path)  is name used in printout command v “w” indicates write-access example: (open “example.dat” my-output “w” ) (printout my-output ?name crlf)

© C. Kemke CLIPS 1 30 Rules - Runtime Effects refraction  each rule fires only once on the same data agenda  rules are activated in sequence and put on agenda; agenda is like a stack: the last rule fires first salience  sequence of rule firings - in case of a conflicts – is determined by their set salience factor: the higher the salience, the higher the rule priority

© C. Kemke CLIPS 1 31 Rules - Salience (defrule say-hello (declare (salience 10)) (person (name ?name)) => (printout t “Hello,” ?name)) (defrule say-happy-birthday (declare (salience 100)) (person (name ?name)) => (printout t “Happy Birthday,” ?name)) Rules defined with salience factor: The higher the salience, the higher the rule priority in conflict situations.