Unformatted text preview: tation
for dealing with relations.
If A and B are sets, a relation from A to B is a subset R of A B. If a b R, we
will write R a b , a R b , and a b
R interchangebly. A relation from A to A is
often called a relation on A.
© © ¨ © ¨ We denote composition of relations by concatenation e.g. x RS z iff there
exists a y such that x R y and y S z. We also write x R y S z. R denotes the reﬂexive
transitive closure of R.
¨ We often think of directed graphs as relations (and vice versa), so we write
C c1 c2 or c1 C c2 when there is an edge from c1 to c2 in C. We take as given the
deﬁnition of a path in a directed graph.
© ¨ 3 The Model Deﬁnition 1 A class graph (sometimes called a class diagram) consists of a set C
(of “classes”), a set E (of ﬁeld names), for each e E a relation (also named e) on
classes (“has part named e”), and a reﬂexive, transitive relation on classes (“is
a subclass of”). We write C c1 c2 iff there exists e E such that e c1 c2 .
© ¨ © ¨ Each relation e codes the effect of ﬁnding the e part of an object. Usually the
relation e is a partial function (that is, for any c1 , there is at most one c2 such
2 that e c1 c2 ), but we will not need this property. When e c1 c2 , we sometimes
say that c1 has an e-part of type c2 . (The signiﬁcance of the word “type” will be
explained momentarily). We use to denote the reﬂexive, transitive closure of the
inheritance relation, so c c means that c is either the same as c or is one of c ’s
© ¨ © ¨ £ £ . We write
© We use C to denote the entire class graph C E
. £ © of for the inverse An object graph is a model of the objects, represented in the heap or elsewhere,
and their references to each other:
Deﬁnition 2 If C is a class graph, then an object graph of C consists of:
1. a set O (of “objects”), 3. for each e ! 2. a map class : O C, and E, a relation (also denoted e) on O such that if e o1 o2 , then
"¨ ¨ ¨ We say that o is of type c when class o class o2
© class o1 c. ¨ An object is of type c when its class is some class that is a descendant of c.
This corresponds to the usual expectation in a typed object-oriented language: if a
variable is of type c, its value is either null or is an object whose class is either c or
a descendent of c.
The traversal of an edge labeled e corresponds to retrieving the value of the
e ﬁeld. Condition 3 captures the notion that every edge in the object graph is an
image of a has-as-part edge in the class graph: There is an edge e o1 o2 in O only
when there exist classes c1 and c2 such that o1 is of type c1 , c1 has an e-part of type
c2 , and o2 is of type c2 , that is,
¨ class o2 © ¨ c1 e c2 c...
View Full Document
This document was uploaded on 03/17/2014 for the course CSG 111 at Northeastern.
- Fall '09