JessTab Tutorial Henrik Eriksson. 2 JessTab Tutorial 20062 Outline 1.Introduction 2.Background 3.Installation 4.Interaction with JessTab 5.Introduction.

Slides:



Advertisements
Similar presentations
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Advertisements

 Copyright 2005 Digital Enterprise Research Institute. All rights reserved. The Web Services Modeling Toolkit Mick Kerrigan.
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
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.
Semantic Web Tools Vagan Terziyan Department of Mathematical Information Technology, University of Jyvaskyla ;
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Introducing Algorithms, Pseudocode and.
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.
JessTab Tutorial Henrik Eriksson. JessTab Tutorial Outline 1.Introduction 2.Background 3.Installation 4.Interaction with JessTab 5.Introduction.
Introduction to Jess.
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.
CS 561, Session 25 1 Introduction to CLIPS Overview of CLIPS Facts Rules Rule firing Control techniques Example.
The JessTab Approach to Protégé and Jess Integration
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
Lesson 4 Computer Software
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
Javascript and the Web Whys and Hows of Javascript.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
INTERNET APPLICATION DEVELOPMENT For More visit:
B. Ross Cosc 4f79 1 Commercial tools Size of system: –small systems 400 rules single user, PC based –larger systems narrow, problem-type specific or hybrid.
Introduction to Python Basics of the Language. Install Python Find the most recent distribution for your computer at:
– Introduction to the Shell 10/1/2015 Introduction to the Shell – Session Introduction to the Shell – Session 2 · Permissions · Users.
Chapter 7: Introduction to CLIPS Expert Systems: Principles and Programming, Fourth Edition.
Python 0 Some material adapted from Upenn cmpe391 slides and other sources.
Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition.
Taxonomic RuleML Tab Onut Iosif-Viorel Sandeep Singh.
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 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Wage Calculator Application: Introducing.
Expert System Development Tools Sean Lydon Daniel Nelson Emily Schwarz.
POS 406 Java Technology And Beginning Java Code
Expert Systems An Introduction to Expert Systems and CLIPS by Charles Weddle.
Practice and Evaluation. Practice Develop a java class called: SumCalculator.java which computes a sum of all integer from 1 to 100 and displays the result.
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
Jess: A Rule-Based Programming Environment Reporter: Yu Lun Kuo Date: April 10, 2006 Expert System.
Chapter 7: Introduction to CLIPS Presented By: Farnaz Ronaghi.
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>
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Artificial Intelligence Lecture No. 26 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
EEL 5937 Ontologies EEL 5937 Multi Agent Systems Lecture 5, Jan 23 th, 2003 Lotzi Bölöni.
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)
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
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.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
Intelligent systems Lecture 11 Tools for development of Expert Systems.
1 1 1 Introduction to Java. 2 History of Java Java – Originally for intelligent consumer-electronic devices – Then used for creating Web pages with dynamic.
The CLIPS Expert System Shell Dr Nicholas Gibbins
Summary for final exam Agent System..
Introduction to CLIPS 2 Session 13 Course: T0273 – EXPERT SYSTEMS Year: 2014.
Business rules.
Intelligent Systems Development
Intelligent Systems JESS constructs.
Chapter 7: Introduction to CLIPS
Chapter 8: Advanced Pattern Matching
بسم الله الرحمن الرحیم آموزش نرم افزار CLIPS
JessTab Tutorial Henrik Eriksson.
Chapter 11: Classes, Instances, and Message-Handlers
Jess Knowledge, Influence, Behavior
Presentation transcript:

JessTab Tutorial Henrik Eriksson

2 JessTab Tutorial Outline 1.Introduction 2.Background 3.Installation 4.Interaction with JessTab 5.Introduction to Jess programming  Jess functions  Rule-based reasoning with Jess 6.Managing Protégé ontologies with Jess 7.Mapping Protégé ontologies to Jess 8.Metalevel mappings 9.JessTab and Protégé OWL 10.Example 11.Conclusion Slides available at

3 JessTab Tutorial Background Ontologies are nice to look at, but… …they do not do anything.

4 JessTab Tutorial Background (cont.) Protégé-related problems  Difficult to directly integrate problem solving and ontology development in Protégé  Languages/shells need direct access to Protégé  Difficult manage large/complex ontologies ðOntology editors should be programmable Protégé allows alternative problem-solving engines through the plug-in API  The Java API allows access to the internal ontology representation

