-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 serialize and deserialize a z3::model (c++)? #4679
Comments
The Z3_model_to_string creates an SMT2 compliant set of definitions.
Then in separate process:
I can see that the C++ API doesn't have a model.to_string() method. I will add this next so future generations don't need stringstream. |
Nikolaj, thanks for your prompt reply! I followed your overall scheme by doing:
in one process, and
in another. (Note: If I use s.model(), I get the following error, so I substituted s.model() with with s.get_model()).
Unfortunately, the model object
My Z3 version is 4.8.9. What am I missing? Thank you for your kind help! Srinivas |
You want to |
I need to check this on my end: the declarations are parsed, but I don't see them in the model as advertised. |
Nikolaj,
I added this statement to the location where the model is printed in the first process. Unfortunately, that didn't help. :( I noted that the value is visible in the serialized model that I receive in the second process, e.g., if I print the
but the constructed model seems not to evaluate anything to its value in the model (e.g., the Please let me know if I can clarify or provide more info to get help on this. Thanks! |
This is what I meant by:
|
Signed-off-by: Nikolaj Bjorner <[email protected]>
Here is a test for the fix that was checked in (Python sets the Z3_PRINT_SMTLIB2_COMPLIANT by default, C++ does not):
|
I have fixed the issue identified. You should be able to reparse models using the latest version in the repository. |
That worked fantastic! Thank you so much for your kind and prompt help with this! |
this is not a supported scenario, sorry. |
Is there any other method to serialize/deserialize models in python? I find myself in a similar situation as OP but I'm using python instead of c++. |
@Kingloko, FWIW we refactored the z3 C++ client-server implementation from our system into a standalone tool. Here it is. https://github.com/smartnic/z3validation Sharing in case it's useful to you. |
Hello,
I'm attempting to find the easiest method to serialize and deserialize a z3 model using the C++ api. We have a multi-process setup where queries are discharged from one process to another via RPC, and the second process runs the z3 solver (check() and get_model() functions). The second process must return the model to the first process so that it can construct a z3::model C++ object out of it.
What's the easiest/right way to do this? I've looked at the Z3 model (c++) api. I found that Z3_model_to_string() can be used to construct a serialized smt2lib string from a model. However, I couldn't find a corresponding deserializing function. Please help?
Srinivas
The text was updated successfully, but these errors were encountered: