运行 命令行为限制 alloy 中的签名数量

run command behavior with limitation on number of signatures in alloy

第一个代码在 Alloy Analyzer 4.2 中找不到任何实例,但是第二个代码找到了! 有什么不同?我的期望是,当我执行 "run show for 1".

时,# > 0 和 # = 1 的行为相同

1:

sig Fruit {}
pred show() { #Fruit > 0}
run show for 1

2:

sig Fruit {}
pred show() { #Fruit = 1}
run show for 1

当您 运行 命令时,您会看到位宽(它决定 Alloy 的最大 Int)为 0。

   Executing "Run show for 1"

   Solver=sat4j Bitwidth=0 MaxSeq=0 SkolemDepth=1 Symmetry=20
   0 vars. 0 primary vars. 0 clauses. 2ms.
   No instance found. Predicate may be inconsistent. 0ms.

您可以通过显式更改位宽来更改它:

sig Fruit {}
pred show() { #Fruit>0}
run show for 1 but 2 int

Executing "Run show for 1 but 2 int"
   Solver=sat4j Bitwidth=2 MaxSeq=1 SkolemDepth=1 Symmetry=20
   1 vars. 1 primary vars. 1 clauses. 3ms.
   . found. Predicate is consistent. 3ms.

我认为当您使用“>”运算符时您需要位宽,但当您使用“=”时则不需要。

在 Alloy.

不鼓励 使用 Int