-
Notifications
You must be signed in to change notification settings - Fork 274
Supports nested quantifiers in function contracts #5968
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
Supports nested quantifiers in function contracts #5968
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has potential but I think some changes may be needed.
dcfb077
to
202359e
Compare
Codecov Report
@@ Coverage Diff @@
## develop #5968 +/- ##
===========================================
+ Coverage 74.02% 74.14% +0.12%
===========================================
Files 1444 1444
Lines 157307 157341 +34
===========================================
+ Hits 116441 116656 +215
+ Misses 40866 40685 -181
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM module the requested changes from @SaswatPadhi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good in principle but please can you use the appropriate exprt
types rather than just pulling things out of the operators array.
fbeef9e
to
9c925b9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving since it's not a blocker, but it would be nice to use const
references (const T &
) in place of copies (T
) wherever possible.
@@ -168,23 +169,56 @@ void code_contractst::add_quantified_variable( | |||
replace_symbolt &replace, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use const exprt& expression
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, I do not think that it is possible. But I the medium/long term, we should get rid of this parameter entirely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approve subject to the requested corrections.
Where possible use the named / most specific accessor functions. This is to avoid the need to rummage around in the irept
formatting. In most cases it is just stylistic but in the case of quantifiers it is covering a bug.
// 1. get quantified symbol | ||
quantifier_exprt quantifier_expression = to_quantifier_expr(expression); | ||
exprt tuple = quantifier_expression.operands().at(0); | ||
exprt quantified_variable = tuple.operands().at(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other ones I have flagged are style but here it really matters, you should use variables()
and where()
so that you can handle the case of multiple quantified variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made the modification as requested. However, I would like to point out that currently, it seems like quantifier expressions with multiple variables are not fully handled (or used, at least). This can be fixed in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, in my experience, most call sites use .symbol()
in place of .variables()
and expect a quantifier over a single variable. But thanks for the fix here. Looks good to me and we could add a regression test later once we handle multi-variable quantification properly.
7e02564
to
4e6f2a7
Compare
This adds support for nested quantifiers in funtion contracts. We recursively handle quantifiers that are nested within other quantifiers or within Boolean connectives.
4e6f2a7
to
33b412b
Compare
This PR adds support for nested quantified expressions in function contracts. It is a direct extension to #5959