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

Slides:



Advertisements
Similar presentations
23-Apr-15 Abstract Data Types. 2 Data types I We type data--classify it into various categories-- such as int, boolean, String, Applet A data type represents.
Advertisements

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.
November 2, 2004AI: CLIPS Language Tutorial1 Artificial Intelligence CLIPS Language Tutorial Michael Scherger Department of Computer Science Kent State.
Chapter 8 Pattern Matching
Inference Methods Propositional and Predicate Calculus.
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.
Data Types in Java Data is the information that a program has to work with. Data is of different types. The type of a piece of data tells Java what can.
Artificial Intelligence Lecture No. 16
Introduction to CLIPS (Chapter 7) Fact List (contains data) Knowledge Base (contains rules) Inference Engine (controls execution)
© C. Kemke CLIPS 1 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.
ECE122 L3: Expression Evaluation February 6, 2007 ECE 122 Engineering Problem Solving with Java Lecture 3 Expression Evaluation and Program Interaction.
Introduction to Jess.
Expressions An expression is a sequence of operands and operators that reduces to a single value expression operator operand An operator is a language-specific.
CSci 142 Data and Expressions. 2  Topics  Strings  Primitive data types  Using variables and constants  Expressions and operator precedence  Data.
Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission.
Expressions, Data Conversion, and Input
Artificial Intelligence Lecture No. 15 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Artificial Intelligence Lecture No. 28 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Unit 11, Part 2: Introduction To Logarithms. Logarithms were originally developed to simplify complex arithmetic calculations. They were designed to transform.
Chapter 7: Introduction to CLIPS Expert Systems: Principles and Programming, Fourth Edition.
CHAPTER 13 Creating a Workbook Part 2. Learning Objectives Work with cells and ranges Work with formulas and functions Preview and print a workbook 2.
Artificial Intelligence Lecture No. 17 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Artificial Intelligence Lecture No. 29 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Input, Output, and Processing
CSC Programming I Lecture 5 August 30, 2002.
Summary of what we learned yesterday Basics of C++ Format of a program Syntax of literals, keywords, symbols, variables Simple data types and arithmetic.
CSC 221 Computer Organization and Assembly Language
Integer numerical data types. The integer data types The integer data types use the binary number system as encoding method There are a number of different.
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 CISC181 Introduction to Computer Science Dr. McCoy Lecture 6 September 17, 2009.
First Programs CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
CMP-MX21: Lecture 4 Selections Steve Hordley. Overview 1. The if-else selection in JAVA 2. More useful JAVA operators 4. Other selection constructs in.
Mixing integer and floating point numbers in an arithmetic operation.
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.
COIT29222 Structured Programming 1 COIT29222-Structured Programming Lecture Week 02  Reading: Textbook(4 th Ed.), Chapter 2 Textbook (6 th Ed.), Chapters.
Artificial Intelligence Lecture No. 19 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Order of Operations Module I, Lesson 1 Online Algebra
29 January 2016Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems.
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.
Artificial Intelligence Lecture No. 22 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Thinking about programming Intro to Computer Science CS1510 Dr. Sarah Diesburg.
Artificial Intelligence Lecture No. 8 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Chapter 2: Data and Expressions. Variable Declaration In Java when you declare a variable, you must also declare the type of information it will hold.
The CLIPS Expert System Shell Dr Nicholas Gibbins
CS 115 Lecture 5 Math library; building a project Taken from notes by Dr. Neil Moore.
Fundamental Programming Fundamental Programming Data Processing and Expressions.
Introduction to CLIPS 2 Session 13 Course: T0273 – EXPERT SYSTEMS Year: 2014.
Topics Designing a Program Input, Processing, and Output
Intelligent Systems JESS constructs.
Introduction to Computer Science / Procedural – 67130
Chapter 7: Introduction to CLIPS
Creating a Workbook Part 2
Chapter 8: Advanced Pattern Matching
بسم الله الرحمن الرحیم آموزش نرم افزار CLIPS
JESS (Java Expert System Shall)
Topics Designing a Program Input, Processing, and Output
Summary of what we learned yesterday
Topics Designing a Program Input, Processing, and Output
PROGRAMMING IN HASKELL
Computer Based Tutoring
Presentation transcript:

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

Summary of Previous Lecture Deftemplate Single-slot or multislot

Today’s Lecture Multiple fields Functional ~ | &

Functional Let's reconsider the problem of designing an expert system to help a robot cross a street. One rule that you would have follows. (defrule green-light (light green) => (printout t "Walk" crlf)) Another rule would cover the case of a red light. (defrule red-light (light red) => (printout t "Don't walk" crlf))

A third rule would cover the case in which a walk-sign said not to walk. This would take precedence over a green light. (defrule walk-sign (walk-sign-says dont-walk) => (printout t "Don't walk" crlf))

