-
Notifications
You must be signed in to change notification settings - Fork 62
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
Uninterpret functions from a Term #1170
Comments
What does "EUF" mean? |
Equalities + Uninterpreted Functions. Essentially, if we uninterpret multiple instances of a function, we also want to say that they are all the same function, that is, they all return the same output if given the same input. |
In general, I feel like it would be pretty hard to predict the output of this procedure... if more than one occurrence of the function appears, what order will the inputs/outputs be generated? What if we want to do this with more than one function? Should we unfold definitions to find more occurrences to uninterpret? I think there's a neat idea here, but I'm not sure how to expose it in a way that I could confidently explain in a user manual. Is this a technique that's implemented in another system already? |
The list of input/output pairs should be treated as unordered. One would necessarily use 'map' to levy extra constraints on them.
There would be new input/output sequences, one for each function uninterrupted, in the order given by the sequence of function names in the command.
Yes. It should work just like the smt-based unint commands.
I don't know. |
So, if we imagine that two calls to
Is that right? Then proving something about f "up to uninterpreted g" would look something like:
I guess, very broadly, we can think about this as a manual process of doing quantifier elimination of the statement that the inputs and outputs of If there are interesting data-dependencies flowing from the output of one "uninterpreted" function into another, I think this transformation will force you to prove a different statement than the one you'd get from a standard uninterpreted theory. Maybe that's OK, though; I think the statement you need to prove then is strictly stronger (although I'll have to think pretty hard to convince myself of that). |
@robdockins That seems about right -- though, because of polymorphism, I'm trying to get to a command where a vanilla SAT solver produces results that are identical (logically) to what an SMT solver would produce using the current SMT |
From a purely user-interface point of view, how do you feel about flattening the function structure using fresh variables? I think it will make the transformation easier to understand and use. For example, the following is an interface I'm thinking about, using the
Here When you're done with manipulating the variable occurrences, you can abstract over them all again with |
@robdockins I like your proposal and the idea of using It occurred to me that this functionality could also be used to apply function overrides to terms (what we earlier called "grafting"). |
OK, I'll work in that direction and see how it goes. I think the result might get a little complicated if Indeed, I think it would be pretty easy to do grafting, or general pre/post verification using something like this. The downside is that it adds this term transformation to your trusted base. Maybe that's not too bad, especially if you prove that "grafting" the original function back into the extracted call sites is equal to the original term. |
I've opened a draft PR with an experimental command that implements the idea discussed above: #1185. A quick example follows. I haven't done a lot of testing yet, but if this basic design will suit your use case @weaversa, then I'll keep working along these lines.
|
PR #1310 is now merged, which incorporates the new experimental I'm going to leave this ticket open for now as we continue to experiment with the design, and to remind myself to add tests. |
This works pretty well. One issue I'm having is that this does not seem to be able to uninterpret a primitive such as |
FWIW, I had to change the above example slightly to get it to work with the current version of SAW. Here is my updated version:
|
@eddywestbrook Thanks for reworking the example. The issue we were experiencing was on our end. |
Here's the issue (and a potential solution!) Say we have the following sawscript file that contains a definition that sometimes calls error:
Even though
This alone makes use of It would be nice to replace the
Now we can use
It would be useful to be able to do this w/out having to write an explicit guard...but I don't think it's possible with the tools we have currently. Contents of
|
Tripping on impossible errors/assertions also appears at least in #2124, so we don't need to keep this open for it. That's a pretty excellent workaround though :-) I think this issue can be closed once some tests get added. |
Here is an idea for a new
saw
command that uninterprets a function (or a sequence of functions) in a Term. To provide an example, below we have a functionf
that callsg
, I then manually uninterpretedg
, creatingf'
. The basic mechanism is to untether the inputs and outputs to the function being uninterpreted, then pull those inputs and outputs up to the top-level Term's entry point. Inputs to the uninterpreted function become new outputs and outputs of the uninterpreted function become new inputs.In the case where the uninterpreted function is called multiple times, the end user could layer equality (by that I mean EUF) on top manually...or any other constraints really. This would allow one to, for example, use SAT rather than SMT in the presence of uninterpreted functions (which is beneficial for tying into work on UNSAT cores, which SAT solvers support but that there is lax support in SMT solver). This also allows one to transform functions with inverses, for example, an encrypt function (encrypt k p == c) into a decrypt (p == decrypt k c), which would enable more efficient solving because the SAT/SMT solver will unit propagate through the decrypt function (with a known key), where it would normally have to invert the encrypt function (which may be possible, but is certainly much slower than unit propagation).
The text was updated successfully, but these errors were encountered: