Artificial Intelligence



Similar documents
The CLIPS environment. The CLIPS programming language. CLIPS production rules language - facts. Notes

Open-Source, Cross-Platform Java Tools Working Together on a Dialogue System

CLIPS User s Guide. by Joseph C. Giarratano, Ph.D. Version 6.30

Reference Manual Volume I Basic Programming Guide

Unix Scripts and Job Scheduling

VHDL Test Bench Tutorial

1 of 1 24/05/ :23 AM

Creating a Simple Macro

Introduction to Java Applications Pearson Education, Inc. All rights reserved.

No Solution Equations Let s look at the following equation: 2 +3=2 +7

GETTING FESTIVAL TO RUN ON WINDOWS XP WITH CYGWIN

Towards Rule-based System for the Assembly of 3D Bricks


Advanced x86: BIOS and System Management Mode Internals SPI Flash. Xeno Kovah && Corey Kallenberg LegbaCore, LLC

A Rules Engine Experiment: Lessons Learned on When and How to use a Rules-Based Solution

Implementing and Maintaining Microsoft SQL Server 2008 Integration Services

Integrating Secure FTP into Data Services

BUSINESS RULES CONCEPTS... 2 BUSINESS RULE ENGINE ARCHITECTURE By using the RETE Algorithm Benefits of RETE Algorithm...

Oracle Business Rules: Technical Overview. An Oracle White Paper February 2007

Lecture 9. Semantic Analysis Scoping and Symbol Table

Sofware Requirements Engineeing

Integrating VoltDB with Hadoop

Backing Up and Restoring Data

Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff

SAS 9.4 Intelligence Platform: Migration Guide, Second Edition

Lab 1: Introduction to C, ASCII ART and the Linux Command Line Environment

C++ INTERVIEW QUESTIONS

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science

CS10110 Introduction to personal computer equipment

Rational Rational ClearQuest

Using the JESS Expert system tool to implement an Online Intrusion Detection System based on Snort Rules

File by OCR Manual. Updated December 9, 2008

Regular Expressions. Abstract

UFTP AUTHENTICATION SERVICE

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

Chapter 7 Configuring Trunk Groups and Dynamic Link Aggregation

Simply Accounting Intelligence Tips and Tricks Booklet Vol. 1

Invitation to Ezhil : A Tamil Programming Language for Early Computer-Science Education 07/10/13

Introduction. Chapter 1

ACT-R: A cognitive architecture. Terese Liadal liadal@stud.ntnu.no Seminar AI Tools Universität des Saarlandes, Wintersemester 06/07

SAP HANA Client Installation and Update Guide

CALL MANAGER INSTALLATION

Installation Manual v2.0.0

LAB THREE STATIC ROUTING

My EA Builder 1.1 User Guide

Data Tool Platform SQL Development Tools

Data Integration through XML/XSLT. Presenter: Xin Gu

MATLAB Programming. Problem 1: Sequential

CLC Server Command Line Tools USER MANUAL

COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing

Oracle Database: SQL and PL/SQL Fundamentals NEW

Sterling Call Center. Upgrade Guide. Release 9.2

CatDV Pro Workgroup Serve r

A Knowledge-based System for Translating FOL Formulas into NL Sentences

Connecting to the Firewall Services Module and Managing the Configuration

Visual Logic Instructions and Assignments

Rule based programming with Drools

Moving from CS 61A Scheme to CS 61B Java

A basic create statement for a simple student table would look like the following.

Automated transformations from ECA rules to Jess

Using Casio Graphics Calculators

ECE 451 Verilog Exercises. Sept 14, James Barnes

1 Introduction. 2 An Interpreter. 2.1 Handling Source Code

OPERATING SYSTEM SERVICES

A methodology for graphical modeling of business rules

Access Queries (Office 2003)

Simple. Control Panel. for your Linux Server. Getting Started Guide. Simple Control Panel // Linux Server

Database Programming with PL/SQL: Learning Objectives

Unix Shell Scripts. Contents. 1 Introduction. Norman Matloff. July 30, Introduction 1. 2 Invoking Shell Scripts 2

Beginner s Matlab Tutorial

1) Explain the following evolutionary process models: a) The spiral model. b) The concurrent development model.

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.

ThinLinX TLXOS NUC / Compute Stick / RePC Installation Guide Creating the Installer (Step 1)

Command Scripts Running scripts: include and commands

bbc Developing Service Providers Adobe Flash Media Rights Management Server November 2008 Version 1.5

1001ICT Introduction To Programming Lecture Notes

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

Oracle Database: SQL and PL/SQL Fundamentals

Programming Languages CIS 443

[Refer Slide Time: 05:10]

Pwn Plug Community Edition 1.1 Installation Guide

Monitoring BPMN-Processes with Rules in a Distributed Environment

Successful Mailings in The Raiser s Edge

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

COMP 110 Prasun Dewan 1

ORACLE 9I / 10G / 11G / PL/SQL COURSE CONTENT

SPROG DCC Decoder Programmer

HP Service Manager. Software Version: 9.40 For the supported Windows and Linux operating systems. Request Management help topics for printing

An Approach to Eliminate Semantic Heterogenity Using Ontologies in Enterprise Data Integeration

Handle Tool. User Manual

What is a Loop? Pretest Loops in C++ Types of Loop Testing. Count-controlled loops. Loops can be...

Audit account logon events

WFU_DICOMtk v1.0. ANSIR Laboratory Wake Forest University School of Medicine

Lab 2: PostgreSQL Tutorial II: Command Line

Sophos Anti-Virus for Linux user manual

Transcription:

Artificial Intelligence Lab 1 Marco Piastra Lab 1-1

Jess? Acronym of Java Expert System Shell A small environment written in Java Author: Ernest Friedman-Hill, Sandia National Laboratories in Livermore, Canada Rule-based system: the main programming construct is the rule if <cond> then <action> It is derived from an older and much larger system: CLIPS Adopts the syntax of the LISP programming language A program in Jess is mostly made up of a set rules to be applied to a set of facts Lab 1-2

