Skip to content
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

CONTRACTS: add doc for loop assigns inference #8516

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

qinheping
Copy link
Collaborator

This PR add an example, explanation, and limitation of the loop assigns inference used in DFCC contracts.

@qinheping
Copy link
Collaborator Author

qinheping commented Nov 21, 2024

Paste @rod-chapman's comment in qinheping#4 here:

Suggestion for future: doc changes like this should always be reviewed by at least one user, in addition to the CBMC development team themselves. There is a danger that the development team "know too much" about all this stuff, and don't appreciate how clueless newbie users (i.e. like me!) really are! I will take a look at this one.

Copy link

codecov bot commented Nov 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.84%. Comparing base (162e0f7) to head (fe41d1c).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #8516   +/-   ##
========================================
  Coverage    78.84%   78.84%           
========================================
  Files         1728     1728           
  Lines       198775   198766    -9     
  Branches     18406    18385   -21     
========================================
  Hits        156719   156719           
+ Misses       42056    42047    -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:


When loop invariant clauses are specified but loop assigns are not, CBMC will infer
loop assigns clauses and use them to apply loop contracts. The idea of the inference
is to include all the left hand side of assignments in the loop.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@rod-chapman 's comment in qinheping#4

What if a reference is taken as a r-value. i.e. a function call that contains f(&x, b) - is that an assign to x?

We inline f and check if there is any assignment to targets aliasing x in the inlined body. See incr function in test_loop_assigns_inference as an example.

3. assigns targets widening.

We do the function inlining first so that we can infer those assigns targets
hidden in the function call, for example, `j` is assigned to in `set_j`.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@rod-chapman 's comment in qinheping#4

What if the body of a called unit is not available, but that unit does have contracts, and --replace-all-with-contract has been specified? If you can't inline what happens? Can you get the info you need from the contract of the called unit alone?

Good point. As a next step, we will use functions' assigns for those with contracts instead of inlining them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant