Skip to content

allow multiple loop invariants #6214

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

Merged
merged 1 commit into from
Jul 7, 2021
Merged

allow multiple loop invariants #6214

merged 1 commit into from
Jul 7, 2021

Conversation

kroening
Copy link
Member

@kroening kroening commented Jul 6, 2021

This extends the grammar to allow multiple loop invariants for one loop.

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@kroening kroening added the Code Contracts Function and loop contracts label Jul 6, 2021
This extends the grammar to allow multiple loop invariants for one loop.
@kroening kroening force-pushed the multiple_invariants branch from 888b0c6 to b06b263 Compare July 6, 2021 12:36
@kroening kroening marked this pull request as ready for review July 6, 2021 13:18
@codecov
Copy link

codecov bot commented Jul 6, 2021

Codecov Report

Merging #6214 (b06b263) into develop (0a0a862) will increase coverage by 0.16%.
The diff coverage is 84.82%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #6214      +/-   ##
===========================================
+ Coverage    75.20%   75.37%   +0.16%     
===========================================
  Files         1458     1458              
  Lines       161311   161367      +56     
===========================================
+ Hits        121318   121634     +316     
+ Misses       39993    39733     -260     
Impacted Files Coverage Δ
src/ansi-c/c_typecheck_code.cpp 72.44% <0.00%> (-5.89%) ⬇️
src/goto-instrument/code_contracts.h 95.83% <ø> (ø)
src/goto-programs/goto_convert_class.h 87.30% <ø> (ø)
src/solvers/smt2/smt2_conv.h 100.00% <ø> (ø)
src/solvers/smt2/smt2_dec.h 100.00% <ø> (ø)
src/solvers/smt2/smt2_conv.cpp 66.62% <64.70%> (+0.08%) ⬆️
src/ansi-c/parser.y 79.16% <88.88%> (+18.29%) ⬆️
src/goto-programs/goto_convert.cpp 91.76% <90.00%> (+0.06%) ⬆️
src/goto-instrument/code_contracts.cpp 86.57% <91.30%> (+0.21%) ⬆️
src/solvers/flattening/boolbv.cpp 80.63% <100.00%> (ø)
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3e0007f...b06b263. Read the comment docs.

@SaswatPadhi SaswatPadhi added aws Bugs or features of importance to AWS CBMC users enhancement labels Jul 6, 2021
Copy link
Contributor

@SaswatPadhi SaswatPadhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also update the side-effect check:

exprt invariant =
static_cast<const exprt &>(code.find(ID_C_spec_loop_invariant));
exprt decreases_clause =
static_cast<const exprt &>(code.find(ID_C_spec_decreases));
if(!invariant.is_nil())
{
if(has_subexpr(invariant, ID_side_effect))
{
throw incorrect_goto_program_exceptiont(
"Loop invariant is not side-effect free.", code.find_source_location());
}

I see that the PR is now assigned to me / @feliperodri.
Should I make this change and merge the PR, @kroening?

@kroening
Copy link
Member Author

kroening commented Jul 7, 2021

No need to change this code, has_subexpr will work as required.

Copy link
Contributor

@SaswatPadhi SaswatPadhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!! Indeed, has_subexpr looks at the operands and would work as expected.

@kroening kroening assigned tautschnig and unassigned SaswatPadhi and feliperodri Jul 7, 2021
Copy link
Collaborator

@feliperodri feliperodri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@feliperodri feliperodri merged commit b35228a into develop Jul 7, 2021
@kroening kroening deleted the multiple_invariants branch January 29, 2022 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws Bugs or features of importance to AWS CBMC users Code Contracts Function and loop contracts enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants