jamilthesis

# On the other hand clause 13 is inherited in r since

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: clause (7), and now there is a unique ancestor q of r that de nes t0 . The \intended" model of P1, formalized in section 3.5.3, is the one in which these de nitions of locality and inherited clauses are respected. Intuitively, (omitting some obvious atoms) we expect the \intended" model of program P1 to contain (among others) the following ground atoms. The complete intended model for the program P1 can be found in Example 3.3. fo ] q ] p : o q : o r : p r : q r :: o(for o = o p q r) q u ! d] o m ! 5] o v ! g] p m ! 2] p s ! 2] p t ! a] p u ! d] p v ! g] q m ! 5] q s ! 5] q t ! c] q v ! g] r t ! c] r v ! g]g. It is interesting to see how we expect p m ! 2] in p. Since clause (8) is inherited in p, it follows by De nition 3.4 that the inherited clause in p is (8 ) = (o m ! X ] o s ! X ] o v ! g]:) o= ] = p m ! X ] p s ! X ] p v ! g]: Since we have p s ! 2] =p in clause (11) and p v ! g] is an instance of clause (14), we now have p m ! 2]. In contrast, (8) inherited in q will become q m ! X ] q s ! X ] q v ! g]: In a similar way we can show that q s ! 5] follows from clause (9). Hence, we have q m ! 5]. This is code reuse { the code for m0 in o is reused by p q and r by dynamically interpreting the context o as \self", namely, the current context of the method. Nicely enough, we have overriding built into the de nition of inherited clauses. Notice that the code for m0 is evaluated in p using the de nition for s0 in p, not the de nition of s0 in o. We are now also able to resolve con icts in inheritance in two di erent ways { by detection and by preference speci cation. Observe that clauses (9) and (11) de ne s0 at both o and p. Let 1] denote the ground closure of 1. According to the de nition of r( 1] s0 r), r inherits neither since intuitively uniqueness of inheritance of s0 in r is lost. Thus with respect to con ict resolution by detection, we take a conservative ! ! ! ! ! ! 0 ! ! ! ! ! ! ! 45 approach. In particular, even if p and q (or o in this case) de ne identical values for s0 , our semantics would reject both. This is a conservative approach and can be justi ed by the following facts. Methods are usually de ned using programs and are computed. Since testing for equivalence of programs in general is undecidable, we take the view that two de nitions in di erent classes are potentially con icting. Hence we reject all. For the sake of uniformity, we also take a similar view to a ground case, which is a special case of a method de ned via a unit ground atom. However, we go a step further to lend a hand to the users to indicate a preferred inheritance from a particular superclass. In this way, users may resolve con icts using withdrawal. For example, although clauses (12) and (13) de ne method t0 at p and q, r inherits t0 from q by inhibiting t0 from p through clause (7). This is con ict resolution by preference speci cation, where the user has full control of how the con ict is to be resolved. 2 ! ! ! ! 3.4 Interpretation Structures A semantic structure S of the language L is a tuple of the form hD O O Id Is L C W i, where D is the domain of interpretation, O is an irre exive binary relation among objects in D, O is a partial order among objects in D which is induced by O , and Id Is L C W are interpretation functions that assign meaning to the symbols in L. Intuitively, D includes the objects and basic values needed to interpret the object identities and constants in L. The irre exive relation O is the semantic counterpart of the immediate is-a association of objects. The partial order O is induced by the O relation since is-a associations are also non-trivially implied by the immediate is-a relation. Note that, for every object o in D, o O o trivially holds, but o O o does not. Thus, O is the re ective transitive closure of O . Formally, the domain D of the semantic structure S includes (i) a set of objects O, (ii) a set of elements B corresponding to basic values, and (iii) a set of elements, one each corresponding to each type name 2 T . For simplicity and clarity, we suppose that the set (iv) above is T itself. Clearly, there is no loss of generality in doing so. So we can suppose that D = B O T . Notice that D includes the domain of elements D corresponding to each type 2 T . In order to keep the semantics rst-order, we treat objects and classes as well 7! 7! 7! 7! 7! 7! 46 as subclasses and instances in a uniform manner. Thus, an object could be viewed as an instance of its superclass object as well as a subclass of instances below it in the object hierarchy. This mirrors a standard trick in mathematical logic 31] which is adopted here in order to provide a rst-order semantics for a language which is syntactically higher order. Models such as \Higher-Order" logic 57] and (earlier) F-logic 47] follow a similar approach. We now de ne the interpretation functions of S . The function Id interprets each symbol in L as follows7: Id associates each object id i in IO with a unique object in O. Id maps each constant c of sort in C to an element of the corresponding basic domain D , i.e...
View Full Document

## This document was uploaded on 01/10/2011.

Ask a homework question - tutors are online