CONTRACTS: Add an option to not unwind transformed loops after applying loop contracts #7524
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
With the loop contracts simplification, applying loop contracts will result in transformed loops which will be executed exactly twice. It requires that the unwinding numbers of transformed loops have to be at least two to pass unwinding assertions. In #7318, we chose to unwind transformed loops for users to avoid them provide unwinding numbers less than two unaware.
Issue
Although unwinding transformed loops for users reduce the risk of unwinding-assertion failures, it introduces some new confusion. Besides making the GOTO program more complicated and less readable, it also duplicate all assertions twice, including the assertions that check whether the loop invariants hold before entry of the loop. Such duplicated properties are reported in the result if we run CBMC on the instrumented GOTO program, which may make users harder to locate the failure.
More importantly, when an assertion is designed to be unique with a unique ID, for example, Kani assign every reachability check a unique ID, duplicate such assertion will result that two assertions have the same ID and fail Kani' CBMC-result rendering.
Solution
In this PR, we add an option, in both
goto-instrument
andgoto-synthesizer
, so that users can choose to not unwind the transformed loops to avoid duplicate properties.