-
Notifications
You must be signed in to change notification settings - Fork 99
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
Confused why this hangs ? #508
Comments
And, likewise I'm struggling to get quantified statements through: #[cfg(rmc)]
#[no_mangle]
pub fn test_02() {
// Create arbitrary array of size 3
let xs : [u32; 2] = __nondet();
// Create arbitrary index within array
let i : usize = __nondet();
__VERIFIER_assume(i < xs.len());
// Ensure known value at that point
__VERIFIER_assume(xs[i] == 0);
// Ensure nothing in array below i matches
for j in 0..2 {
if j != i {
__VERIFIER_assume(xs[j] != 0);
}
}
//
assert!(indexof(&xs,0) == i);
} If I manually unroll the loop then its fine. |
The non-termination in There is an ongoing discussion to change the default unwinding depth to 0 to avoid this confusion. |
Hey @zhassan-aws, Ah, thanks --- I should have looked at that. For some reason I was expecting, since the number of iterations is fixed it would effectively just unroll it. |
Hmmm, have made progress but I don't really understand from the tutorial what exactly the "unwinding assertion" is telling me when its failing. Its somehow telling me that I need to unwind more? How does RMC / CBMC decide this? |
Yes, a failing unwinding assertion indicates that a larger unwinding is needed. The unwinding assertions option adds a check that the |
Thanks! I'm making progress on this. Here's what I have now: const LIMIT : usize = 6;
#[cfg(rmc)]
#[no_mangle]
pub fn test_01() {
// Create arbitrary array
let xs : [u32; LIMIT] = __nondet();
// Create arbitrary element
let x : u32 = __nondet();
// Create arbitrary (valid) length
let len : usize = __nondet();
__VERIFIER_assume(len <= LIMIT);
// Ensure element not in array below len
for i in 0..len {
__VERIFIER_assume(xs[i] != x);
}
// Check
assert!(indexof(&xs[..len],x) == usize::MAX);
}
#[cfg(rmc)]
#[no_mangle]
pub fn test_02() {
// Create arbitrary array
let xs : [u32; LIMIT] = __nondet();
// Create arbitrary element
let x : u32 = __nondet();
// Create arbitrary (valid) length
let len : usize = __nondet();
__VERIFIER_assume(len <= LIMIT);
// Create arbitrary index within array
let i : usize = __nondet();
__VERIFIER_assume(i < len);
// Ensure known value at index i
__VERIFIER_assume(xs[i] == x);
// Ensure nothing in array below i matches
for j in 0..i {
__VERIFIER_assume(xs[j] != x);
}
// Check find correct one
assert!(indexof(&xs[..len],x) == i);
} How does this look in terms of how you would write it? The performance is interesting as with |
Looks good to me. By default, CBMC uses MiniSat. You might want to try with a more modern SAT solver, e.g. Kissat. To specify a different SAT solver, use
|
Ok, will do --- thanks!! |
Hey,
So, basically, I'm just refactoring some tests and I had something like this:
This seems to work fine, and I was writing more tests like this so refactored like so:
But, the second version hangs for reasons unknown. They seem equivalent to me! (full listing below)
Thoughts appreciated!!
The text was updated successfully, but these errors were encountered: