-1

Is there a way to do a modulo operation with z3 c++ api with integers?

I'm trying to do something like this:

var = context->int_const("foo");
var = var + 1; 
expr = var % 5;

It seems there is only a modulo operation for bitvectors?

Am I missing something?

Best Tobias

toebs
  • 389
  • 1
  • 2
  • 13

1 Answers1

0

There are two operations, depending on what semantics you expect for negative numbers. They are exposed as "mod" and "rem". The semantics is documented on http://smtlib.cs.uiowa.edu/theories-Ints.shtml for arithmetical operations.

    /* \brief mod operator */
    friend expr mod(expr const& a, expr const& b);
    friend expr mod(expr const& a, int b);
    friend expr mod(int a, expr const& b);

    /* \brief rem operator */
    friend expr rem(expr const& a, expr const& b);
    friend expr rem(expr const& a, int b);
    friend expr rem(int a, expr const& b);
Nikolaj Bjorner
  • 8,229
  • 14
  • 15
  • Where can I find those methods? There is only z3::urem and z3::srem which both operate on bitvectors. – toebs Jul 03 '17 at 19:23