Knowledge Representation and Reasoning University "Politehnica" of Bucharest Department of Computer Science Fall 2009 Adina Magda Florea

Slides:



Advertisements
Similar presentations
CSC411Artificial Intelligence 1 Chapter 3 Structures and Strategies For Space State Search Contents Graph Theory Strategies for Space State Search Using.
Advertisements

© C. Kemke XPS Implementation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba.
B. Ross Cosc 4f79 1 Frames Knowledge bases can be enhanced by using principles from frame knowledge representation (similar to object orientation) This.
The CLIPS Programming Tool History of CLIPS –Influenced by OPS5 and ART –Implemented in C for efficiency and portability –Developed by NASA, distributed.
1 01/12/2011Knowledge-Based Systems, Paula Matuszek Intro to CLIPS Paula Matuszek CSC 9010, Spring, 2011.
Rule Based Systems Michael J. Watts
Chapter 12: Expert Systems Design Examples
Expert System Human expert level performance Limited application area Large component of task specific knowledge Knowledge based system Task specific knowledge.
Language Specfication and Implementation - PART II: Semantics of Procedural Programming Languages Lee McCluskey Department of Computing and Mathematical.
Introduction to Expert Systems
© 2002 Franz J. Kurfess Introduction 1 CPE/CSC 481: Knowledge-Based Systems Dr. Franz J. Kurfess Computer Science Department Cal Poly.
Expert Systems 3 1 Rewriting Rules, CLIPS Content of this lecture: 1.Interpretation of rules 2.Example: CLIPS Sorting 3.Non-determinism 4.Control regimes:
1 Soar Semantic Memory Yongjia Wang University of Michigan.
© C. Kemke1Reasoning - Introduction COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba.
© C. Kemke Control 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba.
Production Rules Rule-Based Systems. 2 Production Rules Specify what you should do or what you could conclude in different situations. Specify what you.
Chapter 9: Modular Design, Execution Control, and Rule Efficiency Expert Systems: Principles and Programming, Fourth Edition.
1 Lecture-2 CS-120 Fall 2000 Revision of Lecture-1 Introducing Computer Architecture The FOUR Main Elements Fetch-Execute Cycle A Look Under the Hood.
EXPERT SYSTEMS Part I.
Programming Fundamentals (750113) Ch1. Problem Solving
CS 561, Session 25 1 Introduction to CLIPS Overview of CLIPS Facts Rules Rule firing Control techniques Example.
CSC 8310 Programming Languages Meeting 2 September 2/3, 2014.
Knowledge Representation and Reasoning University "Politehnica" of Bucharest Department of Computer Science Fall 2010 Adina Magda Florea
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
Katanosh Morovat.   This concept is a formal approach for identifying the rules that encapsulate the structure, constraint, and control of the operation.
Chapter 9: Modular Design, Execution Control, and Rule Efficiency Expert Systems: Principles and Programming, Fourth Edition.
Review Topics Test 1. Background Topics Definitions of Artificial Intelligence & Turing Test Physical symbol system hypothesis vs connectionist approaches.
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
1 Programming a Knowledge Based Application. 2 Overview.
Chapter 7: Introduction to CLIPS Expert Systems: Principles and Programming, Fourth Edition.
1 Semantic Analysis Aaron Bloomfield CS 415 Fall 2005.
Winter 2007SEG2101 Chapter 71 Chapter 7 Introduction to Languages and Compiler.
Expert Systems An Introduction to Expert Systems and CLIPS by Charles Weddle.
Jess: A Rule-Based Programming Environment Reporter: Yu Lun Kuo Date: April 10, 2006 Expert System.
Computing & Information Sciences Kansas State University Lecture 13 of 42 CIS 530 / 730 Artificial Intelligence Lecture 13 of 42 William H. Hsu Department.
CPS 506 Comparative Programming Languages Syntax Specification.
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
Kansas State University Department of Computing and Information Sciences CIS 730: Introduction to Artificial Intelligence Lecture 17 Wednesday, 01 October.
Chapter 3 Part II Describing Syntax and Semantics.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
The AI War LISP and Prolog Basic Concepts of Logic Programming
Rule-based Systems: Mechanisms & Efficiency Artificial Intelligence CMSC January 10, 2002.
Intelligent Control Methods Lecture 7: Knowledge representation Slovak University of Technology Faculty of Material Science and Technology in Trnava.
Logical and Functional Programming
1 Knowledge Based Systems (CM0377) Lecture 10 (Last modified 19th March 2001)
1 Artificial Intelligence Adina Magda Florea. 2 Lecture No. 6 Prolog Language Rule-based Systems Knowledge representation using rules RBS structure Inference.
Computing & Information Sciences Kansas State University Lecture 12 of 42 CIS 530 / 730 Artificial Intelligence Lecture 12 of 42 William H. Hsu Department.
Mostly adopted from Jason Morris notes (Morris Technical Solutions)
Expert System Seyed Hashem Davarpanah University of Science and Culture.
Knowledge Representation and Reasoning University "Politehnica" of Bucharest Department of Computer Science Fall 2011 Adina Magda Florea
Knowledge Engineering. Sources of Knowledge - Books - Journals - Manuals - Reports - Films - Databases - Pictures - Audio and Video Tapes - Flow Diagram.
Definition and Technologies Knowledge Representation.
Artificial Intelligence: Applications
Summary for final exam Agent System..
Business Rules Engine in Java Introduction to JBoss Rules by Tom Sausner.
Knowledge Representation Techniques
Knowledge Representation and Reasoning
Intelligent Systems JESS constructs.
Knowledge Representation and Reasoning
Chapter 7: Introduction to CLIPS
Knowledge Representation
Knowledge Representation and Inference
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
بسم الله الرحمن الرحیم آموزش نرم افزار CLIPS
Artificial Intelligence
TA : Mubarakah Otbi, Duaa al Ofi , Huda al Hakami
Programming Fundamentals (750113) Ch1. Problem Solving
Expert System Implementation
Programming Fundamentals (750113) Ch1. Problem Solving
Presentation transcript:

Knowledge Representation and Reasoning University "Politehnica" of Bucharest Department of Computer Science Fall 2009 Adina Magda Florea curs.cs.pub.ro Master of Science in Artificial Intelligence,

2 Lecture 7 Rule Based Systems; RETE algorithm Lecture outline  Rule Based Systems - intro  Production rules  RETE algorithm

3 1. Rule Based Systems  Procedural knowledge encoded in a declarative format  Most popular for KBS if LHS then RHD  Many languages and systems  Can be traced to different (correlated) formalisms

4 1.1 Well known RBS Many RB languages and systems:  Soar  OPS, CLIPS, JESS  Web Rule Languages: RuleML, SWRL  Business frameworks, e.g. TIBCO Suite with TIBCO Business Events  Prolog, ECLiPSe (CPS based on logic programming)

5 1.2 Formalisms  Rewriting/Reduction Systems (RS)  (A,R), A - set of objects and a binary relation R:A x A, called reduction relation or rewrite relation.  String Rewriting System (SRS) or semi-Thue system (Σ,R), Σ - alphabet, R: Σ* x Σ* is a binary relation between strings in the alphabet Rewrite rules  s,  t  Σ* s  R t iff  x,  y,  u,  v  Σ* such that s = xuy, t = xvy and uRv  Are Turing complete (Chomsky unrestricted grammar, semi-Thue grammar)

6 Formalisms  Markov algorithm – SRS in which the set of rules is ordered  Formal grammar – SRS which separates the alphabet in terminals, nonterminals and fixes a starting symbol  Lambda calculus – RS with lambda conversion rules

7 Example  A = {a, b, c}  Rewrite rules (P1) $ -> a$a (P2) $ -> b$b (P3) $ -> c$c  Apply P1 to c and get aca  Then apply P2 and get bacab  Using a different order gives a different result  Apply P2 to c and get bcb  Apply P1 and get abcba String Rewriting SystemMarkov algorithm

8 Formalisms  Term Rewriting Systems (TRS) – RS with rewrite rules applied to terms (PL, FOPL) Rewrite rules  x,  y  L (terms) x  R y iff x is not a variable and every variable from y occurs in x A reduction/rewrite step for term r – if  =unif(r, x) then r  R y  A reduction/rewrite step for term r = t 1 r't 2 – if  = unif(r', x) then r  R t 1  y  t 2   Being linked to FOPL – adds semantics of FOPL

9 2 Production Rules Rules can be seen as:  TRS  a subset of the FOPL formal system (together with the associated formal semantics) if L1 and L2 and … then P1 and P2 and … where L1, L2, … P1, P2.. are literals in FOPL LHS, antecedent, conditions RHS, consequent, conclusions, actions

Syntax of rules  Very diverse  (most) Common  The vocabulary consists of a set N of names of objects in the domain a set P of property names that give attributes to objects a set V of values that the attributes can have.  OAV triples (object, attribute, value) triples  Predicates in literals refer to attributes

RBS WORKING MEMORY RULE BASE EXECUTION ENGINE INFERENCE ENGINE PATTERN MATCHER AGENDA

12 RBS  RBS Inference Cycle Match  Conflict Set (CS) Select Act (Execute)  RBS strategy Rule chaining direction: forward, backward Rule selection from CS  Computational effort Match – 80-90%

