Jörg Kewisch, June 10, 2013, LILUG Meeting CLIPS C Language Integrated Production System Developed at the Software Development Branch, NASA Lyndon B. Johnson.

Slides:



Advertisements
Similar presentations
PLDI’2005Page 1June 2005 Example (C code) int double(int x) { return 2 * x; } void test_me(int x, int y) { int z = double(x); if (z==y) { if (y == x+10)
Advertisements

10/4/2003COMP 474/674 Fall 2003 Michelle Khalife1 Conflict Resolution in CLIPS COMP 474/674 FALL 2003 Michelle Khalifé.
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
Programming in Visual Basic
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.
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 CLIPS (Chapter 7) Fact List (contains data) Knowledge Base (contains rules) Inference Engine (controls execution)
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 Control 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba.
ISBN Lecture 01 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Lecture 01 Topics Motivation Programming.
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.
C++ for Engineers and Scientists Third Edition
CS 561, Session 25 1 Introduction to CLIPS Overview of CLIPS Facts Rules Rule firing Control techniques Example.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Language Evaluation Criteria
1 01/12/2011Knowledge-Based Systems, Paula Matuszek More Intro to CLIPS Paula Matuszek CSC 9010, Spring, 2011.
Review Topics Test 1. Background Topics Definitions of Artificial Intelligence & Turing Test Physical symbol system hypothesis vs connectionist approaches.
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
Data Structures & AlgorithmsIT 0501 Algorithm Analysis I.
Evolution of Programming Languages Generations of PLs.
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.
1 Chapter 4: Selection Structures. In this chapter, you will learn about: – Selection criteria – The if-else statement – Nested if statements – The switch.
ARTIFICIAL INTELLIGENCE DR. ABRAHAM AI a field of computer science that is concerned with mechanizing things people do that require intelligent.
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.
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>
Ch. 13 Ch. 131 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes?) Dr. Carter Tiernan.
PROGRAMMING LANGUAGES: PROLOG, CLOJURE, F# Jared Wheeler.
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.
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.
Copyright © 2014 by John Wiley & Sons. All rights reserved.1 Decisions and Iterations.
The CLIPS Expert System Shell Dr Nicholas Gibbins
PROGRAMMING USING PYTHON LANGUAGE ASSIGNMENT 1. INSTALLATION OF RASPBERRY NOOB First prepare the SD card provided in the kit by loading an Operating System.
Programming Logic and Design Fourth Edition, Introductory Chapter 2 Understanding Structure.
Introduction to CLIPS 2 Session 13 Course: T0273 – EXPERT SYSTEMS Year: 2014.
Welcome to Computer Programming II! Computer Programming II Summer 2015.
1 Outline Review Introduction to LISP Symbols and Numbers Lists Writing LISP Functions LISPWorks.
The Ohio State University
Zuse’s Plankalkül – 1945 Never implemented Problems Zuse Solved
Intelligent Systems JESS constructs.
Introduction Characteristics Advantages Limitations
ARTIFICIAL INTELLIGENCE
Chapter 7: Introduction to CLIPS
MATLAB: Structures and File I/O
Lecture 4B More Repetition Richard Gesick
Intro to Jess The Java Expert System Shell
Chapter 8: Advanced Pattern Matching
Objective of This Course
بسم الله الرحمن الرحیم آموزش نرم افزار CLIPS
Coding Concepts (Basics)
Chapter 2 Section 1.
Perl Programming Dr Claire Lambert
The IF Revisited A few more things Copyright © Curt Hill.
Review The Unix Shells Graham Glass and King Ables,
Presentation transcript:

Jörg Kewisch, June 10, 2013, LILUG Meeting CLIPS C Language Integrated Production System Developed at the Software Development Branch, NASA Lyndon B. Johnson Space Center

Jörg Kewisch, June 10, 2013, LILUG Meeting

Jörg Kewisch, June 10, 2013, LILUG Meeting Artificial Intelligence AI features: –Knowledge is added, the system learns AI methods: –Neural nets –Rule based systems »LISP, PROLOG, OPS5, CLIPS

Jörg Kewisch, June 10, 2013, LILUG Meeting Expert System Programs designed to replace an expert The solution is not well understood at design time Knowledge is collected and added during the use of the system Instead of one procedural program the problem is solved by a large number of independent “rules” Rules may be conflicting Famous expert systems: –ELIZA (Josef Weizenbaum) –MYCIN CLIPS is an expert system tool, not an expert system CLIPS is a programming language

Jörg Kewisch, June 10, 2013, LILUG Meeting “Facts” Facts are equivalent to data in procedural programs Facts are lists of words. Words are –Symbols –Strings –Numbers –Other Facts have no inherent meaning; an interpretation must be supplied by “rules” Example: The sentence “ Birne is doof ” has no meaning The difficult part in designing an expert system is to define a language (i. e. a format for facts and an interpretation) that is able to describe the system.

Jörg Kewisch, June 10, 2013, LILUG Meeting Birne

Jörg Kewisch, June 10, 2013, LILUG Meeting Rules Rules are the equivalent of statements in a procedural program Rule have the form: –If (list of facts) is asserted then do (list of actions) There is no “else” clause –Rules are “fired” by the existence of facts –CLIPS does not know what the opposite is There is however a construct to say: if fact1 exists and fact2 does not exist. –Such rule is fired by the existence of “fact1”

Jörg Kewisch, June 10, 2013, LILUG Meeting Firing of rules Whenever a new fact is asserted all rules are checked if the new fact fulfills all or part of the requirements to “fire” the rule. If all requirements are fulfilled the rule and the facts are put on the “agenda' The (run) function selects a rule from the agenda and executes it. The following selection strategies are used: –Depth: newest rule (default) –Breath: oldest rule –Simplicity: lowest number of facts –Complexity: highest number of facts –Lex and Mea: OPS5 strategy –Random: random

Jörg Kewisch, June 10, 2013, LILUG Meeting Creating Facts and Rules Facts are created in CLIPS using the “assert” function: (assert (Birne ist doof)) Rules are defined in CLIPS by: ( defrule rule_name “optional comment” (fact 1)... (fact n) => (function 1) … (function n) )

Jörg Kewisch, June 10, 2013, LILUG Meeting Loops Each set of facts fires a rule only once Infinite Loops : (defrule on_and_on ?r ← (next) => (retract ?r) (printout t “do too!!!” crlf) (assert (next)) ) The fact (initial_fact) exists by default

Jörg Kewisch, June 10, 2013, LILUG Meeting Binding of variables (defrule gramps ( ?x is father of ?y) ( ?y is father of ?z) => (assert (?x is grandfather of ?z) )

Jörg Kewisch, June 10, 2013, LILUG Meeting Multi-field variables (defrule why (I $?x you) => ( printout t “Why do you” ?x “me?” ctlf) ) (assert (I hate You)) (assert (I really really hate you)) (assert ( I you)) (run) Why do you me? Why do you really really hate me? Why do you hate me?

Jörg Kewisch, June 10, 2013, LILUG Meeting Salience Rules may have a defined priority: (defrule important (define salience 100) (fire alarm) => (leave building) ) The salience should not be used to enforce sequential execution of the rules

Jörg Kewisch, June 10, 2013, LILUG Meeting CLIPS functions Creating and deleting rules: defrule, undefrule Creating and deleting facts: assert, retract, facts, reset Creating (local) variables: bind Math functions: +,-,*,/,sin,cos,tan.atan,exp,ln Comparison: eq, neq String functions: str-cat, sub-str, index Control structures: if, while Input/Output: open, read, readline, write, close, printout, load, save User functions: deffunction

Jörg Kewisch, June 10, 2013, LILUG Meeting Functions written in C UserFunctions() { int fun1(); double fun2(); DefineFunction(“fun1”, “i”, fun1, “fun1”); DefineFunction(“fun2”, “f”, fun2, “fun2”); } C functions are provided to access variables, return values, assert and retract facts and rules, and error handling CLIPS can be called from a C program

Jörg Kewisch, June 10, 2013, LILUG Meeting Example: Evaluate an expression Facts have the form: varName = exprssion Example: a = b + c b = 5 c = b*(b+1) The facts are transformed into: a = 35 b = 5 c = 30

Jörg Kewisch, June 10, 2013, LILUG Meeting Variable substitution (defrule insert-variable- into-expression (?n2 "=" ?value&:(numberp ?value)) ?z <- (?n1 "=" $?head ?n2 $?tail) => (retract ?z) (assert (?n1 "=" ?head ?value ? tail)) )

Jörg Kewisch, June 10, 2013, LILUG Meeting Addition (defrule plus (declare (salience 20)) ?z <- (?n1 "=" $?head ?x&:(numberp ?x) "+" ?y&:(numberp ?y) $?tail) => (retract ?z) (assert (?n1 "=" ?head =(+ ?x ?y) ?tail)) )

Jörg Kewisch, June 10, 2013, LILUG Meeting Subtraction (defrule minus (declare (salience 20)) ?z <- (?n1 "=" $?head "-" ?x&:(numberp ?x) $?tail) => (retract ?z) (if (> (length ?head) 0) then (assert (?n1 "=" ?head "+" = (- 0 ?x ) ?tail)) else (assert (?n1 "=" = (- 0 ?x ) ?tail)) )

Jörg Kewisch, June 10, 2013, LILUG Meeting Multiplication (defrule cut-times (declare (salience 30)) ?z <- (?n1 "=" $?head ?x "*" ?y $?tail) => (retract ?z) (bind ?g (gensym)) (assert (?n1 "=" ?head ?g ?tail)) (assert (?g "=" ?x “*_” ?y)) )

Jörg Kewisch, June 10, 2013, LILUG Meeting Multiplication (defrule calc-times ?z <- (?n1 "=" $?head ?x&:(numberp ?x) “*_” ?y&:(numberp ?y) $?tail) => (retract ?z) (assert (?n1 "=" ?head = (* ?x ?y) ? tail)) )

Jörg Kewisch, June 10, 2013, LILUG Meeting Parenthesis (defrule parenthesis (declare (salience 40)) ?z <- (?n1 "=" $?head "\(" $?tail) => (retract ?z) (bind ?pcount 1) (bind ?i 1) (bind ?this (nth ?i ?tail)) (while (and (neq ?pcount 0) (neq ?this nil)) (if (eq ?this "\(" ) then (bind ?pcount (+ ?pcount 1))) (if (eq ?this "\)" ) then (bind ?pcount (- ?pcount 1))) (bind ?i (+ ?i 1)) (bind ?this (nth ?i ?tail)) ) (bind ?g (gensym)) (assert (?g "=" (subseq$ ?tail 1 (- ?i 2)))) (assert (?n1 "=" ?head ?g (subseq$ ?tail ?i (length ?tail)))) )

Jörg Kewisch, June 10, 2013, LILUG Meeting When to use CLIPS If the language describing the problem is defined, but the solution is unclear. If the problem involves recognition of patterns. If the problem involves decision making, and the criteria for the decisions are rapidly changing.

Jörg Kewisch, June 10, 2013, LILUG Meeting When NOT to use CLIPS If you know it can not be done in a procedural programming language. If the problem and the solution is well defined If you end up with too many rules that are executed only once. If the rules are executed always in the same order.

Jörg Kewisch, June 10, 2013, LILUG Meeting Conclusion