Formalizing Spider Diagrams
Formalizing Spider Diagrams
Stuart Kenty
Computing Laboratory
University of Kent, Canterbury, UK
S.J.H.Kent@ukc.ac.uk
1
B Libraries
A C Copies
a
collection
OnHold
Fig. 1: An example spider diagram.
Fig. 1 is a simple spider diagram consisting of three spi- Publications
publication
ders and three contours. The figure uses various visualiza-
tion techniques to specify that
jA B j = 2 Reservations onHoldFor
C\A=C \B =;
a 2 ((B C ) A) [ ((C A) B)
reserved
,
D C
E Regions
Districts Zones
Fig. 6: An example of using zone labels.
is a called zone. Formally, a zone (or a minimal region) is
a region having no other region as a proper subset. Notice
that a zone does not have to be connected. For example, Fig. 7. The set-theoretical relationship between zones, districts and
in Fig. 4, the zone corresponding to (B \ C ) A is not regions.
connected. Districts Zones
Fig. 5 shows all but one of the zones of the clover. The domain
zone not shown is that which is formed by subtracting the
districts of all non boundary contours from the domain.
It is not difficult to see that contours partition the do- Fig. 8: The spider of the domain.
main into disjoint zones. Accordingly, we have that all members, we need a new shape: the spider, which is used
the regions can be generated by taking the union of any to denote elements. Spiders are similar to X-sequences, or
non-empty collection of zones. The clover, for example, chains, in Peirce diagrams, except that unlike X-sequences,
has 28 1 = 255 regions in total, which is the number of spiders must be distinct (unless they are joined by a tie or
non-empty ways its eight zones can be combined. by a strand, see below).
A zone can also be a district, as it the case for two out The visual representation of a spider is as a tree with
of the three zones of Fig. 3b. However, it follows from the nodes, called feet. A foot is a drawn as a little black circle
definition that a zone is either completely contained in a or square, and the connecting edges, the legs of the spider,
district, or it disjoint from it. This dichotomy suggests a are drawn as straight lines. We chose the tree representation
canonical method for denoting zones. instead of the linear structure of X-sequence used in tradi-
Definition 1 Let C be a set of contours, and let b 2 C be a
tional Venn-Peirce diagrams since we found that the greater
special boundary contour. Then, the pair hC1 ; C2 i is called
flexibility enables more visually pleasing diagrams.
a contour division if b 2 C1 , C1 \ C2 = ; and C1 [ C2 = C .
We say that a spider touches a zone if it has a foot in
that zone. No spider may touch the same zone twice. A
For a zone z , let C + (z ) be the set of contours that con- spider inhabits the region formed by the union of all the
tain it, and let C (z ) be the set of contours that don’t. zones that the spider touches. This region, called the habitat
Then, hC + (z ); C (z )i is a contour division of the contours of the spider, is intuitively where the element denoted by the
of the diagram which uniquely identifies z . The converse, spider might reside.
namely that all contours divisions correspond to zones is Spiders can be labeled. By convention, spider labels are
true in Venn diagrams, but may not hold in spider diagrams. all lower case. As a simple reflective example, Fig. 8 shows
Topologically, a zone z is the intersection of the districts that the domain is a district, but it may be in addition a zone
of C + (z ), minus the union of districts of C (z ). For exam- (this happens if a diagram has no contours other than the
ple, the zone highlighted in Fig. 5b is calculated by taking boundary).
the intersection of the sets denoted by the contours high- There is a slight semantical difference between spiders
lighted with solid border in Fig. 5a and subtracting the set with circles as feet and spiders with squares as feet. A spi-
denoted by the contour highlighted with a dashed border. der whose feet are circles corresponds to existential quan-
Zones can be optionally labeled. By convention a zone tification. Thus, in Fig. 1, the semantics of the two left most
label is underlined, initially uppercase and placed inside its spiders is that there are two distinct anonymous elements
zone. Using this convention we can read now read Fig. 6 in A B . A spider whose feet are squares represents a
and determine that its semantics is (among other things) given element. The semantics of Fig. 8 is that the specific
A (D [ C ) = A \ B = E: element called “domain” is a member of the set “Districts”.
A more elaborate example is given in Fig. 9. The seman-
The spider diagram Fig. 7 summarizes (in a reflective tics is that there exists a, b, c such that
fashion) some of the terms introduced above: regions are
sets of points, districts and zones are regions, and there b 2 (B C ) [ (C A)
might be zones which are also districts. a 2 (A B) C
2.3. Spiders c 2 (U A) B
So far, our expressive power was limited to sets and their re- where U is the universal set denoted by the boundary con-
lationships. In order to be able to make statements about set tour. In addition, the semantics includes the condition that
A B Zones
a b Shaded Unshaded
(a) (b)
D = = = = D
(a) (b) Fig. 15: A projected set (a) and its semantics (b).
Fig. 13. Specifying cardinality with shading and spiders (a) and
2.6. Projections
the effect of ties (b). Sometimes it is necessary to show a set in a certain context.
Intersection can be used for just this purpose: an intersec-
tion of A and B shows the set A in the context of B and
b
a vice-versa. However, intersections also introduce regions
C A
B which may not be of interest. Projections are equivalent
c D to taking the intersection of sets, except that they introduce
fewer regions, with the effect that regions which are not the
Fig. 14: Using Schrödinger spiders. focus of attention are not shown resulting in less cluttered
diagrams.
spiders a, b and c may be selected from other zones. In the A projection is a contour which is used to denote an
same fashion we have that 1 jC j 3. intersection of a set with a “context”. By convention, we
In Fig. 13a, jB j and jC j are related: the more elements use dashed iconic representation to make the distinction be-
in B the less in C , and vice-versa. To avoid this depen- tween projections and other contours.
dency, an exclusive element could be introduced into the A determining label must be associated with any pro-
universal set, i.e., an element which is not a member of any jection p. This label is used to denote the set which is be-
of the sets represented by the other contours. In Fig. 13b, ing projected. The convention is that determining labels are
the same restrictions on jB j and jC j are in force, but this rendered within parenthesis when drawn in a diagram. A
time if a, b and c denote elements in B this has no impact projection can also have a contour label.
on on jC j, as the habitats of these spiders do not include C . Consider Fig. 15(a) for example. The dashed contour, la-
The price is the introduction of the constraint that jDj 1 beled X , denotes the set obtained by “projecting” the set A
when jB j = jC j = 0. onto the context (D [ C ) B , i.e.,
Besides being awkward to draw, and being less than im- X = A \ ((D [ C ) B)
mediately intuitive, the exclusive element of the universal
The same semantics could have been obtained by using
set is undesirable since it forces an unnatural constraint on a
More’s algorithm [12] to draw the Venn diagram of four
diagram. We fix the situation by introducing a new symbol,
contours, as in Fig. 15(b)
the Schrödinger spider, which denotes a set whose size is
either zero or one. Just like Schrödinger’s cat one is not sure X =X [X :1 2
whether the element exists or not. Formally, a Schrödinger
The simplicity of Fig. 15(a) when compared to Fig. 15(b) is
spider is nothing but a kind of a spider, whose semantics is
self evident.
specialized.
As noted above, the semantics of a projection is deter-
The feet of a Schrödinger spider are rendered differently mined by its context, defined by:
from normal non-Schrödinger spiders. An example is given
in Fig. 14, in which zone B contains three Schrödinger spi- Definition 2 The context of a contour c, denoted (c) is the
ders, labeled a, b, and c, while region C contains two un- smallest region that strictly contains the district of c.
labeled Schrödinger spiders. In comparison with Fig. 13b, Strictness ensures that the district itself is not the region
Fig. 14 is less cluttered, and does not force an element into containing the contour. A projection p denotes the set ob-
zone D. tained by intersecting the set denoted by its determining la-
There is a limit to the amount we can express in this no- bel with the set denoted by (p). It must be possible to
tation about the cardinality of sets. For example, we are calculate the set denoted by (p) from the sets denoted by
unable to say that jAj = jB j for a disjoint sets A and B . contours other than p itself.
In order to retain the intuitiveness of spider diagrams, con- There are fascinating mathematical intricacies involving
straints such as this should be placed in an auxiliary textual the intersection of several projections. Due to space con-
annotation, not burdening the visual notation. straints, we will not be able to discuss these here, nor shall
we be able to give the full semantics or even the exact defi- Theorem 1 All spider diagrams are self-consistent.
nition of projections.
The proof is based on the construction of the topological
3. Formal Syntax of Spider Diagrams model of a spider diagrams. The details are omitted.
The definition of a model and compliance have a
In this section we give spider diagrams a formal definition straightforward extension to a spider multi-diagram D. The
which is independent of any topological and visual repre-
sentations thereof. For space reasons, the definition of pro-
U
semantics predicate PD ( ) is simply the conjunction of the
^ Pd(U):
semantics predicate of the individual diagrams:
jections is omitted from this paper.
A spider diagram is a tuple P D (U ) =
hC ; ; Z ; Z ; R; S ; S ; ; ; ; i d2D
whose components are defined as follows: Thm. 1 does not extend to multi-diagrams. The reason is
(i) C is a finite set whose members are called contours. that it is possible to simultaneously denote that a certain set
The element , which is not a member of C , is called is empty in one diagram and non-empty in another diagram.
the boundary contour. Since non-given spiders are existentially quantified, we
(ii) The set Z 2C is the set of zones, while Z Z is must map them into formal variables. A non-given spider is
the set of shaded zones. A zone z 2 Z is incident on mapped into a formal variable which will existentially range
a contour c 2 C if c 2 z . U
over .
(iii) R is the set of regions, and let R0 = R [ ;. Let s1 ; : : : ; sk denote the non-given non-Schrödinger
(iv) S is a set of spiders, while S S is a set of spiders, and let sk+1 ; : : : ; sk+l denote the non-given
Schrödinger spiders. Schrödinger spiders. Let 0 = U U
[ f?g, then, predicate
(v) The function : S ! R returns the habitat of a U
Pd ( ) is
spider. The function : S S ! R0 returns the
nest of any two spiders, while : S S ! R0 is a 9xs1 2 U 9xsk 2 U
function that returns the web of any two spiders. 9xsk+1 2 U0 9xsk+l 2 U0 Q
In addition, we use the value ?, which is not a member
of any of the sets we mention, to denote undefined values. where Q is a predicate involving no quantifiers defined by
Q = Q1 ^ Q2 ^ Q3 ^ Q4 ^ Q5 ^ Q6
We use the dot notation to extract components of a tuple.
Thus, d:Z denotes the zones of a diagram d.
A spider multi-diagram is a collection D of spider dia- and the predicates Qi , i = 1; : : : ; 6 are expanded below.
grams. The function maps the contours of d to subsets of . U
Let us extend its definition to include the interpretation of
4. Formal Semantics other elements of d which are to denote sets in the model:
A model for a spider diagram (i) Boundary. The boundary denotes the universal set.
d = hC ; ; Z ; Z ; R; S ; S ; ; ; ; i
( ) = U
(ii) Zones. The semantics of a zone z 2 Z is determined
is a triple
\ [
by which contours enclose it and which don’t
(z ) = (c) (c)
m = hU; ; i
c2z_c= c2C z
U is a set and and are functions:
such that By letting the set intersection operation range over the
: S ! U [ f?g maps given spiders to elements of boundary contour, we make sure that even the zone
U or to the special symbol ?, and that is external to all contours has a well-defined se-
mantics.
: C ! 2U maps contours to subsets of U. (iii) Regions. The value of of a region, or more gen-
Given a diagram, we will define a predicate Pd (), called
erally any other collection of zones is simply the
union of the semantics of the zones in the collection:
its semantics predicate. A model complies with a diagram d
For r 2 2Z f;g, let
U
if it satisfies its semantics predicate, i.e., Pd ( ) is true. A
(r) =
[ (z )
diagram is consistent if it has a compliant model. As shall
become easy to see, the empty set is compliant with any z2Z (r)
legal diagram d which has no spiders, i.e., d:S = ;. Our where, for any region r, Z (r) is the set of zones con-
main result is tained in r.
Predicate Q1 (the plane tiling condition) ensures that all 5. Conclusions and Further Work
elements fall within sets denoted by zones:
[ (z) = U This is the first of a two part semantics for constraint di-
agrams. The second part will deal with the semantics of
arrows. We have begun to explore rules for reasoning di-
z2Z rectly with the diagrams, building on recent work in reason-
ing with Venn diagrams and Euler circles. Early results look
This predicate, means that that an intersection of contours
promising, see [7] for details. It is our eventual aim to de-
that doesn’t appear as a zone must be empty. From it fol-
velop tools to support conceptual modeling, including the
lows our intuitive interpretation of disjoint contours and
modeling of software, based on these formal results. The
containing contours: Let c1 and c2 be two distinct con-
formal work goes hand in hand with attempts to popularize
tours in a topological diagram. Then, it follows from the
and obtain feedback on the utility of the notation.
plane tiling condition that if c1 is disjoint from c2 , then
(c1 ) \ (c2 ) = ;. Similarly, if c1 is contained in c2 then
it follows from that condition that (c1 ) (c2 ). References
Predicates Q2 (the spider condition) and Q3 (the [1] L. Euler. Lettres a Une Princesse d’Allemagne, volume 2.
Schrödinger spider condition) ensure that an element de- 1761. Letters No. 102–108.
noted by a spider is in the set denoted by the habitat of the [2] D. Firesmith and B. Henderson-Sellers. Open Modeling
spider: Language (OML) notation specification. By the OPEN Con-
Q2 =
^ (s) 2 ((s)) sortium, 1996.
[3] J. Gil and S. Kent. Three dimensional software modelling.
In Proceedings of International Conference in Software En-
Q3 =
^ (s) 2 ((s)) [ f?g
s2S S
gineering, Kyoto, Japan, May 1998. IEEE Press.
[4] E. Hammer. Logic and Visual Information. CSLI Publica-
s2S tions, 1995.
[5] D. Harel. On visual formalisms. In J. Glasgow, N. H.
Narayanan, and B. Chandrasekaran, editors, Diagrammatic
Predicate Q4 (the strangers condition) ensures that ele-
Reasoning, pages 235–271. MIT Press, 1998.
ments denoted by two distinct spiders are equal then they [6] D. Harel, H. Lachover, A. Naamad, A. Pnueli, M. Politi, R.
must fall within the set denoted by their web:
^
Sherman, A. Shtull-Trauring and M. Trakhtenbrot. Statem-
ate: A working environment for the development of complex
(s) = (t) ) (s) = ? _ reactive systems. IEEE Transactions on Software Engineer-
s;t2S ;s6=t ing, 16(4), 403-414, 1990.
(s) 2 ( (s; t)) [7] J. Howse, F. Molina, J. Taylor, S. Kent. Reasoning with
Spider Diagrams. In Proceedings of IEEE Symposium on
Visual Languages (VL99), IEEE Press, 1999.
Predicate Q5 (the mating condition) ensures that if the el- [8] S. Kent. Constraint diagrams: Visualising invariants in ob-
ements denoted by two distinct spiders fall within the set ject oriented models. In In Proceedings of OOPSLA97,
denoted by their nest, then these elements must be equal:
^ ^
ACM SIGPLAN Notices 32, 1997.
[9] S. Kent and Y. Gil. Visualising action contracts in oo mod-
(s); (t) 2 (z ) ) (s) = (t) elling. IEE Proceedings Software, 1998. 145.
s;t2S z2Z ( (s;t)) [10] A. Lauder and S. Kent. Precise visual specification of de-
sign patterns. In Proceedings of ECOOP98, Springer Ver-
lag, 1998.
Finally, predicate Q6 (the shading condition) maintains
[11] R. Lull. Ars Magma. Lyons, 1517.
that the set denoted by a shaded zone contains no elements [12] T. More. On the construction of Venn diagrams. Journal of
other than those denoted by spiders
^ (z) [ f
Symbolic Logic, 24, 1959.
[13] OMG. UML 1.1. specification. OMG Documents
(s)g ad970802-ad970809, 1997.
z2Z s2S [14] C. Peirce. Collected Papers. Harvard Univ. Press, 1933.
[15] S.-J. Shin. The Logical Status of Diagrams. CUP, 1994.
Here we adopt the standard convention that a union over [16] J. Venn. On the diagrammatic and mechanical representation
of propositions and reasonings. Phil.Mag., 1880. 123.
an empty range results in the empty set. Together with the
[17] K. Walden and J.-M. Nerson. Seamless Object-Oriented
spider condition, Q6 ensures that the only elements in a set Software Architecture: Analysis and Design of Reliable Sys-
denoted by a shaded zone are the elements represented by tems. Object-Oriented Series, Prentice-Hall, 1994.
any spiders impinging on that zone. Specifically, the set [18] J. Warmer and A. Kleppe. The Object Constraint Language:
denoted by a shaded zone not containing feet of any spiders Precise Modeling with UML. Addison-Wesley, 1998.
is empty.