i doing model in alloy represent subset of java language. below have elements of model:
sig method { id : 1 methodid, param: lone type, return: 1 type, acc: lone accessibility, b: 1 block } abstract sig expression {} abstract sig statementexpression extends expression {} sig methodinvocation extends statementexpression{ pexp: lone primaryexpression, id_methodinvoked: 1 method, param: lone type } sig block { statements: seq statementexpression } pred norecursivemethodinvocationcall [] { no m:method | m in ^getmethodinvokedinsidebody[m] } fun getmethodinvokedinsidebody [m: method] : method { (univ.(m.b.statements)).id_methodinvoked }
the problem block has sequence of statementexpression @ same time recursive calls same method should avoided. thus, thought in solution above.
when try generate corresponding instances following error type:
. name cannot resolved; possible incorrect function/predicate call; perhaps used ( ) when should have used [ ] cannot correct call fun genericlawsmetamodel/javametamodel_withfield_final/getmethodinvokedinsidebody. parameters m: {genericlawsmetamodel/javametamodel_withfield_final/method} arguments cannot empty.
still regarding question, tried changing definition predicate norecursivemethodinvocationcall (thus eliminating mentioned function):
pred norecursivemethodinvocationcall [] { no m:method | m in ^( (univ.(m.b.statements)).id_methodinvoked ) }
however, new type error occurs:
^ can used binary relation. instead, possible type(s) are: {genericlawsmetamodel/javametamodel_withfield_final/method}
any clue? want avoid recursive calls same method. in advance,
you misusing transitive closure operator ^. latter applies on binary relations solely, not on functions.
i declare methodinvokedinsidebody field of method , use transitive closure on way did.
hope helps :)
edit:
here example of how transitive closure operator can used in order achieve want achieve:
sig method { id : 1 methodid, param: lone type, return: 1 type, acc: lone accessibility, b: 1 block methodsinvokedinsidebody: set method } pred norecursivemethodinvocationcall{ no m:method | m in m.^methodsinvokedinsidebody }