Skip to content

Commit

Permalink
rename Assoc to NonInheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
marcellussiegburg committed Mar 19, 2024
1 parent 0268ca6 commit 8d85401
Show file tree
Hide file tree
Showing 30 changed files with 290 additions and 290 deletions.
42 changes: 21 additions & 21 deletions alloy/cd/assoclimits.als
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pred smaller [l, l2 : Limit] {
not l = l2 and smallerOrSame [l, l2]
}

abstract sig Assoc extends Relationship {
abstract sig NonInheritance extends Relationship {
fromLower : one Limit,
fromUpper : one Limit,
toLower : one Limit,
Expand All @@ -34,57 +34,57 @@ abstract sig Assoc extends Relationship {
toLower != Star or toUpper != Star
}

pred validFromLimitsAssoc [a : Assoc] {
pred validFromLimitsNonInheritance [a : NonInheritance] {
smallerOrSame [a.fromLower, a.fromUpper]
a.fromLower = Zero implies a.fromUpper != Zero
}

pred validToLimitsAssoc [a : Assoc] {
pred validToLimitsNonInheritance [a : NonInheritance] {
smallerOrSame [a.toLower, a.toUpper]
a.toLower = Zero implies a.toUpper != Zero
}

pred validLimitsAssoc [a : Assoc] {
validFromLimitsAssoc [a]
validToLimitsAssoc [a]
pred validLimitsNonInheritance [a : NonInheritance] {
validFromLimitsNonInheritance [a]
validToLimitsNonInheritance [a]
}

pred validLimitsComposition [a : Assoc] {
pred validLimitsComposition [a : NonInheritance] {
(a.toLower = Zero or a.toLower = One) and a.toUpper = One
}

pred sameFromLimits [a, a2 : Assoc] {
pred sameFromLimits [a, a2 : NonInheritance] {
a.fromLower = a2.fromLower
a.fromUpper = a2.fromUpper
}

pred sameToLimits [a, a2 : Assoc] {
pred sameToLimits [a, a2 : NonInheritance] {
a.toLower = a2.toLower
a.toUpper = a2.toUpper
}

pred sameLimits [a, a2 : Assoc] {
pred sameLimits [a, a2 : NonInheritance] {
sameFromLimits [a, a2]
sameToLimits [a, a2]
}

pred increasedFromRange [a, a2 : Assoc] {
pred increasedFromRange [a, a2 : NonInheritance] {
smaller [a2.fromLower, a.fromLower] and a.fromUpper = a2.fromUpper
or smaller [a.fromUpper, a2.fromUpper] and a.fromLower = a2.fromLower
sameToLimits [a, a2]
}

pred increasedToRange [a, a2 : Assoc] {
pred increasedToRange [a, a2 : NonInheritance] {
smaller [a2.toLower, a.toLower] and a.toUpper = a2.toUpper
or smaller [a.toUpper, a2.toUpper] and a.toLower = a2.toLower
sameFromLimits [a, a2]
}

pred increasedRange [a, a2 : Assoc] {
pred increasedRange [a, a2 : NonInheritance] {
increasedFromRange [a, a2] iff not increasedToRange [a, a2]
}

pred changedRange [a, a2 : Assoc] {
pred changedRange [a, a2 : NonInheritance] {
increasedRange [a, a2] iff not increasedRange [a2, a]
}

Expand All @@ -104,17 +104,17 @@ pred shiftLimits [l1, l1b, l2, l2b : Limit] {
}
}

pred shiftedRangeUp [a, a2 : Assoc] {
pred shiftedRangeUp [a, a2 : NonInheritance] {
shiftLimits [a.fromLower, a.fromUpper, a2.fromLower, a2.fromUpper] and sameToLimits [a, a2]
iff not (shiftLimits [a.toLower, a.toUpper, a2.toLower, a2.toUpper] and sameFromLimits [a, a2])
}

pred shiftedRange [a, a2 : Assoc] {
pred shiftedRange [a, a2 : NonInheritance] {
shiftedRangeUp [a, a2] iff not shiftedRangeUp [a2, a]
}

assert sameLimits {
all disj a, a2 : Assoc |
all disj a, a2 : NonInheritance |
sameLimits [a, a2] iff sameFromLimits [a, a2] and sameToLimits [a, a2]
}

Expand All @@ -132,11 +132,11 @@ assert shiftingEqually {
}

assert shiftedUpIsValid {
all disj a, a2 : Assoc |
shiftedRangeUp [a, a2] and validLimitsAssoc [a] implies validLimitsAssoc [a2]
all disj a, a2 : NonInheritance |
shiftedRangeUp [a, a2] and validLimitsNonInheritance [a] implies validLimitsNonInheritance [a2]
}

assert increasedRangeIsValid {
all disj a, a2 : Assoc |
increasedRange [a, a2] and validLimitsAssoc [a] implies validLimitsAssoc [a2]
all disj a, a2 : NonInheritance |
increasedRange [a, a2] and validLimitsNonInheritance [a] implies validLimitsNonInheritance [a2]
}
58 changes: 29 additions & 29 deletions alloy/cd/generate.als
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ open uml/cd/assoclimits

sig Inheritance extends Relationship {}

sig Aggregation extends Assoc {}
sig Association extends Assoc {}
sig Composition extends Assoc {}
sig Aggregation extends NonInheritance {}
sig Association extends NonInheritance {}
sig Composition extends NonInheritance {}

pred selfRelationship [r : Relationship] {
r.from = r.to
Expand Down Expand Up @@ -69,14 +69,14 @@ pred thickEdgeCriterion [xFrom, xTo, yFrom, yTo : Class, is : set Inheritance] {
or second and xFrom in yFrom.subs)
}

pred thickEdge [a : Assoc, assocs : set Assoc, is : set Inheritance] {
some a2 : assocs |
pred thickEdge [a : NonInheritance, nonInheritances : set NonInheritance, is : set Inheritance] {
some a2 : nonInheritances |
thickEdgeCriterion [a.from, a.to, a2.from, a2.to, is]
or thickEdgeCriterion [a.to, a.from, a2.from, a2.to, is]
}

pred noThickEdges [assocs : set Assoc, is : set Inheritance] {
no a : assocs | thickEdge [a, assocs, is]
pred noThickEdges [nonInheritances : set NonInheritance, is : set Inheritance] {
no a : nonInheritances | thickEdge [a, nonInheritances, is]
}

pred noDoubleRelationships [rs : set Relationship] {
Expand Down Expand Up @@ -110,23 +110,23 @@ pred sameKind [r, r2 : Relationship] {
pred flip [c : Change] {
c.add.from = c.remove.to and c.add.to = c.remove.from
sameKind [c.add, c.remove]
c.add in Assoc implies sameLimits [c.add, c.remove]
c.add in NonInheritance implies sameLimits [c.add, c.remove]
}

pred changedKind [c : Change] {
sameDirection [c.add, c.remove]
not sameKind [c.add, c.remove]
c.add in Assoc and c.remove in Assoc implies sameFromLimits [c.add, c.remove]
c.add in Assoc and c.remove in Assoc
c.add in NonInheritance and c.remove in NonInheritance implies sameFromLimits [c.add, c.remove]
c.add in NonInheritance and c.remove in NonInheritance
and (validLimitsComposition [c.remove] or not c.add in Composition)
implies sameLimits [c.add, c.remove]
}

pred changedLimit [c : Change] {
c.add in Assoc
c.add in NonInheritance
sameDirection [c.add, c.remove]
sameKind [c.add, c.remove]
validLimitsAssoc [c.add]
validLimitsNonInheritance [c.add]
c.add in Composition implies validLimitsComposition [c.add]
shiftedRange [c.add, c.remove] iff not changedRange [c.add, c.remove]
}
Expand All @@ -135,7 +135,7 @@ pred sameRelationship [r, r2 : Relationship] {
r.from = r2.from
sameKind [r, r2]
sameDirection [r, r2]
r in Assoc implies sameLimits [r, r2]
r in NonInheritance implies sameLimits [r, r2]
}

pred change [c : Change, rs : set Relationship] {
Expand All @@ -158,11 +158,11 @@ abstract sig Boolean {}
one sig True, False extends Boolean {}

pred classDiagram [
assocs : set Assoc,
nonInheritances : set NonInheritance,
compositions : set Composition,
inheritances : set Inheritance,
relationships : set Relationship,
wrongAssocs : one Int,
wrongNonInheritances : one Int,
wrongCompositions : one Int,
selfRelationships : one Int,
selfInheritances : one Int,
Expand All @@ -174,20 +174,20 @@ pred classDiagram [
hasCompositionCycles : one Boolean,
hasCompositionsPreventingParts : lone Boolean,
hasThickEdges : lone Boolean] {
#{ a : assocs | not validLimitsAssoc [a]} = wrongAssocs
#{ a : assocs | not validFromLimitsAssoc [a] iff validToLimitsAssoc [a]} = wrongAssocs
#{ a : nonInheritances | not validLimitsNonInheritance [a]} = wrongNonInheritances
#{ a : nonInheritances | not validFromLimitsNonInheritance [a] iff validToLimitsNonInheritance [a]} = wrongNonInheritances
#{ c : compositions | not validLimitsComposition [c]} = wrongCompositions
#{ r : assocs | selfRelationship [r]} = selfRelationships
#{ r : nonInheritances | selfRelationship [r]} = selfRelationships
#{ i : inheritances | selfRelationship [i]} = selfInheritances
no i : inheritances | not noDoubleRelationships [i]
no i : inheritances, a : assocs |
no i : inheritances, a : nonInheritances |
sameDirection [i, a] or reverseRelationship [i, a]
hasDoubleRelationships = True
implies not noDoubleRelationships [assocs]
else hasDoubleRelationships = False implies noDoubleRelationships [assocs]
implies not noDoubleRelationships [nonInheritances]
else hasDoubleRelationships = False implies noDoubleRelationships [nonInheritances]
hasReverseRelationships = True
implies not noReverseRelationships [assocs]
else hasReverseRelationships = False implies noReverseRelationships [assocs]
implies not noReverseRelationships [nonInheritances]
else hasReverseRelationships = False implies noReverseRelationships [nonInheritances]
hasReverseInheritances = True
implies not noReverseRelationships [inheritances]
else noReverseRelationships [inheritances]
Expand All @@ -205,13 +205,13 @@ pred classDiagram [
else hasCompositionsPreventingParts = False
implies noCompositionsPreventParts [inheritances, compositions]
hasThickEdges = True
implies not noThickEdges[assocs, inheritances]
else hasThickEdges = False implies noThickEdges[assocs, inheritances]
implies not noThickEdges[nonInheritances, inheritances]
else hasThickEdges = False implies noThickEdges[nonInheritances, inheritances]
}

pred changeOfFirstCD [
c : one Change,
wrongAssocs : one Int,
wrongNonInheritances : one Int,
wrongCompositions : one Int,
selfRelationships : one Int,
selfInheritances : one Int,
Expand All @@ -223,13 +223,13 @@ pred changeOfFirstCD [
hasCompositionCycles : one Boolean,
hasCompositionsPreventingParts : lone Boolean,
hasThickEdges : lone Boolean] {
let Assoc2 = Assoc - (Change.add - c.add) - c.remove,
let NonInheritance2 = NonInheritance - (Change.add - c.add) - c.remove,
Composition2 = Composition - (Change.add - c.add) - c.remove,
Relationship2 = Relationship - (Change.add - c.add) - c.remove,
Inheritance2 = Inheritance - (Change.add - c.add) - c.remove {
change[c, Relationship - Change.add]
classDiagram [Assoc2, Composition2, Inheritance2, Relationship2,
wrongAssocs, wrongCompositions, selfRelationships, selfInheritances,
classDiagram [NonInheritance2, Composition2, Inheritance2, Relationship2,
wrongNonInheritances, wrongCompositions, selfRelationships, selfInheritances,
hasDoubleRelationships, hasReverseRelationships, hasReverseInheritances,
hasMultipleInheritances, hasNonTrivialInheritanceCycles, hasCompositionCycles,
hasCompositionsPreventingParts, hasThickEdges]
Expand Down
18 changes: 9 additions & 9 deletions legacy-app/generate/Modelling/CdOd/Generate/Edges.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import GHC.Generics (Generic)

data Connection
= Inheritance'
| Assoc AssociationType String (Int, Maybe Int) (Int, Maybe Int) Bool
| NonInheritance AssociationType String (Int, Maybe Int) (Int, Maybe Int) Bool
deriving (Eq, Generic, Read, Show)

data AssociationType = Association' | Aggregation' | Composition'
Expand All @@ -40,8 +40,8 @@ type DiagramEdge = (String, String, Connection)
nameEdges :: [DiagramEdge] -> [DiagramEdge]
nameEdges es =
ihs
++ [(s, e, Assoc k [n] m1 m2 b)
| (n, (s, e, Assoc k _ m1 m2 b)) <- zip ['z', 'y' ..] ass]
++ [(s, e, NonInheritance k [n] m1 m2 b)
| (n, (s, e, NonInheritance k _ m1 m2 b)) <- zip ['z', 'y' ..] ass]
where
(ihs, ass) = partition isInheritanceEdge es

Expand All @@ -53,10 +53,10 @@ edgeToRelationship (from, to, connection) = case connection of
subClass = from,
superClass = to
}
Assoc t _ _ _ True -> error
NonInheritance t _ _ _ True -> error
$ "This never happens: Got a thick edge of type "
++ show t
Assoc t n s e False -> case t of
NonInheritance t n s e False -> case t of
Association' -> Association {
associationName = n,
associationFrom = LimitedLinking from s,
Expand Down Expand Up @@ -128,17 +128,17 @@ flattenInheritance :: String -> String -> DiagramEdge -> [DiagramEdge]
flattenInheritance s e edge@(s', e', t) = case t of
Inheritance' | e == s', s /= e' -> [(s, e', Inheritance')]
| s == e', e /= s' -> [(s', e, Inheritance')]
Assoc {} | e == s' -> [(s, e', t), edge]
Assoc {} | e == e' -> [(s', e, t), edge]
NonInheritance {} | e == s' -> [(s, e', t), edge]
NonInheritance {} | e == e' -> [(s', e, t), edge]
_ -> [edge]

isComposition :: Connection -> Bool
isComposition (Assoc Composition' _ _ _ _) = True
isComposition (NonInheritance Composition' _ _ _ _) = True
isComposition _ = False

wrongLimits :: [DiagramEdge] -> [DiagramEdge]
wrongLimits es =
[c | c@(_, _, t@(Assoc _ _ s@(sl, sh) e _)) <- es
[c | c@(_, _, t@(NonInheritance _ _ s@(sl, sh) e _)) <- es
, isComposition t && (sh /= Just 1 || sl < 0 || sl > 1)
|| not (inLimit s)
|| not (inLimit e)]
Expand Down
4 changes: 2 additions & 2 deletions legacy-app/generate/Modelling/CdOd/Generate/Generate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ generateEdge (conf, cs) mt
generateLimits (Just Composition') = do
ll1 <- getRandomR (0, 1)
l2 <- generateLimit
return $ Assoc Composition' "" (ll1, Just 1) l2 False
return $ NonInheritance Composition' "" (ll1, Just 1) l2 False
generateLimits (Just t ) = do
l1 <- generateLimit
l2 <- generateLimit
return $ Assoc t "" l1 l2 False
return $ NonInheritance t "" l1 l2 False
generateLimit :: MonadRandom m => m (Int, Maybe Int)
generateLimit = do
l <- getRandomR (0, 2)
Expand Down
Loading

0 comments on commit 8d85401

Please sign in to comment.