How to use Ints.abs
with Java Bindings?
#4947
-
Hi! Obviously, Z3 supports some (declare-const x Int)
(assert (= x -1))
(declare-const y Int)
(assert (= y (abs x)))
(check-sat)
(echo "Next line is expected to be '((y 1))'.")
(get-value (y))
I suspect After this successful test I'd like to re-create above example program using the Java API, but I fail to achieve this. I am looking for something like Put differently, and a little more generally: How does one call, but not declare, a function via the Java API? I found Note that I did not add (assert (= y 1)) on purpose, because then we wouldn't see |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The java API does not expose the "abs" function. It is really just treated as a shorthand for (if (>= x 0) x (- x)) so you can define an auxiliary function "abs" in Java that produces this term. |
Beta Was this translation helpful? Give feedback.
The java API does not expose the "abs" function. It is really just treated as a shorthand for (if (>= x 0) x (- x)) so you can define an auxiliary function "abs" in Java that produces this term.