I'm trying to do a really basic example using Z3.Monad interface in Haskell. Unfortunately the package doesn't list a simple, working example so I'm starting from scratch. I have also checked and the examples listed in the package work for me, so there should be no underlying issue with my Z3 installation.
What am I doing
This is the function that fails when run it:
import Z3.Monad
computeTwo = evalZ3 $ do
x <- mkFreshIntVar "x"
_2 <- mkInteger 2
assert =<< mkEq x _2
fmap snd $ withModel $ \m -> fromJust <$> evalInt m x
The error I'm getting is as follows:
uncaught exception: ErrorCall
Z3.Base.toBool: illegal `Z3_bool' value
CallStack (from HasCallStack):
error, called at src/Z3/Base.hs:3197:23 in z3-4.3.1-
JxhFvE2Tmnm1VKrfgyob6s:Z3.Base
What answer was expected
The model should check with x=2.
What other things I've tried
The equivalent example works in the Z3 online checker
(declare-const x Int)
(assert (= x 2))
(check-sat)
(get-model)
Producing the answer:
sat
(model
(define-fun x () Int
2)
)
Fixed by:
1) Updating XCode
Using the App Store.
2) Reinstalling z3
brew uninstall z3
brew install z3
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
echo 'export LDFLAGS="-L/usr/local/opt/openssl/lib"' >> ~/.bash_profile
echo 'export CPPFLAGS="-I/usr/local/opt/openssl/include"' >> ~/.bash_profile
Last three were specific instructions from the brew install
process.
Thanks all for your help.