CS 561, Session 25 1 Introduction to CLIPS Overview of CLIPS Facts Rules Rule firing Control techniques Example.

Slides:



Advertisements
Similar presentations
Expert systems CLIPS Seyed Hashem Davarpanah
Advertisements

10/4/2003COMP 474/674 Fall 2003 Michelle Khalife1 Conflict Resolution in CLIPS COMP 474/674 FALL 2003 Michelle Khalifé.
© C. Kemke XPS Implementation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba.
Resolving Rule Conflicts Assign explicit priorities to rules Specificity of a rule’s antecedents R1: IF car will not start THEN battery is dead R2: IF.
(FO) Inference Methods CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
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.
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)
Samad Paydar Ferdowsi University of Mashhad.  C Language Integrated Production System (CLIPS)  A tool for building expert systems  An expert system.
B. Ross Cosc 4f79 1 Forward chaining backward chaining systems: take high-level goal, and prove it by reducing it to a null goal - to reduce it to null,
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
© C. Kemke CLIPS 1 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba.
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.
Rule Based Systems Michael J. Watts
Chapter 12: Expert Systems Design Examples
Expert System Human expert level performance Limited application area Large component of task specific knowledge Knowledge based system Task specific knowledge.
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.
Lecture 04 Rule Representation
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:
© 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.
© 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.
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.
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.
1 Programming a Knowledge Based Application. 2 Overview.
Introduction to Python
Chapter 7: Introduction to CLIPS Expert Systems: Principles and Programming, Fourth Edition.
Production Systems A production system is –a set of rules (if-then or condition-action statements) –working memory the current state of the problem solving,
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.
Introduction to Engineering MATLAB – 2 Introduction to MATLAB - 2 Agenda Defining Variables MATLAB Windows.
Introduction to Unix – CS 21 Lecture 8. Lecture Overview More detail on emacs and vi Regular expression matching in emacs and vi.
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.
1 Defining a Problem as a State Space 1. Define a state space that contains all the possible configurations of the relevant objects. 2. Specify one (or.
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.
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)
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.
Variables and Functions ROBOTC Software © 2012 Project Lead The Way, Inc.Principles of Engineering.
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.
Intelligent Systems JESS constructs.
Presented By S.Yamuna AP/CSE
Chapter 7: Introduction to CLIPS
Chapter 8: Advanced Pattern Matching
بسم الله الرحمن الرحیم آموزش نرم افزار CLIPS
CPE/CSC 481: Knowledge-Based Systems
Presentation transcript:

CS 561, Session 25 1 Introduction to CLIPS Overview of CLIPS Facts Rules Rule firing Control techniques Example

CS 561, Session 25 2 CLIPS basic elements Fact-list: global memory of data Knowledge-base: contain all the rules Inference engine: controls overall execution using forward chaining

CS 561, Session 25 3 Inference cycle Working Memory (Facts) Knowledge-Base (Rules) Pattern Matching Conflict Resolution (select rule) Fire rule User’s program assert/ retract/ modify facts change rules Agenda

CS 561, Session 25 4 Antecedent Matching 1.matches facts in working memory against antecedents of rules 2.each combination of facts that satisfies a rule is called an instantiation 3.each matching rule is added to the agenda

CS 561, Session 25 5 Selection of a rule from the Agenda Some selection strategies: Recency (most recent first) triggered by the most recent facts Specificity (most specific first) rules prioritized by the number of condition elements Random choose a rule at random from the agenda

CS 561, Session 25 6 Execution of the rule Can modify working memory add facts remove facts alter existing facts Alter rules Perform an external task (read sensors, control actuator)

CS 561, Session 25 7 Control mechanism Consider the following rule-base: (1)Car won’t start  check battery (2)Car won’t start  check gas (3)Check battery AND battery bad  replace battery If the fact “car won’t start” is asserted, then which of the rules (1) and (2) should be placed on the agenda? (1), (2), or both? We need a mechanism to place instantiations of rules on the agenda.

CS 561, Session 25 8 Control mechanisms Markov algorithms: Approach: Apply rule with highest priority, if not applicable then take the next one etc. Problem: inefficient for systems with many (1000s of) rules. Has to do pattern matching on every rule in each cycle. Rete algorithm: Fast pattern matching that obtains speed by storing information about all rules in a network. Only looks for changes in pattern matches in every cycle.

CS 561, Session 25 9 Install and run Access to CLIPS: On aludra: at ~csci561a/clips In Windows: install Running Clips On aludra: > clips In Windows: run clips.exe

CS 561, Session Overview shell agendafocus facts instances globals

CS 561, Session Getting started Shell commands: ( ) (help) (reset)  places (initial-fact) on factlist (run)  runs till completion of program (run 1)  runs 1 step (facts)  shows the factlist (assert (fact))  puts (fact) on factlist (retract 0)  removes fact with ID 0 from factlist (defrule myrule …)  defines a rule named myrule (clear)  removes all facts from factlist

CS 561, Session Facts (field1 field2 … fieldN)an ordered, flat list E.g., (Hans 561a) is not equal to (561a Hans) (Hans (561a 561b)) is illegal Common to start with the relation that fact describes e.g., (class Hans 561b) Keyword nil: used to indicate that a field has no value deftemplates to have names for each field

CS 561, Session Field types Types: Float:1.34 Integer:1, 2, 10, 20 Symbol:alkflksjfd String:"duck/soup" external-address: fact-address: instance-name: instance-address: The type of each field is determined by the type of value stored in the field. In deftemplates, you can explicitly declare the type of value that a field can contain.

CS 561, Session Deffacts (deffacts [ ] > ) used to automatically assert a set of facts (deffacts status “some facts about emergency” (emergency fire) (fire-class A) ) Are asserted after a (reset) command

CS 561, Session Adding and removing facts (assert >>) used to assert multiple facts (retract >>) removes a number of facts e.g., (assert (fact1) (fact2) ) (retract 1) Is assigned a unique fact identifier: (e.g., f-1) starts with ‘f’ and followed by an integer called the fact-index Fact-index: can be used to refer to that fact (e.g., retract it) Fact-list: can be viewed in the fact-list window or using the (facts) command. (facts [ [ [<maximum]]])

CS 561, Session Components of a rule (defrule [ ] >> => >>) (defrule fire-emergency “An example rule” (emergency fire) => (assert (action activate-sprinkler-system))) Rules can be inserted into the shell or loaded from a file using the (load) command

CS 561, Session The agenda and activation (run [ ]) runs a CLIPS program, is the number of rules to fire Activating a rule: requires that all its patterns on LHS (Left-Hand- Side) are matched. Asserting an existing fact has no effect. List of activated rules: can be seen in the agenda window or listed using (agenda) 0 fire-emergency f-2 salience rule name matching facts

CS 561, Session Rule firing and refraction (run) will cause the most salient rule on the agenda to fire What if the run command is issued again?

CS 561, Session Rule firing and refraction (run) will cause the most salient rule on the agenda to fire What if the run command is issued again? There are no rules on the agenda so nothing will happen. Refraction: CLIPS rule firing models the refraction effect of a neuron to avoid endless loops

CS 561, Session Commands used with rules (rules) displays the rules in the knowledge-base (pprule ) displays a rule (load ) loads rules described in a file (save ) saves the stored rules into a file Comments: start with the character “;”

CS 561, Session Multiple rules (defrule fire-emergency (emergency fire) => (assert (action activate-sprinkler-system))) (defrule flood-emergency (emergency flood) => (assert (action shut-down-electrical-equipment))) Asserting (emergency fire) will fire rule 1 asserting (emergency flood) will activate rule 2

CS 561, Session Rules with multiple patterns (defrule class-A-fire-emergency (emergency fire) (fire-class A) => (assert (action activate-sprinkler-system))) (defrule class-B-fire-emergency (emergency fire) (fire-class B) => (assert (action activate-carbon-dioxide-extinguisher))) All patterns must be matched for the rule to fire

CS 561, Session Removing rules (clear) removes all rules from the knowledge-base (excise ) removes rule

CS 561, Session Debugging (watch {facts, rules, activations, all}) is used to provide the information about facts, rules, activations (unwatch {facts, rules, activations, all}) undoes the a (watch) command (matches ) indicates which patterns in a rule match facts (set-break ) allows execution to be halted before a rule (remove-break [ ]) removes all or a given breakpoint (show-breaks) lists all breakpoints

CS 561, Session Variables ?speed ?sensor ?value (defrule grandfather (is-a-grandfather ?name) ?name bound to the 2 nd field of fact => (assert (is-a-man ?name))) E.g: (is-a-grandfather John)  ?name = John (is-a-grandfather Joe)  ?name = Joe

CS 561, Session Wildcards (person ) (person John brown black) (person Joe blue brown) (defrule find-brown-haired-people (person ?name ?brown) => (printout t ?name “ has brown hair”)) States that eye color doesn’t matter.

CS 561, Session Control techniques Using control facts Using salience Using control rules

CS 561, Session Example

CS 561, Session Example