5 JessTab Tutorial Why Jess and JessTab? Jess  Popular language/shell  Active user community  Implemented in Java JessTab  A Protégé plug-in for running Jess under Protégé  Combines the strengths of Protégé and Jess

6 JessTab Tutorial Practical uses of JessTab Macro language  Creating lots of classes quickly  Making large changes to ontologies Rule engine  Information retrieval  Classification  Decision support  Planning

7 JessTab Tutorial Examples of applications Ontology engineering and reengineering  Jess as macro/scripting for ontologies Importing ontologies  Jess as input filter Semantic Web Problem-solving methods Agent frameworks  JadeJessProtege Classic expert-system development

8 JessTab Tutorial What is Jess? Java Expert System Shell; based on CLIPS Forward chaining; production rules Fact-base and pattern matching Lisp-like syntax No support for object orientation  The Cool subsystem of CLIPS not implemented Developed by Sandia Laboratories 

9 JessTab Tutorial Historical background CLIPS Jess Current Protégé ArtOPS5 Protégé-II Cool Protégé-I Java KIF/OKBC/Clos Descendants Influences Protégé/Win JessTab

10 JessTab Tutorial Tool integration – Two possibilities Loose integration  No changes to each representation model  Translators between formats  Independent software Tight integration  Changes to representation models when needed  Integrated software (e.g., same Java VM)  Unified user interface JessTab supports tight integration

11 JessTab Tutorial Approach – JessTab plug-in for Protégé Jess console window in Protégé Mapping instances to Jess facts Functions for knowledge-base operations Mirroring Jess definitions in Protégé knowledge bases Support for metalevel objects Support for methods and message handlers

12 JessTab Tutorial Installation JessTab is bundled with the Protégé distribution Latest JessTab version available from SourceForge It is necessary to download and install Jess separately  Because of licensing

13 JessTab Tutorial Enabling JessTab Enable the tab

14 JessTab Tutorial JessTab with no Jess engine

15 JessTab Tutorial Jess installation Visit Choose license type  Trial – expires after 30 days  Licensed – commercial or academic (includes source) Choose version  Stable (e.g., 6.1p8)  Development (e.g., 7.0b7) Tip: Development versions of Jess are usually stable

16 JessTab Tutorial Jess installation (cont.) The distribution contains the file jess.jar Put the file jess.jar in the Protege/plugins/JessTab directory in the Protégé installation JessTab.jar jess.jar plugin.properties Tip: The file names sometimes contain version number. Protégé will usually find them anyway

17 JessTab Tutorial Installation troubleshooting tips Make sure everything is in the correct directory  The files jess.jar, JessTab.jar, and plugin.properties should be in the plugins/JessTab directory Two or more versions of the same.jar file on the CLASSPATH means trouble. Double check this. Check Jess version number in startup message Check the plugin.properties file Try running Jess without Protégé/JessTab If all else fails, try a clean installation of Protégé

18 JessTab Tutorial Interaction with JessTab Ready to go  Jess installation completed  JessTab enabled Interaction based on read-evaluate-print loop  Just like Lisp

19 JessTab Tutorial Jess console window in Protégé

20 JessTab Tutorial Console window (upper part) JessTab selected Jess prompt Jess startup message subtabs Jess version Console selectedDefault engine

21 JessTab Tutorial Console window (lower part) Enter Jess expressions here Break execution Clear console window Command history Tip: It is possible to copy & paste commands with ctrl-C and ctrl-V Evaluate expression

22 JessTab Tutorial Console Window (subtabs) Console Facts Rules Functions Message handlers Methods Defglobals Deftamplates Deffacts Settings Lists of Jess constructs Various settings The Jess console

23 JessTab Tutorial Introduction to Jess programming The CLIPS heritage Jess basics Running Jess Jess facts Jess constructs

24 JessTab Tutorial CLIPS Forward-chaining system Object-oriented part (COOL) Lisp-like syntax Based on Art Developed by NASA Implemented in C  available on several platforms (e.g., Unix, PC, and Macintosh)  source code available Homepage:  documentation, discussion forum, download area

25 JessTab Tutorial Jess Based on CLIPS  Rules from CLIPS but no object-oriented part Developed by Dr. Ernest Friedman-Hill at Sandia National Laboratories Implemented in Java  source code license available Homepage:  documentation, download area

