From: AAAI-84 Proceedings. Copyright ©1984, AAAI (www.aaai.org). All rights reserved. VERY-HIGH-LEVEL KNOWLEDGE PROGRAM-MING REPRESENTATION Stephen Stanford Kestrel J. Westfold University Institute, paper using proposes system, BC, representation maintenance The heritance. by describing base features, which allows program in the the same knowledge porated into the program a whole easier of BC description be ex- and its This knowledge as well as making incor- the system as and extend. BC attachment. are given in [Westfold, definitions later in this language including A knowledge-based gram and a knowledge knowledge guage language that piled. be specified This that the may be viewed based to define using of the and t.here is a mechanism very-high-level program, into the BC, knowledge same with the words, components itself non-uniform, techniques with different base. In this The of key to its [Green tem way BC ponents, pre-processing and in the knowledge- system. that crossing 344 a matheand func- is convenient syntax the parser properties by BC. By use BC whose problem structure is specification. interfaces In can be defined of the different but the implementation and taking domain in that transformation the description of the problem for define are defined have program interfaces con- can users; (compilation) uniform for of existing that that of the of the system, can be advantage in order of to produce program. in this the CHI paper implementation: parallel ment, the data useful in building whole is better use of BC structure derivation, manager, and BC tested CHI includes make algorithm database are being knowledge-based et al., 19811. all of which design, systems. is described designer as equivalence convenient, differencing, This research is supported in part by the Defense Advanced Research Projects Agency Contract NOOOld-81-C-0582, monitored by the Office of Naval Research. The views and conclusions contained in this paper are those of the author and should not be interpreted as representing the official policies, either expressed or implied of KESTREL, DARPA, ONR or the US Government. two of these for defining relations objects such from ideas in building as relations, for system into manipulation views an efficient and main- is the compiler, it is used efficiently other com- as part is convenient for the user and to facilitate repre- knowledge which and different such is basically in terms the system an implemented quite program to be viewed program. can produce lan- describes system, their of and proce- BC language Thus language of manipulation sets, constructs of mathematical facilitate The repre- can be efficiently the base as a knowledge so that paper of ease of comprehension knowledge incorporation knowledge knowledge This they are associated specification efficient be used uses. features for EC structs, terms of a pro- a very-high-level programming so that in BC advantages allows in a special the knowledge-based Furthermore, tainability the can consists the program interprets. language languages the same that is essentially the program how BC sentation base that a very-high-level shows typically base is expressed sentation can system types implementation of the. first logic, new language that entities particular 19841. This this for representing paper. tions. converts of implementation link maintenance, defining a language The to define The specification language a descrip- a description representation inverse the new constructs. fj1 Introduction be used into and or solving knowledge matical factored schemes can inheritance, The language efficiently include for fully be be solved description property features to to of the solution. schemes dural language very-high-level can sub-problem. in- features. to be more to understand can representation programs problem of the problem as examples, and property representation a knowledge-based to be written links allows of the the implementation a programming providing language a knowledge its knowledge systems can be used to implement of inverse specification to include tion on a very-high-level of such and shows how BC automatic permits based an overview knowledge tended knowledge-based system It gives CA 94304 BC building a programming language. and Palo Alto, ABSTRACT This OF SCHEMES itself. Many knowledge-based than just by using sys- the following com- in their specification selection, algorithm and project program of these manage- analysis, finite components systems, RC for building BC programming are so CHI as a knowledge-based $2 Overview BC is essentially from of the that problem are needed assertions and the dition parts: the the in an efficient assertion an action (applicability after condition) formulas, written definition of the how the defining language in terms Lisp. by language, (what is VLogic, P+Q where P is the precondition (Note that symbol part of specification Compiler into to make many that rules different a rule inference. The is the Rule called the ‘j’ that part that (RC). It works to other [B arstow, as PECOS and D ar 1in gt on, 19771. TI procedure. rules [Balzer, At intermediate (with form as the consequent. Lisp be treated as an implication. systems 19811, stages and of constructs in a The use second of the left. general considered a special case the to using An equality is a directionality a function can dimension is choice provides the code. The result as a the con- advantage but each using of typically one. For ex- an equality of code. of other important maintain as a rule. ing the rule to form and then state, that circumventing for the compila- at compile time is to Constraint incor- where a proce- compilation involves us- in logic of the relationship states before producing and after a procedure will produce the relationship. The intermediate convenient form for performing constraints stated in logic the efficient, an assertion affects of compilation Rule a statement the computation application, for and producing as constraints. is done at the stage is expressed versus at com- use of assertions and use them poration of compile-time of compiling tion initial or, assertion Use of an assertion interfaces use is a procedure an with possibility specification-level between to forward to enforcing be defined compile-time dure the is commutative, use of an assertion. time An to to backward or taking associated j of or right j(z)=def. third tangled latter be also direction corresponds the the can It may to the corresponds latter r. left, to right Considering the former and run-time pile and inference. constraint, precondition the former which with r ==+p=q example: from inference goal-directed clean of BC to the an implication corresponds form: For implication, The Compiler with dimension general or data-driven the form 1. Structure BC of in- either of an implication For of step- into there Figure type may have a precondition antecedent an equality ample, 1 forms as the the constraint. Assertion equivalence of the general straint Logic be used. the corresponds is used: considered framework. LAC for p=9is written all these includes first that asser- an inference proThe user specifies should of choice The in VLogic into P=+Q Each guage be used that written assertion. dimensions of the assertion stat- a mixture of constructs so a wide-spectrum lan- must three LAC refinement the program contains from very-high-level to low-level, unified language, of equality) particular by a process transformational 19791, logic language a procedural procedure be used context, of that compiles to that Assertion could and instructions of BC a number predicate Lisp. assertion is the assertion Logic and in what is a specification similar logic which inferences, inference Compiler wise refinement is is the defined refined postcondition. and the F rom an assertion, particular produces compiles VRL; inference or an equality BC (LAC). ing which [Burstall Q is the construct for implication.) The such and ’ -+ ’ is a procedural each specialized ference It contains is the basic specification a specification particular form it Use of Assertions compiles provides V and a first-order language by converting cedure is called group. a rule language, Procedural LAC CHI which the target which as by the sub-languages: used by BC; tions BC CHI. V was initially 19821 and has since been [Phillips, of integrated VP;,and by throughout extended 2.1 used used Phillips and A of two logical language language of its precon- and postcondition consists to in going to procedural A rule ob- It is convenient rule (procedure) its application). basic of auxiliary about language code The implementation and information logic Lisp assertions. definition use an intermediate rule specifies true produces of logic are to be used procedurally. identify from of three domain; domain; that in the form consists problem The a compiler a specification specification jects of BC a new state statement inference assertions. the rule that, that given satisfies in logic is a to incorporate Use of an it to the assertion run-time vironment. at run time constructs requires available Therefore we need to consider the model of computation the specification basically level a recursive any run-time Goal-directed, mented efficiently adding an extra of a function In order need extra procedures are triggered need are that are uses a database be function the goal (Transform that be the values imple- [function, by the that attached values of a property for argument. is called, that 2.3 The Specifying The ways ing simple BC and VRL. is written then to describes an assertion the basic of LAC the it. value to see function Run-time use is encapsulated The the function necessary to specify the name section (the formi computes (the Other are fni, are options are: of the function For of being machine and then assertion the an is to be used This value some the error values examples storage is used forms assertion into equivalent form to that The it can implementation for the use of assertions to get in Zetalisp 19811 [Weinreb Compatibility and is in the has been and Masinter, assertions particular has been designed BC and and this compile preprocesses form to specify as the links that developed on a DEC and Moon, in 2060 19811 Package on Symbolics of Knowledge attached first Inverse example in a database. assertion repre- are for main- inheritance. are specialized Other treatment and memoing of com- Links is the convention, quantified, so f, assertion. task This requires database, f-‘(y)=z of maintaining that whenever is also informally inverse f(z)=y stored. The as necessary. The is: (f)= f(z)=y 346 only triples, knowledge presented procedures, used is introduced this defining and property in the By that properties. inverse tests) for language or for database of binary-relation examples is stored basic a simple have been specified Maintaining ones. redundant basis of inverse for optimiza(or both), retrieval tenance The whether with and features links violated) begin The 3.1 (Backward) remove needed in Lisp was compiled version. form features. puted in database) if assertion as a constraint Lisp where Interlisp of transitivity, functions) to be computed) to be maintained compile-optimize (Use functions of RC machines. The forms) use it is necessary or as a constraint transforming the in its own languages-VLogic of RC was written implemented. [Teitelman provides use it is whose (Closed ... (Give For compile-time tion triggering generate for- ... (Save computes check the fna, fn; memo the ones BC can of BC of LAC Interlisp form that For backward forma, the new annotation, stage into the correct sentation formr, from which 53 Example Implementations Representation Features by BC. is to be computed: triggered-by New basic by attachThis the triggering to be called. the exact part process 3600 as a function. to specify given version is at the in the them for is one. are specified provided of these annotations. specification replaced given which is examined a Lisp to the assertion. options ward use it is necessary causes is used in terms primarily ,4 basic the VRL version How to Use an Assertion meta-assertions that, Internally, of assertions. at the meta-level basic to by their referent. annotations. properties Implementation BC using 2.2 meta-level be defined demons way are called procedures if there produce may be referred is an unambiguous meta-level can the equivalent may functions When otherwise we in the database in this of a property the database value, the value from properties. form) triples things other is needed, value] and inference are the basic using logic assertions be done (the forward is a stored computing argument, are treated an equivalent so that can objects the value if this are simply annotations so that compute This as mappings constraint) and they need function stores that Storing they wanted. the form to the forms function These they environment. somewhere to maintain form For convenience primary may involve procedures target time, that when of Functions may trigger in the (Forward) code compile-transform is in the form forward-inference arguments) properties. if there can This to be attached found indexed store a functional at the appropriate a database may means into inference form in-line is This functions. machinery to store values values. which model. so that to implement The with Lisp model to be put run-time using definition they the have Lisp (Add en- call. some to be able the function inferences form. and target two models as inference of computation: at compile-in-line converting in the g A one-to- one (f) =+ g(y)=z unbound variables g, z and y are universally are universally quantified over 3.1.1 Maintaining Constraint the ’ with a that Run-time One way makes make Procedure of maintaining a demon function whenever a property that the constraint is executed is stored. to This attach the inverse add can The is to be specified code (f>=g A one-to-one(f) fb>=y = triggered-by a=‘Sutisfy as where “triggered-by means whenever be made + =+ which, g(y)=2 f(z)=y p is asserted (stored) annotation the assertion should true. LAC produces the following demon from this uses a generalized of a triggering f(z)=y, event-in and a procedure applicability condition one- to-one(f) make its right-hand database. The that database side DB the rule This ineffectual forward RC compiles then each the (NEQ true if its new 3.2 someit is im- would be from the order RC in which Property of the procedures the in the x y z) are functions conjuncts is to be used--either respec- in-line code, inverse way to maintain specified (f)=g and used. maintain specification of the BC scheme and the derives can ways code for or use the invariant invariant, so all the of property inheritance Using the if all elephants in this same value are the color grey, then we can deduce VLogic these z E elephants example that statements is all for a property. and Clyde Clyde is the color are: =+ color (z)=grey and Clyde E elephants then the database system should deduce that asked for color(Clyde). are used and how tested or used to bind A scheme with In-line the constraint Code all-prop scheme this behavior property color-of-all) This is to add for doing inheritance property is for each (e.g. that color), applies and connect property to the these that to introduce set has a cor- as a whole two properties by the ( coloT )= color-of-all). (so all-prop can be described by the invariant: as follows: A one-to-one(f) (z E s =+ p(z)=p-of-all(S)) =$ f(z)=y g(y)=2 compile-in-line j(z)=y where is for z as are consistent. when example (e.g. An alternative invariant that of a set having responding the Constraint which rule is looking color (CIyde)=grey this Maintaining single type members if simple of It may by f -‘(y)=z, another a single it is to be maintained grey. is stored in this a test f(z)=y. of just shows how an implementation by stating is an elephant, into the database, when each The code: y g) x) does the Inheritance section procedures a variable. 3.1.2 also be used to optimize that y g x)))) (db-put in compil- of y. For example, and storing what may for example, from and of infinite a property form into code to make A f-‘(y)=2 t 0 a test be used to replace f (z)=y be described 1 DB( g( y)=z) Clisp to be to make of state. constraint This in the f ‘inverse))) (db-get x y) and Basically transformed state A in the stored action the act expressions new expressions change as an intermediate is later quotes side match cause means where bold is to in the because possibility (db-put (db-get conjunct true the following ((g (db-get whenever is decide (f)=g action if z is stored applying is executed for retrieving left-hand side It is used that a function a rule whose whose the condition also f ‘one-to-one) then tively. only the rule into (let on the Satisfy(p) change useful, chaining. (if database. case is inverse side) being prevents (if (db-get that this it is explicitly Thus from case the assertion is used to distinguish because something redundant. con- DB( g( y)=z) predicate is true from which right-hand on the The which and if and by the database. prevents this (left-hand is true construct body-in A 1 DB( g(y)=z) DB( z) state. plied demon in-line Sutisfy(Ihs(m)=n) in single f(r)=y ~B(g(Y)=4 + this lhs-of(n)=m) Th e f orms and A 1 DB(g(y)=z) to (f) transforms lhs-of. that desired g A one-to-one(f) (f)= code A g(y)=z)’ A as patterns p be true. f( z)=y inverse This (lhs)= ing rules, trigger extra for adding one-to-one A example, constructed. specification: (f)=g u=‘!htisfy(f(z)=y for inverse that add (f(z)=y)’ Satisfy(lhs(m)=n into p” is a meta-level compiled, rule procedure compile-time A inverse inverse thing is being true. is: follows: sists p true the assertion “compile-in-line p” means In that whenever the invariant.” code 347 following, We I z refer want to to all-prop(p)=p-of-all this use as this the “scheme invariant to compute value p(z) of when is To maintain For example, serted, when need to make of the the are expressed complete specification of this we These that all-prop in BC - 3.2.3 Maintaining The it is used and p-of-all. third when is: when it looking native, from similar could be used when needed at how this each LAC scheme value in different three ways: that is stored then In this case, Computing The an Inherited first case puting p(z) f rom the scheme is deriving * puting color (Clyde) as color-of-all converts the scheme treating the equivalence merging the nested with invariant procedure (elephants). to the form into r + p(z)=d all-pTop (p)=p-of-all function - produces 3.3 implication all-prop(p)=p-of-all Default the partial sal statement x E S + This variant involves conjunct as the trigger + gives the p-of-all(S)=v. that z should default be returned direct as the the property individual scheme is not in our logic inheritance scheme conflicts with with value to be used only We can scheme is basically an extra condition: (DB(p(x)=l) A for is a member stored the DB is for an the value on the set if a specific known. using scheme of property by the sets the individual words, value of the above value for a value express predicate. the same the The as the xE S =k p(x)=p-of-most(S)) = most-prop(p)=p-of-most Inheritance procedure is given In other default a variation a specific may be given which is a default xE S A stored is Links is made. a For to ensure relevant subset univer- example, is asserted, there when it using hand side as a triggering the typically of the other, equivalence condition of the sary to carry out this the for the procedure. inleftThe 348 condition a most-prop then S A x E 5’1 A p-of-most makes scheme and using a stronger by adding the ones above. implication, undefined. are two sets with be expressed color-of-all. as a left-to-right I_ means In fact, necessary whenever color(z)=color-of-all(S) all-prop (color)= all-prop(p)=p-of-all Inheritance in which particular means second all-prop E procedure: AI systems of. function: value (p-of-all(S)) Maintaining The second In many where that split A (2: E S =+ p(x)=v) implemented of the function. 3.2.2 to the scheme x f S =+ p(x)=v the property p(x) value (x) where value in order converts by A z E S =+ p(x)=p-of-all(S). all-prop (p)=p-of-all + the demon individual LAC q =+ v whose and becomes this, This variable as antecedent: (x E s =+ p(x)=p-of-all(S)) From as- (assuming LAC implication a single is into the form a new p-of-all(S) and all-prop (p)=p-of-all com- First to p(x) trigger for com- for example as a right-to-left implications a conjunction following invariant, For x)=grey p-of-all(S)=v. Choosing Property a partial assertion p(x)=p-of-all(S). all-prop(p)=p-of-all is also stored. 3.2.1 made. into p when color (Clyde)=grey the scheme b y introducing 2 E S =$ p(x)=p-of-all(S) constraint of computing instead be maintained. color( + p-of-all store color-of-ull(elephants)=grey converts is equal an alter- this to are invariant: procedures we mention to emphasize it could Clyde E elephants of the specification, necessary statements x E elephants adds the equality Before is universal p-of-ull(S)=d x E s =N p(x)=p-of-all(S) is derived Properties all-prop (color )=color-of-all). that all-prop(p)=p-of-all S * p(z)=~, z E Inheritable procedure suitable example, p computes triggered-by (p)=p-of-all. uses serted, (x E s =$ p(x)=p-of-all(S)) p(x)=p-of-all(S) all-prop and is asserted, by saying p and used to maintain + is as- color-of-ull(elephants)=grey. assertion is stated: 2E S 3 true of p-of-all. and the instances =+ color(z)=grey demon trigger invariant all-prop(colo7)=color-of-all, z E elephants to compute because x E S=+ color(x)=color-of-all(S) when we need to make later, The all-prop to update resulting the example, color-of-ull(elephants) al l-prop (cola? )= color- of-all. we need For applicable. color (Clyde) the smaller is used so that value set is used. the further condition (Sl) # _L]. The scheme with 13 procedures are all derived if one set a This can Si [Si C neces- similarly to $4 Related The [Genesereth Work Russell specification language be used to express knowledge. of BC with facility respect with schemes allows to be described relation logic it to sentation the schemes of property of sets, specifier to logic. inheritance A similar scheme elements more others, have may should be Other are 19793, et and systems that [Stefik et al., These systems lows for building a more useful be useful for representation these be combined may for the particular their specification of the system. such systems the closely supply where linked provides as and in that easily. specified integrated like BC, aims the implemen- goal is in contrast to knowledge semantic networks language tools of to decouple of the user from specification provides but because and used a few implementation BC of as needed implemented knowledge. It may in BC, modified the user with compile BC it al- on a library frame is more representations. for the user to speci.fy et Beverly Kedzierski, choices how to System J” Kestrel [Green and Westfold. Press Implementation: Software An Engineering, Example,” January, [Barstow, 19791 Program Construction. Library, Holland Balzer David 1981, Barstow. pp. 3-14. Westfold, [Hayes, Wiley). Computer Series. Science Elsevier-North Report Cordell 10. Ellis Daniel KES.U.81.1 Green, Stephen Self Applied,” Forward and Halsted “The Logic of Frames, (eds) Readings Publishing Aiello, “AGE 19791 (Attempt Based Program in ” in B. in Artificial Company, 1979, pp. 1-I. Penny to for Building Proceedings of Palo Alto, Ca., Nii Generalize): and A Knowledge-Bused the Sixth on Artificial Nelleke KnowledgePrograms International Intelligence. J” Joint Tokyo, Japan, 645-655. [Nilsson, 19801 Nils J. Nilsson, Intelligence. Tioga Principles Publishing of Artificial Company, Palo Alto, Ca., 1980. [Phillips, 1982) Programming Theory [Stefik et Sanjay al., Programming 19831 Mittal pp. [Teitelman and Masinter, 19801 Ca., Daniel AI G. “Knowledge Magazine Vol. 4 19811 Warren Interlisp Vol. 14, 4, April van that Consultation Science 1981. A Melle, Aids Teitelman Programming in Domain- Constructing Programs. Department, Ph.D. Stanford 1980. and Lisp Moon. Stefik, Conway. “The William system Computer University, J. Lynn Masinter, ” Computer, Melle, Science 3-13. and Larry Computer Ph.D 1983. Mark and of a Systems. and University, in Loops J” in The 3, 1983, Thesis, -4n Application Engineering Stanford Bobrow, Self-Described Phillips, to Programming Electrical Departments, No. Jorge Environments: of Design Thesis, Moon, Machine 19811 Daniel Manual. Weinreb Symbolics, and David Chatsworth, 1981. [Westfold, 19811 TINTEX,” Internal Stephen “Documentation Westfold Report. Kestrel Institute. for Palo Alto, 1981. Science 44-67. and Programming 1982. Tioga and Aiello. 24 No. pp. Phillips, 1979. Ca., 1977. 1980. Angebranndt, Programming and N. J. Nilsson Intelligence. [Burstall and Darlington, 19771 Rod M. Burstall and John Darlington. “A Transformation System for Developing Recursive Programs J” in Journal of the ACM. Vol. 1. January, 19821 19791 P. J. Hayes. L. Webber [Weinreb Knowledge-Based The Programming Language Inc. New York. 1979. “Transformational Transactions on IEEE Technical Intelligence (John [van Robert Jorge Susan Mont-Reynaud, “Knowledge-Based independent 19811 Green, Knowledge-Based Institute Knowledge-based [Balzer, Computer December 1981. March, Environment, References University, Bernard Me tu-level HPP-83-28, Cordell a Genesereth, “A Tom Pressburger, “Towards Chapiro, IJ Memo 19811 Westfold, Michael Smith. Stanford al., Stephen Conference of facilities systems. to draw and Aiello, [Genesereth a set to the actual whereas BC systems [Nii view and tightly This representations MRS AGE 19831 and MRS MRS, they 19801. [Green Dave System, Department, [Nii knowledge-based language that languages knowledge-based features in BC. the specification tation [Nilsson, lan- for synthesis. flexibly system the amongst in order 19791, builder knowledge because Science 19831 al., and Representation in Machine prototypical different to be programmed a system properties. representation programming-oriented facilities use repre- is in terms from logic 19801, 19831. are useful 3.2 the building Melle, LOOPS al., t,akes [Hayes, for [van to the formulation to express to be used as a tool EMYCIN no BC between knowledge using easily have Hayes and Nilsson, understood more logic Knowledge of example, be analyzed better compared allows that is the that in section difficult to logic is less direct. utility knowledge properties relation guages ability relations inheriting argued the For and is a little defined to relate can representation be given quantification, the main implemented. may However, logic. encourages which representation, knowledge and schemes is logic, However, to knowledge which representation for BC et Greiner, [Westfold, cations 19841 for Steph en Compiling. Department, Stanford Westfold, Ph.D. Logic Thesis, University, 1984. SpecifiComputer