Sound trigger-independent function encoding#650
Merged
Conversation
…n preconditions. Function applications in quantifiers don't work yet.
Closed
…ons, and for posts for bodyless functions
mschwerhoff
approved these changes
Nov 25, 2022
mschwerhoff
left a comment
Contributor
There was a problem hiding this comment.
Generally LGTM. I left a few comments, only the one about documentation would entail some work.
| import viper.silicon.state.terms.{And, App, HeapDepFun, Implies, Ite, Let, Literal, Not, Or, Quantification, Term, True} | ||
| import viper.silver.ast | ||
|
|
||
| object PreconditionPropagationTransformer { |
Contributor
There was a problem hiding this comment.
Assuming the transformer propagates preconditions, how about PreconditionPropagatingTransformer?
Contributor
Author
There was a problem hiding this comment.
After writing down what it actually does, I settled on FunctionPreconditionTransformer. While it doesn't transform function preconditions, it transforms terms to state that all function preconditions are fulfilled.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR solves the unsoundness from issue #376 and #369.
The solution (which Gaurav and I worked out based on earlier discussions by other people, and which Gaurav is in the process of implementing for Carbon) is, for every heap-dependent function with a precondition, to use a new boolean uninterpreted function on the SMT-level that represents whether the function's precondition holds, and make definitional and postcondition axioms conditional on that new function being true.
Then, we emit the information that a function's precondition holds in different places:
The PreconditionPropagationTransformer (I'm very open to suggestions for better names and better places to put this code) takes a term that may contain applications of heap-dependent functions, and returns a term stating that the preconditions of all such function applications hold if the conditions under which they are called hold. That is, for a term t, after checking that it is well-defined, one may assume the transformed version of t.