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

z3 python solver copying #556

Closed
bannsec opened this issue Apr 6, 2016 · 4 comments
Closed

z3 python solver copying #556

bannsec opened this issue Apr 6, 2016 · 4 comments
Labels

Comments

@bannsec
Copy link
Contributor

bannsec commented Apr 6, 2016

Another question regarding my use of z3 in the python script symbolic execution engine. In longer examples of the engine, the script spends much of it's time re-creating the z3 solver when it state splits. My current implementation simply instantiates a new solver, and then copies over all the solver.assertions(). The obvious slowdown here is that I'm asking z3 the solve something it has already solved. This becomes a more serious problem (exponential in some cases) when it gets deeper into execution.

Is there any way to copy the solver without having this overhead?

@wintersteiger
Copy link
Contributor

No there isn't, but you can use the incremental solving facilities for this purpose, i.e., solve with assumptions or push/pop parts of your problem.

For examples, see here (they are in C++, but the function names are the same/very similar in Python).

@NikolajBjorner
Copy link
Contributor

There is also the translate method (Z3_solver_translate or Solver.translate) that lets you clone a solver. This may work for your scenario.

@bannsec
Copy link
Contributor Author

bannsec commented Apr 10, 2016

Nikolaj,

I think what you're talking about is what I'm trying to do. However, when I attempt that I get an error that I don't understand "translation of contexts is only supported at base level".

@NikolajBjorner
Copy link
Contributor

This would mean that you did a push. You have to pop back everything.

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

No branches or pull requests

3 participants