Java: using the CLASSPATH variable Lab 1-3 You do not know what this is? It s normal: you never used Java at all Impostazione della variabile CLASSPATH $ CLASSPATH=<value> $ is the system prompt (do not write it, the system does $ export CLASSPATH To make sure that the above worked $ echo $CLASSPATH In our case: $ CLASSPATH=/home/opt/Jess61p8 $ export CLASSPATH Make sure you respect small and capital letters! (It s Linux, not Windows Starting Jess $ java jess.main Jess> Quitting Jess Jess> (exit $ (Wow, you made it!

Lists (file finitestatemachine.jess The LISP syntax It could hardly be simpler: everything is either an symbol or a list. LISP: Lots of Impossible Stupid Parenthesis (deftemplate fsm (slot current-state (multislot input-stream (multislot output-stream Lists can be nested at will (make sure you balance parentheses (exit Every Jess command is a list. Every legitimate Jess expression is a list Lab 1-4

deftemplate (file finitestatemachine.jess It defines template for structured facts (=basic data items in Jess (deftemplate event (slot current-state (slot input-symbol (slot output-symbol (slot new-state It is the template of individual facts like this: (event (current-state even (input-symbol 1 (output-symbol 1 (new-state odd Every slot will have exactly one value Lab 1-5

(file finitestatemachine.jess ( state-transition?current <- (fsm (current-state?cs (input-stream?is $?rest (output-stream $?output (event (current-state?cs (input-symbol?is (output-symbol?os (new-state?ns " to state "?ns " output "?os crlf (modify?current (current-state?ns (input-stream?rest (output-stream?os?output The meaning: the whole Jess language could fit it in. Lab 1-6

(file finitestatemachine.jess The whole thing is a list ( state-transition?current <- (fsm (current-state?cs (input-stream?is $?rest (output-stream $?output (event (current-state?cs (input-symbol?is (output-symbol?os (new-state?ns " to state "?ns " output "?os crlf (modify?current (current-state?ns (input-stream?rest (output-stream?os?output Lab 1-7

(file finitestatemachine.jess Name of the rule, just an id ( state-transition?current <- (fsm (current-state?cs (input-stream?is $?rest (output-stream $?output (event (current-state?cs (input-symbol?is (output-symbol?os (new-state?ns " to state "?ns " output "?os crlf (modify?current (current-state?ns (input-stream?rest (output-stream?os?output Lab 1-8

(file finitestatemachine.jess ( state-transition?current <- (fsm (current-state?cs (input-stream?is $?rest (output-stream $?output (event (current-state?cs (input-symbol?is (output-symbol?os (new-state?ns Separator: just find this first " to state "?ns " output "?os crlf (modify?current (current-state?ns (input-stream?rest (output-stream?os?output Lab 1-9

(file finitestatemachine.jess ( state-transition?current <- (fsm (current-state?cs (input-stream?is $?rest (output-stream $?output (event (current-state?cs (input-symbol?is (output-symbol?os (new-state?ns " to state "?ns " output "?os crlf (modify?current (current-state?ns (input-stream?rest (output-stream?os?output (LHS - Left Hand Side: the logical conditions that determine the applicability of the rule Lab 1-10

(file finitestatemachine.jess ( state-transition?current <- (fsm (current-state?cs (input-stream?is $?rest (output-stream $?output (event (current-state?cs (input-symbol?is (output-symbol?os (new-state?ns " to state "?ns " output "?os crlf (modify?current (current-state?ns (input-stream?rest (output-stream?os?output Think about the LHS as the description of a pattern to be applied to facts Lab 1-11

(file finitestatemachine.jess ( state-transition?current <- (fsm (current-state?cs (input-stream?is $?rest (output-stream $?output (event (current-state?cs (input-symbol?is (output-symbol?os (new-state?ns " to state "?ns " output "?os crlf (modify?current (current-state?ns (input-stream?rest (output-stream?os?output (RHS - Right Hand Side: it describes the actions to be performed when the rule is FIREd Lab 1-12

(file finitestatemachine.jess ( state-transition?current <- (fsm (current-state?cs (input-stream?is $?rest (output-stream $?output (event (current-state?cs (input-symbol?is (output-symbol?os (new-state?ns " to state "?ns " output "?os crlf (modify?current (current-state?ns (input-stream?rest (output-stream?os?output Facts can be either asserted or retracted Messages can be printed Lab 1-13

(file finitestatemachine.jess ( state-transition?current <- (fsm (current-state?cs (input-stream?is $?rest (output-stream $?output (event (current-state?cs (input-symbol?is (output-symbol?os (new-state?ns " to state "?ns " output "?os crlf (modify?current (current-state?ns (input-stream?rest (output-stream?os?output This is a variable Lab 1-14

(file finitestatemachine.jess ( state-transition?current <- (fsm (current-state?cs (input-stream?is $?rest (output-stream $?output (event (current-state?cs (input-symbol?is (output-symbol?os (new-state?ns " to state "?ns " output "?os crlf (modify?current (current-state?ns (input-stream?rest (output-stream?os?output A Jess variable is always preceded by? Lab 1-15

(file finitestatemachine.jess ( state-transition?current <- (fsm (current-state?cs (input-stream?is $?rest (output-stream $?output (event (current-state?cs (input-symbol?is (output-symbol?os (new-state?ns " to state "?ns " output "?os crlf (modify?current (current-state?ns (input-stream?rest (output-stream?os?output If the overall pattern matches each variable will bind to a symbol CAUTION: matching the pattern in the LHS is an all or nothing matter Lab 1-16

(file finitestatemachine.jess ( state-transition A variable can also bind to a fact?current <- (fsm (current-state?cs (input-stream?is $?rest (output-stream $?output (event (current-state?cs (input-symbol?is (output-symbol?os (new-state?ns " to state "?ns " output "?os crlf (modify?current (current-state?ns (input-stream?rest (output-stream?os?output Lab 1-17

(file finitestatemachine.jess ( state-transition?current <- (fsm (current-state?cs (input-stream?is $?rest (output-stream $?output (event (current-state?cs (input-symbol?is (output-symbol?os (new-state?ns " to state "?ns " output "?os crlf (modify?current (current-state?ns (input-stream?rest (output-stream?os?output The $ operator makes the variable bind to a list of values Lab 1-18

(file finitestatemachine.jess ( state-transition?current <- (fsm (current-state?cs (input-stream?is $?rest (output-stream $?output (event (current-state?cs (input-symbol?is (output-symbol?os (new-state?ns " to state "?ns " output "?os crlf (modify?current (current-state?ns (input-stream?rest (output-stream?os?output Different occurrences of the same variable in the LHS: they all bind to the same value Lab 1-19

(file finitestatemachine.jess ( state-transition?current <- (fsm (current-state?cs (input-stream?is $?rest (output-stream $?output (event (current-state?cs (input-symbol?is (output-symbol?os (new-state?ns " to state "?ns " output "?os crlf (modify?current (current-state?ns (input-stream?rest (output-stream?os?output A logical clause, part of the LHS Lab 1-20

(file finitestatemachine.jess ( state-transition?current <- (fsm (current-state?cs (input-stream?is $?rest (output-stream $?output (event (current-state?cs (input-symbol?is (output-symbol?os (new-state?ns " to state "?ns " output "?os crlf (modify?current (current-state?ns (input-stream?rest (output-stream?os?output If the pattern matches, each clause binds to a fact, not necessarily distinct Lab 1-21

(file finitestatemachine.jess ( state-transition?current <- (fsm (current-state?cs (input-stream?is $?rest (output-stream $?output (event (current-state?cs (input-symbol?is (output-symbol?os (new-state?ns " to state "?ns " output "?os crlf (modify?current (current-state?ns (input-stream?rest (output-stream?os?output Another logical clause. There are two clauses in this LHS. Lab 1-22

(file finitestatemachine.jess ( state-transition?current <- (fsm (current-state?cs (input-stream?is $?rest (output-stream $?output (event (current-state?cs (input-symbol?is (output-symbol?os (new-state?ns " to state "?ns " output "?os crlf (modify?current (current-state?ns (input-stream?rest (output-stream?os?output Different occurrences of the same variable define a constraint across clauses, since they all bind to the same value Lab 1-23

(file finitestatemachine.jess ( state-transition?current <- (fsm (current-state?cs (input-stream?is $?rest (output-stream $?output (event (current-state?cs (input-symbol?is (output-symbol?os (new-state?ns " to state "?ns " output "?os crlf (modify?current (current-state?ns (input-stream?rest (output-stream?os?output Another constraint Lab 1-24

(file finitestatemachine.jess ( state-transition?current <- (fsm (current-state?cs (input-stream?is $?rest (output-stream $?output (event (current-state?cs (input-symbol?is (output-symbol?os (new-state?ns " to state "?ns " output "?os crlf (modify?current (current-state?ns (input-stream?rest (output-stream?os?output This variable binds to the fact that matches the clause Lab 1-25

(file finitestatemachine.jess ( state-transition?current <- (fsm (current-state?cs (input-stream?is $?rest (output-stream $?output (event (current-state?cs (input-symbol?is (output-symbol?os (new-state?ns " to state "?ns " output "?os crlf (modify?current (current-state?ns (input-stream?rest (output-stream?os?output The binding of variables propagates from the LHS to the RHS Lab 1-26

(file finitestatemachine.jess ( state-transition?current <- (fsm (current-state?cs (input-stream?is $?rest (output-stream $?output (event (current-state?cs (input-symbol?is (output-symbol?os (new-state?ns " to state "?ns " output "?os crlf (modify?current (current-state?ns (input-stream?rest (output-stream?os?output More examples Lab 1-27

deffacts (file paritychecker-fsa.jess It is used to define the initial facts, that are in memory at the beginning The (reset command erases the working memory and re-asserts all facts defined with deffacts (deffacts test-string (fsm (current-state even (input-stream 0 1 1 1 0 0 1 1 (output-stream Lab 1-28

deffacts (file paritychecker-fsa.jess It is used to define the initial facts, that are in memory at the beginning The (reset command erases the working memory and re-asserts all facts defined with deffacts (deffacts test-string (fsm (current-state even (input-stream 0 1 1 1 0 0 1 1 (output-stream In this particular case, just an individual fact is asserted Lab 1-29

deffacts (file paritychecker-fsa.jess It is used to define the initial facts, that are in memory at the beginning The (reset command erases the working memory and re-asserts all facts defined with deffacts (deffacts test-string (fsm (current-state even (input-stream 0 1 1 1 0 0 1 1 (output-stream In this particular case, just an individual fact is asserted In general, any number of facts can be asserted via a deffacts Lab 1-30

deffacts (file paritychecker-fsa.jess It is used to define the initial facts, that are in memory at the beginning The (reset command erases the working memory and re-asserts all facts defined with deffacts (deffacts test-string (fsm (current-state even (input-stream 0 1 1 1 0 0 1 1 (output-stream In this particular case, just an individual fact is asserted In general, any number of facts can be asserted via a deffacts There can be many deffacts in the same program Lab 1-31

deffacts (file paritychecker-fsa.jess It is used to define the initial facts, that are in memory at the beginning The (reset command erases the working memory and re-asserts all facts defined with deffacts (deffacts test-string (fsm (current-state even (input-stream 0 1 1 1 0 0 1 1 (output-stream In this particular case, just an individual fact is asserted In general, any number of facts can be asserted via a deffacts There can be many deffacts in the same program All of them will be executed by the command (reset Lab 1-32

How to load a program Start Jess first (it improves the effect $ java jess.main Jess> Loading a file (batch paritychecker-fsa.jess also (batch paritychecker-fsa.jess If it worked, Jess will say: TRUE Lab 1-33

How Jess works (in a first approximation Once activated, Jess repeats the same execution cycle MATCH Find all rule applications (i.e. combinations of a rule and facts matching its LHS Are there rule applications? yes no CONFLICT RESOLUTION Select one rule (always, one and only one FIRE Apply the selected rule by executing its RHS Lab 1-34

How to start Jess execution Reset: erases memory and re-asserts the initial facts It causes the execution of deffacts Make sure you always do a reset before a new run! (reset Jess answers: TRUE Run: starts the main execution cycle (run Jess answers: <here comes the program s output> TRUE Lab 1-35

A few debugging commands Execute one cycle at time (i.e. step mode (run 1 Also (run n to execute n cycles List all facts currently in memory (facts The answer is not very readable, it takes some effort to decode it List all rule applications (one rule + facts matching its LHS (agenda The answer is not very readable, it takes some effort to decode it Lab 1-36