简体   繁体   English

合金规格

[英]Alloy specifications

I'm a beginner learning Alloy, I want to know what means this n.^address (maybe with an example)?我是一个学习合金的初学者,我想知道这个 n.^address 是什么意思(也许有一个例子)? 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.因为从逻辑上讲,如果我们将地址视为一组像 (A0,A1) 这样的对,那么我们如何将 n(例如 N0)与该集合连接起来?因为地址中最左边的对的元素与 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)} .所以如果address{(a,b), (b,c)}那么^address{(a,b), (b,c), (a,c)}

n.^address is the projection of the new relation on n . n.^address是新关系在n上的投影。

So if n is a , then n.^address is {b,c}所以如果na ,那么n.^address{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?"你问“这个 n.^ 地址是什么意思?”

The expression n.^address is a join between the set of tuples denoted by n and the set of tuples denoted by ^address .表达式n.^addressn表示的元组集和^address表示的元组集之间的连接。

The expression ^address , in turn, denotes the transitive closure of the relation address , ie the smallest relation containing address which is transitive.表达式^address又表示关系address的传递闭包,即包含传递地址的最小关系。

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.事实上,或原则上是否存在n中的任何元组,其最右边的值与^address中某个元组的最左边的值相同——或者,换句话说,表达式n.^address是否保证是否表示空集——部分取决于变量n和关系地址的定义方式,部分取决于宇宙的填充方式。 The same is true for whether the transitive closure of address is the same as address or a larger relation. address的传递闭包是否与address相同或更大的关系也是如此。

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.如果N0A0A1都是原子,并且如果关系地址仅包含对(A0, A1) ,并且表达式n表示(包含 singleton 集合)原子N0 ,那么实际上表达式n.^address将表示空集。 If on the other hand address contains a tuple (N0, A0) as well as the tuple (A0, A1) , then另一方面,如果地址包含元组(N0, A0)以及元组(A0, A1) ,则

  • the expression address denotes the singleton set containing the tuple (A0, A1) ,表达式地址表示包含元组(A0, A1)的 singleton 集合,
  • the expression ^address also denotes the singleton set containing the tuple (A0, A1) , and表达式^address也表示包含元组(A0, A1)的 singleton 集合,并且
  • 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)} .表达式n.^address表示包含元组(N0, A1)的 singleton 集合,因为集合{(N0, A0)}与集合{(A0, A1)}的连接是集合{(N0, A1)} ) {(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.由于您没有提供有关您心目中的合金 model 的更多信息,因此无法多说。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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