Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty model with Z3 >=4.8 #28

Open
valderman opened this issue Oct 1, 2019 · 4 comments
Open

Empty model with Z3 >=4.8 #28

valderman opened this issue Oct 1, 2019 · 4 comments

Comments

@valderman
Copy link

Haskell-Z3 408.0 returns an empty model, even when deciding that a query is satisfiable, when used with Z3 >= 4.8. The problem does not occur with Z3 4.4.

Steps to reproduce

Compile and run the following program:

module Main where
import Control.Monad.IO.Class
import Z3.Monad

main :: IO ()
main = evalZ3 $ do
  a <- mkFreshBoolVar "a"
  b <- mkFreshBoolVar "b"
  assert =<< mkAnd [a, b]
  (result, model) <- withModel modelToString
  liftIO $ do
    print result
    maybe (putStrLn "no model") putStr model

Expected result

The program prints:

Sat
b!1 -> true
a!0 -> true

This is what happens when Z3 4.8 is replaced with 4.4.

Actual result

The program prints:

Sat

Additional details

The problem is not just with modelToString, as calling numConsts on the model returns 0 (and calling getConsts causes a Z3 error: index out of bounds to be thrown).

@IagoAbal
Copy link
Owner

IagoAbal commented Oct 1, 2019

Thanks for reporting.

Are you saying that Z3 408.0 works as expected with Z3 4.4 but it doesn't print any model with Z3 4.8?

Does it work with the Python API?

@IagoAbal
Copy link
Owner

IagoAbal commented Oct 1, 2019

If you are able to look into this yourself and submit a patch that would be a lot faster than waiting for me... these days I barely have time to discuss issues and review patches.

@valderman
Copy link
Author

valderman commented Oct 6, 2019

Are you saying that Z3 408.0 works as expected with Z3 4.4 but it doesn't print any model with Z3 4.8?

Exactly.

Does it work with the Python API?

I haven't been able to try the Python API, unfortunately. It does work when using the Z3 binary (4.8) however.

If you are able to look into this yourself and submit a patch that would be a lot faster than waiting for me...

I'll look into it if I have the time, but that's a fairly big "if" at the moment I'm afraid.

@IagoAbal
Copy link
Owner

Unfortunately, the Z3 API changes fairly often and things break. My suggestion would be to "translate" that example to Z3.Base and run it.

I don't have time to look at this either, there is no "if" in my case unfortunately, I just don't have time. The library should be maintained by the ones who need it. But I am happy to donate time in order to help those who want to contribute, like explaining details about the code or reviewing patches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants