Saving the “state” of a Z3 solver in SMT2 format

℡╲_俬逩灬. 提交于 2019-12-12 17:26:03

问题


is it possible, using the Z3 API (e.g. the Python API), to save the current state of a solver, including what the solver has learned (in SAT solving we would say the "learned clauses") in a file in SMT2 format?

Because I would like to be able to save the state of the solver in a temporary file in order to resume solving later, in order to have some time to understand what further queries I should make to it.

Many thanks in advance...


回答1:


SMT2 has no provisions of saving a given solvers state, which will no doubt differ widely from solver to solver. Each solver might have different mechanisms of doing so, however, but it will definitely not be in SMTLib2 format.

Since your question is entirely Z3 specific, I recommend asking it on https://github.com/Z3Prover/z3/issues to see if they might have anything interesting. So far as I know, however, this isn't possible currently.




回答2:


At the end Levent was right :)

Below are some observations by Nikolaj Bjorner, from the Z3 github website.

"The state of the solver isn't fully serializable to SMT2 format. You can print the solver to smt2 format based on the current assertions, but not learned clauses/units using the sexpr() method on the Solver object."

...

"We don't expose ways to print internal state. You could perhaps interrupt the solver, then clone it using the "translate" methods and access the translated solver state using internal print utilities. You would have to change the code a bit to get to this state. The print features on solvers don't access the internal state of any of the solvers, instead they look at the asserted formulas and print them. I don't translate learned lemmas. For example, the code in smt_context.cpp line 176 is disabled because it didn't help with any performance enhancements. Similarly, the copy code in sat_solver does not copy learned clauses even though it retains unit literals and binary clauses that are learned."

You can see the above comments by Nicolaj at this link.



来源:https://stackoverflow.com/questions/44110746/saving-the-state-of-a-z3-solver-in-smt2-format

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!