0

Is it possible to check if an object is element of an array in UPPAAL?

If I have a integer array

int ap[1,2];

I want to do a query in the verifier, where I have something like:

E<> 1 \in Process.ap[1]

And additionally, are there String types or character types in UPPAAL?

Thanks in advance!

tschens
  • 39
  • 2
  • 7

1 Answers1

1

You are probably looking for exists expression.

Here is an example:

const int size=5;
typedef int[0,size-1] range_t;
typedef int set_t[range_t];

bool contains(const set_t& s, int el)
{
  return exists(i:range_t) s[i]==el;
}
mariusm
  • 1,483
  • 1
  • 11
  • 26
  • I saw the custom user functions only used in the _update_ part of a transition. Is it also possible to use them in a query? If yes, can you describe how? :) Sorry for the lot of questions – tschens Mar 30 '18 at 12:54
  • Yes they can, they must be side-effect-free, e.g. pass by value or const reference. – mariusm Mar 30 '18 at 14:43
  • I used your example code to have a contains method, but I always get syntax errors when using them in a Query. Here is a example: `E<> P0.a and contains({1},1)` unexpected '{', expecting ')' ... I placed the _contains_ method in the standard Project > Declarations path. What am I missing? Do I have to use other syntax for the set_t type? – tschens Apr 08 '18 at 10:50
  • Uppaal does not accept in-place constructions. A workaround is to create "const set_t one = {1,0,0,0,0,0,0,0,0,0};" and then use "one" in the query. – mariusm Apr 08 '18 at 12:22