Dealing with multirelations (of arity ~10)

天涯浪子 提交于 2019-12-13 20:43:26

问题


I have a model with a sig similar to this one:

sig State {
  ps: set P,
  cs: set C,
  o: set C -> set P,
  m: set M
}

And predicates like this, dealing with two States:

pred my_pred [s, s': State] {
  ...
}

I'm trying to create a parameterized version of my model, where I don't have a State sig, and instead I pass those fields around explicitly in functions and predicates. That would mean having predicates that look something like

pred my_pred [(M -> P -> C -> (C -> P)) ->
              (M -> P -> C -> (C -> P))] {
  ...
}

My question is, how can one easily deal with relations of relatively large arity, such as the one in my_pred? For instance, I was trying to use dom from util/relation, but dom is defined over a binary relation, and unfortunately it seems that alloy sees this

  (M -> P -> C -> (C -> P))
  ->
  (M -> P -> C -> (C -> P))

as a relation of arity 10 rather than 2; meaning that the parenthesizing is ignored. So using dom would return something of type M, rather than of the desired type of (M -> P -> C -> (C -> P)).

Also on a related note, I was wondering if/how one could use the transitive closure operators on relations like this.


回答1:


It's generally bad practice to have relations of arity greater than 3.

Why don't you simply declare your predicate as follows :

pred my_pred [m,m':M , ps,ps':P , cs,cs':C , o,o':(C -> P)] {
  ...
}


来源:https://stackoverflow.com/questions/51997723/dealing-with-multirelations-of-arity-10

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!