-
Notifications
You must be signed in to change notification settings - Fork 102
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
proof_for_contract
much slower than proof
(or even runs out of memory)
#3797
Comments
Thanks for filing this issue @BusyBeaver-42. The performance difference is not unexpected. The Nevertheless, we'll investigate to check if performance can be improved. |
Hi, I can confirm @zhassan-aws answer. Contracts instrumentation adds a number of ghost array variables to the model in order to track detailed read/write permissions, each allocation or assignment triggers a lookup in these ghost arrays. Our generation of array theory lemmas in CBMC is known to have a quadratic blowup in bad cases. The size of these ghost arrays is determined by the value passed to CBMC for Possible workarounds would be:
|
Hi, thanks for your replies! Since the locations where the function writes are statically known, I naively assumed that verifying the I understand that I can use loop contracts in this case, but I was aiming to provide a simple example. The actual functions I am trying to verify are Regarding loop contracts, I tried using them, but they didn’t seem to have any effect (whether or not I used PS: On the topic of documentation, there’s a small issue in the documentation for |
CC @qinheping
Good catch. Can you file an issue? |
Thank you for your feedback!
I guess you did nothing wrong with loop contracts. The reason it didn't work is that the loop contracts now only support while-loops with boolean expressions as conditions. You could try to use loop contracts by rewriting your loops as follow. let mut i = 0;
#[kani::loop_invariant(0 <= i && i <= SIZE)]
while i < SIZE {
let mut j = 0;
#[kani::loop_invariant(0 <= j && j <= SIZE)]
while j < SIZE {
copy(s, i, j);
j += 1;
}
i += 1;
}
Good point. There are some examples in https://github.com/model-checking/kani/tree/main/tests/expected/loop-contract. I will add more to the documentation. |
Thanks for your replies!
@zhassan-aws I've opened issue #3815.
I actually did not think of looking at the tests ^^', that's a great advice. :-) |
Note: To reproduce the example, the loops must be manually unrolled otherwise an other issue occurs (see #3796).
I tried this code:
using the following command line invocation:
with Kani version:
I expected to see this happen: Both of the verifications to take roughly the same time.
Instead, this happened:
SIZE = 5
proof
Verification Time: 1.4301268sproof_for_contract
Verification Time: 48.407013sSIZE = 10
proof
Verification Time: 4.190568sproof_for_contract
Verification Time:CBMC failed VERIFICATION:- FAILED CBMC appears to have run out of memory.
The text was updated successfully, but these errors were encountered: