From: AAAI Technical Report WS-96-05. Compilation copyright © 1996, AAAI (www.aaai.org). All rights reserved.
Object-Oriented ProgrammingSupport for CLASSIC
Ralf M~iller University of Hamburg,Computer Science Department Vogt-KOlln-Str.30, D-22527Hamburg, Germany moeller@in formatik,uni-hamburg, de
Abstract:The main thesis of this paperis that in order to tional programmingpoint of view it is irrelevant useDescription Logics in practical applications, a seamless whether a result of a function call is defined by integration with object-oriented systemdevelopment meth- merely looking up a set of instances in a relation odologiesmust be realized. It presents an object-oriented table or by actually computinginstances with com- programminglayer for CLASSIC. plex algorithms and auxiliary data structures. Sec- 1. Introduction ond, using genetic accesser functions for retrieving the objects that are directly set into relation to a spe- Althoughthe logical semantics of Description Logics cific individual allows a lot of error checkingcode to (DL)modeling constructs is a big plus, to ensure deci- be automatically generated. A unified interface for dability of the subsumptionproblem, the expressive- accessing the services that an object provides hides ness of the logical language must be limited. The manyrepresentation details whichare irrelevant from consequenceis that in a real application without toy a moreabstract perspective. problems, currently not all aspects can be formally modeled with DL constructs. This means that pro- For example,in a graphical user interface, the draw- grammingis still necessary. As a DL we use the ing function for an object might depend on the CLASSICsystem [9]. Reducing CLASSICto practice object’s concepts. User interface programmingis one [1] means that the DL can be integrated into the of the best examplesfor the application of object-ori- whole system development approach which, at the ented programmingtechniques. For rapid user inter- current state of the art, uses object-oriented modeling. face development however, an existing UIMSmust In this paper, the CLOSOOP perspective will be used be reused. UIMSsprovide powerful programming [10]. Thepaper presents an object-oriented programming abstractions which are modeledwith the object-ori- layer for CLASSIC.It assumes basic knowledgeabout ented representation techniques (e.g. for CLOSthe CLOS1 [3]. UIMSCLIM might be used [7]). There is no way to rebuild these software libraries with CLASSICor The integration of CLASSICand CLOSrequires that any other DLin a reasonable time. So what can be genetic functions and methods can be written for done? Copying information associated with a DL CLASSICindividuals. The procedural parts of an object into a CLOSobject which is used for UI part application should be able to use CLASSICindividu- of an application is inadequate as well. Unfortu- als just like CLOSinstances. The "services" of an nately, managing multiple "copies" of the same object are accessed only by the use of generic func- object is a direct contradiction to the principles of tions. This meansthat the relational part of CLASSIC object-otiented programming.Thus, for rapid appli- should be hidden behind a functional layer because, cation development, object-oriented programming from a software engineering point of view, dealing techniques must be made available to CLASSICindi- with individuals and relations earl be quite cumber- viduals. The next chapter discusses an approach that somefor at least two reasons: First of all, froma func- demonstrates how this can be achieved with an extension to CLASSICthat uses CLOS-like genetic 1. Thispaper is a shortenedand rewritten version of a paperpre- functions to access information about an individual. sentedat OOPSLA’96[5]. Theextensions for the CLASSICsys- It will be shownthat the implementation of CLAS- tempresented in this paperare availablefrom the author[6]. SIC methoddispatch can be surprisingly simple.
- 170- 2. Integrating OOP and DL ated. If they do not already exist, corresponding generic2 functions are automatically generated. Generic functions for Description Logics have also been developed in the LoomSystem [2]. Methoddis- The first role option :single-value-p specifies patch for individuals is provided by specific genetic whether a single value or a set of values should be functions which dispatch on ABoxobjects but not on returned by the role reader function. The other option CLOSobjects. Loomalso supports CLOSclasses for :error-if-null is used to insert code for error the implementation of ABoxindividuals but only a checking to avoid an empty set to be returned. The limited sort of reasoning is implemented on these following example illustrates the use of define- instances (no dynamic reclassification by forward accessor. For concept and role declarations the inferences). KRSSsyntax is used [8]. (define-primitive-conceptship classic-thing) Theapproach presented in this paper clearly separates (define-primitive-rolehas-position-x nil) CLASSICand CLOSbut provides a unified way to (define-primitive-rolehas-position-y nil) access the services of both systems. (define-accessorsship (has-position-xposition-x : single-value-pt 2.1. Accessors: A Functional Interface to a :error-if-nullt) Knowledge Base (has-position-yposition-y CLASSICitself provides a relational interface for : single-value-pt :error-if-nullt) retrieving and adding role fillers. Givenan individual and a role, the set of fillers can be retrieved: (cl- As in CLOS,for accessing information of an object, fillers
For each role description mentionedafter the concept 2. The explicit declaration of a generic aeeessor function is nee- name, a reader method and a serf writer method for essary, for instance, whena special methodcombination that dif- the generic function
- 171- (either :clos or :classic). Just as defgeneric function can be defined as follows (comparethis to from CLOS,define-generic-function alSO sup- initialize- instance from CLOS). ports ordinary argumentswithout specializer (called (define-methodinitialize-individual :after other-arguments). The optionsfor define- ((ind
- 172- 3.1. Reducing CLASSIC dispatch to CLOS (DEFMETHOD F-METHOD dispatch ( (A The implementation of generic functions and method (# : TYPE6807
- 173- (find-class(first class-names) three times slower than directly using CLASSIC’s (let ((class (gethash class-names retrieval functions on the sameprocessor. *class-table*) ) ( if class (find-class-prototypeclass) 4. Summary (let* ( (class-name(gensym)) The main thesis of this paper is that in order to use (class (find-class class-name)) Description Logics in practical applications, a seam- (ensure-clos-class less integration with object-oriented system develop- : name class-name ment methodologies must be realized. Extended : superclassesclass-names) generic functions and multimethods with CLASSIC (setf(classic : : di-clos-instance ind) dispatch not only allow an incremental way of soft- ( find-class -prototype ware definition. In addition to this, they can even (find-classtype-name) ) been seen as a form of defining assertions that (setf (gethash class-names *class-table* ) enforce a safer systemarchitecture also for the proce- class) dural parts (the sameholds for CLOS[4]). (find-class-prototypeclass) ) ) ) References With access to the internal data structures of CLAS- SIC (classic: : di- clos- instance), an individ- [1] Brachman,R.J., "Reducing"CLASSIC to Practice: KnowledgeRepresentation Theory Meets Reality, in: ual can be directly associated with its CLOS Prec. KR’92Principles of Knowledge counterpart, i.e. the procedure compute- type- arg Representationand Reasoning,Nebel, B., Rich, C., is used only when the individual is reclassified. Swartout,W. (F_xls.) MorganKaufrnann Publ., 1992, pp. 247-258. CLASSIChas been extended to reset the association [2] Brill, D., LoomReference Manual, Version 2.0, between an individual and its CLOSrepresentative USC/ISI,4676 AdmiraltyWay, Marina del Rey, CA whenthe individual is reclassified. 90292, December,1993. [3] Keene,S.E., Object-OrientedProgramming in The definition of compute-type-argindicates that CLOS:A Programmer’sGuide to CLOS,Addison- the straightforward implementation of CLASSICdis- Wesley,1989. [4] Lamping,J., Abadi,M., Methodsas Assertions, patch comesat a certain cost. In addition to static XeroxPale Alto ResearchCenter, available as: costs for the definition of CLOSclasses for named ftp ://parcftp. xerox, com/pub/ openimp I ementat ion s/methods - as - CLASSICconcepts, there are some initial dynamic assertions, ps. Z. costs: [5] M611er,R., A FunctionalLayer for Description Logics: KnowledgeRepresentation Meets Object- ¯ some calls to retrievalfunctions (classic:cl- Oriented Programming,in: Prec. OOPSLA’96,in name, classic : cl- ind-parents), press. [6] MOiler,R., ExtendingCLASSIC with Generic ¯ a complex hashing operation over a list of sym- Functions and Methods, http://kogs - bols, www. informatik, uni-hamburg, de/ ~moeller/, 1996. ¯ possibly a dynamiccreation of a CLOSclass, [7] M611er,R., User Interface ManagementSystems: ¯ The CLIMPerspective, http ://kegs- the access to the CLOSclass prototype, w-w-w, informatik,uni-hamburg, de/ ¯ and an additional CLOSdispatch step for the sub- ~moeller/uims-clim/clim- intro, html, 1996. stitute argument. [8] Patel-Sclmeider,P.F., Swartout,B., Description Furthermore, a lot of garbage is created (mapcar). LogicSpecification from the KRSSEffort, ksl. stanford, edu :/pub/knowledge- Measurements on a Symbolies MacIvory-Model-3 sharing/papers/dl- spec. ps. indicate that a dispatched access to a relation with a [9] Resnick,L.A., Borgida,A., Brachman,R.J., generic function created by define-accessors McGuiness,D.L., Patel-Schneider,P.F., Zalondek, K.C., CLASSICDescription and Reference Manual takes less than one millisecond. This is approximately for the CommonLisp Implementation,Version 2.2, 1993. [10] Steele, G.L., CommonLisp - The Language,Second Edition, Digital Press, 1990. - 174-