experops5: a rule-based, data-driven production system language puts a mind behind a macintalk...

18
JFS Consulting Services: Al Special Report Prepublication Personal Communication © 1985J. F, Salmons ~ Tutorial/Review FxperOPS5™4 Prepubhcation Personal Communication— page 1 ExperOPS5: A Rule-based, Data-driven Production System Language Puts a Mind behind a MacinTalk Tongue Jim Salmons Consultant!Student Irvine, California USP has long been preferred within the AI research community as a language in which to write new languagesextending the forms and thereby the expressible content of communication between human and computer. This article showcases a new Mac-based commercial AI development environment, ExperOPSS™ from ExperTelligence of Santa Barbara, California. Sufficient information is presented for you to obtain a complete overview of the OPS5 language and its production system computational model. Enjoy. A Tutorial Application Example MOE the Bartender in “Apprentice’s Daze” An OPS5 cognitive model. Sage Words from the Past The Master said, T never enlighten anyone who has not been driven to distraction by trying to understand a difficulty or who has not got into a frenzy trying to put his ideas into words/ Confucius, ‘The Analects’ VII.8 circa 500 B.C. By this tutorial, Benevolent Master, I reaffirm my qualification for enlightenment. “If you’ll give me one of those, TIL.” or The Hidden Cost of Paying for Software with Fast Talk & Big Promises If all the folks more qualified to write this OPS 5 tutorial laid head to toe around its circumference, they would just about reach around my head as swelled as it must have been that day in September when I marched up to a major Macintosh programming journal’s booth at the Anaheim AppleFest and announced my intention to contribute just such an effort. I am not an expert on OPS5 nor Expert Systems generally. This brash tactic simply seemed an expedient means of getting ahold of some exciting new software that I couldn’t afford. Well, it worked. With complimentary reviewer’s copy in hand I began an adrenaline pumping rush into what is certainly yet another Mac-driven frontier of affordable access to computing environments which until recently were the province of the most elite and well-funded military, educational and corporate R&D labs. OPS5 Origins: Charles Forgy & Carnegie Mellon Among the early AI pioneering research centers, Carnegie Mellon University in Pittsburgh, Pennsylvania has a long history of significant and on-going contribution. During the late seventies and early eighties, Charles Forgy and his associates specified the grammar and an efficient interpretive architecture for the implementation of a new language called the Official Production System, or OPS acronystically speaking, which through revision is now generally called OPS5. For those unfamiliar with the production system model, it is one of a number of conceptualizations of knowledge representation which AI scientists use to describe where and how information is stored and processed in “thinking machines”. The production system model has found wide use in the exploration of AI applications collectively known as expert systems. These systems are capable of performing at human expert levels within a limited task domain such as medical diagnosis, mineral exploration and computer system configuration among many uses cited. The production system model is distinguished by its architecture consisting of rules (aka productions) held in Production Memory, data elements stored as a relatively unstructured global database in Working Memory and an Inference Engine which performs a recognize-act cycle to drive the relationship between rules and data. Jim Salmons is an entreprenurial doctoral student of Mathematical Social Sciences at the University of California, Irvine. His research interest is the use of expert system technology in die generation and interactive display of social network process models for human resource strategic and interpersonal applies* tions. He founded JFS Consulting Services to support himself while attending graduate school. JFS currently represents Mr. Salmans and a number of associated graduate students contracting diverse manage- ment consulting services with specialization in market and product research, small business microcomputer information systems development, desktop publishing services and training as well as a full range of statistical services with emphasis on multidimensional scaling of sociometric market research data. JFS Consulting Services can be reached at (714)-731-9022 or 345 West First Street #56, Tustin, CA 92680. ExperOPS57V is a product of ExperTelligence, Inc. Tele: (805>969-7874. Mailing address: 559 San Ysidro Road, Sanata Barbara. CA 93108.

Upload: jim-salmons

Post on 10-Feb-2017

85 views

Category:

Software


0 download

TRANSCRIPT

JFS Consulting Services: Al Special ReportPrepublication Personal Communication

© 1985J. F, Salmons ~ Tutorial/Review FxperOPS5™4Prepubhcation Personal Communication— page 1

ExperOPS5: A Rule-based, Data-driven Production System Language Puts a Mindbehind a MacinTalk Tongue

Jim SalmonsConsultant!StudentIrvine, California

USP has long been preferred within the AI research community as a language in which to write new languages— extending the forms and thereby the expressible content o f communication between human and computer. This article showcases a new Mac-based commercial AI development environment, ExperOPSS™ from ExperTelligence o f Santa Barbara, California. Sufficient information is presented for you to obtain a complete overview o f the OPS5 language and its production system computational model. Enjoy.

A Tutorial Application ExampleMOE the Bartender in “Apprentice’s Daze”An OPS5 cognitive model.

Sage Words from the PastThe Master said, T never enlighten anyone who

has not been driven to distraction by trying to understand a difficulty or who has not got into

a frenzy trying to put his ideas into words/ Confucius, ‘The Analects’ VII.8

circa 500 B.C.

By this tutorial, Benevolent Master, I reaffirm my qualification for enlightenment.

“If you’ll give me one of those, TIL.”or

The Hidden Cost of Paying for Software with Fast Talk & Big Promises

If all the folks more qualified to write this OPS 5 tutorial laid head to toe around its circumference, they would just about reach around my head as swelled as it must have been that day in September when I marched up to a major Macintosh programming journal’s booth at the Anaheim AppleFest and announced my intention to contribute just such an effort. I am

not an expert on OPS5 nor Expert Systems generally. This brash tactic simply seemed an expedient means of getting ahold of some exciting new software that I couldn’t afford.

Well, it worked. With complimentary reviewer’s copy in hand I began an adrenaline pumping rush into what is certainly yet another Mac-driven frontier of affordable access to computing environments which until recently were the province of the most elite and well-funded military, educational and corporate R&D labs.

OPS5 Origins: Charles Forgy & Carnegie Mellon

Among the early AI pioneering research centers, Carnegie Mellon University in Pittsburgh, Pennsylvania has a long history of significant and on-going contribution. During the late seventies and early eighties, Charles Forgy and his associates specified the grammar and an efficient interpretive architecture for the implementation of a new language called the Official Production System, or OPS acronystically speaking, which through revision is now generally called OPS5.

For those unfamiliar with the production system model, it is one of a number of conceptualizations of knowledge representation which AI scientists use to describe where and how information is stored and processed in “thinking machines”. The production system model has found wide use in the exploration of AI applications collectively known as expert systems. These systems are capable of performing at human expert levels within a limited task domain such as medical diagnosis, mineral exploration and computer system configuration among many uses cited.

The production system model is distinguished by its architecture consisting of rules (aka productions) held in Production Memory, data elements stored as a relatively unstructured global database in Working Memory and an Inference Engine which performs a recognize-act cycle to drive the relationship between rules and data.

Jim Salmons is an entreprenurial doctoral student of Mathematical Social Sciences at the University of California, Irvine. His research interest is the use of expert system technology in die generation and interactive display o f social network process models for human resource strategic and interpersonal applies* tions. He founded JFS Consulting Services to support himself while attending graduate school. JFS currently represents Mr. Salmans and a number o f associated graduate students contracting diverse manage­ment consulting services with specialization in market and product research, small business microcomputer

information systems development, desktop publishing services and training as well as a full range of statistical services with emphasis on multidimensional scaling o f sociometric market research data. JFS Consulting Services can be reached at (714)-731-9022 or 345 W est First Street #56, Tustin, CA 92680.

ExperOPS57V is a product o f ExperTelligence, Inc. Tele: (805>969-7874. Mailing address: 559 San Ysidro Road, Sanata Barbara. CA 93108.

A typical application takes a particular configuration of data in working memory and a set of rules which transform the data stepwise under the control of the Inference Engine until a solution state is reached. This computational model has led production systems and OPS5 applications to be referred to as forward chaining and data driven. It is this “matchmaker” mediated interplay between rules and data which distinguish the OPS5 production system environment.

From its CMU roots, OPS5 has found its way onto a variety of mainframes and AI workstations through the release of independently developed OPS5 implementations which meet the CMU/Forgy specification. Science Applications International Corporation (SAIC) of San Diego was among the early commercial implementors of OPS5 within the large system marketplace.

OPS5 on the Mac: SAIC & ExperTelligence

SAIC implemented OPS5 in LISP. By its open-ended extensible nature, LISP is the starting point of ‘virtual machine* implementations of a variety of computing environments envisioned by AI researchers. With the release of ExperTelligence’s ExperLISP™, SAIC was able to bring its OPS5 to the Macintosh. The result is ExperOPS5™ written by SAIC and published by ExperTelligence of Santa Barbara.

As an extension to ExperLISP™, ExperOPS5™ provides direct access to ExperLISP’s broad and growing range of Macintosh Toolbox and general system resources as well as to ExperLisp’s own unique features which include two, three and spherically dimensioned turtle-type ‘bunny* graphics. By any objective standard, the Macintosh delivers the cheapest yet most dynamic OPS5 environment available anywhere.

Undeniably, ‘cheapest* is a relative term. By comparison to the $80K+ LISP-machine workstations or even more costly mainframe environments previously required, the $820 entry fee for OPS5 software on the Macintosh is an unexpected bargain. Actually this cost is split between two ExperTelligence products. ExperOPS5™ retails for $325 and requires the $495 ExperLISP™ as an application shell in which to run its production system environment

Those considering ExperOPS5 as a means to a relatively low- cost Expert System development environment for the purpose of self-study, take note. While working on this article I received a Beta copy of ExperOPS5 2.0 (used here for its improved debug output). Happily for those learning OPS5 on the Mac, Version 2.0 brings the ExperOPS5 toplevel system response essentially in line with the user-system dialogue cited throughout the text of Programming Expert Systems in OPS5: An Introduction to Rule-Based Programming[Brownston, Farrell, Kant & Martin, 85] a must-have supplement to ExperOPS5’s fifty-two page manual.

If you own ExperOPS5 but have not yet received an invitation to upgrade, contact ExperTelligence. The improvements and fixes in Version 2.0 are well worth the effort.

Tutorial/Review gxperOPSS™— © 1985J. F. Salmons2 - page Prepubhcation Personal Communication

If you do not have ExperLISP and ExperOPS5, don’t worry. There is sufficient ‘documentary evidence* provided with MOE that you will be able to explore not only the code that makes him tick but trace the step by step execution of a sample run (aka MOE’s typical day) from opening the bar to last call.

So how about popping down to MacCheers for a beer? I hear there’s a real moron working the Singing Beer Wall tonight. But first, something completely different... (if you are totally new to OPS5 or rule-based languages you may want to skip the next section until after you’ve “had a few” from MOE.)...

Bottomline First Impression

“Is that a new line in your BNF?Or are you just glad to see me?”

What makes ExperOPS5 2.0 an exciting addition to our now almost confusingly rich range of programming languages and development environments available on the Macintosh concurrently presents a unique challenge and opportunity to the AI research community generally and OPS5 researchers specifically.

By consciously or otherwise attaching a negative weight to machine specific extensions which restrict program transportability, ExperOPS5’s incredible potential may be unintentionally ignored by current OPS5 programmers and intentionally cursed by OPS5 purists. The source of this potential is the software interface between OPS5 and its implementation language (being primarily and here limited to OPS5 versions in Lisp).

To date, OPS5 programmers have wrestled restrictive syntactical constructs to cross the Lisp - OPS5 boundary. The frequency and means of crossing over is a recurring topic within the OPS5 literature. That this boundary exists as a significant and influential psychological construct is apparent in representative advice from Programming Expert Systems in OPS5;

“Whether to write an external routine or implement the desired effect within OPS5 depends primarily on the relative ease with which the effect can be programmed using OPS5 rules as compared with using another language?*

[BFK&M 85 p.211 Italics added.]

While supporting the CMU/Forgy syntax for production rule Right Hand Side (RHS) user defined actions and functions (including e x e c result element parameter passing), ExperOPS5 removes the traditional constraints on execution of Lisp forms within RHS actions. Given such transparency, utility of the boundary construct is suspect and warrants reconsideration.

Further reducing the programmer’s boundary perception, ExperOPS5 does not require e x t e r n a l declartions. By virtue of the shared first class data type of all ExperLISP and ExperOPS5 functions, ExperOPS5 allows direct execution of all ExperLISP functions as if they were built-in OPS5 RHS

© 11985J. F. Salmons - Tutorjal/Review pxperOPSS™Prepubhcation Personal Communication— page 3

actions. This puts the 500+ ExperLISP primitives on syntactic par with such OPS5 actions as make, m o d ify or b in d !

The utility of these functions is compounded by the access they provide to the Toolbox ROM and global system resources, such as MacinTalk speech synthesis (used here in MOE) or MacroMind’s VideoWorks graphics animation development system. In addition, ExperOPS5 provides a unique function, lisp _ _ e v a l, which will evaluate Lisp forms in an OPS5 RHS action and return either atomic or list values into OPS5 working memory. If the returned value is a list, the elements of the list are inserted in order into a Working Memory Element (WME). In many situations l i s p _ e v a l replaces the need for the more complex construct of parameter passing required when using e x e c exchange between OPS5 and its parent Lisp.

Consider a brief example from the instructional samples supplied with ExperOPS5. Those familiar with OPS5 will be as surprised by what they see as much as they will with what they don’t. To those new to OPS5, it is only important to understand the idea of close integration between these two powerful languages.

Taking each new line of RHS actions as the next in the neverending stream of events characteristic of the Mac architecture, the language lables reveal an ‘alternating current* where the user’s experience is driven by first one language then the other. Since there is no restriction on the size of either language’s representative line ‘chunk’, this alternating pattern can be intuitively generalized to an understanding that you have the power of using either language as needed, ExperLISP/OPS5.

Summary

I chose to highlight this integration aspect of ExperOPS5 for two reasons. First, speaking about ExperOPS5 to Mac programmers, the Lisp/OPS5 hybrid is exciting. OPS5 has the “look and feel” of a BrainToolbox added to the standard selection of resources which support the already interesting potential of ExperLISP. If you can afford it or have access to it, ExperOPS5 as a personal learning laboratory is tremendous fun. And having been introduced to computers as a PLATO courseware developer at Control Data, I get squirrly thinking about the MacinTalking ExperLISP/OPS5 VideoWorks environment as an incredible computer-based education workstation.

; COLD START COMPILE USER FUNCTION, RULE & WME ; *** DECLARATION SECTION ***(defun return-list (1) ; User Defined Instruction.(list 'this 'is 'a 'sample 111)); *** PRODUCTION SECTION ***(p test-rule

(data <x>)— >z(make new-data (lisp-eval '(return-list <x>)))) (paintrect ' (0 0 50 50) ; QUICKDRAW CALL DIRECT RHS ; *** TEST CASE WORKING MEMORY ELEMENT ***

(make data 1) ; *** END OF FILE ***; SYSTEM RESPONSE TO COMPILING THE ABOVE ;return-list ;*(compiled test-rule); nil(ppwm) ; DISPLAY WORKING MEMORY ELEMENTS; (1 (data 1 )) ; (TIME_TAG (ELEMENT_CLASS ATTRIBUTE));nil ; SYSTEM RESPONSE TO ADDING DATA(cs) ; SHOW THE CONFLICT SET;test-rule; (test-rule dominates)(run 1) ; NOT SHOWN: A GRAPHICS WINDOW; ★break***" ; OPENS AND paintrect DRAWS SQUARE(ppwm) ; WME STATE AFTER 'FIRING' RULE; (2 (new-data this is a sample 1 1 1 ));(1 (data 1 )); PLUS THE GLOBAL SIDE EFFECT OF EVALUATING paintrect.; END OF RUN!...The significance of the relatively unrestricted evaluation of Lisp primitives within RHS actions of ExperOPS5 rules is more apparent when additional RHS actions are added along with boldface labels to indicate the environment under which a line will be evaluated;

(p test-rule (data <x>)

— > ;(make new-data (lisp-eval (paintrect '(0 0 50 50) ; (make new-data (lisp-eval (paintrect '(50 05 0 0) ; (make new-data (lisp-eval (paintrect '(0 0 50 50) ; (make new-data (lisp-eval (paintrect '(50 50 0 0) ;

Event Stream'(return-list <x>))))OPS5

LISP'(return-list <x>))))OPS5

LISP'(return-list <x>))))OPS5 LISP'(return-list <x>))))OPS5

When the hoped-for-soon stand-alone developer’s version of ExperLISP is released, the ExperLISP-OPS5 combination should be given your serious consideration as a development environment. And while there will be a tendency to think about applying AI to business and scientific applications, do not overlook the potential of the combination for incredible games, entertainment and personal development software... especially real time graphical simulations. After looking over MOE, take another look a Mindscape’s Deja Vu. ExperLISP and ExperOPS5 together make a great Deja Vu Construction Set. This and other potential applications will suggest themselves as we become more familiar with the capabilities of these new tools.

Open minds fired by our own development goals will define a range of new applications for Expert System and similar AI tools as they become increasingly available to us. And by these applications, we will begin to fulfill the dreams of the dedicated computer scientists who have worked so long to bring them to us. I am certain we won’t let them down. And I wouldn’t be surprised if we don’t give them a few surprises.

Next, to address AI professionals generally... Hello, friends: And thank you for what we are about to receive. Congratulations on years of dedicated cumulative work which will soon see a significant diffusion to our ranks.

Speaking from my own recent experience, the potential of this technology transfer is incredible. Facilitated not only by the accessibility of hard and software to run these environments; the quality, quantity and diversity of recent publications will significantly accelerate the learning curve of the army of “closet computer scientists” that MacTutor readers (and others) represent. Our naivete with regard to your scientific specialty in combination with the artistic creativity, raw talent and can-

do spirit we bring to software development on the Mac will likely be the incubator of unexpected significant innovation. When so many people have so many powerful computers with such powerful software, significant innovation is a certainty.

So keep an eye on us. Not only can you expect the pleasure of documenting the fruits of your labors, you might stand a chance to keep us from making an “end run” around your research labs as we all rush into the Future.

Tutoriat/Review ExperOPSSm — © 1985J. F. Salmons4 -page Prepublication Personal Communication

MOE the Bartender in “Apprentice’s Daze”10 Rules Do Not a Mixologist Make

Objective

OPS5 must be understood both as a language and as a computing environment. Since the computational model is significantly different than that of the statement and procedural oriented languages, MOE gives you all the information you need to explore the language and to simulate a full run of Ids cognitive model even though you may not have access to OPS5 software.

OPS5, Cognitive Modeling & MOE

Among its uses, cognitive psychologists have used OPS5 to develop explicit models of human thinking. To obtain any degree of explanatory power, these models elaborate through research until they become quite complex in the number of rules and their interactions. MOE (Macintosh OPS5 Environment) is a simple demonstration developed in the spirit of a cognitive model although far too trivial to be taken as an example of actual research applications.

The process of developing a particular cognitive model often involves taking detailed notes as someone talks their way through the mental process which is being modeled. This transcript is called a protocol and from it, the researchers develop a model This model usually takes the form of a series of English statements of individual rules and a node-link graph of their relations called a problem space.

This rigorous descriptive model is a blueprint to write an OPS5 program. This program consists of data element declarations (descriptions of the type of things known categorized by attributes and also known as declarative knowledge) followed by production rules (individual recipes for what to do under particular conditions and known as procedural knowledge to AI reseachers).

MOE’s Background

On a very limited scale, I imitated this process to develop MOE. I took the “group sing” tune ‘99 Bottles of Beer on the Wall* as his behavioral protocol because it is widely familiar as a tune and because it is an iteration algorithm which is

handled differently in OPS5 than in number crunching languages such as BASIC, Fortran or Pascal. In addition to iteration, MOE demonstrates the sequencing of goal-directed tasks using a control element in working memory and task or context conditional restrictions which group rules according to which task or context they are used.

I broke the tune into a series of goal oriented steps. I next made a list of exactly what conditions had to exist in MOE’s World before he would perform a specific series of activities. I then made a list of what conditions had to be met before moving from one task to another. I elaborated MOE’s behavioral scenario to include reporting to work, shooting the breeze with the boss, taking inventory, restocking the empty wall and once all the beers are served, last call and closing up the bar. To learn how MOE’s mind works to do all this in just ten simple OPS5 rules, you will need a bit more background...

Data Types & Working Memory(aka things in MOE’s world & Ideas in his mind)

OPS5 has weakly typed data, being LISP symbolic atoms or numbers at the primitive level, which are called elements stored in working memory. These working memory elements, or WMEst represent objects which are both physical such as a beer in MOE’s world, or mental such as a goal he keeps in mind to organize his activities.

These data objects may be made, modified or removed from working memory much like we would learn and forget as well as change our ideas about things in the course of routine activity. For something to be perceived by MOE and thereby become part of his active domain, an element is added to his “mental state” (aka working memory) with the OPS5 action,

(make b e e r ) which results in an entry to working memory in which the new or changed object is paired with a time tag or recency attribute and stored as

( i n t e g e r _ t im e _ ta g ( o b j e c t ) ) . Inmaking the beer above, a Lisp list representation of MOE’s mental state would show

(1 ( b e e r ) ) in working memory. Adding another beer would result in a working memory configuration

(2 ( b e e r ) )(1 ( b e e r ) ) where the new beer is assigned a

larger time value much like a new customer coming into a deli and taking a number for service. And like a deli, the number is only good for one transaction. Every time a WME is changed by rule firings as an OPS5 program runs, the WME is assigned a new time tag. (This important time tag concept will be brought home by watching the state of the same four beers in MOE’s world as they move from inventory to consumption.)

The time tag value is assigned internally and is inaccessible to the programmer. The exact value of the tag is assigned by the inference engine’s conflict resolution algorithm. We’ll take this process as a Black Box for the moment and accept that the time tags are upwardly monotonic meaning they always increase although the assignment is not strictly incremental.

<9 1985J. F, Salmons - Prepubhcation Pers

Tu torial/Reviow pxperOPSS™mat Communication— page 5

So if we had a rule compiled in memory which looked for a beer and drank it, that is made it “empty”, the process of modifying the WME would result in assignment of a new time tag. Drinking a beer from the two above would result in a working memory state of

(4 (empty))(1 (beer)) where the second beer was modified

to empty and given a new larger (but not 3) time tag when the drinking rule fired after having found a full beer during the recognize phase of the recognize-act cycle of the inference engine.

If existence of an object was all that could described within OPS5’s working memory, MOE’s world would be very boring. You couldn’t sell an expert system to Eskimoes that only allowed one word for snow, so to achieve descriptive power OPS5 allows the declaration of element classes with associated attributes. (OPS5 also supports a vector attribute allowing an even deeper nesting of multiple descriptive features. We’ll ignore this complication for now .)

Element classes are declared at the beginning of an OPS5 program file and are literalized in the form

(literalize element_class attribute^ attribute^ ’

attributejn) where the element and attribute names must be symbolic atoms. In terms of MOE’s limited apprenticeship concerns, a beer is on the wall, somewhere in stock or empty after having “taken one down and passed it around” as the tune suggests. The demands of position are met by

(literalize beeron ) where the attribute “on” may take the

assignment of “wall”, “storage shelf’ or “empty” (like a gas tank gets on empty). To create a particular beer on a particular place, the make action is expanded to

(make beer A on wall) where the up_caret prefix operator, (space)A(space), signals an attribute assignment of the beer as being on the wall. When executed this form creates a WME

(1 (beer wall)) where the embedded beer list is expanded to show it is on the wall. (Lispers will immediately recognize the nature of the OPS5 working memory global database as inwardly embedded lists and thereby have a quick understanding of the internal execution of OPS5 working memory changes.) With this much information about OPS5 data and working memory, you should be able to take on MOE. But first you need some background on...

Rules & Program Structure

In Bottomline First Impressions I described the exciting potential stemming from ExperOPS5*s ability to freely alternate between its production system and the Lisp environments. This capability is like being able to ride a black hole between two parallel universes where different laws of physics apply. When you are on the OPS5 side of this porthole, programs consist of unstructured collections of data-

sensitive rules which by design (hopefully) synergize through collective action to achieve some significant goal state which no one of them is capable of achieving individually. This collective action is facilitated by the control structure of the Inference Engine and has led the OPS5 environment to be characterized as a bunch of independent contractors bidding on little tasks within a big project administered by the Inference Engine auctioneer.

The rules managed by the Inference Engine broker are expressed in a widely shared logical construct which is generally expressed as

Rule_name IF conditional

condition 1

THEN actionj. action 2

endjrule.

Examining one of these independent contracting rules or productions (‘rule’ being shorter and more general, I use it over the more obscure but more specific ‘production’), the general form is

(p constant__symbolic__atom Left Hand Side Condition

— >Ride Hand Side Action Response)

where p is an OPS5 built-in abbreviating production which signals the beginning of a rule given a symbolic atom name followed by a sequence of conditional elements which restrict the situations under which the rule will execute its RHS actions. (Note the OPS5 special atom, —>, which signals the end of the LHS and start of the RHS actions.) Each condition element is a template used to find matching WMEs thereby signaling the prerequisite conditions for the rule to fire. When all the condition elements of a particular rule are satisfied, the rule is said to be instantiated which consists as an association of a particular rule with a specific collection of WMEs which satisfy the restrictions on the rule’s firing.

The scope of restrictions on LHS conditional elements can be summarized in a four-step expansion. Shown on the LHS of a single rule in order of increased complexity, conditional elements may take the forms

(p rule_name (class_name)(class A attribute atom/#/<var>)(class{ A att { a/#/<v> pred. a/#/<v> ) })

{ <var> (one of the above forms) )—>

RHS actions ; where• the first restriction matches any WME of the named

element class...• the second matches any WME of the named class with

the named attribute^, they can repeat) equal to specific symbolic atom or numeric constant values or will bind a

Tutorial/Review ExperOPS5™— © 1985J. F. Salmons6 - page Prepublication Personal Communication

WME to the form < v ariab le_ n am e> ...• the third enhances the range of matches from the second

type by using OPS5 curly brackets, { }, and predicateoperators (=,<>,<,<=,>=,>,<=>) to associate multiple conditional values under a more flexible range o f conditional operators than the previous forms* implied equality tests and the special case of unrestricted variable assignment...

• and the fourth form creates an element variable which binds a temporary name to the entire conditional element so the element can be referred to by a more readable label than the primitive integer reference within RHS actions. (While there are advantages to the element variable’s labeled reference, MOE’s rules are in the more primitive integer format to make an explicit connection between WMEs temporarily bound to LHS conditions and subsequent RHS actions.)

Next level out in terms of understanding the interpretation of the LHS conditional restrictions is the relationship between individual conditional elements and the effect o f using the same variable name in different conditional elements to create logical associations among the objects tested. These interpretations are read onto the OPS5 rule form as follows

(p match__some__folks__ages(person) ; THIS NON-NEGATED CONDITION MET (person A age <how_old>) ; AND

- (person A age <how_old>) ; AND(person { A age < <how_old> }) ; AND

— >RHS actions ; where for this rule to fire,

working memory would have to contain at least the following;• any one person PLUS• a person with any specified age PLUS• any one person NOT of the specified age PLUS• a person younger than the specified age.

Note the implied conjunction between conditional elements as well as the negation syntax, a minus sign preceding the conditional element. The effect of these between conditional element semantics is enhanced by the logical ties of shared variable names among the selection restrictions of individual elements. Together these between element expressive forms combine with the within element forms to give a complete interpretation of the minimally acceptable working memory configuration which must be “recognized” before a specific rule will announce its eligibility to “act” by “firing”.

Any confusion you have from this shotgun condensation of the LHS rule interpretation should be reduced by your review of MOE’s program listing. Comparing the description of the conditional restriction in the English Version of a rule which precedes its equivalent OPS5 code, the ten rules which constitute MOE’s simple mind should help reduce confusion by generalization from example.

Fortunately, the interpretation of an OPS5 rule’s Right Hand Side is decidely more straightforward and requires only summary information before cutting you loose on MOE’s listings.

In Mac terms, the RHS of the OPS5 rule is a specification of the stream of events which will preoccupy the machine for the

duration of their action. There is no need to discuss convoluted semantics among these individual RHS actions because they simply are evaluated one after another in the order in which they follow the side-separating arrow, — >, an OPS5 built-in which is given the logical THEN interpretation in the general form of an OPS5 rule.

Each RHS action is expressed as a Lisp-like list structure which follows the general syntactic form

(ac t_ n am e argum ent_JL . . a rg _ n ) .The RHS actions cluster in a hierarchy which begins by distinguishing;

• actions strictly within the OPS5 environment and• actions which facilitate interaction between OPS5 and its

implementation language, in this case ExperLisp.

On the OPS5 side of things, RHS actions either• take direct action on working memory, being The Big

T hree-m ake , m o d ify and remove... or• they are terms or functions which facilitate• actions on working memory, including action terms

b in d and c b in d for variable bindings on the RHS prior to WME modifications later in the action event stream sequence and RHS functions com pu te to calculate new values prior to WME actions and s u b s t r used to transfer values between old and new WME,

• user interaction being fairly restricted to text messages using the w r i t e action and its associated c r l f action to start a new line which can be used with the a c c e p t and a c c e p t l i n e actions to interactively prompt for keyboard interaction from the user,

• control of file input and output performed by the o p e n f i l e , c l o s e f i l e , a c c e p t , a c c e p t l i n e and d e f a u l t action terms which simply were not needed to implement MOE’s limited world and will be left for elaboration in subsequent articles,

• program termination being the simple ( h a l t ) RHS action statement, and the “window to smart programs”

• self-modification through automatic rule-writing during program execution by way of the b u i l d action (which is excitingly beyond the scope of this introductory example and, besides obvious ‘serious’ applications, suggests such fun as ‘Deja Vu Worlds’ which elaborate themselves through player interaction).

Providing access to the Lisp environment from within RHS actions is the function of OPS5 primitives which

• provide flexible parameter-based two-way access between Lisp and OPS5 by way of c a l l and user defined functions, such as

( c a l l u s e r _ f u n c < p a s s in g _ v a r> ) inwhich the user-defined function uses a set of special parameter- referencing forms involving a result element template to pass values in and out of OPS5 working memory,

• provide quick exchange o f OPS5 values to the top level Lisp forms using the e x e c form, such as

(e x e c ’ ( s e t q l i s p _ v a r < o p s _ v a r> ) ) which passes the currently bound value of the OPS5 variable to an associated Lisp variable, and the unique

• direct evaluation of Lisp forms which open up the

© 1985J.F, Salmons - Tutoriat/Reviaw£xperOPS&* PrepubhcaUon Personal Communication— page 7

ExperOPS5 environment to all the enrichment available in the ExperLisp and general Macintosh resources, such as

(say "MacinTalk spoken here.") which hints at the open door available to the creative Macintosh OPS5 programmer.

With this general information as background to the interpretation of rules, you should be comfortable plowing into MOE’s greymatter (aka his listing). Since MOE’s actions map so logically to the machine actions required to express them as state changes in working memory, (as in ‘Taking a beer down to pass it around” being expressed as a m o d ify action on a beer class object from the A on attribute of the wall to the consumed state of empty), no attempt will be made in this introductory example to discuss details of the forms individually.Any additional information required to understand MOE’s ten rules will be found as short comments within the listing.

MOE’s program listing shares a structure common to OPS5 program files. In structural out­line terms;

beginning of file *** DECLARATION SECTION ***(literalize object classes & associated attributes...)(user defined & misc.definitions & declarations...)*** PRODUCTION SECTION ***; rule cluster name & extensive explanatory comments

; rulel name & extensive explanatory comments (P actual j-uleljcode LHS - - > RHS)

; rule2 name & extensive explanatory comments (P actual_/ule2j:ode LHS — > RHS)

; rule cluster name & extensive explanatory comments ; rulel name & extensive explanatory comments

*** TEST CASE WMEs *** (make some^object)

end_ofJile

Now briefed for your mission and armed with a map of the terrain, you are almost ready for a Fantastic Voyage into the inner reaches of a man who, if you met him on the street you would likely say, “Now there goes a real moron!” But before jumping to such a cynical observation, consider what drives him onward in a single-minded commitment to occupational excellence... to be the best damn Beer Wall operator MacCheers has ever seen. To know MOE you must know his Inference Engine.

The Inference Machine

In its most abstract level (and a controversial one, at least among researchers,) the OPS5 Inference Engine can be interpreted as a stimulus—>response model of perception. More often in the AI literature this model is referred to as the recognize->act cycle in which each act leads to an assessment of the changed world around the actor which, in turn, may lead to yet another recognition state followed by its prescribed action response. The connection between this perceptual

model and the logical construct of the rules is apparent by the conjuncted expression;

I f these conditions are Recognized,Then perform these Acts.

In implementation terms, the recognize-act cycle is a three- stage finite state machine consisting of match, select and execu te steps. As a simple iterative algorithm with termination conditions, the recognize-act cycle can be expressed as loop

match rules to WMEs - instantiations to the conflict set stop if any of the following are true

no instantiations in the conflict set (no stimulus to act) a halt action was evaluated a user-specified cycle count has been reached a breakpoint has been reached (usually used during debug)

perform conflict resolution (pick dominant instantiation) execute the dominant instantiations (rule-WME binding)

goto loop.

The structure provided by laying this algorithm over the potential of the rules is what energizes the OPS5 environment. Without the inference engine’s administrative aid, the potential of the rules’ collective action is lost. To facilitate this synergistic expression, the inference engine treats all rules as equals with no ordering or clusters while searching for rule- WME instantiations during the match stage of the cycle.

Working Memory Go

Run #2CL

Working Memory: Run #1 Goal: report_to_work [5]

Beers

[1] 12] T®*al13] 14] [0]

Production Memory

MOE’s 10 Rules(see listing for details)

MATI

(conflict set)DATA changes by run

(f;rst column of Audit Trail)(second column |

of Audit Trail) |

Perform actions in third column of Audit Trail SELECT(referring to listing & protocol for details) |add 1 to the run count to arrive at n e x t^ -------- EXECUTE

Working Memory state.

InferenceEnginecontrol

flow

Tutorial/Review ExpqrOPSS™— © 1985J. F. Salmons8 -page Prepubucabon Personal Communication

Once all rules are given a chance to ‘announce’ their membership in the current conflict set (aka an unordered list of rules ready and able to fire, the engine moves to “hold court”.

In a Solomon-like scenario of administering benevolent justice, the inference engine considers the ‘requests to act’ appearing on the current “court docket”, the conflict set. And just as Solomon used a consistent set of transcending principles to give consistency to his pronouncements, so the inference engine is guided by a combination of interacting selection strategies when it comes to selecting the rule-WME instance which will fire on a given round.

Although there are a variety of subtle ways in which the inference engine selection strategy may be modified from its default state thereby dramatically altering its ‘mode of thought’, the requirements with respect to understanding MOE are limited to a few basic conflict-resolution strategies. Faced with a crisis of multiple potential actions, MOE applies the following guidelines, in decreasing order of selection priority, to determine which rule- WME instance will dom­inate the conflict set;

• context limitation, a ‘pre-processing* criter­ia in which only a limited subset of all rules even has a chance of appearing in the conflict set by virtue of members of the set matching on a control element in working memory... in MOE’s case, a G oa l class control element limits potential conflicts due to every rule’s LHS restric­tion requiring a match against the current value of the t a s k attribute,

• refraction ensures that the same instant­iation (a specific rule and its time-tagged WME match) will not fire twice (although RHS actions can modify an object thereby assign­ing a new time tag which opens the way for re-instantiation)... which explains why the three rule cluster which takes inventory does not count the same beer on the wall twice (thereby relieving the need to

mark and unmade items typical of traditional programming approaches to such a problem),

• recency takes any instantiations which cannot be eliminated by the above criteria and partially orders them based on the recency of the time tags associated with the WMEs currently mapped onto the rule’s LHS conditional elements... which, while an important part of the default LEX inference engine strategy described here, was not required in the resolution of MOE’s limited mental conflicts when faced with administering the Beer Wall,

• specificity which, while ‘deeper* in the priority scale of resolution factors, is actually among the most frequent considerations determining dominance by virtue of its criteria which awards priority to the rule with the most complex, that is the longest list of, conditional restrictions (which is intuitively consistent with the interpretation that more important things are described in greater detail than everyday trivialities)... as in MOE’s case when the presence of an

MOE The Bartender: An OPS5 Run As A ‘Behavioral Audit Trail’

Run RECOGNIZE ACT# ' WORKING MEMORY | RULE MEMORY CONFLICT SET RIGHT HAND SIDE ACTIONS

Goal, task name [tag][#] <BEERSonwall

KEY jm <on other [tagfTotal. H<em pty [Temp, tag]

Rule{>1 instantiations} Dominant rule {#} [LHS binding]

• “Cross-Ref: Moe’s Dialogue"• Transient Enabling Actions• Working Memory Effects

CLASS Action @ [tag]

1Goal, report to work [5]

Bl “

Open_For_Business [5] • “Hi Boss. It’s me, Moe Raun ..." •none•GOAL Remove<§>[5] Add@[8]

2Goal, openingjnventory [0]

B] % [6] 0Done Countin Brewskies See_Brewsky_On_Wall {2} [8 3]

• “See one." •none•TICK Add@ [9]

3Goal, opening inventory [8]

G! S ' 161 3Done Countin Brewskies See BrewskyDn Wall Count_BrewsTy [S~8 6]

• “Count it."• compute new inventory count •TICK Remove® [9]

TOTAL Remove <g> [8] Add @ [12]

4Goal, opening inventory [8]

B] 1

Done Countin Brewskies See_Brewsky_On_Wall [81 ]

• “See one."•none•TICK Add@[13]

5Goal, opening inventory [8]

Bl f t " 2' M3-,

Done Countin Brewskies Count_BrewsRy [13 812]

• “Count it."• compute new inventory count •TICK Remove® M3]

TOTAL Remove @ [12] Add @ [16]

6Goal, opening inventory [8]

Bl S ™ %Done_Countin_Brews [8] • “Done countin brewskies, Boss....”

• none• GOAL Remove @ [8] Add @ [18]

7Goal, serve customers [18]

Bl S 1,61 2Stop_Serving_& Check Stock Sing_Tune_&_Take.. [1816]

• Two bottles of beer on the wall...." •Callnumber word •ORDER MaTe® [19]

8Goal, serve customers [18]

Bl M " V iStop Serving & Check Stock Serve_A_Brew [1819 316]

• Take one down. Pass it around...." •Call number word, bind & compute •BEER Remove®[3] Add@(21]

ORDER Remove @[19]TOTAL Remove @ [16] Add @ [23]

9Goal, serve customers [18]

® 12311Stop Serving & Check Stock Sing_Tune_&_Take.. [1$ 23]

• “One bottles of beer on the wall...." •Callnumber word •ORDER MaRe @[25]

10Goal, serve customers [18]

Gil SStop Serving & Check Stock Serve_A_Brew p 8 25 1 23]

• Take one down. Pass it around...." •Call number word, bind & compute• BEER Remove @ [1] Add @ [27]

ORDER Remove @[25]TOTAL Remove @ [23] Add @ [29]

© 1985J.F. Salmons - Tutorial/Reviqw FxperOPSS™Prepubbcation Personal Communication— page 9

inventory tick mark or customer order WME triggers the complex requirements of the counting and serving rules which then remove the triggering WME, thereby allowing re­instantiation on the less complex rules which triggered the more specific rule in the first place, and when all else fails...

• whim being the arbitrary selection of a remaining instantiation to fire thereby keeping some small but inevitable inconsistency among rules from grinding the environment to a halt through indecision and creating the potential for subsequent different action based on the changes the arbitrarily selected rule’s firing has on working memory.

By applying these conflict resolution strategies, a dominant rule is selected and fires. This fired rule then contributes the

characteristic of the OPS5 and other production system environments. And it should be clear, now, why this extensive introductory explanation was required to reach a “critical mass” of understanding which will allow subsequent articles to address particulars of the language and its associated programming techniques.

To have turned you loose on an OPS5 program listing without the explicit underpinning of the inference engine and run-time dynamics would have been worthless. Indeed, this integral relationship between the language and the inference engine accounts for a tendency of an OPS5 program to

MOE’S BEER WALL PROTOCOL:a transcript of his MacinTalk remarks.

sequential evaluation of its RHS actions to the event stream which the user is experiencing as the effect of running the OPS5 program. This incremental tail-end extension of the user experience as a function of on-going inference engine mediation of the rule and data conditional relations is

accomplish alot with a little code. For example, cutting away the documentary comments of MOE’s ten rules leaves very few lines of code

Rur#

I RECOGNIZEI WORKING MEMORY | RULE MEMORY CONFLICT SET

| ACT | RIGHT HAND SIDE ACTIONS

11Goal, serve customers [18]

[27] (2) [29] 01*1] N

Sto p_Se rvingL&_Check_Sto. .[18] • “Oops. Hold on. I ran out of beers.." •none• GOAL Remove @ [18] Add @ [32]

12Goal, restock wall [32]

[2?] [2 r [29] 0 [21] [4]

Serve Newfoundjnventory Beer Gone Close Business Restock_The_Wall {2} [32 4 4 29]

• “Alright, I found one on the stool."• CallTocationjword, bind & compute• BEER Remove @ [4] Add @ [34]

TOTAL Remove @ [29] Add @ [36]

13Goal, restock wall [32]

[2?] [2 r [3b] 1 [21] [34]

Serve Newfound Inventory Restock_The_Wall [32 2 2 36]

• “Alright, I found one on the table."• CallTocation word, bind & compute •BEER Remove @ [2] Add@ [38]

TOTAL Remove @ [36] Add @ [40]

14Goal, restock wall [32]

[%?] [38]““ [40] 2 [21] [34]

Se rve_Newfo undJ nventory [32] • “Okay, I'm back and we've got.."• none• GOAL Remove @ [32] Add @ [42]

15Goal, serve customers [42]

[2?] [38] [40] 2 [21] [34]

Stop ServingL& Check Stock Sin g_Tune_&_Take_Or"3.. [42 40]

• Two bottles of beer on the wall...."• Call number word• ORDER Make @ [43]

16Goal, serve customers [42]

[2?] [38] [40] 2 [21] [34] [43]

Stop Serving & Check Stock Serve_A_Brew J 2 } [4243 3840]

• Take one down. Pass it around....”• Call number word, bind & compute• BEER Remove @ [38] Add @ [45]

ORDER Remove @[43]TOTAL Remove @ [40] Add @ [47]

17Goal, serve customers [42]

[27] m [47] 1 [2 t] [34]

Stop Serving & Check Stock Sing Tune &“ Take Ord.. [42 47]

• “One bottles of beer on the wall...."• Call number word• ORDER Make @ [49]

18Goal, serve customers [42]

[27] m [47] 1 [21] [34] [49]

Stop Serving & Check Stock Serve_A_Brew [42 49 3T47]

• Take one down. Pass it around...."• Call number word, bind & compute •BEER Remove @[34] A dd@ [it]

ORDER Remove @[49]TOTAL Remove @ [47] Add @ [53]

19Goal, serve customers [42]

[27] [«S] [53] 0 [21] [51]

Sto p_Serving_&_Check_St.. [42] • “Oops. Hold on. I ran out of beer...." •none• GOAL Remove @ [42] Add @ [56]

20Goal, restock wall [56]

W ) [4§]““ [S3] 0m m

Serve Newfoundjnventoiv BeerJGone_Close_BusL [56 53]

• “Sorry folks. The beer is gone....’’• none• GOAL Remove @ [56] Add @ [58]

haltGoal, dean & close [58]

[27] [Ǥ) ~ [53] 0 [21] [51]

nil

Run Results ===>

10 production rules produced 20 firings in which 58 RHS actions changed WM

from state @ #1 to HALT

Typeface alternates with underlying rule changes.

“ HI Boss. Its me Moe Raun your faithful Apprentice Bartender. n l takeinventory before opening the Beer Wall. Okay?”“See one."“Count it.”“See one."“Count it.”“Done counting brewskies Boss. The Beer wail is officially open. I’ve got."“Two bottles of Beer on the Wall.

Two bottles of beer.Pop the return key and

I’ll pop you a brew.”Take one down.

Pass it around.One bottles of Beer on the

Wall."“One bottles of Beer on the Wall.

One bottles of beer.Pop the return key and

I’ll pop you a brew.”Take one down.

Pass it around.No more bottles of Beer on the

Wall."“OOPS Hold on. I ran out of beers. I’ll be right back.”“Alright I found one on the Stool."“ Alright I found one on the Table.”“Okay. I am back and we have got.""Two bottles of Beer on the Wall.

Two bottles of beer.Pop the return key and

I’ll pop you a brew.”Take one down.

Pass it around.One bottles of Beer on the

Wall."“ One bottles of Beer on the Wall.

One bottles of beer.Pop the return key and

I’ll pop you a brew.”Take one down.

Pass it around.No more bottles of Beer on the

Wall."“ OOPS Hold on. I ran out of beers. I will be right back.”“Sorry folks, the Beer is gone. Time to close down. See you tomorrow. Close the door behind you. Goodnight."

Tutorial/Review ExperOPSSm— (Q 1985J. F. Salmons10 - page Prepublication Personal Communication

to account for the extent and flexibility of his behavior (he’ll find as many beers in as many places as you put them). This affect is largely a function of the ‘implied code* which the inference engine contributes to the execution environment as opposed to explicit code, such as GOTOs or GOSUBs, typical of a statement oriented language such as BASIC or Pascal.

To put this accumulation of information to test and thereby bring MOE to life, examine the diagram on page seven to gain an understanding of the relationship between MOE’s listing which follows, his ‘Behavioral Audit Trail* spread on pages eight and nine (aka a state change record of the OPS5 Inference Engine’s activity during program execution) as well as Moe’s MacinTalked Protocol annotation on page nine. Using these simple print materials you will be able to experience an OPS5 program run without having ExperOPSS software.

And with this OPS5 “paper chase” behind you, you might reasonably expect to gain a sufficient appreciation of the ExperOPS5™ computing environment to stimulate a decision to call ExperTelligence, visit your favorite software retailer or simply pursue further library research. Your decision will determine whether you get the jump on future computing today, or play catch up tomorrow. So go ahead, check out MOE’s listing to get a handle on what’s in store when you drop an Inference Engine into your little beige buddy.

MOE the Bartender’s Program Listing

Note:Inept MacPaint illustrations are not part of typical OPS5

listing comments and are not required to run the software. They are, in fact, additional evidence of the

wholesale abuses readers can anticipate being subjected to as editorially unbridled authors explore the

limits of their talents through desktop publishing.

......... MOE, A BARTENDER”: PART 1***** Career Episode: APPRENTICESHIP ***** A serial OPS5 tutorial inspired by the tune ***** '99 BOTTLES OF BEER ON THE WALL' ***** taken as a behavioral specification ***** for Moe's first job at MacCheers.***** Next Episode: Mixologist Training Begins ***** by Jim Salmons*****************************************************

; ***** DECLARATION SECTION *****

(literalize Beer ; An Element class of bottled brewskies.; A myriad of attributes suggest themselves ; as prerequisite subtlties of perception if MOE is to

on ; perform at a expert level of bartending. Initially ; MOE only cares about serving full beers from the "wall" ; and moving beers to the wall for sale. MOE ignores

) ; "empty” brews until closing time.

(literalize lnventory_Tick_Mark ; Element class where as ; soon as one of these is created, a rule is enabled which ; increments the total count of brews on the wall. The ; rule then immediately erases the tick to avoid the tick’s ; causing a miscount if the it was left in WM during

) ; subsequent cycles of the Inference Engine.

(literalize Order ; like the tick mark above, it triggers Moe’s ) ; beer serving reaction »

(literalize TotaLBrews ; An Element class under which a single ; WME is created having a "one-to-many” relationship

still_on_wall ; with the subset of WMEs of the Beer class ) ; which remain on the wall.

»(literalize Goal ; An Element class whose single instance is

; created so its task attribute can be progressively ; updated to a new value which will match the LHS ; conditions of rules with RHS actions which contribute ; to performing the current task. Such WME-mediated

task ; enabling and disabling of independent rule firings to ; achieve an intended sequence of action is one of the ; explicit forms of control structure which distinguish the ; Data Driven environment from traditional Statement ; Oriented imperative languages such as BASIC, Pascal

) ; or Fortran.

;***** END OF DECLARATIONS *****;***** USER DEFINED FUNCTIONS &MISC. *****

(defun numberj/vord nil (prog (cnt_number)

(setq cnt_number ({parameter 1); Pops OPS5 binding of ) ; LHS variable <cnt> to LISP variable “crrt_number”(setq cnt_word ; index to look up a speakable

(nth cnt_number number_words_list) ; ‘number word' ) ) ) ; for the integer value of the OPS5 <cnt> variable.

>(setq number_wordsJist ; Creates LISP list of number

'("N o^ore" "one" "two" "three" ; words to be mapped "four" "five" "six" "seven" ; onto the current numeric "eight" "nine" "ten") ; binding on the OPS5 <cnt>

) ; conditional variable. Zero is ‘no more’ to fit tune; algorithm. Limit to ten or less simplifies tutorial.; Generalized algorithm could interpret any numeric.

(defun location_word nil(setq where ({parameter 1)) ; Beta 2.0 ExperOPSS liked

) ; saying LISP strings rather than OPS5 <variables>>

(speechon"" ,athespeech) ; SAY takes a string and says it. (defun say (str &optional parse ; function defined without

&aux sptr len (phonh (newhandle 500))) ; comment, (hlock (coercetype $68 astring_space)) ; Courtesy (setq sptr (makeloc (deref astring_space); D. Bollay,

(coercetype $10 str))) ; ExperTelligence (setq len (fetchbyte sptr))(speechreader athespeech (makeloc sptr 1) len phonh) (hunlock (coercetype $68 astring_space))(macintalk athespeech phonh)(disposhandle phonh) ; MACINTALK DRIVER MUST BE

) ; ON THE OPS5 SYSTEM DISK

<0 1985J.F. Salmons - Tutorial/Revjew ExperOPS5™Prepubhcabon Persona] Communication — page 11

***** PRODUCTION SECTION: the pool of rules ********* RULE CLUSTER TO COUNT BEERS ON WALL ****

ENGLISH VERSION - Open_For_Business IF the goal is to report to work

THEN chit chat with the boss and proceed with counting beers on the wall

}(P Open.ForJSusiness

(GoalA task report_to_work)

)

(modify 1 Maskopeningjnyentory)(say MHi Boss. Its me, Moe Raun, your faithful ; misspelled

Apprentis Bartender, ile take inventory before ; words opening the Beer Wall. OH KAY") ; are for MacinTalk

; ENGLISH VERSION - See_Brewsky_On_Wall; IF the goal is opening inventory AND ; there is an uncounted beer on the wall ; THEN make a tick mark on a pad ; and verbally announce the sighting.

(P See_Brewsky_On_Wall(GoalA task openingjnventory) (BeerA on wall)

(make Inventory_Tick__Mark)(say "See one.")

; ENGLISH VERSION - Count_Brewsky; IF there is a tick mark on the pad AND; the goal is opening inventory AND; Total Brews still on wall have a count now called <cnt>; THEN erase the tick mark AND; add one to the number <cnt> for new inventory count; and announce the act of counting.

(P Count_Brewsky(lnventory_Tick__Mark <T>) ; tick before goal for(GoalA task openingjnventory) ; efficiency (TotalJ3rews A still__on__wall <cnt>)

~>

)

(remove 1)(modify 3 A still__on_wall (compute <cnt> +1))(say "Countit.")

; ENGLISH VERSION - Done_Countin_Brewskies ; IF the goal is opening inventory only ; THEN announce done countings open the wall ; and proceed to next task of serving beers to customers

(P Done_Countin_Brewsk!es(GoalA task openingjnventory); ..fewest LHS restrictions ; mean it will fire only after all counting is done as ; enforced by Inference Engine selection strategy ; decision rules.

(say "Dun countin brewskies, Boss.The Beer Wall is oh fish alley open. Ive got") ; "officially"

(modify 1 Ataskserve_customers)) ***** RULE CLUSTER TO SERVE CUSTOMERS *****

ENGLISH VERSION - SingJTune_&_TakeOrder IF the goal is serving customers AND the Total Beers count, now <cnt>, is greater than 1

THEN sing the first part of the Beer Wall Tune, solicit orders which customers place by pressing Return which creates an Order that triggers the 2nd part of the tune.

(P Sing__Tune_&_Take_Order(GoalA task serve_customers)(Total_Brews A still_on_wall { <cnt> > 0})

~>(call number_word <cnt>)(say cnt_word)(say "bottles of beer on the wall")(say cnt_word)(say "bottles of beer.")(say "Pop the RETURN key and ile pop you a brew.") (make Order (accept)) ; currently MOE takes any

) ; "accepted" keyboard input as a beer order

Notes

Tutorial/ReviewExperOPS5th— © 1985J. F. Salmons12 - page Prepublication Personal Communication

ENGLISH VERSION - Serve_A_Brew IF the goal is to serve customers AND there is an unfilled Order waiting AND there is a Beer on the Wall AND a Total Beers count is found and called <cnt> for now

THEN sing the second half of the Beer Wall Tune, fill the order by removing the Order WME and take a beer from the wall, pass it around, which makes it empty compute the decreased number of beers on the wall.

(P Serve_A_Brew(GoalA task serve_customers) (Order)(BeerA on wall)(Total__Brews A still_on_wall <cnt>)

)

(say 'Take one down")(say "Pass it around")(modify 3 A on empty)(bind <cntdwn> (compute <cnt> -1))(modify 4 A still_on_wall <cntdwn>) decrement stock (call number_word <cntdwn>)(say cnt_word)(say "bottles of beer on the wall.")(remove 2); turns this rule off til another order is taken

; ENGLISH VERSION - Stop_Serving_&_Check_Stock ; IF the goal is serving customers only ; THEN apologize for inconvenience and ; set a new mental goal to restock the Beer Wall.

(P Stop_Serving_&_Check_Stock(GoalA task serve_customers) ; Its fewest LHS ; conditional tests among rules clustered within the ; ‘serve_customers’ task mean Select state ; dominace will not be achieved until all beers are ; gone from the Beer Wall.

(say "OOPS Hold on. I ran out of beers, ile be rite back.") (modify 1 A task restock_wall) ; Check for unsold brews

) ; before considering closing the Wall.

; ***** RULE CLUSTER *****; ***** TO MAINTAIN BEER WALL INVENTORY ****

ENGLISH VERSION - Beer_Gone_Close_BusIness IF the goal is to restock the wall AND there is a Total Beers count, cal! it <cnt>, less than 1

THEN Apologize while closing the Beer Wall, clear folks out and make the next goal be to clean & dose up... HALT in suspended animation until more rules help out.

(P Beer_Gone__Close_Business ; The Termination Rule (GoalA task restock_wall)(Total__Brews A still_on_wal! { <cnt> < 1})

(say "Sorry folks. The beer is gone.")(say "Time to close down. See you tomorrow.")(say "Close the door behind you. Good nite.")(modify 1 A task clean_&_close) ; MOE didn't learn ; everything in one day, 'clean_&_close' training ; came later in his apprenticeship.

(halt) ; MOE goes into suspended animation till next time) ;

ENGLISH VERSION - Serve_NewfoundJnventoryIF the goal is to restock the wall only

THEN Greet customers on return from stockroom, smoothly lead into the first round of the Tune and set the current goal to serving customers.

(P Serve_NewfoundJnventory(GoalA task restock_wall); ..again, minimal LHS conditional ; test ensures this will be the last rule to dominate during ; the restock wall task.

; ENGLISH VERSION - Restock_the_Wall; IF the goal is to restock the wall AND ; there is a NON-empty Beer NOT on the wall AND ; there is a Total Beers count called <cnt> for now ; THEN put the NON-empty Beer on the wall ; increment the Inventory count of Beers on Wall and ; announce happily where the Beer was found.

(P Restock_the_Wall(GoalA task restock_wall)(BeerA on { <location> <> wall})(BeerA on { <location> <> empty})(TotaLBrews A stilLon_wall <cnt>)

-->(modify 2 A on wall)(bind <newcnt> (compute <cnt> +1))(modify 4 A still__on_wall <newcnt>); update inventory count (call location_word <location>)(say "Alright I found one on the ")(say where)

(say "Oh kay I am back and weave got")(modify 1 A task serve__customers)

)

; *** TEST CASE WMEs for FOUR (2x2) BEERS ***

(make BeerA on Wall); set one up - becomes original WME [1 ] (make BeerA on "Table"); set up - becomes original WME [2] (make BeerA on Wall); set one up - becomes original WME [3] (make BeerA on "Stool"); set up -- becomes original WME [4]

>(make GoalA task report_to_work) ; trigger open_for_business(make Total_Brews A still_on_wall 0) ; init counter

; ***** END LISTING-MOE THE BARTENDER, PART 1 ****

© 1985J.F. Salmons - Tutgrial/Review ExperOPS5™Prepublication Personal Communication— page 13

In Conclusion & With Reference

Congratulations if you have stuck with the article to this point. You are either irrepressibly attentive or, like me, you have an intense desire to open up the world of expert system and related technologies on your Macintosh. The selection of the opening Confucian quote was no accident. If your reading of this material stimulates a fraction of the excited insights I have had in preparing it, I can consider my effort rewarded. If on the other hand it reveals nothing to you, I apologize.

In either case, I encourage you to consider extension of this line of inquiry by running immediately to your local computer book store and picking up the two volumes which I have found indispensable to my own studies. The first, OPS5 specific, shatters the opinion that no truly great book is written by committee;

Brownston, L., Farrell R., Kant E., and M artin, N. Programming Expert Systems In OPS5: An In­troduction to Rule-based Programming. Reading: Addison Wesley Publishing Co., Inc. 1985.

Not only is an absolute necessity as a source of specific information on OPS5, it provides a fascinating overview of expert system technologies through its extensive cross- referencing between the particulars of OPS5 and other popular rule-based environments such as GRAPES, PRISM, DUCK, PROLOG, KEE, LOOPS and S .l. This book is worth every penny... as is;

Winston, P.H. Artificial Intelligence, 2nd Ed­ition. Reading: Addison Wesley Publishing Co.,Inc. 1984.

With most Lispers indebted to him for the classic, Lisp 2nd Edition, AI 2nd Edition is a fountainhead of inspiration as well as basic skills and concepts destined to become everyday fare within available Macintosh development environments. Extensively illustrated to communicate right hemispherically in conjunction with its crisp and ever-moving text, I challenge you not to be stimulated by Winston's outstanding condensa­tion of a vast range of knowledge previously accessible only to an elite group of dedicated computer scientists. It, too, is worth every penny.

So, at last I have reached the end of the Long and Winding Road, where the process of getting there is as important as the destination. And again, for any of my own confusion which I have inadvertently perpetuated and compounded by this effort, I apologize. Although Dennnis Bollay and ExperTelligence have been kind enough to produce and distribute this paper at the Apple Developer Conference, any errors or mistatements about ExperOPS5™ are purely my own, as they had no time to critically comment and correct a draft prior to attending the Conference.

Any reservation I had over the value of what I might say was overcome by my excitement in assessing the implications of the incredible technologies which are unfolding before us. I hope the enthusiasm and not my ignorance is contagious.

Jim Salmons Irvine, California December 1985

Notes

3

4

12 13from the E lectron ic C ottage...

This article is a "desktop publishing” product of the author. Among the companies whose

products made this possible, a special thanks to Aldus Corporation for Pagemaker, Apple

Computer for the Macintosh and LaserWriter and Microsoft for Word. For consultation,

services or information on Macintosh publication systems, contact JFS Consulting

Services (714)-731-9022.

TML

ExperOPS5A Rule-based, Data-driven

Production System Language for the development of

Expert Systems on the MacintoshM i n i jp§§§|P»»»11

j § |g |§ | |

An ExperTelligence New Product Profile

prepared by Jim Salmons

Ae1M©Siil [M@DDI]g)@[ii)<g@ i 0 © m s

© 1985J. F, Salmons - Tuprial/Review FxperOPSS™Prepubhcation Personal Communication— page 1

JFS Consulting Services: Al Special ReportPrepublication Personal Communication

ExperOPS5 : A Rule-based, Data-driven Production System Language Puts a Mindbehind a MacinTalk Tongue

Jim SalmonsConsultant! StudentIrvine, California

LISP has long been preferred within the Al research community as a language in which to write new languages— extending the forms and thereby the expressible content of communication between human and computer. This article showcases a new Mac-based commercial Al development environment, ExperOPSS™ from ExperTelligence o f Santa Barbara, Cailfornia. Sufficient information is presented for you to obtain a complete overview of the 0PS5 language and its production system computational model. Enjoy.

A Tutorial Application ExampleMOE the Bartender in “Apprentice’s Daze”An OPS5 cognitive model.

Sage Words from the Past The Master said, 7 never enlighten anyone who

has not been driven to distraction by trying to understand a difficulty or who has not got into

a frenzy trying to put his ideas into words* Confucius, ‘The Analects* VII.8

circa 500 B.C.

By this tutorial, Benevolent Master, I reaffirm my qualification for enlightenment.

“If you’ll give me one of those, I’ll...”or

The Hidden Cost of Paying for Software with Fast Talk & Big Promises

If all the folks more qualified to write this OPS5 tutorial laid head to toe around its circumference, they would just about reach around my head as swelled as it must have been that day in September when I marched up to a major Macintosh programming journal’s booth at the Anaheim AppleFest and announced my intention to contribute just such an effort. I am not an expert on OPS5 nor Expert Systems generally. This

brash tactic simply seemed an expedient means of getting ahold of some exciting new software that I couldn’t afford.

Well, it worked and this article is the result—the result of an adrenaline pumping rush into what is certainly yet another Mac-driven frontier of affordable access to computing environments which until recently were the province of the most elite and well-funded military, educational and corporate R&D labs. Unfortunately the magazine turned down the article. So—have LaserWriter, will publish—I share it with you, the attendees of the 1986 Apple Developer Conference.

OPS5 Origins: Charles Forgy & Carnegie Mellon

Among the early Al pioneering research centers, Carnegie Mellon University in Pittsburgh, Pennsylvania has a long history of significant and on-going contribution. During the late seventies and early eighties, Charles Forgy and his associates specified the grammar and ’an^efTicient interpretive architecture for the implementation of a new language called tiie Official Production System, or OPS acronystically speaking, which through revision is now generally called OPS5.

For those unfamiliar with the production system model, it is one of a number of conceptualizations of knowledge representation which Al scientists use to describe where and how information is stored and processed in “thinking machines”. The production system model has found wide use in the exploration of Al applications collectively known as expert systems. These systems are capable of performing at human expert levels within a limited task domain such as medical diagnosis, mineral exploration and computer system configuration among many uses cited.

The production system model is distinguished by its architecture consisting of rules (aka productions) held in Production Memory, data elements stored as a relatively unstructured global database in Working Memory and an Inference Engine which performs a recognize-act cycle to drive the relationship between rules and data.

Jim Salmons is a doctoral student of Mathematical Social Sciences at the This article or its variation will be submitted for publication considera-University of California at Irvine. His research interest is the applica- tion at a later date. In the interest of timely distribution of this informa­tion of expert system technology to the generation and interactive tion ExperTelligence has arranged for these prepublication copies to bedisplay of scoial network process models for human resource strategic made available at the Al Panel of the Apple Developer Conference,and interpersonal applications. He supports himself doing anything ExperOPS5™ is a product of ExperTelligence, Inc. Tele: (805)-969-7874.people will pay him to do on or about Macs. He can be reached by Mailing address: 559 San Ysidro Road, Santa Barbara, CA 93108.phone at (714)-731-9022 or 345 W. First Street #56, Tustin CA 92680.

The “Rule Gremlin”: anthropomorphic embodiment of an OPS5 ‘decision --> action’ Production Rule

EYES let it evaluate the state of data in Working Memory,a prerequisite to its decision to take action.

Condition Part (also Antecedent

or Situation)

PARTICLE BEAM PICKET TRANSMUTER is its means to action, providing shape

and color mutation as well as picket reordering using levitation and

a patented Particle Beam driven anti-matter staple.

Action Part (also Consequent

or Response)The individual Rule Gremlim’s BRAIN or BEHAVIOR CENTER takes a focused view of

the world dispensing Eastwood-like Transmuterized Justice to an unwitting and normally fun-loving decorative fence picket community. Slavish committment to taking specific

action triggered by fulfilled prerequisite conditions limits the range and extent of individ­ual rule’s understanding of and action on elements in its environment. But rules don’t

go it alone. In combination, these seemingly impotent individual rules transform and emerge as an entity of significant collective action commonly referred to as an

Expert System.

0PS5 Inference Engine... New Wave control structure squeezed in

a three step finite-state machine...

its “Recognize/Act” cycle delivers a

ritual and norms to channel the

collective expression of the rather autono­

mous activities of individual

Production Rules. There are no

GOTOs here... no frequent branchings to libraries of subroutines...

Hopefully “Rule-Gremlins & the Picket Fence” will

whet your appetite for rules and data to fuel this powerfully simple engine

reference between rules. startin9 with next month's column.Represented graphically, no edge can directly connect two rule-nodes.

Rule-to- rule influence is achieved indirectly by each fired rule's manipulation of the Working Memory Elements data. Graphically, 0PS5 rule interdepend­encies propagate along paths leading alternately from rule to data to rule to data and so on. This vital "broker's" role of Working Memory Element data mediating contact among a collection of rules aspiring to coordinated activity accounts for the DATA-DRIVEN characterization given to 0PS5 and related Rule-Based Production Systems.

“Rule-Gremlins & the Picket Fence”Although in danger of loosing its meaning through overly generalized

and non-critical usage, the term 'Expert System' was originally well-chosen by the early Al researchers. The term alluded to the hoped-for human

expert level of performance to be achieved by a computer program within its limited task domain.

Expert systems help doctors diagnose disease, geologist find oil, MIS managers configure computer systems among other real world commercial

and research applications. Regardless of the particular application, all expert systems share this common goal of achieving recognized excellence

in performing within its intended domain.

The five Rule-Gremlins, however, are happy if their collective activity occasionally results in completion of any of four acceptable configurations

(aka GOAL STATES) for a six-picket fence. To peek in on their Fence-making Task Domain, review the Goal Stales at right and Rules of

the Game on the top of the next page prior to following them around during a series of Inference Engine MATCH, SELECT and EXECUTE cycles. With this common ground and overview orientation behind us, ril tackle nuts and bolts in next and subsequent months. To share your

thoughts or contribute to upcoming issues, I can be reached by CompuServe ID# 72157,3577. VMCO-enhanced exchanges welcome.

' '

0 P S5

0PS5 Working Memory Elements disguised as Fence Pickets

. . . . . - . • ... But we’d rather be thought o f as fenceWe re talking primitive tZvsical obiectsdata typos here... ^ L L . a ^ e

No strong data typing for us.

. resources, ready for transmutation\ into the immensly popular Full Decorator

Picket Fence sold exclusively by Mac America..L . _ . /99

WME4

8'W- \ ]

WME5

99

\^E6

And don’t ‘ forget tip

SHAPE, g tool

We are literally Steralizedin Working Memory as the Picket Element Class... Attributes like the the class name being a mnemonic to associate c o t- o f our tips, various and sundry descriptive Attributes routinely \ ,used to differentiate one picket *instance’from another.... and ”

is ADJACENT to which?

Welcome to the first in a tutorial series exploring an exciting new Mac

implementation o f the renowned Carneige-Meilon developed RULE-BASED

PRODUCTION SYSTEM originally dubbed the Official Production System

(OPS). Through revision OPS matured to a standard now referred to as

OPS5. The commercially available implementation to be referenced for

on-going examples in this series is ExperTeliigence's recent publication

of Science Applications International Corporation’s implementation of a

robust OPS5 standard enhanced by virtually transparent access between

the data-driven ExperOPS5™ environment and the potent set o f display

graphics and Mac interface capabilities currently supported within Exper-

LISP™. In other words, our Macs are running the most dynamic OPS5

enviroments anywhere. ExperOPS5™ holds great promise as an access­

ible, affordable EXPERT SYSTEM development environment capable of

supporting serious research and commercial application development and

for that reason is worthy of attention. But what are you likely to get really

exited about is that THERE’S A NEAT NEW GAME IN TOWNI... Data-driven

programming is challenging and fun... ExperOPS5™provides a porthole to

access the exciting new world of data-driven languages where data-sensitive

unordered rules rather than sequenced instructions reign as the basic

unit o f computation.

Goal States for an acceptable Decorator Picket FenceThe collective action of the five Rule-Gremlins has achieved its purpose

IF any one of the following four Picket Tip Configurations (PTC) is generated: THEN HALT, (congratulations, you did it... now back to those transmuters!)

Goal 1 - All Dark Rounds3oal 3 - All Dark Points

oal 4Goal 2 - All -ite Rounds

____ i____ i__

All Lite Points___ fl____1__No one configuration is more valued than any other.

rCStep 1. M atching LHSes to WMEs. >OPS5 Inference

WMEs

MATCHES3_shapes_same

- 4 lWORKING MEMORY or DATA MEMORY

(aka a potentially decorative picket fence)

Engine/VsJL 8 /Un 8

0^=0= } {

J O o l l f l C L .0 0 0 } { OB0ago

} { 0 B 0: ^ a o } { o o Q ( c o o > t o o o

action: MUTATE

These four Match Lists represent all potential

|attribute combinations |among adjacent pickets j |whlch would trigger a

Rule-Gremlin’s adding ■fan element to the ^‘Instantiation’ list during i |the MATCH stage of the j | ‘Recognize - Act’ Cycle |o f the Inference Engine, ;

OPS5 Left-Hand Side |command syntax allows § || |compact, descriptive ^algorithms to specify |conditional restrictions | | | |on WME configurations. |Such data descriptive | abstract ion allows more | | | Icomplex rule building |than would be possible | | | | i f all Match Lists had to i | i | Ibe literalized in RAM |eating look-up tables.

r INSTANTIATTh#a r n n f

ION LIST: ^l i r t So*

RULE NAME WME BINDINGS

SHUFFLE_COLORS_2 WMEs 2 & 3 WMEs 4 & 5 WMEs 5 & 6

SHUFFLE_SHAPES_2 WMEs1 & 2 WMEs 3 & 4

MUTATE COLORS 3 WME 4, 5 & 6v J

MATCHES £_shapes_same

00 HOC)}{ Q 0 H O Q } { 0 O H O O > { 0 0 H Q Q }

ion; .SHUFFLE,..

PRODUCTION MEMORY or RULE MEMORY

(aka Fence Building Experts.)GOAL STATES

J T f W n jT iT iT i

action: HALT

|When all LHS Condition |Elements are met during jj |a rule’s inspection of jijWorking Memory, LHS variables are bound to

|attribute values matched !j |by WME configurations. \ |This binding allows faction affecting informa- jj ition to be passed to the ;j rule’s RHS as well as

H provides a means tointer-relate LHS

{ O Q H 0 0 } | I conditional restrictions.

^ 0 0 > ^ 8 0 } BjjjiLHS variable binding !:< ^restrictions on WME |matches are important § | in the Picket Fence fjexample because LHS j|

algorithms will !be based on the picket ADJACENCY

attribute restricting COLOR and SHAPE §

MATCHES colors same

0 0 H 0 0 > 0 0 } { 0 0 }tion: SHUFFLE

jj: equality comparisons by the Gremlins.