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 - 08:40:09 GMT


Hello!

Gerrit Renker wrote:

>Dear Herman,
>
>there is no Cartesian Product type in OCL. All there is is the Tuple
>type. That means, in effect  modelling cartesian Products remains a
>complex endeavour (see my mail earlier on this list).
>
A very simple possibility to model the Cartesian Product is the following:

Suppose you want to model the product of objects of classes A and B.
This can be done by introduction of a new class ProdAB a s follows:

  -----                              -----
  - A  -                               - B  -
  -----                              -----
     | 1                                       |1
     |                                          |
     |              --------          |
     ------|  ProdAB |-----
               * -------- *

constraints:

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

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


>As a consequence, mathematical relations (subsets of Cartesian
>Products) remain hard to model, too.
>  
>
In order to model a relation, just omit the last constraint (totality).

Best regards,

Thomas



-- 

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

Date view Thread view Subject view Author view Attachment view