DEC OPS5 Guide to DEC OPS5

*HyperReader

  CONTENTS

  Title Page

  Copyright Page

  Preface

  Part I   Writing DEC OPS5 Programs

  1      Introduction to DEC OPS5

  1.1     Working Memory

  1.2     Rules
    1.2.1      The Left-Hand Side
    1.2.2      The Right-Hand Side

  1.3     Recognize-Act Cycle

  1.4     Conflict Resolution

  1.5     Other Program Components
    1.5.1      Declarations
    1.5.2      STARTUP Statement
    1.5.3      Comments
    1.5.4      Compiler Directives

  2      Knowledge Representation and Working Memory

  2.1     Object Class Hierarchy

  2.2     Working Memory Objects
    2.2.1      Object Identifiers
    2.2.2      Time-Tags
    2.2.3      Class Name

  2.3     Attributes
    2.3.1      Scalar Attributes
    2.3.2      Compound Attributes
    2.3.3      Default Value Declarations
    2.3.4      Fill Value Declarations

  2.4     Value Expressions
    2.4.1      Atoms
      2.4.1.1      Symbolic and Quoted Atoms
      2.4.1.2      Integer Atoms
      2.4.1.3      Floating-Point Atoms
      2.4.1.4      Instance Identifier Atoms
    2.4.2      Variables
    2.4.3      Numeric Expressions
    2.4.4      Function Calls

  3      Rules' Left-Hand Sides: Condition Elements

  3.1     Matching the Object Class

  3.2     Writing Attribute-Value Tests
    3.2.1      Attribute Names
      3.2.1.1      Matching the Exact Class
      3.2.1.2      Matching the Instance Identifier
    3.2.2      Predicates
    3.2.3      Specifying Values
      3.2.3.1      Constants
      3.2.3.2      Variables
      3.2.3.3      Function Calls
      3.2.3.4      The Quote Operator
    3.2.4      Accessing Compound Attributes
      3.2.4.1      A Single Element
      3.2.4.2      The Last Element
      3.2.4.3      The Entire Compound
      3.2.4.4      Predicates for Compound Attributes
      3.2.4.5      Searching for a Value
      3.2.4.6      Counting the Number of Elements
      3.2.4.7      Testing for Emptiness
      3.2.4.8      Functions for Compound Values

  3.3     Conjunctions of Tests

  3.4     Disjunctions of Values

  3.5     Negative Condition Elements

  3.6     Disjunctions of Condition Elements

  3.7     Test Specificity

  4      Rules' Right-Hand Sides: Actions

  4.1     The Format of RHS Actions

  4.2     Initializing a Program

  4.3     Changing Working Memory
    4.3.1      Creating Working-Memory Objects
      4.3.1.1      Using the MAKE Action
      4.3.1.2      Using the COPY Action
    4.3.2      Changing the Values in Working-Memory Objects
      4.3.2.1      Modifying Compound Attributes
      4.3.2.2      Applying Functions to Compound Values
      4.3.2.3      Using Common Idioms for Compound Values
    4.3.3      Deleting Objects from Working Memory

  4.4     Binding Variables

  4.5     Performing Input and Output Operations
    4.5.1      Opening Files
    4.5.2      Setting the Default Input Source and Output Destination
    4.5.3      Closing Files
    4.5.4      Reading Input
      4.5.4.1      Reading Scalar Atoms
      4.5.4.2      Reading Compound Values
    4.5.5      Writing Output
      4.5.5.1      Producing Output on a New Line
      4.5.5.2      Specifying the Column in Which to Start Writing Output
      4.5.5.3      Producing Right-Justified Output

  4.6     Using a Catcher

  4.7     Iterating Through a Compound Value

  4.8     Adding Rules to an Executing Program

  4.9     Saving and Restoring the State of Working Memory and the Conflict Set

  4.10    Stopping Program Execution

  5      Using DEC OPS5 with Other Languages

  5.1     Calling External Routines from DEC OPS5
    5.1.1      Passing Parameters
      5.1.1.1      External Data Types
      5.1.1.2      Passing Mechanisms
      5.1.1.3      Type Changes to Arguments
      5.1.1.4      Visibility of Changes to Arguments
    5.1.2      Returning a Value to DEC OPS5

  5.2     Writing Portable Code

  5.3     Calling DEC OPS5 from Another Language

  5.4     Using DEC OPS5 Run-Time Library Routines
    5.4.1      Choosing Bindings
      5.4.1.1      Using the VAX Bindings
      5.4.1.2      Using the C Bindings
      5.4.1.3      Using the f77 Bindings
      5.4.1.4      Using Multiple Bindings on VMS Systems
    5.4.2      Declaring RTL Routines
    5.4.3      Strings, Read Forms, and Print Forms

  5.5     Handling an Interrupt

  5.6     Summary of Restrictions

  6      Persistent Data Storage

  6.1     SQL Expression Syntax
    6.1.1      Using Vertical Bars ( | )
    6.1.2      Using Variables
    6.1.3      Using Single Quotes ( ' )
    6.1.4      Examples of SQL Expressions

  6.2     Mapping Data to Working Memory Objects
    6.2.1      One-to-One Mappings
    6.2.2      Flexible Mappings

  6.3     Linking with the SQL Libraries

  6.4     Attaching to a Database

  6.5     Starting an SQL Transaction

  6.6     Reading from a Database
    6.6.1      Using the Simple Fetch Action
    6.6.2      Using the Flexible Fetch Action
    6.6.3      Using Views to Fetch Data

  6.7     Using Database Key Values

  6.8     Writing to a Database
    6.8.1      Updating Existing Records
    6.8.2      Inserting New Records

  6.9     Error Handling

  6.10    Ending an SQL Transaction

  6.11    Detaching from a Database

  Part II   Running DEC OPS5 Programs

  7      Compiling and Linking DEC OPS5 Programs on VMS Systems

  7.1     Using the OPS5 Command

  7.2     Controlling the Compiler
    7.2.1      Creating an Index File for Modular Compilation (/CREATE)
    7.2.2      Producing a Program Entry Point (/ENTRY)
    7.2.3      Generating and Naming an Executable Image (/EXECUTABLE)
    7.2.4      Defining an Index File (/INDEX_FILE)
    7.2.5      Producing a Listing File (/LIST)
    7.2.6      Including Machine Code in the Listing File (/MACHINE_CODE)
    7.2.7      Naming an Object File (/OBJECT)
    7.2.8      Customizing Obsolescent Messages (/OBSOLESCENT )
    7.2.9      Controlling Listing File Options (/SHOW)

  7.3     Dividing a Program into Modules

  7.4     Using the %INCLUDE Compiler Directive

  7.5     Linking DEC OPS5 Programs
    7.5.1      Linking with the DEC OPS5 Run-Time System
    7.5.2      Linking External Routines

  8      Compiling and Linking DEC OPS5 Programs on ULTRIX and DEC OSF/1 Systems

  8.1     Using the OPS5 Command

  8.2     Controlling the Compiler
    8.2.1      Producing an Object File (-c)
    8.2.2      Using an Index File for Modular Compilation (-i, -ic, and -if)
    8.2.3      Suppressing an Entry Point Address (-noentry)
    8.2.4      Naming an Output File (-o)
    8.2.5      Customizing Obsolescent Messages (-obc and -obl)
    8.2.6      Creating a Listing File (-S)
    8.2.7      Verifying DEC OPS5 Operations (-v)
    8.2.8      Printing the Version Number

  8.3     Dividing a Program into Modules

  8.4     Using the %INCLUDE Compiler Directive

  8.5     Compiling and Linking External Routines

  9      Executing DEC OPS5 Programs

  9.1     Running Recognize-Act Cycles

  9.2     Using the DEC OPS5 Command Interpreter
    9.2.1      Entering DEC OPS5 Commands
    9.2.2      Exiting the Command Interpreter
    9.2.3      Suppressing the Command Interpreter
    9.2.4      Setting Up Initial Conditions
      9.2.4.1      Disabling and Enabling Run-Time Messages
      9.2.4.2      Choosing a Conflict-Resolution Strategy
      9.2.4.3      Initializing Working Memory
    9.2.5      Using DEC OPS5 Command Files
    9.2.6      Controlling Input and Output
      9.2.6.1      Opening Files
      9.2.6.2      Setting the Default Input Source and Output Destination
      9.2.6.3      Closing Files

  9.3     Interrupting Recognize-Act Cycles
    9.3.1      Pausing the Program
    9.3.2      Using Breakpoints
    9.3.3      Executing HALT Actions

  9.4     Restarting Programs

  9.5     Adding Statements, Rules, and Catchers to Executable Images

  10     Debugging DEC OPS5 Programs

  10.1    Using DEC OPS5 Debugging Commands
    10.1.1     Using Breakpoints
      10.1.1.1     Setting and Deleting Breakpoints
      10.1.1.2     Listing Breakpoints
    10.1.2     Displaying the Inheritance Hierarchy
    10.1.3     Displaying Working-Memory Objects
      10.1.3.1     Displaying the Contents of Working Memory
      10.1.3.2     Displaying Specific Working-Memory Objects
      10.1.3.3     Displaying the History of Specific Working-Memory Objects
      10.1.3.4     Displaying the Working-Memory Objects of an Object Class
      10.1.3.5     Displaying Working-Memory Objects that Match a Pattern
    10.1.4     Modifying Working Memory
      10.1.4.1     Creating Working-Memory Objects
      10.1.4.2     Copying Working-Memory Objects
      10.1.4.3     Deleting Objects from Working Memory
      10.1.4.4     Changing the Values in Working-Memory Objects
    10.1.5     Displaying Conflict Set Information
      10.1.5.1     Displaying the Contents of the Conflict Set
      10.1.5.2     Displaying the Instantiation of the Next Rule To Be Executed
      10.1.5.3     Displaying Instantiations of Rules that Contain Disjunctions of Condition Elements
    10.1.6     Saving and Restoring the State of Working Memory and the Conflict Set
      10.1.6.1     SAVESTATE Command
      10.1.6.2     RESTORESTATE Command
      10.1.6.3     ADDSTATE Command
    10.1.7     Displaying Trace Information
      10.1.7.1     Setting the Trace Level
      10.1.7.2     Displaying the Current Trace Level
      10.1.7.3     Trace Level 1-RULE
      10.1.7.4     Trace Level 2-RULE and WM
      10.1.7.5     Trace Level 3-RULE, WM and CS
      10.1.7.6     Trace Level 4-RULE, WM, CS and PM
    10.1.8     Displaying Match Information
      10.1.8.1     Match Information for Negated CEs
      10.1.8.2     Match Information for Interelement Variables
      10.1.8.3     Match Information for CE Disjunctions
    10.1.9     Backing Up over Recognize-Act Cycles
    10.1.10    Disabling Rules
    10.1.11    Using the Performance Measurement and Evaluation Package

  10.2    VMS Debugger

  10.3    ULTRIX Debugger

  11     Using the DEC OPS5 Development Environment

  11.1    Starting the Development Environment

  11.2    Exporting Files from the Development Environment

  Part III   DEC OPS5 Reference Dictionary

  +

  -

  *

  /

  \

  ^

  =

  <>

  >

  >=

  <

  <=

  <=>

  <->

  [+]

  [-]

  [=]

  [<>]

  [>]

  [>=]

  [<]

  [<=]

  { }

  << >>

  //

  \\

  @

  ACCEPT-ATOM

  ACCEPTLINE-COMPOUND

  ADDSTATE

  AFTER

  BACK

  BIND

  BUILD

  CATCH

  CLOSEFILE

  COMPOUND

  CONCAT

  COPY

  CRLF

  CS

  DEFAULT

  DISABLE

  ENABLE

  EXCISE

  EXIT

  EXTERNAL-ROUTINE

  FLOAT

  FOR-EACH

  GENATOM

  HALT

  %INCLUDE

  INTEGER

  LENGTH

  MAKE

  MATCHES

  MODIFY

  NEXT

  NTH

  OBJECT-CLASS

  OPENFILE

  PBREAK

  POSITION

  PPCLASS

  PPWM

  PRODUCTION

  REMOVE

  REPORT

  RESTART

  RESTORESTATE

  RJUST

  RULE

  RUN

  SAVESTATE

  SHOW BACK

  SHOW SPACE

  SQL-ATTACH

  SQL-COMMIT

  SQL-DELETE

  SQL-DETACH

  SQL-FETCH-EACH

  SQL-FETCH-AS-OBJECT

  SQL-INSERT

  SQL-INSERT-FROM-OBJECT

  SQL-ROLLBACK

  SQL-START

  SQL-UPDATE

  SQL-UPDATE-FROM-OBJECT

  STARTUP

  STRATEGY

  SUBCOMPOUND

  SYMBOL

  TABTO

  WATCH

  WBREAK

  WM

  WMHISTORY

  WRITE

  A   Diagnostic Messages

  A.1     Message Format

  A.2     Location of Message Explanations and Recommended Responses

  A.3     Online Help System
    A.3.1      Starting the Help System on VMS Systems
    A.3.2      Starting the Help System on ULTRIX and DEC OSF/1 Systems

  B   BNF Syntax Summary

  C   The DEC OPS5 Run-Time Library

  ops_atom_is_fatom

  ops_atom_is_iatom

  ops_atom_is_symbol

  ops_atom_is_instance_id

  ops_atom_to_string

  ops_attr_is_compound

  ops_clear

  ops_completion

  ops_copy_instance

  ops_debug

  ops_end_id_translation

  ops_fatom_to_float

  ops_float_to_fatom

  ops_gensym

  ops_get_attr_atom

  ops_get_class_string

  ops_get_comp_attr_length

  ops_get_comp_attr_string

  ops_get_comp_elem_atom

  ops_get_firing_rule

  ops_get_instance

  ops_get_next_instance

  ops_iatom_to_integer

  ops_initialize

  ops_integer_to_iatom

  ops_is_attribute

  ops_is_class

  ops_is_instance

  ops_is_subclass

  ops_make_instance

  ops_remove_instance

  ops_run

  ops_set_attr_atom

  ops_set_attr_float

  ops_set_attr_integer

  ops_set_attr_string

  ops_set_comp_attr_string

  ops_set_comp_elem_atom

  ops_set_comp_elem_float

  ops_set_comp_elem_integer

  ops_set_comp_elem_string

  ops_start_id_translation

  ops_startup

  ops_string_to_atom

  ops_string_to_symbol

  ops_symbol_to_string

  Glossary

  EXAMPLES

  1-1        A Sample Rule

  2-1        Declaring Additional Attributes

  3-1        Sample OBJECT-CLASS Declarations

  3-2        Object Class Match Rules

  3-3        Using $ID Variables as Pointers

  4-1        A Sample Input File

  4-2        A Program That Loops

  5-1        Calling an External Routine from DEC OPS5

  5-2        Passing a Compound Value:  C Function

  5-3        Passing a Compound Value: DEC OPS5 Program

  5-4        Passing a Compound Value: Results

  5-5        External Function That Returns an Array

  5-6        DEC OPS5 Program That Passes a READ-WRITE Parameter

  5-7        Nonportable Sample Program

  5-8        Portable Program in Uppercase

  5-9        Portable Program in Lowercase

  5-10       C Program That Calls DEC OPS5

  5-11       DEC OPS5 Routine To Be Called from C

  5-12       Changing Working Memory: DEC OPS5 Program

  5-13       Changing Working Memory:  C Routine

  5-14       Testing and Converting Values: DEC OPS5 Program

  5-15       Testing and Converting Values: C Routine

  5-16       Handling a Signal:  DEC OPS5 Program

  5-17       Handling a Signal:  C Routines

  5-18       Handling a Signal:  Results

  6-1        Fetching Fields from an SQL Database

  6-2        SQL Error Objects

  6-3        Handling an SQL Error

  7-1        Modular Compilation on VMS Systems

  7-2        Compiling with a VMS Library

  8-1        Modular Compilation on ULTRIX and DEC OSF/1 Systems

  8-2        Compiling with a Library on ULTRIX and DEC OSF/1 Systems

  10-1       A Sample Disjunction of Condition Elements

  10-2       Match Information of a CE Disjunction

  FIGURES

  1-1        Class Hierarchy of Parts

  1-2        Format of a Rule

  1-3        Recognize-Act Cycle

  2-1        Example of a Single Inheritance Hierarchy

  2-2        Inheritance from $ROOT

  2-3        Model of a Working-Memory Object

  2-4        Time-Tag Representation

  2-5        Storing the Values of Scalar Attributes

  2-6        Conceptual Model of Compound Attributes

  7-1        Modular Compilation on VMS Systems

  8-1        Modular Compilation on ULTRIX and DEC OSF/1 Systems

  TABLES

  1-1        Parts Manufactured by Kiwi Computer Company

  1-2        Conflict Resolution Criteria

  2-1        Inherited Characteristics

  2-2        Special Characters

  2-3        Read Forms and Print Forms

  3-1        Matching Object Classes

  3-2        DEC OPS5 Match Predicates

  3-3        LHS Functions for Scalar Values

  3-4        LHS Functions for Compound Values

  4-1        DEC OPS5 Statements, Actions, and Functions

  4-2        Functions for Compound Values

  5-1        External Data Types and Passing Mechanisms

  5-2        Type Conversions of External Routine Parameters

  5-3        Include Files

  5-4        RTL Routines for Accessing Working Memory

  5-5        RTL Routines for Changing Working Memory

  5-6        RTL Routines for Testing Declarations

  5-7        RTL Routines for Testing Values

  5-8        RTL Routines for Converting Values

  5-9        RTL Routines for Controlling DEC OPS5 Execution

  5-10       RTL Routines That Accept or Return Read Forms

  6-1        SQL Statements Generated by DEC OPS5 Actions

  7-1        File Specification Defaults on VMS Systems

  7-2        DEC OPS5 Compiler Qualifiers

  8-1        File Specification on ULTRIX and DEC OSF/1 Systems

  8-2        DEC OPS5 Compiler Options

  10-1       Debugging Commands

  10-2       Trace Levels

  10-3       Trace Keywords

  OPS-1     Summary of DEC OPS5 Operators

  OPS-2     Summary of DEC OPS5 Predicates

  OPS-3     Summary of DEC OPS5 Declarations

  OPS-4     Summary of DEC OPS5 Statements

  OPS-5     Summary of DEC OPS5 Actions

  OPS-6     Summary of DEC OPS5 Functions

  OPS-7     Summary of DEC OPS5 Commands

  OPS-8     Summary of DEC OPS5 SQL Actions

  OPS-9     DEFAULT Keywords

  OPS-10    DISABLE Keywords

  OPS-11    ENABLE Keywords

  OPS-12    Trace Names

  OPS-13    Trace Levels

  A-1        Message Severity Level Codes

  A-2        Diagnostic Messages and Location of their Explanations

  A-3        Conventions for Diagnostic Messages