alloy - 删除合金中的谓词关系
问题描述
我正在学习如何使用合金,我已经编写了这个代码:
module test/SlotsAndFillers
sig Slot { content: one Filler}
sig Filler { slots: set Slot}
fact AllSlotsAreOwned {
all s:Slot | some x:Filler | s in x.slots
}
fact ImproperParthoodSlots {
all x:Filler | some y, z:Slot | y in x.slots implies z in x.slots and x in z.content
}
fact SlotInheritance {
all x, y : Filler, z, z' : Slot | x != y and z != z' and z in y.slots and x in z.content and z' in x.slots implies z' in y.slots
}
fact SingleOccupancy {
all x:Slot, y:Filler | x in y.slots implies one z:Filler | z in x.content
}
fact MutualOccupancyIsIdentity {
all x, y: Filler, z, z': Slot | x != y and z != z' and
z in y.slots and x in z.content and z' in x.slots and y in z'.content implies x = y
}
pred show() {}
run show
当我执行和显示模型时,除了关系content和slot之外,模型还有新的关系,名为$show_x、$show_y和$show_z。通过测试,我了解到如果我在谓词中添加内容,就会存在这些关系。但是对于这段代码,show是空的,仍然存在这些关系。所以我有两个问题:它们来自哪里以及如何删除它们?我知道我可以隐藏它们,但是模型看起来都(几乎)相同。所以我想探索只使用我的两个关系而不是新关系的不同模型。
不要犹豫,重新制定或重新命名这篇文章。
谢谢!
解决方案
当您执行一个运行命令后跟一个谓词时,您实际上是在生成满足该谓词的实例。据我了解,当谓词被命名时,实例可视化器会尝试突出显示实例的哪些元素满足谓词。在您的情况下,“一切”都符合这个空谓词,因此您的谓词名称随处可见。
一个简单的解决方法是简单地不命名您作为参数提供给运行命令的谓词:
module test/SlotsAndFillers
sig Slot { content: one Filler}
sig Filler { slots: set Slot}
fact AllSlotsAreOwned {
all s:Slot | some x:Filler | s in x.slots
}
fact ImproperParthoodSlots {
all x:Filler | some y, z:Slot | y in x.slots implies z in x.slots and x in z.content
}
fact SlotInheritance {
all x, y : Filler, z, z' : Slot | x != y and z != z' and z in y.slots and x in z.content and z' in x.slots implies z' in y.slots
}
fact SingleOccupancy {
all x:Slot, y:Filler | x in y.slots implies one z:Filler | z in x.content
}
fact MutualOccupancyIsIdentity {
all x, y: Filler, z, z': Slot | x != y and z != z' and
z in y.slots and x in z.content and z' in x.slots and y in z'.content implies x = y
}
run {}
编辑:
看来这个修复并不能解决问题。事实上,在事实中定义的量化变量仍然由实例查看器显示。摆脱它们的唯一选择(我能想到的)是在主题菜单中手动禁用它们的表示。
推荐阅读
- response - ISC-DHCP-SERVER 失败,但问题 IP 正常
- java - 如果通过打开相机完成 onActivityResult 不会在小米设备上触发
- regex - Powershell RegEx 模式未返回预期结果
- javascript - 优雅关闭 Websocket NodeJs
- java - gradle build 中的 java.lang.unsupportedclassversionerror
- android - 如何在不使用外部库的情况下在 Jetpack Compose 中显示 base64 编码的图像
- scala - 如何使用 Coursier 在命令行中运行 Scala 3 应用程序
- reactjs - React 中的单选按钮 - 我必须单击两次才能看到选择和更新状态
- javascript - 剑道反应自动完成不过滤
- flutter - 如何摆脱 Flutter Web 中的溢出像素错误