简体   繁体   中英

Alloy specifications

I'm a beginner learning Alloy, I want to know what means this n.^address (maybe with an example)? because logically if we consider address as a set of pairs like (A0,A1), then how we can join n which is for example N0 with this set?, since the left most element of pairs in address are not the same nature with n. I supposed that it would not possible. I'd really appreciate if anyone can guide me

It's been a while since I used alloy, but the ^ operator represents the transitive closure of its operand relation. So if address is {(a,b), (b,c)} then ^address is {(a,b), (b,c), (a,c)} .

n.^address is the projection of the new relation on n .

So if n is a , then n.^address is {b,c}

Example:

abstract sig atom{
    address: lone atom
}
one sig a,b,c extends atom{}

fact {
    address = a->b + b->c
}

check {
    a.^address = b+c
}

You ask "what means this n.^address?"

The expression n.^address is a join between the set of tuples denoted by n and the set of tuples denoted by ^address .

The expression ^address , in turn, denotes the transitive closure of the relation address , ie the smallest relation containing address which is transitive.

Whether there is in fact, or can be in principle, any tuple in n whose rightmost value is the same as the leftmost value of some tuple in ^address -- or, said another way, whether the expression n.^address is guaranteed to denote the empty set or not -- depends partly on how the variable n and the relation address are defined and partly on how the universe is populated. The same is true for whether the transitive closure of address is the same as address or a larger relation.

If N0 , A0 , and A1 are all atoms, and if the relation address contains only the pair (A0, A1) , and the expression n denotes (the singleton set containing) the atom N0 , then indeed the expression n.^address will denote the empty set. If on the other hand address contains a tuple (N0, A0) as well as the tuple (A0, A1) , then

  • the expression address denotes the singleton set containing the tuple (A0, A1) ,
  • the expression ^address also denotes the singleton set containing the tuple (A0, A1) , and
  • the expression n.^address denotes the singleton set containing the tuple (N0, A1) , because the join of the set {(N0, A0)} with the set {(A0, A1)} is the set {(N0, A1)} .

Since you don't provide any more information about the Alloy model you have in mind, it's not possible to say much more.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM