Re: Single element of set



Date view Thread view Subject view Author view

sj_cook@uk.ibm.com
Mon, 1 May 2000 00:24:03 +0100


One thing I don't understand. If FlatSets have all the axioms of Set, then it must be possible to prove FS {a, a} = FS {a}. In which case, what do we make of FS {a, a} ->asBag? Haven't we irrevocably lost the fact that there were 2 a's as soon as we make it a FS? What am I missing? Steve Cook Distinguished Engineer & Executive Consultant Component Technology Services Email: sj_cook@uk.ibm.com Tel: +44 20 8818 5137 (IBM internal 7-365137) Mobile: +44 7802 155856 (Mobx 271096) Alan Cameron Wills <alan@trireme.com> on 14/04/2000 13:46:31 Please respond to alan@trireme.u-net.com To: puml-list@cs.york.ac.uk cc: jdaniels@cix.co.uk (bcc: Steve J Cook/UK/IBM) Subject: Re: Single element of set The Catalysis version of the 'set flattening' is more powerful than the OCL one, and I commend it to OCL semanticists. It solves this problem. In the Catalysis expression language, which is not quite OCL, you'd write Let h = hotel->select(x | "some test on x" ) in h.frontDesk..... instead of the OCL Let h= hotel->select(x | "some test on x" )->asSequence->first in h.frontDesk.... The only danger in the Catalysis approach is that h might turn out to be a set with a size <> 1; in which case h.frontDesk is a set of front desks, rather than a single one. Nevertheless, it does have a meaning. The Catalysis version works thus: * Multiple associations by default represent Flat Sets (of the target type). (You can annotate an association end with <<set>> or <<seq>> if you want some other interpretation.) * FlatSet is a type distinct from Set and other collections. * FlatSet has all the axioms of Set; together with the extra rule x == FS{x} where FS{a,b,c} is the flat set containing a, b, and c. * When applied to a flat set, the operator "." yields a flat set whose results include all the results of applying to the inputs. This is like OCL, except that in OCL the result is a bag. We have found the flat set result more useful in most of the examples we've tried. (You can coerce the input to a Bag if you really want a Bag result: xx->asBag.doStuff ) You might like to check that the extra axiom has the following effects: * FS{a,{b,c}, d} == FS{a,b,c,d} * Of course it works both ways -- hence no need to extract an element explicitly. * It doesn't of course disturb the meaning of ordinary sets. Alan > At 07:31 PM 4/13/00 +0100, John Daniels wrote: > >Dear list, > > > >I keep finding myself writing OCL like this: > > > >---------------- > >Let h = hotel->select(x | "some test on x" )->asSequence->first in > >---------------- > > > >where I have already asserted that the hotel set includes a single > >element that matches the select condition. > > > >Is there a simpler way to access the single element of a set? > > > >Thanks, > >--John > > > >========================================================================= > >John Daniels > >Tel/fax: +44 (0)20 8777 6007 > > > > -- Alan Cameron Wills TriReme International Ltd http://www.trireme.com Tel: +44 161 225 3240 Fax: +44 161 257 3292 Catalysis: Objects, Components and Frameworks in UML To remove yourself from this list please mail puml-list-request@cs.york.ac.uk with a message containing the word "unsubscribe".


Date view Thread view Subject view Author view