not allow The previous rules are simplified and don't cover all cases such as the breakdown of the traffic-light. For example, what does the robot do if the light is red or yellow and the walk-sign says walk? A way of handling this case is to use a field constraint to restrict the values that a pattern may have on the LHS. The field constraint acts like constraints on patterns. One type of field constraint is called a connective constraint. There are three types of connective constraints. The first is called a ~ constraint. Its symbol is the tilde "~". The ~ constraint acts on the one value that immediately follows it and will not allow that value.

As a simple example of the ~ constraint, suppose you wanted to write a rule that would print out "Don't walk" if the light was not green. One approach would be to write rules for every possible light condition, including all possible malfunctions: yellow, red, blinking yellow, blinking red, blinking green, winking yellow, blinking yellow and winking red, and so forth. However, a much easier approach is to use the ~ constraint as shown in the following rule:

(defrule walk (light ~green) => (printout t "Don't walk" crlf)) By using the ~ constraint, this one rule does the work of many other rules that required specifying each light condition.

Bar constraint The second connective constraint is the bar constraint, "|". The "|" connective constraint is used to allow any of a group of values to match. For example, suppose you wanted a rule that printed out "Be cautious" if the light was yellow or blinking yellow. The following example shows how it's done using the "|“ constraint.

(defrule cautious (light yellow | blinking-yellow) => (printout t "Be cautious" crlf)) (assert (light yellow)) (assert (light blinking-yellow))

The symbol of the & The third type of connective constraint is the & connective constraint. The symbol of the & connective constraint is the ampersand, "&". The & constraint forces connected constraints to match in union, as you'll see in the following examples. The & constraint normally is used only with the other constraints, otherwise it's not of much practical use. As an example, suppose you want to have a rule that will be triggered by a yellow or blinking-yellow fact. That's easy enough—just use the | connective constraint as you did in a previous example. But suppose that you also want to identify the light color? The solution is to bind a variable to the color that is matched using the "&" and then print out the variable. This is where the "&" is useful, as shown below.

(defrule cautious (light ?color&yellow|blinking-yellow) => (printout t "Be cautious because light is " ?color crlf)) The variable ?color will be bound to whatever color is matched by the field yellow|blinking-yellow. The "&" also is useful with the "~". For example, suppose you want a rule that triggers when the light is not yellow and not red.

(defrule not-yellow-red (light ?color&~red&~yellow) => (printout t "Go, since light is " ?color crlf))

Basic arithmetic CLIPS provides basic arithmetic and math functions +, /, *, -, div, max, min, abs, float, and integer. For more details, see the CLIPS Reference Manual. In CLIPS, a numeric expression that customarily would be written as must be written in prefix form, (+ 2 3). In the prefix form of CLIPS, the function precedes the arguments, and parentheses must surround the numeric expression. The customary way of writing numeric expressions is called infix form because the math functions are fixed in between the arguments.

(defrule addition (numbers ?x ?y) => (assert (answer-plus (+ ?x ?y)))) ; Add ?x + ?y CLIPS> (assert (numbers 2 3)) (defrule addition (numbers ?x ?y ?z) => (assert (answer-plus (+ ?x ?y ?z)))) ; ?x + ?y + ?z

CLIPS> (+ 2 2) ;both integer arguments give integer 4 ;result CLIPS> ( ) ;both floating-point arguments give 4.0 ;floating-point result CLIPS> ( ) ; mixed arguments give float result 4.0

CLIPS> (float (+ 2 2)) ;convert integer to float 4.0 CLIPS> (integer ( )) ; convert float to integer 4 (defrule mixed-calc (numbers ?x ?y ?z) => (assert (answer (+ ?x (* ?y ?z))))) ; ?y * ?z + ?x

bound variable. CLIPS> (clear) CLIPS> (defrule addition (numbers ?x ?y) => (assert (answer (+ ?x ?y))) (bind ?answer (+ ?x ?y)) (printout t "answer is " ?answer crlf))

Start Reading Besides matching a pattern, a rule can get information in another way. CLIPS can read the information that you type from the keyboard using the read function. Note that no extra (crlf) is needed after the (read) to put the cursor on a new line. The (read) automatically resets the cursor to a new line.

CLIPS> (clear) CLIPS> (defrule read-input => (printout t "Name a primary color" crlf) (assert (color (read)))) CLIPS> (defrule check-input ?color <- (color ?color-read&red|yellow|blue) => (retract ?color) (printout t "Correct" crlf)) CLIPS> (reset)

The (read) function is not a general-purpose function that will read anything you type on the keyboard. One limitation is that (read) will read only one field. So if you try to read primary color is red only the first field, "primary", will be read. To (read) all the input, you must enclose the input within double quotes. Of course, once the input is within double quotes, it is a single literal field.

Summery of Today’s Lecture Multiple fields Functional ~ | & Read