1

I'm trying to create a constraint such that a value X is one of the members of the expr_vector such as,

context c;
expr_vector v(c);
expr x = c.int_const("x");
expr i1 = c.int_val(5);
expr i2 = c.int_val(7);
solver s(c);
s.add(x == i1 || x == i2); // this is what I want to create iteratively

I tried to create an expression by looping on expr_vector v to create the boolean expression but I failed.

What I basically want is to be able to write such an expression.

v.push_back(i1);
v.push_back(i2);
s.add(belongs(x, v));

1 Answers1

2

This functionality is provided by the z3 API, and is called expr_mk_or, available here

You can also implement this as a loop: Start with a boolean-expression initialized to false, and in each iteration use the or combinator to string them together. If you post what you tried, we can point out what you might've done wrong.

alias
  • 28,120
  • 2
  • 23
  • 40