-
Notifications
You must be signed in to change notification settings - Fork 273
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
Handle quantifiers with statement expressions #8605
base: develop
Are you sure you want to change the base?
Handle quantifiers with statement expressions #8605
Conversation
5fe1c65
to
f9f9581
Compare
2c11ad1
to
7e30d2c
Compare
I am sure it makes sense to extend what's allowed in quantifiers. I am surprised by the choice of a (fragment) of statement expressions, which are a gcc extension at the C language level. In particular, note that this means you can't actually use these in Kani. The examples suggest that you are perhaps looking for let expressions? These are unproblematic to use in quantifiers, and Kani can use these right away. |
Kani is actually the motivation of support statement expressions in quantifiers. In Kani, we generate GOTO programs from Rust MIR. However, all Rust expressions will be compiled into a sequence of statements (including decl, assign, and conditional goto) in Rust MIR. We typically wrap all such statements into a closure function (in Rust) so that the evaluation of the Rust expressions becomes a single function call in GOTO. This approach doesn't work here because function calls are also side-effect expressions in GOTO. Therefore, we are considering inlining all function calls in MIR and generating a statement expression in GOTO from the inlined expression. I don't think let-expressions are enough here because there will still be function calls or statement expressions in the where clauses of the let-expressions. |
Ok, then how about defining the concept of a "pure" function, and then allowing those in quantifiers? We need that in the front-end anyway, for C++'s |
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.
A few initial comments, still need to work through the core piece of the implementation (see my "Note to self").
regression/cbmc/Quantifiers1/quantifier-with-function-call.desc
Outdated
Show resolved
Hide resolved
But then |
In the design of this PR, no function calls are allowed in quantifiers. |
35a0665
to
449b771
Compare
449b771
to
7969993
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #8605 +/- ##
===========================================
- Coverage 79.63% 79.17% -0.46%
===========================================
Files 1733 1733
Lines 197704 198973 +1269
Branches 17963 17967 +4
===========================================
+ Hits 157438 157536 +98
- Misses 40266 41437 +1171 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
68f15c9
to
d8d55ec
Compare
This commit addresses the issue of handling quantifiers that contain statement expressions in CBMC. Previously, quantifiers without side effects were not supported. Changes include: - Added logic to handle quantifiers with statement expressions in `goto_clean_expr.cpp`. - Updated `c_typecheck_expr.cpp` to allow quantifiers with statement expressions. - Introduced new tests to verify the correct handling of quantifiers with statement expressions.
d8d55ec
to
5cdfb0b
Compare
This pull request addresses the issue of handling quantifiers that contain statement expressions in CBMC. This fix ensures that CBMC can correctly process and verify programs that use quantifiers with statement expressions.
Changes
goto_clean_expr.cpp
: Added logic to handle quantifiers with statement expressions. This includes:find_base_symbol
to identify the base symbol in an expression.clean_expr
to handle quantifiers with statement expressions by converting them pure expressions.c_typecheck_expr.cpp
: Updated to allow quantifiers with statement expressions.Motivation and Context
Statement expressions may not contain side effects, and should be accepted as quantifier bodies when they don't.
Supporting quantifiers with statement expressions enhances CBMC's capability to handle a broader range of programs, e.g., GOTO program compiled from Rust MIR model-checking/kani#3737.