Rule example (deftemplatestudent (slot name) (slot sex) (slot placed_in (default nil)) (slot special_considerations (default no)) (deftemplate room (slot number) (slot capacity (type INTEGER)(default 4)) (slot sexes_are) (slot vacancies (type INTEGER)) (multislot occupants)) (deffacts start (student (name Mary) (sex F)) (student (name Peter) (sex M)) (special_consideration yes)) (room (number 221) (capacity 1) (vacancies 1)) (room (number 346) (capacity 2) (vacancies 1))) WMEs 41 (student name Mary sex F placed_in nil special_consideration no) 52 (student name Peter sex M placed_in nil special_consideration yes) 9 (room number 221 capacity 1 vacancies 1) 12 (room number 346 capacity 2 vacancies 1)

Rule example (defrule assign-student-empty-room ?unplaced_student  (student (name ?stud_name) (placed_in nil) (sex ?gender)) ?empty_room  (room (number ?room_no) (capacity ?room_cap) (vacancies ?free_places)) (test (= ?room_cap ?free_places)) => (modify ?unplaced_student (placed_in ?room_no)) (modify ?empty_room (occupants ?stud_name) (sexes_are ?gender) (vacancies (-- ?free_places))))  s  r  x  y  z  t name(s,x)  placed_in(s,nil)  sex(s,y)  number(r,z)  capacity(r,t)  vacancies(r,t)  placed_in(s,z)  ….

Match step  Disadvantage of RBS – large computational requirement to perform match of LHS – determine if all instantiations of rules are satisfied by the content of the WM (Working Memory)  O(comparison to check the satisfaction of a rule) = |WM| |CE| |WM| - no of WMEs (Working Memory Elements) |CE| - number of condition elements in a rule

16 Match step  What is the best way to determine the changes to the CS that result from changes to the WM?  2 ways of incorporating state information in the Match step to gain efficiency  (1) Memory support Provides knowledge about which WMEs partially satisfy each individual CE An indexing scheme indicates which subset of WM partially matches each CE  alpha memory  (2) Condition relationship Provides knowledge about the interaction of CE within a rule and the partial satisfaction of rules  beta memory

17 3. RETE Algorithm  The Rete algorithm was designed by Charles Forgy of Carnegie Mellon University - first in 1974, and later in his 1979 Ph.D. thesis and a 1982 paper  The Rete algorithm compiles the LHS of the production rules into a discrimination network  The network is in the form of an augmented dataflow network  Changes to WM are input to the network  The network reports changes to the CS - output of the network

(defrule cat-job-size (message (jobs ?x) (size ?y) (status new)) (job-def (size ?y) (size-def medium)) => (assert (job (job-name ?x) (job-size ?y)))) Distribute WM changes message (status new) job-def (size-def medium) Alpha memories Test for consistent sizes Beta memory Changes to conflict set ?y RETE match Network for the rule Memory support Condition relationship

(defrule show-actWM (a ?x)(a 1) (b ?x ?y)(b 1 2) (b 2 3) (b 2 4) (c ?y ?z)(c 3) (c 2) => … show-act select Resulting relations (alpha memories) Intermediate partial result (beta memories) Changes to conflict set Join x Initial state of RETE Network b ca a 1b 1 2c 3 b 2 3 b 2 4 c 2 a 1b 1 2 Join y a 1b 1 2c 2

select Resulting relations (alpha memories) Intermediate partial result (beta memories) Changes to conflict set Join x Activity of the RETE Match during an Addition b ca a 1b 1 2c 3 b 2 3 b 2 4 c 2 a 1b 1 2 Join y a 1b 1 2c 2 a b 2 3c 3 a 2b 2 3 a 2b (defrule show-act (a ?x) (b ?x ?y) (c ?y ?z) => …

select Resulting relations (alpha memories) Intermediate partial result (beta memories) Changes to conflict set Join x Activity of the RETE Match during a Deletion b ca a 1b 1 2c 3 b 2 3 b 2 4 c 2 a 1b 1 2 Join y a 1b 1 2c 2 a b 2 3c 3 a 2b 2 3 a 2b (defrule show-act (a ?x) (b ?x ?y) (c ?y ?z) => …

22 PROs and CONs  PROs Sufficient state is maintained so that the comparison of 2 WMEs on two different cycles is minimized Similar rules will compile to similar networks  CONs Every time a WME is removed, the same sequence that occurred during addition must be performed and the stored state unwound A beta-memory may contain the full Cartesian product of its two-input memories – size combinatorially explosive To maintain beta-memories, the join operation must be performed in a fixed order, determined statically at compile time

23 RETE II and III  1980s - Charles L. Forgy developed Rete II, not in public domain Rete II claims orders-of-magnitude better performance Rete II was created by Forgy at Production Systems Technologies Inc (PST)  Mid 2000s - Rete III, successor to Rete II Was developed and copyright by Charles L. Forgy at RulesPower Better performance than Rete III for problems that involve both complex rules and large collections of facts