We use this example to intuitively understand the

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: s in terms of the introduced concepts in this section in a close to real life application. In the next example we will explain the working of ORLog in greater detail with a more abstract application. tseat := firstclass + ecoclass tseat ecoclass := 300 inheritance conflict inherits firstclass := 50 noeng := 2 inherits (as a result) inherits noeng := 4 Example 3.1 Consider an aircraft design database scheme in OR notation 40] (in- reject overrides firstclass := 25 p_craft p_craft.noeng:int c_craft r_craft md10 dc1030 b747 h333 tseat := 325 if inherits code for tseat tseat := 350 if inherits value for tseat l370 h50 Figure 4: An Aircraft Design Database Scheme. In Figure 4, we abuse the OR notation and in most cases show the values and codes corresponding to methods in the scheme instead of their signatures for brevity and simplicity. The ORLog program P = h i6 corresponding to this scheme 0 0 0 0 We used molecular formula in this example a la 47] as follows: p craft crew ! 4 noeng ! 2] p craft crew ! 4] ^ p craft noeng ! 2]. 6 42 is given in Figure 5. In the diagram of Figure 4, p craft, r craft and c craft refers to passenger aircraft, rescue aircraft and cargo aircraft respectively. In the diagram of Figure 4, the attribute rstclass in instance object md10 overrides the corresponding attribute value in its class p craft. Hence, the value of tseat (total seats) at the p craft level is 350 while the value at md10 will be 325 since md10 inherits the code for tseat, not the value (350) from p craft. But dc1030, for example, will have 350 as the value for tseat since it inherits the value for rstclass and ecoclass from p craft and hence inheriting the code for tseat from p craft does not make any di erence even when the code is evaluated at the dc1030 level. Furthermore, since r craft inhibits noeng from p craft, noeng in c craft can now be inherited in r craft (and onward) since r( ] noeng0 r craft) = c craft. 0 ! 0 (1) (2) (3) (4) := (5) (6) (7) (8) (9) md10 : p craft: r craft : p craft: r craft : c craft: h50 : r craft: l370 : r craft: h333 : c craft: dc1030 : p craft: b747 : p craft: r craft noeng0 < p craft]: ! 0 := 0 (10) p craft ecoclass ! 300 firstclass ! 50 crew ! 4 noeng ! 2]: (11) p craft tseat ! T ] p craft ecoclass ! E f irstclass ! F ] T = E + F: := (12) md10 firstclass ! 25]: (13) c craft noeng ! 4 tseat ! 4]: (14) X makeen ! p&h] X :: c craft: Figure 5: Example program P 0 0 0 Now the question is what P entails? Leaving the details to be explained in example 3.2, we expect the following from program P among several others. 1. h50 :: c craft 2. p craft tseat ! 350] 3. md10 ecoclass ! 300] { inherited from p craft. 43 4. md10 tseat ! 325] { using inherited tseat code in p craft. 5. h50 makeen ! p&h] { by deduction. It is interesting to observe how we expect md10 tseat ! 325] rather than md10 tseat ! 350] from program P . Since r( ] tseat0 md10) = p craft, the code for tseat0 is inheritable in md10. Then we have the clause 0 0 ! ! md10 tseat ! T ] md10 ecoclass ! E f irstclass ! F ] T = E + F: p craft ecoclass ! E f irstclass ! F ] =md T = E + F:) p craft= 10] =md by context switching from p craft to md10 in rule 11 (i.e., apply p craft= 10]) as (p craft tseat ! T ] which now correctly yields md10 tseat ! 325]. 2 1 1 1 Example 3.2 Consider the following program P1 = h and r. Usually, the l- and i-clauses are not speci ed by the users. Rather the users implicitly assume the locality and inheritability of clauses according to the De nitions 3.2 and 3.4. (1) (2) (3) := (4) 1 (5) (6) (7) i with objects o p q o ]: q ]: q : o: p : o: r : p: r : q: r t0 < p]: ! 1 := (8) o m ! X ] o s ! X ] o v ! g]: (9) o s ! 5]: (10) P u ! d] P : o: 1 := (11) p s ! 2]: (12) p t ! a]: (13) q t ! c]: (14) Q v ! g]: Figure 6: Example program P1 From De nition 3.2 it follows that clauses (8) and (9) are local to object o only. Similarly clauses (11) and (12) are local to p, and clause (13) is local to q only. However, clause (10) is local to p and q since these are the two objects P in P1 for which P : o holds true. Note that (10) is not local to o since o : o never holds in ORLog. In fact, it is local to only p and q. If we change P : o to P :: o in the body, then (10) becomes local to all four objects in P1 since :: is a partial order. Clause 44 (14) is clearly local to all four objects. This is simply because the descriptor of (14) is a variable and is not constrained by any is-a literal in the body. Clause (8) is inherited in p since p does not de ne m0 = meth(o m ! X ]). Similarly, (8) is inherited in q and r. However, clause (9) is only inherited in q since q does not de ne s0 whereas p has a local de nition for s0 , i.e., clause (11). It is interesting to note that neither clause (11) nor clause (9) is inherited in r. This is because r can access two distinct de nitions of s0 { the one in o and the one in p { via two non-overlapping paths. On the other hand, clause (13) is inherited in r since the de nition of t0 in p is inhibited by r through...
View Full Document

This document was uploaded on 01/10/2011.

Ask a homework question - tutors are online