Skip to content

Allow quantifiers within loop invariants #6012

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 2 commits into from
May 20, 2021

Conversation

ArenBabikian
Copy link
Contributor

@ArenBabikian ArenBabikian commented Apr 5, 2021

This PR adds support for quantified expressions in loop contracts. This PR depends on #5942.

We have included 3 regression tests in this PR. However, two of them are marked as KNOWNBUG due to a current limitation of quantifiers that does not allow symbolic ranges for the quantified variable when using the SAT back-end.

  • 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).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@codecov
Copy link

codecov bot commented Apr 5, 2021

Codecov Report

Merging #6012 (c3ba7e0) into develop (763f6a2) will decrease coverage by 0.65%.
The diff coverage is 100.00%.

❗ Current head c3ba7e0 differs from pull request most recent head 6993cf4. Consider uploading reports for the commit 6993cf4 to get more accurate results
Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #6012      +/-   ##
===========================================
- Coverage    74.90%   74.24%   -0.66%     
===========================================
  Files         1447     1444       -3     
  Lines       158198   157335     -863     
===========================================
- Hits        118491   116810    -1681     
- Misses       39707    40525     +818     
Impacted Files Coverage Δ
src/goto-instrument/code_contracts.h 94.11% <ø> (+0.36%) ⬆️
src/goto-programs/goto_convert.cpp 91.07% <ø> (-0.63%) ⬇️
src/goto-instrument/code_contracts.cpp 84.53% <100.00%> (-0.82%) ⬇️
src/goto-checker/goto_verifier.h 0.00% <0.00%> (-100.00%) ⬇️
src/goto-instrument/wmm/shared_buffers.h 0.00% <0.00%> (-95.24%) ⬇️
src/goto-checker/goto_symex_fault_localizer.cpp 0.00% <0.00%> (-82.46%) ⬇️
src/goto-instrument/wmm/shared_buffers.cpp 0.00% <0.00%> (-77.84%) ⬇️
src/goto-checker/fault_localization_provider.h 33.33% <0.00%> (-66.67%) ⬇️
...er/stop_on_fail_verifier_with_fault_localization.h 0.00% <0.00%> (-60.87%) ⬇️
src/ansi-c/literals/convert_character_literal.cpp 31.70% <0.00%> (-40.09%) ⬇️
... and 744 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 c2f711b...6993cf4. Read the comment docs.

@ArenBabikian ArenBabikian force-pushed the loop-quantifiers-temp branch 2 times, most recently from d620735 to 27858ec Compare April 9, 2021 14:28
@SaswatPadhi SaswatPadhi changed the title Loop quantifiers temp Allow quantifiers within loop invariants [depends on: #5968, #5942] Apr 9, 2021
@ArenBabikian ArenBabikian force-pushed the loop-quantifiers-temp branch from 27858ec to ea1a0ca Compare April 9, 2021 20:02
@SaswatPadhi SaswatPadhi changed the title Allow quantifiers within loop invariants [depends on: #5968, #5942] Allow quantifiers within loop invariants [depends on: #5942] Apr 9, 2021
@SaswatPadhi SaswatPadhi added aws Bugs or features of importance to AWS CBMC users Code Contracts Function and loop contracts labels Apr 9, 2021
@ArenBabikian ArenBabikian force-pushed the loop-quantifiers-temp branch from ea1a0ca to bc2b17f Compare April 12, 2021 13:30
@SaswatPadhi
Copy link
Contributor

Hi @ArenBabikian,

For the KNOWNBUG test cases, could you please try the SMT backend? CPROVER SMT2 is not expected to succeed if the SAT backend does not, but we might have some luck with Z3.

  • Try running CBMC with --z3 locally
  • For CI, replace KNOWNBUG with CORE smt-backend broken-cprover-smt-backend

@SaswatPadhi SaswatPadhi force-pushed the loop-quantifiers-temp branch from bc2b17f to 97e1e19 Compare May 14, 2021 23:47
@SaswatPadhi SaswatPadhi changed the title Allow quantifiers within loop invariants [depends on: #5942] Allow quantifiers within loop invariants May 14, 2021
@SaswatPadhi SaswatPadhi force-pushed the loop-quantifiers-temp branch 3 times, most recently from 6224332 to dce19e2 Compare May 20, 2021 01:03
@SaswatPadhi SaswatPadhi force-pushed the loop-quantifiers-temp branch from dce19e2 to 86cb295 Compare May 20, 2021 01:19
@SaswatPadhi SaswatPadhi marked this pull request as ready for review May 20, 2021 01:19
@SaswatPadhi SaswatPadhi marked this pull request as draft May 20, 2021 05:01
@SaswatPadhi
Copy link
Contributor

Marking this as draft for now.

The failure traces look like the one from #6106, but they don't use char*. Need to take a closer look, and may be #6106 is due to some issue with contracts -> assertion/assumption translation and not char * or __CPROVER_w_ok.

Copy link
Collaborator

@martin-cs martin-cs left a comment

Choose a reason for hiding this comment

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

This doesn't look too controversial...

@SaswatPadhi SaswatPadhi force-pushed the loop-quantifiers-temp branch from 86cb295 to d4e1291 Compare May 20, 2021 17:16
@feliperodri feliperodri self-requested a review May 20, 2021 17:20
@feliperodri feliperodri marked this pull request as ready for review May 20, 2021 17:23
@SaswatPadhi SaswatPadhi force-pushed the loop-quantifiers-temp branch from d4e1291 to 54d930b Compare May 20, 2021 18:14
@SaswatPadhi SaswatPadhi force-pushed the loop-quantifiers-temp branch from 54d930b to 365cb82 Compare May 20, 2021 21:16
@ArenBabikian ArenBabikian requested a review from kroening as a code owner May 20, 2021 21:16
@SaswatPadhi SaswatPadhi force-pushed the loop-quantifiers-temp branch from 365cb82 to d06f847 Compare May 20, 2021 21:21
We do not need to do quantifier replacement within ASSIGNS annotation.
The replacement maps for ENSURES and REQUIRES clauses should also be
maintained independently.
@SaswatPadhi SaswatPadhi force-pushed the loop-quantifiers-temp branch from d06f847 to 8d448e5 Compare May 20, 2021 21:45
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.

5 participants