This preview shows page 1. Sign up to view the full content.
Unformatted text preview: d to model exceptions or overriding. Hence the distinction between implication and is-a speci cation is lost. There is no constructs to specify is-a speci city and hence the intended rule ordering is also lost. Some researchers have proposed complicated extensions to this approach to achieve the desired rule ordering 28, 75]. But this ad hoc xes makes it hard to use this approach to model object-oriented applications in general since these solutions are mostly application dependent. As pointed out by Kifer 46], it is easier and perhaps desirable to develop a new language altogether for object-oriented data modeling by extending the current technology with special constructs to capture objects, methods, classes and instances, is-a hierarchy, overriding, etc. We now show that, with appropriate adaptation, we can easily give a semantics to the Tweety program above. Consider the ORLog representation of the Tweety program of Figure 15 in Figure 16. The answer to the queries tweety locomotion ! fly] and tweety locomotion ! X ] 96 are shown. As can be seen that ORLog correctly assigns the intended meaning of the program and correctly computes the answers. r1 r2 r3 r4
0 0 0 0 : : : : bird locomotion ! fly]: penguin locomotion ! walk]: penguin : bird: tweety : penguin:
? tweety locomotion ! fly]: false ? tweety locomotion ! X ]: X = walk Figure 16: The ORLog representation of the Tweety program. It is easy to see that the structures present in ORLog (and other object-oriented languages such as F-logic 47], Gulog 29, 30], etc.) made it possible to capture the intended behavior of the program in Figure 16. Specially, the concepts such as locality, and inheritability played in important role in deciding which de nition of locomotion the object Tweety will inherit. Although, F-logic and Gulog will assign the same meaning to this particular program, they do so at a very high computational cost since they take a model selection approach. Moreover, they are not able to assign meanings to every program, as we shall see later. 6.1.2 Semantics Based on Translation
We now take an OOLP+ 25] representation in Figure 17 of the Tweety program in Figure 15. OOLP+ is a language which does not have its own semantics and proof procedure. Instead, it relies on rewriting every OOLP+ program into Prolog and giving a relational interpretation to the source programs in OOLP+. When rewritten in Prolog, the translated program looks like one in Figure 18. During translation, (i) every super class de nition of the form class a has super class b is translated into a Prolog clause of the form b(X ) a(X ), (ii) every method de nition of the form class a has methods p(Y) body is translated into 97 class class bird has methods transport-mode( y). wingless-bird has super class bird methodso transport-mode(walk). instance chipper is-a bird. instance tweety is-a wingless-bird.
? tweety ? tweety transport-mode( y). transport-mode(X). Figure 17: An OOLP+ representation of the Tweety program. a(X ) body, (iii) every overridden method de nition of the form class a has methodso p(Y) body is translated into a pair of clauses of the form p(X Y ) a(X ) ! p (Y ) and p (Y ) body, and nally (iv) every instance declaration of the form instance a is-a b translates simply into b(a). A message call of the form target p(X), however, translates as p(target X ) where target is an object id. An override method of a class overrides any other methods of the same name from the superclasses. The translation and assertion of an override method is identical to the method translation scheme, except that a cut (!) is inserted in the body of the clause after the rst sub-goal (which tests for class membership). The semantics of Prolog cut achieves the desired e ect of overriding. The answers to the queries are also given in Figure 18. The OOLP+ language uses keywords to override methods, and can not override class or instance variables. Hence it can not assign default values to instances. Furthermore, overriding is modelled via keywords and left as the responsibility of the users and hence is open to errors. Furthermore, it is not suitable for bottom-up computation due to the presence of the cut in overridden methods. p(X Y )
0 0 98 r1 r2 r3 r4 r5 r6 : : : : : : bird(X ) wingless-bird(X ): transport-mode(X fly) bird(X ): transport-mode(X Y ) wingless-bird(X ) ! transport-mode (Y ): transport-mode (walk): bird(chipper): wingless-bird(tweety):
0 0 ? transport-mode(tweety fly): false ? transport-mode(tweety X ): X = walk Figure 18: Prolog representation of the Tweety program in OOLP+. 6.1.3 Comparison with F-logic
F-logic does not directly capture behavioral inheritance as in code reuse. The only way to realize it is by simulating it via F-logic's pointwise overriding and deduction. But then, this makes it the programmer's responsibility. Consider Example 3.2. In our case clause (8) produces p m ! 2] by code reuse (as discussed in Example 3.2), while F-logic (for the program as it is in Example 3.2) will inherit the ground dat...
View Full Document