Reference Manual
Total Page:16
File Type:pdf, Size:1020Kb
Reference Manual Volume I Basic Programming Guide Version 6.05 November 1st 1997 CLIPS Reference Manual CLIPS Basic Programming Guide Version 6.05 November 1st 1997 CONTENTS Preface..........................................................................................................................................xv Acknowledgements.....................................................................................................................xix Section 1 - Introduction ................................................................................................................1 Section 2 - CLIPS Overview.........................................................................................................3 2.1 Interacting with CLIPS .......................................................................................................3 2.1.1 Top Level Commands................................................................................................3 2.1.2 Automated Command Entry and Loading .................................................................4 2.1.3 Integration with Other Languages..............................................................................5 2.2 Reference Manual Syntax ...................................................................................................5 2.3 Basic Programming Elements.............................................................................................6 2.3.1 Data Types .................................................................................................................6 2.3.2 Functions....................................................................................................................9 2.3.3 Constructs.................................................................................................................10 2.4 Data Abstraction ...............................................................................................................10 2.4.1 Facts .........................................................................................................................10 2.4.1.1 Ordered Facts ..................................................................................................11 2.4.1.2 Non-ordered Facts...........................................................................................12 2.4.1.3 Initial Facts......................................................................................................13 2.4.2 Objects .....................................................................................................................13 2.4.2.1 Initial Objects..................................................................................................14 2.4.3 Global Variables ......................................................................................................14 2.5 Knowledge Representation ...............................................................................................15 2.5.1 Heuristic Knowledge – Rules ..................................................................................15 2.5.2 Procedural Knowledge.............................................................................................16 2.5.2.1 Deffunctions....................................................................................................16 2.5.2.2 Generic Functions ...........................................................................................16 2.5.2.3 Object Message-Passing .................................................................................16 2.5.2.4 Defmodules .....................................................................................................17 2.6 CLIPS Object-Oriented Language ....................................................................................17 2.6.1 COOL Deviations from a Pure OOP Paradigm .......................................................17 2.6.2 Primary OOP Features .............................................................................................18 2.6.3 Instance-set Queries and Distributed Actions..........................................................18 Section 3 - Deftemplate Construct.............................................................................................19 3.1 Slot Default Values ...........................................................................................................20 3.2 Slot Default Constraints for Pattern-Matching .................................................................20 CLIPS Basic Programming Guide i CLIPS Reference Manual 3.3 Slot Value Constraint Attributes .......................................................................................21 3.4 Implied Deftemplates........................................................................................................21 Section 4 - Deffacts Construct....................................................................................................23 Section 5 - Defrule Construct.....................................................................................................25 5.1 Defining Rules ..................................................................................................................25 5.2 Basic Cycle Of Rule Execution ........................................................................................26 5.3 Conflict Resolution Strategies ..........................................................................................27 5.3.1 Depth Strategy..........................................................................................................27 5.3.2 Breadth Strategy.......................................................................................................27 5.3.3 Simplicity Strategy...................................................................................................27 5.3.4 Complexity Strategy ................................................................................................28 5.3.5 LEX Strategy............................................................................................................28 5.3.6 MEA Strategy ..........................................................................................................29 5.3.7 Random Strategy......................................................................................................29 5.4 LHS Syntax .......................................................................................................................30 5.4.1 Pattern Conditional Element ....................................................................................30 5.4.1.1 Literal Constraints...........................................................................................31 5.4.1.2 Wildcards Single- and Multifield....................................................................33 5.4.1.3 Variables Single- and Multifield.....................................................................35 5.4.1.4 Connective Constraints ...................................................................................37 5.4.1.5 Predicate Constraints.......................................................................................40 5.4.1.6 Return Value Constraints ................................................................................42 5.4.1.7 Pattern-Matching with Object Patterns ...........................................................43 5.4.1.8 Pattern-Addresses............................................................................................45 5.4.2 Test Conditional Element.........................................................................................46 5.4.3 Or Conditional Element ...........................................................................................47 5.4.4 And Conditional Element.........................................................................................48 5.4.5 Not Conditional Element .........................................................................................49 5.4.6 Exists Conditional Element......................................................................................50 5.4.7 Forall Conditional Element......................................................................................52 5.4.8 Logical Conditional Element ...................................................................................54 5.4.9 Automatic Addition and Reordering of LHS CEs ...................................................57 5.4.9.1 Rules Without Any LHS Pattern CEs .............................................................57 5.4.9.2 Test and Not CEs as the First CE of an And CE.............................................58 5.4.9.3 Test CEs Following Not CEs ..........................................................................58 5.4.9.4 Or CEs Following Not CEs.............................................................................59 5.4.9.5 Notes About Pattern Addition and Reordering ...............................................59 5.4.10 Declaring Rule Properties ......................................................................................59 5.4.10.1 The Salience Rule Property...........................................................................60 5.4.10.2 The Auto-Focus Rule Property .....................................................................60 Section 6 - Defglobal Construct .................................................................................................63 ii Table of Contents