Artificial Intelligence Lecture No. 19 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.

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.
Expert System Shells - Examples
Programming TBE 540 Farah Fisher. Objectives After viewing this presentation, the learner will be able to… Given a task, create pseudocode Given pseudocode,
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
Simple Rule Based Systems Directly implementing rule based systems in Java Need vocabulary Simplicity sometimes works.
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.
Lecture 2 Introduction to C Programming
Artificial Intelligence Lecture No. 16
Using Pine to send your ICS111 homework First Log in into UNIX using SSH either from home (If you have previously installed SSH or from the Lab. Once in.
Introduction to CLIPS (Chapter 7) Fact List (contains data) Knowledge Base (contains rules) Inference Engine (controls execution)
How to Create a Java program CS115 Fall George Koutsogiannakis.
EGR 106 – Week 2 – Arrays & Scripts Brief review of last week Arrays: – Concept – Construction – Addressing Scripts and the editor Audio arrays Textbook.
© 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.
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
CS 561, Session 25 1 Introduction to CLIPS Overview of CLIPS Facts Rules Rule firing Control techniques Example.
Fundamentals of Programming in Visual Basic 3.1 Visual basic Objects Visual Basic programs display a Windows style screen (called a form) with boxes into.
Simple Python Loops Sec 9-7 Web Design.
Programming For Nuclear Engineers Lecture 12 MATLAB (3) 1.
Artificial Intelligence Lecture No. 15 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Chapter 9: Modular Design, Execution Control, and Rule Efficiency Expert Systems: Principles and Programming, Fourth Edition.
Chapter 7: Introduction to CLIPS Expert Systems: Principles and Programming, Fourth Edition.
1 Functions 1 Parameter, 1 Return-Value 1. The problem 2. Recall the layout 3. Create the definition 4. "Flow" of data 5. Testing 6. Projects 1 and 2.
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.
Artificial Intelligence Lecture No. 29 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Basic & Advanced Reporting in TIMSNT ** Part Two **
Collecting Things Together - Lists 1. We’ve seen that Python can store things in memory and retrieve, using names. Sometime we want to store a bunch of.
CMPS 1371 Introduction to Computing for Engineers MatLab.
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.
Chapter 3 MATLAB Fundamentals Introduction to MATLAB Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
CONTENTS Processing structures and commands Control structures – Sequence Sequence – Selection Selection – Iteration Iteration Naming conventions – File.
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
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.
1 Knowledge Based Systems (CM0377) Lecture 10 (Last modified 19th March 2001)
Artificial Intelligence Lecture No. 23 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Programming Fundamentals. Topics to be covered Today Recursion Inline Functions Scope and Storage Class A simple class Constructor Destructor.
Debugging tools in Flash CIS 126. Debugging Flash provides several tools for testing ActionScript in your SWF files. –The Debugger, lets you find errors.
Mostly adopted from Jason Morris notes (Morris Technical Solutions)
Discrete Mathematics Lecture # 22 Recursion.  First of all instead of giving the definition of Recursion we give you an example, you already know the.
Searching CSE 103 Lecture 20 Wednesday, October 16, 2002 prepared by Doug Hogan.
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..
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
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
CSCE 206 Lab Structured Programming in C
Chapter 1 c++ structure C++ Input / Output
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

Artificial Intelligence Lecture No. 19 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology (CIIT) Islamabad, Pakistan.

Summary of Previous Lecture Facts command Watch that Fact Use of backslash, "\“ Rules in CLIPS

Today’s Lecture Reopen Rule Print out Variables

Reopen The load command loads in the rule that you had previously saved to disk in the file "duck.clp" or whatever name and directory that you had saved it under. You can load a file of rules made on a text editor into CLIPS using the load command. File –> Load-> file_name.clp Assert fact

Rule (defrule duck "Here comes the quack" ; Rule header (animal-is duck) ; Pattern => ; THEN arrow (assert (sound-is quack))) ; Action Only one rule name can exist at one time in CLIPS.

Show Me the Rules Sometimes you may want to see a rule while you're in CLIPS. There's a command called ppdefrule – the pretty print rule – that prints a rule. To see a rule, specify the rule name as an argument to ppdefrule. For example, CLIPS> (ppdefrule duck)

What if you want to print a rule but can't remember the name of the rule? No problem. Just use the rules command in response to a CLIPS prompt and CLIPS will print out the names of all the rules. For example, enter CLIPS> (rules)

Fire the rule If there is only one rule on the agenda, that rule will fire. Since the LHS pattern of the duck-sound rule is (animal-is duck) This pattern will be satisfied by the fact (animal- is duck) and so the duck-sound rule should fire. To make a program run, just enter the run command. Type (run) and press the carriage return key. Then do a (facts) to check that the fact was asserted by the rule.

What if you (run) again? if you try this and (run) again, you'll see that the rule won't fire. you need to know a little more about some basic principles of expert systems. A rule is activated if its patterns are matched by a – 1. a brand new pattern entity that did not exist before or, – 2. a pattern entity that did exist before but was retracted and reasserted, i.e., a "clone" of the old pattern entity, and thus now a new pattern entity.

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. CLIPS executes the RHS of the rule with the highest salience on the agenda, and removes the activation. This execution is called firing the rule in analogy with the firing of a neuron. A neuron emits a voltage pulse when an appropriate stimulus is applied. After a neuron fires, it undergoes refraction and cannot fire again for a certain period of time. Without refraction, neurons would just keep firing over and over again on exactly the same stimulus.

The following example shows activations and firing of a rule. CLIPS> (clear) CLIPS> (defrule duck (animal-is duck) => (assert (sound-is quack))) CLIPS> (watch facts) CLIPS> (watch activations) CLIPS> (assert (animal-is duck)) ==> f-1 (animal-is duck) ==> Activation 0 duck: f-1 ; Activation salience is 0 by ; default, then rule name:pattern entity index CLIPS> (run)

Nothing in If part If ´there is no conditions in if part of the rule then (defrule noif => (assert (Hello)))

Write to Me Besides asserting facts in the RHS of rules, you also can print out information using the printout function. CLIPS also has a carriage return/linefeed keyword called crlf which is very useful in improving the appearance of output by formatting it on different lines. For a change, the crlf is not included in parentheses. As an example, CLIPS> (defrule duck (animal-is duck) => (printout t "quack" crlf)) ; Be sure to type in the "t" CLIPS> (run)

Stop And Go Suppose you wanted to write an expert system to determine how a mobile robot should respond to a traffic light. It is best to write this type of problem using multiple rules. For example, the rules for the red and green light situations can be written as follows.

(defrule LR (light red) => (printout t "Stop" crlf)) (defrule LG (light green) => (printout t "Go" crlf))

suppose we want a rule to fire if the robot is walking and if the walk-sign says walk. A rule could be written as follows: (defrule take-a-walk (status walking) (walk-sign walk) => (printout t "Go" crlf))

logical AND You can have any number of patterns or actions in a rule. The important point to realize is that the rule is placed on the agenda only if all the patterns are satisfied by facts. This type of restriction is called a logical AND conditional element (CE) in reference to the AND relation of Boolean logic. An AND relation is said to be true only if all its conditions are true. Because the patterns are of the logical AND type, the rule will not fire if only one of the patterns is satisfied. All facts must be present before the LHS of a rule is satisfied and the rule is placed on the agenda.

Variables 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. The general format is ? Just as in other programming languages, variable names should be meaningful for good style. Some examples of valid variable names follow. ?x ?noun ?color ?sensor ?valve ?ducks-eaten

Assigned a value Before a variable can be used, it should be assigned a value. As an example of a case where a value is not assigned, try to enter the following and CLIPS will respond with the error message shown. (defrule test => (printout t ?x crlf))

Bind value to a variable CLIPS gives an error message when it cannot find a value bound to ?x. The term bound means the assignment of a value to a variable. Only global variables are bound in all rules. All other variables are only bound within a rule. Before and after a rule fires, nonglobal variables are not bound and so CLIPS will give an error message if you try to query a nonbound variable. CLIPS> (bind ?a 5)

Be Assertive One common use of variables is to match a value on the LHS and then assert this bound variable on the RHS. For example, enter (defrule make-quack (duck-sound ?sound) => (assert (sound-is ?sound)))

Summery of Today’s Lecture Reopen Rule Print out Variables