我有以下型号:
sig A1 {
// ...
}
sig A2 {
// ...
}
sig S {
s_a1: one A1,
s_a2: one A2
}
我想基于s0:S的元素“生成”一个子集s1:S,但受以下限制:
目的是模拟集合中某些项目的修改。 我试图用理解表达式来解决这个问题,但我找不到正确的方法来表达s_a2关联中的变化。
答案 0 :(得分:1)
这样的事情?
-- s1 has the same number of atoms as s0
#s1 = #s2
-- those atoms s_valid in s0 that meet condition c1[s_valid.s_a1] must also be contained in s1
{x: s0 | c1[x.s_a1]} in s1
-- for each of those atoms s_invalid in s0 that does not meet c1[s_invalid.s_a1] there must be an atom in s1 with the same s_a1 but a different s_a2 association
all x: s0 | not c1[x.s_a1] implies some y: s1 | y.s_a1 = x.s_a1 and y.s_a2 != x.s_a2