-
Notifications
You must be signed in to change notification settings - Fork 168
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
Support PySMT #26
Comments
Implementing this would close issue #6 |
I can help with this (if it is still of interest). We are preparing the new release of pySMT (0.7.0) and afterwards, we would like to better understand possible use-cases that could be improved. |
Hi! Yes, it is still of interest. Any help will be very much appreciated. Let me know when you are ready and we'll talk about the details. |
We recently released pySMT 0.7.0 ! I took a quick look at barf.core.smt and it seems that:
If the above is true, integrating pySMT should be reasonably straight forward. I would probably do it directly within the smttranslator module, by replacing calls to smtlibv2 to corresponding calls to pySMT. Testing-wise, it seems that the tests in test_smttranslator are accessing directly the underlying solver. This means that the tests will have to change as the same time as the implementation. Do you have system tests that cover the end-to-end behavior of the tool? |
Great! :) Yes, your assessment is accurate. All the changes should be made in the Yes, the current tests need to be improved. We use BARF in another project which uses the SMT features extensively so we can test its behavior in case of changes. Unfortunately, that project is not release yet. As a intermediate solution you can run the scripts located in the |
I looked closer into this and looked into a couple of approaches. In particular, I was attempting to implement a PySMTSolver class that would be equivalent to Z3Solver and CVC4Solver as defined in smtlibv2.py. This would make the change backwards compatible, however, the current implementation mixes a bit the definition of the formula and the use of the solver, and this makes it hard to keep the change contained in one place. For example, the following is a simplified version of what happens in test_smttranslator.py : def test_add_mem_reg(self):
self._solver.reset()
# add constrains
mem = self._translator.get_memory()
eax = self._solver.mkBitVec(32, "eax_0") # !!!
constraint = (mem[eax] != 42) # This is not supported by pySMT
self._solver.add(constraint)
trans = self._translator.translate(instr)
self._solver.add(trans)
[...] The symbol eax is created in the solver, instead of being defined in the translator. My understanding is that this is in order to perform the symbol definitions, since that function calls another more general function where the solver is stored within the expression If the introduction of pySMT is meant to completely replace smtlibv2.py, then we can go with a more clean separation of expressions and solvers, but this will break backwards compatibility, and touch many parts of the code, therefore, I wanted to ask you before spending time on this.
Let me know what you think! |
I would definetly like a cleaner separation between formula and solver. I'm not sure, right now, which is the best way to achieve this; I need to take a better look into the code. However, I think the first step is to refactor the In conclusion, let me do the refactoring and then I will get back to you on this issue. |
An update on this. I refactored the entire smt package. It changed quite a bit from last time. I keep only functionality that was used and removed the rest. Now there is a cleaner separation between modules and, specially, between formulae and solvers (symbols are no longer created in the solver). Also, I added some more tests for all the modules. Please, take a look into the new code and let me known whether pySMT integration is possible. |
https://github.com/programa-stic/barf-project/compare/master...marcogario:intro_pysmt?expand=1 I made an example of how the testcases in test_smtsolver.py would be converted after the introduction of pySMT. There are two points that I would like your opinion on:
|
Hi! I took a look into the
I have a question. In your example it is no longer necessary to declare |
In pySMT we distinguish between expressions and the solver being used to reason on the expression. These are two distinct concepts that can live independently of each other. In many cases, we use pySMT to manipulate those expressions, and solving is just one of these manipulations. For this reason, the pySMT object that represents an expression is not linked with the solver. Each solver contains a Having said this, the way I see the integration is by replacing the class
Outside of the smt package, you can expose the pySMT objects directly. See line 93 of code analyzer:
If
or
However, as an initial step, I will try to see if it is possible to only change smtfunction.py and wrap pySMT there. |
Great! Thanks for the explanation. |
Current support for SMT solvers interaction is provided by a Python module taken from PySymEmu with custom modifications. It only supports Z3 and CVC4 solvers. The goal is to replace the aforementioned module with the package PySMT which supports multiple solvers very easily.
The text was updated successfully, but these errors were encountered: