, , 1{27 ()
c Kluwer Academic Publishers, Boston. Manufactured in The Netherlands.
On the Declarative and Procedural Semantics of Deductive Object-Oriented Systems GILLIAN DOBBIE
[email protected]
RODNEY TOPOR
[email protected]
Department of Computer Science, Victoria University, Wellington, New Zealand
School of Computing and Information Technology, Grith University, Nathan, Qld 4111, Australia
Editor: Michael Kifer Abstract. We present declarative and procedural semantics for a deductive object-oriented language, Gulog. The declarative semantics is based on preferred minimal models. We describe both bottom-up and top-down query evaluation procedures and show that they are sound with respect to the declarative semantics. The results contribute to our understanding of the interaction of inheritance, overriding and deduction in the presence of both functional and set-valued methods, and multiple inheritance. Keywords: complex objects, deductive databases, xpoint semantics, procedural semantics, knowledge bases, object-oriented databases, rule based
1. Introduction The aim of this paper is to propose a simple mathematical foundation for objectoriented systems with deduction. In particular, we present a declarative and procedural semantics for a simple language that includes classes, objects, functional and set-valued methods, (multiple) inheritance, overriding, and derived methods and predicates with the aim of providing better understanding of how to eectively apply and implement these concepts. Several proposals that have previously addressed dierent aspects of this problem are (Abiteboul, 1990a), (Abiteboul, 1990b), (Abiteboul, 1989), (Abiteboul, 1993) (Beeri, 1990), (Delobel, 1991), (Kim, 1989), (McCabe, 1992). In general, this work has succeeded in providing insight into the interaction of some of these concepts, but either the semantics of the language is described by a translation to a logic programming language, thus providing little direct insight, or all the concepts are not addressed in the language. The description of F-logic by Kifer et al. in (Kifer, 1990) does provide a direct semantics of a large set of concepts, and our work is intended to provide an alternative description with the aim of providing additional insight into the relationships between the dierent concepts. In (Dobbie, 1993a), we de ned and studied a simple deductive object-oriented language, investigating the interaction of deduction, inheritance, and overriding in the simplest possible context. In particular, we considered only functional methods, de nite clauses, and simple inheritance. In this paper, we extend this language with
2
set-valued methods and multiple inheritance. These additions make the language more expressive and provide more powerful modeling facilities. The new language is called Gulog. Some of the de nitions changed substantially with the addition of set-valued methods. We describe the reasons for these changes and use examples to highlight them. Our main contributions are the de nition of a declarative semantics for this richer language and generalizations of our bottom-up and top-down query evaluation procedures. As in (Abiteboul, 1990a), our language separates schema declarations from data de nitions, and as in (Kifer, 1990) it allows methods to be overridden on speci c instances of a subclass, which generalizes many other deductive object-oriented languages. The declarative semantics is based on Przymusinski's perfect model semantics for logic programs (Przymusinski, 1988). This semantics requires the de nition of a priority relation between atoms (and between models). The priority relation between atoms is based on overriding as well as negation. As in Przymusinski's perfect model semantics the de nition of preferred models is based on this priority relation. We also de ne bottom-up and top-down query evaluation procedures. The bottom-up method requires the program to be partitioned according to the priority relation and generalizes Apt et al.'s construction of the standard model of a strati ed logic program (Apt, 1988). The partitioning ensures that clauses de ning overriding methods are lower than clauses de ning methods that may be overridden. In the top-down procedure, a set of possible answers for a selected literal in a goal is computed, the subset of minimal answers according to a priority relation is selected, and the minimal answers are applied to the rest of the goal. Both procedures are sound with respect to the declarative semantics. In (Abiteboul, 1993), Abiteboul et al. discuss method resolution. Method resolution consists of choosing at least one method de nition, where the same method name may correspond to several method de nitions. Abiteboul et al. consider two kinds of resolution: static and dynamic. Gulog, F-logic (Kifer, 1990), and the dynamic inheritance in (Abiteboul, 1993) use dynamic method resolution. However, we provide a new characterization of the semantics of dynamic method resolution by showing its relationship to similar methods used in the semantics of logic programs. This dynamic approach to overriding in Gulog (and F-logic) is more general than that of L&O and the static inheritance in (Abiteboul, 1993), as it allows a method in a superclass to be overridden by a method in a subclass for some instances of the subclass but not others, depending on whether the body of the method de nition in the subclass succeeds or not. This generalization appears to be necessary for reasoning about inheritance hierarchies in arti cial intelligence (Touretzky, 1986), if there is no way to describe views in the language (Abiteboul, 1993). In this paper, we extend the language described in our earlier work (Dobbie, 1993a) with two new language features. The rst extension is the inclusion of set-valued methods as introduced in F-logic (Kifer, 1990). This extension allows us to write programs that manipulate sets, without the use of set-valued variables. The second extension is the inclusion of multiple inheritance. We impose a restriction that allows a class to have several superclasses, but that restricts each method to in-
3
herit its de nition from at most one of its superclasses, as in (Mumick, 1993). We brie y discuss how this restriction may be lifted by de ning a static ordering on the superclasses of a class, or by including annotations in the program that specify at run-time which superclass should be used for inheritance. The paper is organized as follows. In Section 2, we introduce the syntax of Gulog. In Section 3, the declarative semantics of Gulog is described. Sections 4 and 5 outline the bottom-up and top-down query evaluation procedures. In Section 6, we brie y describe two approaches to resolving ambiguities that arise due to multiple inheritance. In the nal section, we discuss the signi cance of this work and suggest further work in this area. Due to space limitations we have omitted proofs, which are included in the full version of the paper (Dobbie, 1994b).
2. Syntax and informal semantics In this section we describe the syntax of declarations, and of programs with respect to a set of declarations. We describe typed substitutions and a class of programs that we are particularly interested in, namely simple programs. Gulog can be considered as either a deductive object-oriented logic (cf. F-logic) or as a deductive object-oriented database programming language. In the latter interpretation, each program in the language, which includes both facts and rules, corresponds to a database. Similarly, goals in the language correspond to queries. The syntax of Gulog is based on that of F-logic (Kifer, 1990), which originated from Maier's O-logic (Maier, 1986), which in turn was strongly in uenced by LOGIN (Ait-Kaci, 1986). In order to concentrate on the semantics of inheritance and overriding in a well understood context, schema declarations are separated from data de nitions, as in the relational approach. As in C++, we distinguish between objects and types (or classes). To maintain a general approach, method overriding can be de ned on speci c instances of a subtype. Our approach to the de nition of the semantics of set-valued methods is dierent from that of (Kifer, 1990), but both involve dynamic rather than static inheritance. De nition. A declaration is de ned as follows: If and 0 are type symbols then < 0 is a type lattice declaration. We say is a subtype of 0 , and 0 is a supertype of . For any type 00 such that 0 < 00, is also a subtype of 00 and 00 is a supertype of . If < 00 or = 00 we write 00. If a is an object symbol and is a type symbol then a : is an object declaration. We say a is an object of inherited type . For any type 0 such that 0 is a supertype of , a is also of inherited type 0 . If p is an n-ary predicate symbol and 1; : : :; n are type symbols then p(1 ; : : :; n ) is a predicate declaration. We say the signature of predicate p is 1 n .
4
If m is an n-ary functional method symbol and ; 1; : : :; n; 0 are type symbols then [m@1; : : :; n ) 0 ] is a functional method declaration. We say the signature of functional method m is 1 n ! 0. If m is a 0-ary functional method symbol, we write [m ) 0]. If m is an n-ary set-valued method symbol and ; 1; : : :; n; 0 are type symbols then [m@1 ; : : :; n ) ) 0 ] is a set-valued method declaration. We say the signature of set-valued method m is 1 n ! ! 0. If m is a 0-ary 0 set-valued method symbol, we write [m ) ) ]. For each object declaration, we introduce another type to the type lattice. Let a : be an object declaration, we introduce type a, such that a < and object a is of type a. Clearly, the minimum type of object a is type a. With the new type, we are able to generalize the results in (Dobbie, 1993a) to apply to methods that act only on one instance. The relation < is a partial order on the set of type symbols. There is exactly one declaration for each object symbol, predicate symbol, functional method symbol and set-valued method symbol. We now de ne data de nitions. Data is de ned by a program with respect to a set of declarations. As described above, the declarations de ne a set of types arranged in a lattice, a set of typed object symbols, a set of functional method symbols each with a given signature, a set of set-valued method symbols each with a given signature, and a set of predicate symbols each with a given signature. We do not assume that the type lattice has a top or bottom element. It is possible for the same symbol to be used for both functional and set-valued methods. In Gulog, variables are typed. De nition. If x is a variable and is a type then x : is a typed variable de ning that variable x is of type . A variable typing is a set of typed variables where each variable is distinct and will be denoted by ?. In this paper, we say an object or variable t is of type if is its minimum type. If t is of type and < then t is of inherited type . The de nitions of terms, atoms, and clauses are similar to those in logic programming except that in Gulog we include type information. De nition. A term is de ned as follows: ? ` x : is a term if x is a variable and x : 2 ?. We usually write ? ` x when the type of x is obvious. The variable x can be assigned an object o if and only if o is of inherited type . ? ` a : is a term if a is an object of type . We write the term simply as a when the type of a is clear. The term ? ` t : is called a ground term if t is not a variable. De nition. An atom is de ned as follows:
5
If p is an n-ary predicate symbol with signature 1 n and there ex-
ists a variable typing ? that contains type assignments for all the variables in t1 ; : : :; tn, and ? ` t1 : 1 ; : : :; ? ` tn : n are terms with 1 1 ; : : :; n n , then ? ` p(t1; : : :; tn) is a predicate atom. If m is an n-ary functional method symbol with signature 1 n ! 0 and there exists a variable typing ? that contains type assignments for all the variables in t; t1; : : :; tn and t0, and ? ` t : , ? ` t1 : 1; : : :; ? ` tn : n, and ? ` t0 : 0 are terms with , 1 1 ; : : :; n n and 0 0, then ? ` t[m@t1 ; : : :; tn ! t0 ] is a functional method atom. We say method m is de ned on type . If m is an n-ary set-valued method symbol with signature 1 n ! ! 0 and there exists a variable typing ? that contains type assignments for all the variables in t; t1; : : :; tn and t0, and ? ` t : , ? ` t1 : 1; : : :; ? ` tn : n, and ? ` t0 : 0 are terms with , 1 1 ; : : :; n n and 0 0, then ? ` t[m@t1 ; : : :; tn ! ! t0 ] is a set-valued method atom. We say method m is de ned on type . An atom is a method atom if it is a functional method atom or a set-valued method atom. The atom ? ` A is a ground atom if A contains no variables. Let ; denote ! or ! !, and M be a 0-ary method atom ? ` t[m@ ; t0]. M can be written ? ` t[m ; t0]. Clauses are used to de ne methods and predicates. Each clause also has type information. De nition. If ? ` A; ?1 ` B1 ; : : :; ?n ` Bn are atoms where the variables common to ?; ?1; : : :; ?n have the same types then ? [ ?1 [ [ ?n ` (A B1 ^ ^ Bn ) is a clause. A is the head of the clause. B1 ^ ^ Bn is the body of the clause. We can write the following compound atoms: ? ` t[m1@t1;1 ; : : :; t1;n ! t1; : : :; mj @tj;1 ; : : :; tj;k ! tj ], as a shorthand for ? ` t[m1@t1;1 ; : : :; t1;n ! t1 ] ^ ^ t[mj @tj;1; : : :; tj;k ! tj ]. ? ` t[m1 @t1;1; : : :; t1;n ! t0 [mj @tj;1; : : :; tj;k ! tj ]], as a shorthand for ? ` t[m1 @t1;1; : : :; t1;n ! t0 ] ^ t0 [mj @tj;1; : : :; tj;k ! tj ]. ? ` (t[m@t1 ; : : :; tn ! ! ft01 ; : : :; t0pg], as a shorthand for ? ` t[m@t1 ; : : :; tn ! ! t01 ] ^ ^ t[m@t1 ; : : :; tn ! ! t0p ]. If a1 ; : : :; ap are object symbols we can write ? ` t[m@t1 ; : : :; tn ! ! fa1 ; : : :; ap g] B1 ^ ^ Bm as a shorthand for the p clauses: ? ` t[m@t1; : : :; tn ! ! a1 ] B1 ^ ^ B m .. . ? ` t[m@t1; : : :; tn ! ! ap ] B1 ^ ^ B m :
6
If ? ` t[m ! y] (resp., ? ` t[m ! ! y]) is an atom, where ? ` t: is a term then this atom is of type . The type of a predicate atom is unde ned. If the head of a clause is an atom of type , then the clause is of type . A goal does not have a type. De nition. A goal is a clause of the form ? ` B1 ^ ^ Bn , i.e., a clause with an empty head. If ? is empty we write B1 ^ ^ Bn . De nition. A program with respect to a set of declarations is a nite set of clauses. Let P be a program with respect to a set of declarations D. Then [P]D denotes the set of all ground instances of clauses of P with respect to D. We write P (resp., [P]) when the set of declarations under consideration is clear. Example 1 Consider a database that records information about failures in reactor systems. There is a lattice of failures where total failure (tf) is a special kind of feed system failure (fsf), total failure is also a special kind of condenser failure (cf), feed system failure and condenser failure are special kinds of cooling system failure (csf), and cooling system failure is a special kind of system failure (sf). When there is a failure, there are inputs from the system that indicate if measurements like temperature and flow are high or low. In this example we record the failure identi er and the date of the failure. We assume the existence of a function that generates today's date and an equivalence predicate. Consider the declarations D: csf < sf cf < csf fsf < csf tf < cf tf < fsf r1 : reactor temp sensor : part high : degree low : degree f1 : tf reactor[failure@date ) ) sf] sf[problem ) string] sf[temp ) degree] sf[flow ) degree] and the Gulog program P with respect to declarations D: fx : reactor; d : date; y : sf; z : stringg ` x[failure@d ! ! y] y[problem ! z] ^ d = today fx : sf g ` x[problem ! \system failure"] fx : csf g ` x[problem ! \cooling system failure"] x[temp ! high] fx : fsf g ` x[problem ! \cooling system ow high"] x[flow ! high] f1[temp ! high] f1[flow ! high]: The goal fx : reactor; y : date; z : sf g ` x[failure@y ! ! z] asks for x, y and z such that reactor x has a system failure z on date y. We de ne substitutions that are similar to those in logic programming except that they are typed and hence satisfy additional restrictions.
7
De nition. Let ? ` fx1 =t1; : : :; xn=tn g be a pair where x1; : : :; xn are distinct variables, ? ` t1 ; : : :; ? ` tn are terms, and no ti equals xi. ? ` fx1 =t1; : : :; xn=tn g is a substitution if for each i, ? ` xi : i and ? ` ti : i are terms, and i i . The empty substitution is denoted by ". De nition. An expression (? ` T) is a term, a predicate atom, a method atom, a conjunction of atoms or a clause. A simple expression is a term, a predicate atom, or a method atom.
We now describe how substitutions are applied to expressions. De nition. Let = (? ` fx1=t1; : : :; xk =tk g) be a substitution and E = (?E ` T) an expression. For any i, such that 1 i k, let ? ` xi : i and ? ` ti : i be terms and xi : i0 be a typed variable in E (with respect to ?E ). We say range() = ft1; : : :; tk g and vars(T) is the set of variables in T. Construct T 0 from T by simultaneously replacing each occurrence of a variable xi in T by ti . Construct ?0 , a variable typing for the variables in T 0 , as follows. For each variable x in T 0, if x is identical to a ti for some i, then the typing of x in ?0 is x:glb(i; i0); otherwise the typing of x in ?0 is just that in ?E . If for each variable xi in vars(T) \ range(), ti is a variable and glb(i ; i0) exists, or ti is an object and i i0 then the instance E of E is ?0 ` T 0 ; otherwise, E is unde ned. If E is ground, then E is a ground instance of E. Example 2 Assume D is the set of declarations from Example 1 plus the object
declaration f2:sf. Let E be fx:fsf; y:stringg ` x[problem ! y] and substitution be fx : sf; x0 : cf g ` fx=x0g with respect to declarations D then the instance E is fx0 : tf; y : stringg ` x0 [problem ! y]. Let 1 be fx : sf g ` fx=f2g. E1 is unde ned because sf 6 fsf. Let S = fE1; : : :; Eng be a nite set of expressions and a substitution. Then S denotes the set fE1; : : :; Eng. We now describe how substitutions are composed. De nition. Let 0 be fx1=t1 ; : : :; xn=tng, 0 be fy1 =s1 ; : : :; ym =sm g, and and be the substitutions ? ` 0 and ? ` 0 . Construct from fx1=t1; : : :; xn=tn; y1=s1 ; : : :; ym =sm g (with respect to ? and ? ) by deleting any binding xi =ti for which xi = ti , and deleting any binding yj =sj for which yj 2 fx1; : : :; xng. Construct ?, the variable typing for the variables in as follows. For each variable x in , if x: 2 ? [ ? then include x: in ?, otherwise if x: 2 ? and x: 0 2 ? then include x : glb(; 0 ) in ?. If for any variable x, where x : 2 ? and x : 0 2 ? , glb(; 0 ) does not exist, then = ; else = ? ` .
8
is the composition of and . To ensure that programs have well-de ned semantics, we impose restrictions that ensure they are \strati ed" and that functional methods really are single-valued. Programs that satisfy these restrictions are called \simple". Before de ning the classes of strati ed and simple programs, we must de ne a relationship \possibly overrides" between clauses. De nition. Let D be a set of declarations, P be a program with respect to D, C be ? ` x[m@y1 ; : : :; yk ! z] B, (resp., ? ` x[m@y1 ; : : :; yk ! ! z] B) and C 0 be ?0 ` x0 [m@y10 ; : : :; yk0 ! z 0] B 0 (resp., ?0 ` x0 [m@y10 ; : : :; yk0 ! ! z 0] B 0 ), where C; C 0 2 P, ? ` x : is a term, ?0 ` x0 : is a term and < . If there are ground instances C of C and C 0 0 of C 0 such that x = x0 0 , yi = yi0 0 for all i, 1 i k, and z 6= z 0 0 then clause C possibly overrides clause C 00 with respect to P and D. A program is inheritance-strati ed if there are no cycles in the de nition of a method. That is the de nition of a method does not depend on an inherited de nition of the same method. De nition. A program P with respect to a set of declarations D is inheritancestrati ed (or i-strati ed) if there exists a mapping from the set of ground atoms to the set of non-negative integers such that, for every ground instance C of every clause C in P, (A0 ) (A), where A0 is an atom in the body of the clause instance C, and A is the head of the clause instance C, (B 0 ) < (A) for every ground instance C 00 that possibly overrides C, where B 0 is an atom in the body of C 00 and A is the head of C, and (A0 ) (A) for every ground instance C 0 0 that possibly overrides C, where A0 is the head of C 00 , and A is the head of C. Example 3 Assume the declarations in Example 1. Consider the following program
P with respect to declarations D: fx : sf g ` x[problem ! \system failure"] fx : csf g ` x[problem ! \cooling system failure"]
x[problem ! \system failure"]:
Then [P]D is: f1[problem ! \system failure"] f1[problem ! \cooling system failure"] f1[problem ! \system failure"]:
(1) (2)
9
Method problem is a functional method. It has either the value \system failure" or \cooling system failure". If it has value \system failure" then it should also have value \cooling system failure" (due to deduction). If it doesn't have value \cooling system failure" then it should have value \system failure" (due to inheritance). This is contradictory. Thus we conclude that program P has no natural meaning. Based on the above declarations, we can say that Clause 2 possibly overrides Clause 1. The i-strati cation of [P]D requires (f1[problem ! \system failure"]) (f1[problem ! \cooling system failure"]) (f1[problem ! \cooling system failure"]) (f1[problem ! \system failure"]) (f1[problem ! \system failure"]) < (f1[problem ! \system failure"]); which is unsatis able. Hence P is not i-strati ed. We now present examples, which illustrate ambiguities that can occur due to multiple inheritance. The rst illustrates possible schema ambiguities and the second possible data ambiguities. Example 4 Consider the system description in Example 1 and the following decla-
rations: csf < sf fsf < csf tf < fsf tf error < fsf error cf[problem ) cf error] \call supervisor" : tf error
cf < csf tf < cf tf error < cf error fsf[problem ) fsf error] \check history" : tf error:
The type of the value of method problem when applied to an object of type tf could be cf error inherited from cf , fsf error inherited from fsf , or cf error and fsf error inherited from cf and fsf . In Gulog the type must be compatible with both parents. That is, the type of the value of method problem when applied to an object of type tf is tf error. Thus inheritance of signatures is monotonic as in F-logic. The following example illustrates alternatives when values of methods are inherited from more than one parent. Example 5 Now consider program P with respect to the declarations in Example 4:
fx : cf g ` x[problem ! \call supervisor"] fx : fsf g ` x[problem ! \check history"]: An object of type tf could inherit the value \call supervisor" for method problem from cf , or inherit the value \check history" for method problem from fsf , or inherit both values.
10
For simplicity, in this paper, we disallow programs with ambiguities that arise due to multiple inheritance. In Section 6, we brie y discuss alternative ways of dealing with multiple inheritance that are less restrictive but more complicated. We rst describe what an unambiguous program is. De nition. Let P be a program and D a set of declarations. For each type in D, let R() be f j functional method m! of arity n is de ned on type ; and g [ f j set-valued method m! of arity n is de ned on type ; and g. Program P is unambiguous with respect to D i for every type in D, if 2 R() (resp., 2 R()) and 2 R() (resp., 2 R()), then either 1 < 2 or 2 < 1 . Now, to ensure that functional methods really are single-valued, we impose the following condition on programs. De nition. A variable z is restricted with respect to the terms t, t1 ; : : :; tn in the conjunction C if C contains a method atom t0[m0 @t01 ; : : :; t0k ! z] and any variable in t0 , t01; : : :; t0k either occurs in t, t1 ; : : :; tn or is itself restricted with respect to t, t1 ; : : :; tn in the remainder of C. For example, the variable z is restricted with respect to a and x in the conjunction a[m0 @x ! y] ^ a[m00@y ! z]. De nition. A program P with respect to a set of declarations D is well-de ned if the following three conditions hold: For each clause ? ` t[m@t1 ; : : :; tn ! u] C in P with respect to D, u is either an object symbol or a variable that is restricted with respect to t, t1 ; : : :; tn in C. This is the usual \safety" condition. For each functional method m of signature 1 n ! 0 , and for each type , program P with respect to D does not contain two clauses ? ` t[m@t1 ; : : :; tn ! u] C ? ` t0 [m@t01 ; : : :; t0n ! u0] C 0
such that ? ` t : , ? ` t0 : are terms, and atoms t[m@t1 ; : : :; tn ! x] and t0 [m@t01 ; : : :; t0n ! x0] (where x and x0 are new variables) are uni able. This condition ensures that, for objects a, a1 ; : : :; an and functional method atom a[m@a1 ; : : :; an ! t], there is at most one clause of each type whose head is uni able with the atom. This together with the rst condition ensures that functional methods really are single-valued. P with respect to D is unambiguous with respect to multiple inheritance.
The following example illustrates how the conditions are applied to exclude unreasonable programs.
11
Example 6 Assume appropriate declarations D. Consider program P with respect
to D:
fx : csf; y : stringg ` x[problem ! y] temp problem(x; y) fx : csf g ` x[problem ! \cooling system failure"] x[temp ! high]:
In this program, an object of type csf may have more than one value for the functional method problem. Thus the functional method problem is not singlevalued. More formally, based on the de nition of well ? defined programs above, this program is not well-de ned because fx : csf; z : stringg ` x[problem ! z] and fx : csf; z 0 : stringg ` x[problem ! z 0 ] are uni able. In addition, the program is not well-de ned because the variable y is not restricted with respect to x in the rst clause in P. We can now de ne a class of programs that can be shown to have well-de ned and natural semantics. De nition. A program P with respect to a set of declarations D is simple if the following two conditions hold: P is i-strati ed, and P is well-de ned.
3. Semantics In this section we describe the declarative semantics of a program. We rst de ne typed Herbrand interpretations and models. A simple program may have more than one minimal model, so we de ne a priority relation that is used to identify preferred models of a program. We start by de ning a Herbrand interpretation of a program P with respect to a set of declarations D. The interpretation assigns a truth value to every ground instance of a clause in P. The typed Herbrand base of P with respect to a set of declarations D is the set of all ground atoms that can be formed from the typed objects, typed predicates, typed functional and set-valued methods in P with respect to D. De nition. A typed Herbrand interpretation I for P with respect to a set of declarations D consists of a set of ground atoms of P. De nition. Let ? be a variable typing. A variable assignment V (with respect to ?) is an assignment to each variable x of an object o such that, if x : 2 ? and o : 0 2 D, then 0 (with respect to D). De nition. Let ? ` t : be a term and V a variable assignment (with respect to ?). Then the term assignment T (based on V with respect to ?) is the assignment to each term ? ` t : of an object a as follows:
12
If t is a variable, then T (t) = V (t). If t is an object symbol, then T (t) = t. De nition. Let I be an interpretation, ? ` A an atom, and T a term assignment (with respect to ?). Then an atom is given a truth value in I (with respect to T and ?) as follows: If A is p(t1; : : :; tn), and t01; : : :; t0n are the term assignments of t1; : : :; tn (with respect to T and ?), then ? ` p(t1; : : :; tn) is true in I (with respect to T and ?) if p(t01 ; : : :; t0n) 2 I. If A is t[m@t1 ; : : :; tk ! tn ], and t0 ; t01; : : :; t0k ; t0n are the term assignments of t; t1; : : :; tk ; tn (with respect to T and ?), then ? ` t[m@t1 ; : : :; tk ! tn ] is true in I (with respect to T and ?) if t0 [m@t01 ; : : :; t0k ! t0n ] 2 I. If t[m@t1 ; : : :; tk ! ! s] is a set-valued method atom, and t0 ; t01; : : :; t0k ; s0 are the term assignments of t; t1; : : :; tk ; s (with respect to T and ?), then ? ` t[m@t1 ; : : :; tk ! ! s] is true in I (with respect to T and ?) if t0 [m@t01; : : :; t0k ! ! 0 s ] 2 I.
A ground instance of a clause is given a truth value in I (with respect to T and ?) in the normal way. Because of the presence of inheritance and overriding, we require one more concept before we can de ne a \model" of a program. De nition. Let P be a program with respect to a set of declarations D, and I an interpretation. A ground clause C overrides a ground clause C 0 with respect to P, and I if: C possibly overrides C 0 with respect to P, and the bodies of C and C 0 are both true in I. De nition. Let P be a program with respect to a set of declarations D, and I an interpretation. We say that I is a model of P if, for every ground instance C 0 of a
clause in P, either: C 0 is true in I, or there exists another ground instance C of a clause in P such that C overrides C 0 with respect to I. If I is a model of P, we write I j= P.
Note that a program with respect to a set of declarations may have more than one model and that not every ground instance of a clause need be true in a model.
13
As in (Przymusinski, 1988), we can de ne a priority relationship between ground atoms (but using possible overriding instead of negation), and use this to de ne a preference relationship between models. As in (Przymusinski, 1988), we prefer models in which there are fewer occurrences of higher priority atoms. We say a model of a program P with respect to a set of declarations D is preferred if no models of P are preferable to it. De nition. Let P be a program with respect to a set of declarations D. We de ne a priority relation