26 JessTab Tutorial Running Jess > jess  Jess, the Rule Engine for the Java Platform Copyright (C) 2004 Sandia Corporation Jess Version 7.0a5 2/2/2005 Jess> exit  exit Jess> (+ 3 4)  7 Jess> (exit)  > Exits Protégé if running in JessTab

27 JessTab Tutorial The Deftemplate Construct Declaration of valid slots for a given relation name The general format of deftemplate is (deftemplate [ ] *) where is defined as (slot ) | (multislot )

28 JessTab Tutorial Sample Deftemplate Information about a person (deftemplate person ”A sample deftemplate” (slot name) (slot age) (slot eye-color) (slot hair-color))

29 JessTab Tutorial Jess Facts Jess manages a list of known facts Sample Jess fact: (person(hair-color black) (name ”John Smith”) (eye-color blue) (age 23))

30 JessTab Tutorial Multifield slots Normal, single-field slots can hold only one value Multifield slots can hold several values The values are ordered in a list

31 JessTab Tutorial Sample Fact Revisited (person(name John Smith) (age 23) (eye-color blue) (hair-color brown)) Illegal if name is a single-field slot, but legal is name is a multifield slot

32 JessTab Tutorial Ordered Facts Implied deftemplate: Single implied multifield slot List of elements Order of elements important; slot names not required Example: list of numbers (number-list )

33 JessTab Tutorial Adding and Removing Facts All facts known to Jess are stored in the fact list Add new facts with the assert command: (assert +) More than one fact can be added with assert

34 JessTab Tutorial Adding Facts: Example Jess> (deftemplate person (slot name) (slot age) (slot eye-color) (slot hair-color))  Jess> (assert(person (name ”John Q. Public”) (age 23) (eye-color blue) (hair-color black)))  Jess>

35 JessTab Tutorial Displaying Facts The facts command: (facts) Example: Jess> (facts)  f-0 (MAIN::person (name ”John Smith”) (age 23) (eye-color blue) (hair-color black)) For a total of 1 fact. Jess>

36 JessTab Tutorial Adding another Fact Jess> (assert(person (name ”Jane Smith”) (age 36) (eye-color green) (hair-color red)))  Jess> (facts)  f-0(person (name ”John Smith”) (age 23) (eye-color blue) (hair-color black)) f-1(person (name ”Jane Smith”) (age 36) (eye-color green) (hair-color red)) For a total of 2 facts. Jess> Normally, Jess does not accept duplicate fact entries

37 JessTab Tutorial Jess Rules Step 1 — Define the relevant deftemplates: (deftemplate emergency (slot type)) (deftemplate response (slot action)) IF the emergency is a fire THEN the response is to activate the sprinkler system Sample rule:

38 JessTab Tutorial Jess Rules (cont.) Step 2 — Define the rule (defrule fire-emergency ”A sample rule” (emergency (type fire)) => (assert (response (action activate-sprinkler-system)))) actions patterns rule header

39 JessTab Tutorial The Run Command Run the forward-chaining system Jess> (run)  Jess> (facts)  f-0(emergency (type fire)) f-1(response (action activate-sprinkler-system)) For a total of 2 facts in module MAIN. Jess>

40 JessTab Tutorial Printing the Result (defrule fire-emergency (emergency (type fire)) => (printout t ”Activate the sprinkler system” crlf)) output stream (t = stdout)

41 JessTab Tutorial Multiple Rules (defrule fire-emergency (emergency (type fire)) => (printout t ”Activate the sprinkler system” crlf)) (defrule flood-emergency (emergency (type flood)) => (printout t ”Shut down electrical equipment” crlf))

42 JessTab Tutorial Single-Field Patterns (deftemplate person (multislot name) (slot social-security-number)) (deffacts some-people (person(name John Smith) (social-security-number )) (person(name Jack Smith) (social-security-number ))) (defrule print-social-security-numbers (print-ss-numbers-for ?last-name) (person(name ?first-name ?middle-name ?last-name) (social-security-number ?ss-number)) => (printout t ?ss-number crlf))

43 JessTab Tutorial Conditional Patterns (defrule black-or-brown-hair (person (name ?name) (hair brown | black)) => (printout t ?name ” has dark hair” crlf)) (defrule black-or-brown-hair (person (name ?name) (hair ?color&brown | black)) => (printout t ?name ” has ” ?color ” hair” crlf))

44 JessTab Tutorial Conditional Patterns (cont.) (defrule not-black-or-brown-hair (person (name ?name) (hair ?color&~brown&~black)) => (printout t ?name ” has ” ?color ” hair” crlf))

