Reputation: 133
I am a newbie in Alloy and would like to understand how # works in connection with the restrictions on Int. Consider the following simple model for an undirected graph with no self-loops:
sig Node {
nearBy : set Node
}
fact {
no iden & nearBy // irreflexive
~nearBy in nearBy // symmetric
}
pred connected[nodes : set Node ] {
all n: Node | Node in n.*nearBy
}
pred ringTopology[nodes : set Node ] {
connected[nodes]
all n: nodes | #n.nearBy = 2
}
run { // (1)
ringTopology[Node]
} for exactly 5 Node
run { // (2)
ringTopology[Node]
} for exactly 5 Node, 5 Int
If I execute (1) shown above some solutions violate the #n.nearBy = 2 restriction in ringTopology, e.g. For the same example, in the evaluator I get #Node4.nearby = -4 (minus 4!). This does not happen with (2), where I get a unique and correct solution (10-node graph with a ring topology).
Thanks, Eduardo
Upvotes: 0
Views: 269
Reputation: 3857
Which version of Alloy are you using? It looks like you are getting that solution due to integer overflows. The latest version of Alloy (Alloy 4.2_2015-02-22) has "Prevent Overflows" option (Options -> Prevent Overflows) which should prevent that from happening.
Upvotes: 1