I read in the alloy website that a signature defines a set. Given this definition, I was trying to understand the below alloy code:
enum dooroptype { unlocked, locked, opened}
enum enginetype {on,off}
enum motortype { ismoving, still}
enum key_location { in_car, faralone}
abstract sig state{
inside,far, near : set Person,
car_action : motortype,
engine : enginetype,
key_position : (Person + key_location),
door : dooroptype
}
If a signature actually defines a set, then why do we have so many parameters in the signature definiton as a set is a unary relation? If I am wrong, how does one interpret this definition.
I’m taking my first steps in Alloy, but I’ll try to answer. This is what you have in the above code:
state -> set Personstate -> one motortypestate -> one enginetypestate -> Personandstate -> key_location(but with multiplicity that constrains each state to appear at most once, so a state can be associated with either aPersonor akey_location, but not with both)state -> dooroptypeIn short, everything defined above is a relation, some are unary, some are binary. The binary relations
inside, far and nearare defined withsetmultiplicity, while all the others are defined with a multiplicity of one.In other words, a signature is a set, and relations are defined inside the signatures, but are visible globally.