45 JessTab Tutorial Conditional Patterns (cont.) (defrule no-identical-birthdays (not (and (person (name ?name) (birthday ?date)) (person (name ~?name) (birthday ?date)))) => (printout t ”No two people have the same birthday” crlf)

46 JessTab Tutorial Loading Jess Constructs from a File Create the Jess source file with a text editor Use the batch command: (batch ) Example: Jess> (batch ”fire.clp”)  Defining deftemplate emergency Defining deftemplate response Defining defrule: fire-emergency +j

47 JessTab Tutorial Managing Protégé ontologies with Jess The Protégé GUI is nice but sometimes scripting or programmatically modifying an ontology is better JessTab adds several functions and constructs for managing ontologies Naturally, these functions and constructs are available from the Jess command prompt and from Jess programs

48 JessTab Tutorial Defining classes and instantiating them Jess> (defclass Person (is-a :THING) (slot name (type string)) (slot age (type integer)))  TRUE Jess> (make-instance john of Person (name "John") (age 20))  Jess>

49 JessTab Tutorial Modifying slots Jess> (slot-set john age 21)  Jess> Jess> (slot-get john age)  21 Jess>

50 JessTab Tutorial Creating a second instance Jess> (make-instance sue of Person (name "Sue") (age 22))  Jess> Jess> (slot-get sue age)  22 Jess>

51 JessTab Tutorial Functions for knowledge-base operations mapclass mapinstance unmapinstance defclass make-instance initialize-instance modify-instance duplicate-instance definstances unmake-instance slot-get slot-set slot-replace$ slot-insert$ slot-delete$ slot-facets slot-types slot-cardinality slot-range slot-allowed-values slot-allowed-classes slot-allowed-parents slot-documentation slot-sources facet-get facet-set class class-existp class-abstractp class-reactivep superclassp subclassp class-superclasses class-subclasses get-defclass-list class-slots instancep instance-existp instance-name instance-address instance-addressp instance-namep slot-existp slot-default-value set-kb-save get-kb-save load-kb-definitions load-project include-project save-project jesstab-version-number jesstab-version-string get-knowledge-base get-tabs

52 JessTab Tutorial Mapping Protégé ontologies to Jess Transferring the Protégé representation to the Jess representation Protégé ontology Jess facts f-0 f-1 f-2 f-3

53 JessTab Tutorial Mapping classes Jess> (defclass Person (is-a :THING) (slot name (type string)) (slot age (type integer)))  TRUE Jess> (make-instance john of Person (name "John") (age 20))  Jess> (mapclass Person)  Person Jess> (facts)  f-0 (object (is-a Person) (is-a-name "Person") (OBJECT ) (age 20) (name "John")) For a total of 1 facts.

54 JessTab Tutorial The “object” fact Pattern for facts corresponding to Protégé instances (object (is-a Person) (is-a-name "Person") (OBJECT ) (age 20) (name "John")) Fact nameClass name Class name as string Slot values Reference to Protégé instance

55 JessTab Tutorial Modifying slots Jess> (slot-set john age 21)  Jess> (facts)  f-1 (object (is-a Person) (is-a-name "Person") (OBJECT ) (age 21) (name "John")) For a total of 1 facts.

56 JessTab Tutorial Adding a Jess rule Jess> (defrule twenty_one (object (is-a Person) (name ?n) (age ?a&:(>= ?a 21))) => (printout t "The person " ?n " is 21 or older" crlf))  TRUE Jess> (run)  The person John is 21 or older The person Sue is 21 or older 2 Jess>

57 JessTab Tutorial More rule examples (defrule twenty_two (object (name ?n) (age 22)) => (printout t "The object " ?n " is 22" crlf)) (defrule print_age (object (is-a Person) (name ?n) (age ?a)) => (printout t "The person " ?n " is " ?a crlf))

58 JessTab Tutorial Accessing instances from rules (defrule print_age_2 (object (is-a Person) (OBJECT ?obj) (name ?n)) => (printout t "The person " ?n " is " (slot-get ?obj age) crlf)) (defrule print_age_3 ?f <- (object (is-a Person) (name ?n)) => (printout t "The person " ?n " is " (slot-get ?f age) crlf))

59 JessTab Tutorial Modifying slot values from rules (defrule upgrade_my_age ?f <- (object (is-a Person) (name ”Joe Hacker”) (age 20)) => (slot-set ?f age 21))

60 JessTab Tutorial FIM