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

Slides:



Advertisements
Similar presentations
CPS120: Introduction to Computer Science INPUT/OUTPUT.
Advertisements

The CLIPS Programming Tool History of CLIPS –Influenced by OPS5 and ART –Implemented in C for efficiency and portability –Developed by NASA, distributed.
The Web Warrior Guide to Web Design Technologies
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.
Simple Rule Based Systems Directly implementing rule based systems in Java Need vocabulary Simplicity sometimes works.
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.
IT151: Introduction to Programming
Introduction to CLIPS (Chapter 7) Fact List (contains data) Knowledge Base (contains rules) Inference Engine (controls execution)
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
© C. Kemke CLIPS 1 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba.
ECE122 L3: Expression Evaluation February 6, 2007 ECE 122 Engineering Problem Solving with Java Lecture 3 Expression Evaluation and Program Interaction.
Python Programming Chapter 2: Variables, expressions, and statements Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2011/2012.
Introduction to Python
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.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
A First Book of ANSI C Fourth Edition
Advanced Shell Programming. 2 Objectives Use techniques to ensure a script is employing the correct shell Set the default shell Configure Bash login and.
Artificial Intelligence Lecture No. 15 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Chapter 7: Introduction to CLIPS Expert Systems: Principles and Programming, Fourth Edition.
CS161 Topic #21 CS161 Introduction to Computer Science Topic #2.
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.
Artificial Intelligence Lecture No. 29 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Input, Output, and Processing
Arrays and ArrayLists in Java L. Kedigh. Array Characteristics List of values. A list of values where every member is of the same type. Each member in.
Introduction to C Programming Angela Chih-Wei Tang ( 唐 之 瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2010 Fall.
CHAPTER 4: CONTROL STRUCTURES - SEQUENCING 10/14/2014 PROBLEM SOLVING & ALGORITHM (DCT 1123)
Week 1 Algorithmization and Programming Languages.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Variables, Arithmetic, etc.)
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
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.
CS346 Javascript -3 Module 3 JavaScript Variables.
SE-1010 Dr. Mark L. Hornick 1 Variables & Datatypes.
1 Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
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>
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
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.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
Programming Fundamentals. Summary of previous lectures Programming Language Phases of C++ Environment Variables and Data Types.
Artificial Intelligence Lecture No. 19 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Python Let’s get started!.
Artificial Intelligence Lecture No. 23 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Introduction to Computer Programming - Project 2 Intro to Digital 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.
ICS102 Lecture 1 : Expressions and Assignment King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer.
The CLIPS Expert System Shell Dr Nicholas Gibbins
Topics Designing a Program Input, Processing, and Output
CSC201: Computer Programming
Python Let’s get started!.
Variables and Primative Types
Chapter 7: Introduction to CLIPS
Chapter 3 Introduction to Classes, Objects Methods and Strings
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Object Oriented Programming in java
Lexical Elements & Operators
Presentation transcript:

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

Summary of Previous Lecture What is CLIPS? CLIPS difference Interacting with clips

Today’s Lecture Facts command Watch that Fact Use of backslash, "\“ Rules in CLIPS

CLIPS shell The CLIPS shell provides the basic elements of an expert system: 1. fact-list, and instance-list: Global memory for data 2. knowledge-base: Contains all the rules, the rule-base 3. inference engine: Controls overall execution of rules

Making a List As with other programming languages, CLIPS recognizes certain keywords. For example, if you want to put data in the fact-list, you can use the assert command. CLIPS> (assert (duck)) CLIPS> (facts) f-0 (initial-fact) f-1 (duck) For a total of 2 facts. CLIPS>

What happens if you try to put a second duck into the fact-list? Let's try it and see. Assert a new (duck), then issue a (facts) command as follows

Facts command The keyboard command to see facts is with the facts command. Enter (facts) in response to the CLIPS prompt and CLIPS will respond with a list of facts in the fact-list. Be sure to put parentheses around the command or CLIPS will not accept it. The result of the (facts) command in this example should be CLIPS> (facts) f-0 (initial-fact) f-1 (duck) For a total of 2 facts. CLIPS>

Clearing Up the Facts The (clear) command actually does more than just remove facts. Besides removing all the facts, (clear) also removes all the rules. CLIPS> (facts) f-0 (initial-fact) f-1 (duck) f-2 (quack) For a total of 3 facts. CLIPS> (clear) CLIPS>

