Check the when-condition for recursive call of spec fn#2039
Open
WeituoDAI wants to merge 3 commits intoverus-lang:mainfrom
Open
Check the when-condition for recursive call of spec fn#2039WeituoDAI wants to merge 3 commits intoverus-lang:mainfrom
WeituoDAI wants to merge 3 commits intoverus-lang:mainfrom
Conversation
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.
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.
Related to #2036 .
I notice that the decrease_when condition is not checked when it is recursively called inside a spec fn. For example, the definition below is allowed currently.
And an example found in
examples/syntax.rs:In fact, we cannot do any meaningful proof about this
dec0, since any call ofdec0(a)(a>0) will recursively calldec0(0)at last, but it is uninterp since it does not meet the when-condition (If I make no mistake, the decrease_when is implemented as such).It does not lead to soundness problem, but it must be a bug. For any recursive function
f, We knowf(x)is uninterp ifxdoes not meet the when-condition; if inside its body, there is a recursive callf(y)whereydoes not meet the when-condition, then the function can only return uninterp..In my eyes, decrease_when should really work like a pre-condition here.
So I (1) add the check of when-condition for any recursive call inside the body of spec function (2) change some related testcase