Re: product types in OCL 2.0



Date view Thread view Subject view Author view Attachment view

From: Thomas Baar (baar@ira.uka.de)
Date: Thu 20 Feb 2003 - 16:42:22 GMT


Dear Herman!

Herman Balsters wrote:

>Thomas,
>
>I think your solution might be problematic.
>
>(1) Uniqueness: How do you model the Cartesian product of a class A 
>with itself (i.e. A x A)? Is there a  (generic) way to distinguish between 
>the left and right hand sides?
>
>(2) Uniqueness and Totality:  In your solution I think that ProdAB = 
>ProdBA. Symmetry, in general,  is not a property of Cartesian 
>products.
>
>-Herman 
>
You can solve both problems by using role-names. Just add to the 
associationends
on A and B the roles 'first' and 'second'. In this case, the constraints 
uniqueness and totality
must be adapted to:

--  uniqueness
   ProdAB.allInstances->forall(p1,p2| p1.first = p2.first and p1.second 
= p2.second implies p1 = p2)

-- totality
  A.allInstances->forAll(a1| B.allInstances->forAll(b1|
       ProdAB->exists(p| p.first = a1 and p.second = b1)))



As you can see, you can distinguish between the first and the second 
component
of a pair and ProdAB is not the same as ProdBA.

In case of ProdAA you have to draw two associations from ProdAA to A.


Best regards,

Thomas


-- 

Thomas Baar
University of Karlsruhe
http://i11www.ira.uka.de/~baar

Date view Thread view Subject view Author view Attachment view