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

How to get all solutions from a theorem? #41

Open
LittleLittleCloud opened this issue Oct 22, 2024 · 1 comment
Open

How to get all solutions from a theorem? #41

LittleLittleCloud opened this issue Oct 22, 2024 · 1 comment

Comments

@LittleLittleCloud
Copy link

LittleLittleCloud commented Oct 22, 2024

e.g.
input theorem

using (var ctx = new Z3Context())
{
    var theorem = from t in ctx.NewTheorem<(bool x, bool y)>()
                  where t.x ^ t.y
                  select t;
}

output

(true, false) (false, true)
@LittleLittleCloud LittleLittleCloud changed the title How to get all solutions from a theorm? How to get all solutions from a theorem? Oct 22, 2024
@idg10
Copy link
Contributor

idg10 commented Oct 23, 2024

Although we maintain this library, I don't actually have in depth knowledge of Z3, so I'm not entirely sure whether this is a feature available in Z3 that we can surface.

But I note that this: https://brandonrozek.com/blog/obtaining-multiple-solutions-z3/ shows that with the Python wrapper for Z3, the way to do it is to introduce the results of earlier solutions as additional constraints. (So whether or not Z3 has a built-in feature to do this, the Python Z3 wrapper exposes no such functionality.)

So as I understand it, the process is to ask Z3 for a solution, and then to essentially add a constraint saying "But not this particular solution please", and then ask it to solve that. And you keep going until it's unable to find a solution.

Is that something that could work in your scenario?

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