==========================================================================
For You To Do Exercise
Lecture: 02-alloy-logic (e)
FYTD #1: Relation Multiplicities
==========================================================================
1. For each of the relations, give the most precise declaration with multiplicities.
Answers:
(a) r: S lone -> lone T
(b) r: S one -> set T
or
r: S one -> T
(c) r: S set -> one T
(d) r: S some -> some T
2. For each of the declarations below, draw two relations with the same
domain / range as the relations above such that the first relation
satisfies the multiplicities in the declaration while the second one
violates it.
(note: for the answers below, let S = {S0,S1,S2,S3}, T = {T0,T1,T2,T3}.
(a) r: S some -> lone T
Example (satisfies constraints)
{(S0,T0),
(S1,T1),
(S2,T2),
(S3,T3)}
Bonus Question: Can constraint be satisfied with the sets given for S
and T if we have a relation where two S elements map to the same T element?
Non-Example (doesn't satisfy constraints). This example satisfies the
"some" constraint, but not the "lone" constraint.
{(S0,T0), ...lone constraint violated..
(S0,T1), .............................
(S1,T1),
(S2,T2),
(S3,T3)}
(b) r: S set -> one T
Example (satisfies constraints). Each S maps to one T ("one T"
constraint). Two S items are associated with T2, and none with T3 but
that is acceptable for the "S set" constraint.
{(S0,T0),
(S1,T1),
(S2,T2),
(S3,T2)}
Non-Example (doesn't satisfy constraints). This example satisfies the
"some" constraint, but not the "lone" constraint.
{(S0,T0), ...one constraint violated..
(S0,T1), .............................
(S1,T1),
(S2,T2),
(S3,T3)}
(c) r: S lone -> lone T
Example (satisfies constraints). Each S and T item is associated with
a most one counterpart item.
{(S0,T0),
(S2,T2),
}
Non-Example (doesn't satisfy constraints). This example does not satisfy the
"lone" constraint, because S0 maps to more that one T element.
{(S0,T0), ...lone constraint violated..
(S0,T2)}} .............................
(d) r: S some -> some T
Example (satisfies constraints)
{(S0,T0),
(S1,T1),
(S2,T2),
(S2,T1),
(S2,T3),
(S3,T3)}
Non-Example (doesn't satisfy constraints).
{(S0,T0),
(S0,T1),
(S3,T3)}
There are no elements associated with S1, S2 and no elements
associated with T2. Each of "missing element" situations leads to the
constraints being violated.