CLIPS> (clear) CLIPS> (assert (a) (b) (c)) CLIPS> (facts) f-0 (initial-fact) f-1 (a) f-2 (b) f-3 (c) For a total of 4 facts.

Retract that Fact 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. CLIPS> (retract 3) CLIPS>

You can also retract multiple facts at once, as shown by the following. CLIPS> (retract 1 3) CLIPS> (facts) f-0 (initial-fact) f-2 (animal-sound quack) For a total of 2 facts. You can just use (retract *) to retract all the facts, where the "*" indicates all.

Watch that Fact One command allows you to continuously watch facts being asserted and retracted. CLIPS> (assert (animal-is duck)) ==> f-1 (animal-is duck) CLIPS> (retract 1) <== f-1 (animal-is duck) CLIPS> (facts) f-0 (initial-fact) For a total of 1 fact. CLIPS> To turn off watching facts, enter (unwatch facts).

(watch facts) (watch instances) ; used with objects (watch slots) ; used with objects (watch rules) (watch activations) (watch messages) ; used with objects (watch message-handlers) ; used with objects (watch generic-functions) (watch methods) ; used with objects (watch deffunctions) (watch compilations) ; on by default (watch statistics) (watch globals) (watch focus) (watch all) ; watch everything

white space Multiple fields normally are separated by white space consisting of one or more spaces, tabs, carriage returns, or linefeeds. (assert (The duck says "Quack")) FALSE be careful if you insert a carriage return inside of a string CLIPS> (assert (The duck says "Quack "))

CLIPS> (assert (grocery-list ice-cream cookies candy sauce)) CLIPS> (facts) f-0 (initial-fact) f-1 (grocery-list ice-cream cookies candy fudge- sauce)

CLIPS is said to be case-sensitive because it distinguishes between uppercase and lowercase letters. For example, assert the facts (duck) and (Duck) and then issue a (facts) command. You'll see that CLIPS allows you to assert (duck) and (Duck) as different facts because CLIPS is case-sensitive.

CLIPS> (assert (animal-is "duck")) CLIPS> (assert (animal-is "duck ")) CLIPS> (assert (animal-is " duck")) CLIPS> (assert (animal-is " duck ")) CLIPS> (facts) f-0 (initial-fact) f-1 (animal-is "duck") f-2 (animal-is "duck ") f-3 (animal-is " duck") f-4 (animal-is " duck ") For a total For a total of 5 facts. CLIPS>

What if you want to include the double quotes in a field? The correct way to put double quotes in a fact is with the backslash, "\", as the following example shows. CLIPS> (clear) CLIPS> (assert (single-quote "duck")) CLIPS> (assert (double-quote "\"duck\"")) CLIPS> (facts) f-0 (initial-fact) f-1 (single-quote "duck") f-2 (double-quote ""duck"") For a total of 3 facts. CLIPS>

Numeric fields A field which represents a number which can be either an integer or floating-point type field. A floating-point type is commonly referred to simply as a float. All numbers in CLIPS are treated as “long long” integers or double- precision floats. CLIPS> (assert (number 1)) CLIPS> (assert (x 1.5)) CLIPS> (assert (y -1)) CLIPS> (assert (z 65)) CLIPS> (assert (distance 3.5e5)) CLIPS> (assert (coordinates 1 2 3)) CLIPS> (assert (coordinates 1 3 2))

Making Good Rules To accomplish useful work, an expert system must have rules as well as facts. The pseudocode for a rule about duck sounds might be IF the animal is a duck THEN the sound made is quack CLIPS> (assert (animal-is duck)) CLIPS> (defrule duck (animal-is duck) => (assert (sound-is quack))) CLIPS>

(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.

Rule name Entering the same rule name, in this case "duck", will replace any existing rule with that name. That is, while there can be many rules in CLIPS, there can be only one rule which is named "duck". This is analogous to other programming languages in which only one procedure name can be used to uniquely identify a procedure.

The general syntax of a rule is shown following. (defrule rule_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

The part of the rule before the arrow is called the left-hand side (LHS) and the part of the rule after the arrow is called the right-hand side (RHS). If no patterns are specified

Before going on, let's save the duck rule with the save command so that you don't have to type it in again. Just enter a command such as (save "duck.clp")

Summery of Today’s Lecture Facts command Watch that Fact Use of backslash, "\“ Numeric fields Rules in CLIPS