[英]Specifying A Scope for Sig in Alloy
i am new to Alloy and there is an error due to which my program can't execute or show. 我是Alloy的新手,由于我的程序无法执行或显示而出现错误。 Error iam having is
IAM的错误是
A Syntax error has occurred: You must specify a scope for "this/Name"
发生语法错误:您必须为“此/名称”指定范围
My Code is 我的代码是
module language/Family
sig Name { }
abstract sig Person {
name: one Name,
siblings: Person,
father: lone Man,
mother: lone Woman
}
sig Man extends Person {
wife: lone Woman
}
sig Woman extends Person {
husband: lone Man
}
sig Married extends Person {
}
fact {
no p: Person | p in p.^(mother + father)
wife = ~husband
}
fun grandpas[p: Person] : set Person {
let parent = mother + father + father.wife + mother.husband | p.parent.parent & Man
}
pred ownGrandpa[p: Person] {
p in grandpas[p]
}
These are my run commands 这些是我的运行命令
run ownGrandpa for 4 Person
run ownGrandpa for 2 Person
run ownGrandpa for 1 Person
Can Any one point out This Error for me Please. 任何人都可以为我指出此错误。
There are three ways to assign a scope to your model. 有三种方法可以为模型分配范围。
The first one is by assigning a scope to each signature of your model. 第一个是通过为模型的每个签名分配一个范围。 eg :
run ownGrandpa for 4 Person, 3 Name
例如:
run ownGrandpa for 4 Person, 3 Name
The second one is by giving a global scope that will be applied to all the signatures. 第二个是通过提供将应用于所有签名的全局范围。 eg
run ownGrandpa for 4
例如
run ownGrandpa for 4
The last one is a mix of the two previous and consists of a global scope accompanied by one or several individual scope definitions. 最后一个是前两个的组合,由一个全局范围和一个或几个单独的范围定义组成。 eg
run ownGrandpa for 5 but 4 Person.
例如,
run ownGrandpa for 5 but 4 Person.
The global scope is to be applied to all the signature for which an individual scope declaration is missing. 全局范围将应用于缺少单个范围声明的所有签名。
Thus, in your example, run ownGrandpa for 5 but 4 Person
is equivalent to run ownGrandpa for 5 Name, 4 Person
因此,在您的示例中,
run ownGrandpa for 5 but 4 Person
run ownGrandpa for 5 Name, 4 Person
等效于run ownGrandpa for 5 Name, 4 Person
Note that providing scopes like this only gives an upper bound to the number of atoms derived from a signature. 请注意,提供像这样的作用域仅给出了从签名派生的原子数的上限。
If you want to express that any of your instance should contain exactly 4 persons (no more, no less) then you should use the keyword exactly
. 如果您想表达您的任何实例应恰好包含4个人员(不多,不少于),则应使用关键字
exactly
。 eg run ownGrandpa for 5 but exactly 4 Person
例如,
run ownGrandpa for 5 but exactly 4 Person
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.