forked from diffblue/cbmc
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Library functions: mark them as compiled
When adding library functions to the goto model we no longer need their function bodies as values in the symbol table. Marking them as "compiled" will make sure we don't re-convert them in any subsequent run (e.g., running cbmc after goto-instrument). Doing so would undo any application of "drop-unused-functions." This was most notable with contracts/dynamic frames, where we ended up reporting thousands of properties as "SUCCESS" in library functions that were never actually called. For some contracts examples this now reduces the number of properties reported from over a thousand to tens of properties, and in other cases this made apparent that we were spuriously reporting "SUCCESS" when we never actually invoked those functions in the first place.
- Loading branch information
1 parent
0760cd7
commit 1e687f6
Showing
9 changed files
with
69 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
regression/contracts/variant_multidimensional_ackermann/loop.desc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
CORE | ||
main.c | ||
--apply-loop-contracts | ||
^\[ackermann\.\d+\] line 21 Check loop invariant before entry: SUCCESS$ | ||
^\[ackermann\.\d+\] line 21 Check that loop invariant is preserved: SUCCESS$ | ||
^\[ackermann\.\d+\] line 21 Check decreases clause on loop iteration: SUCCESS$ | ||
^\[ackermann.assigns.\d+\] line 29 Check that m is assignable: SUCCESS$ | ||
^\[ackermann.assigns.\d+\] line 30 Check that n is assignable: SUCCESS$ | ||
^\[ackermann.assigns.\d+\] line 35 Check that m is assignable: SUCCESS$ | ||
^\[ackermann.overflow.\d+] line 39 arithmetic overflow on signed \+ in n \+ 1: FAILURE$ | ||
^\*\* 1 of \d+ failed | ||
^VERIFICATION FAILED$ | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
-- | ||
-- | ||
It tests whether we can prove (only partially) the termination of the Ackermann | ||
function using a multidimensional decreases clause. | ||
|
||
Note that this particular implementation of the Ackermann function contains | ||
both a while-loop and recursion. Therefore, to fully prove the termination of | ||
the Ackermann function, we must prove both | ||
(i) the termination of the while-loop and | ||
(ii) the termination of the recursion. | ||
Because CBMC does not support termination proofs of recursions (yet), we cannot | ||
prove the latter, but the former. Hence, the termination proof in the code is | ||
only "partial." |
28 changes: 4 additions & 24 deletions
28
regression/contracts/variant_multidimensional_ackermann/test.desc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,18 @@ | ||
CORE | ||
main.c | ||
--apply-loop-contracts --replace-call-with-contract ackermann | ||
--replace-call-with-contract ackermann | ||
^\[ackermann.precondition\.\d+\] line \d+ Check requires clause of ackermann in main: SUCCESS$ | ||
^\[ackermann.precondition\.\d+\] line \d+ Check requires clause of ackermann in ackermann: SUCCESS$ | ||
^\[ackermann\.\d+\] line 21 Check loop invariant before entry: SUCCESS$ | ||
^\[ackermann\.\d+\] line 21 Check that loop invariant is preserved: SUCCESS$ | ||
^\[ackermann\.\d+\] line 21 Check decreases clause on loop iteration: SUCCESS$ | ||
^\[ackermann.assigns.\d+\] line 29 Check that m is assignable: SUCCESS$ | ||
^\[ackermann.assigns.\d+\] line 30 Check that n is assignable: SUCCESS$ | ||
^\[ackermann.assigns.\d+\] line 34 Check that n is assignable: SUCCESS$ | ||
^\[ackermann.assigns.\d+\] line 35 Check that m is assignable: SUCCESS$ | ||
^VERIFICATION SUCCESSFUL$ | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
-- | ||
It tests whether we can prove (only partially) the termination of the Ackermann | ||
function using a multidimensional decreases clause. | ||
|
||
Note that this particular implementation of the Ackermann function contains | ||
both a while-loop and recursion. Therefore, to fully prove the termination of | ||
the Ackermann function, we must prove both | ||
(i) the termination of the while-loop and | ||
(ii) the termination of the recursion. | ||
Because CBMC does not support termination proofs of recursions (yet), we cannot | ||
prove the latter, but the former. Hence, the termination proof in the code is | ||
only "partial." | ||
|
||
Furthermore, the Ackermann function has a function contract that the result | ||
The Ackermann function has a function contract that the result | ||
is always non-negative. This post-condition is necessary for establishing | ||
the loop invariant. However, in this test, we do not enforce the function | ||
contract. Instead, we assume that the function contract is correct and use it | ||
(i.e. replace a recursive call of the Ackermann function with its contract). | ||
(i.e. replace a recursive call of the Ackermann function with its contract). | ||
|
||
We cannot verify/enforce the function contract of the Ackermann function, since | ||
CBMC does not support function contracts for recursively defined functions. | ||
As of now, CBMC only supports function contracts for non-recursive functions. | ||
As of now, CBMC only supports function contracts for non-recursive functions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters