CodeWalk's picture
Add CodeWalk verus-proof-completion benchmark
c62beea verified
Raw History Blame Contribute Delete
982 Bytes
use vstd::prelude::*;
fn main() {}
verus!{
fn f1_linear_search(nums: Vec<i32>, target: i32) -> (ret: i32)
requires
nums@.len() < 0x8000_0000,
{
let mut i = 0;
while i < nums.len()
{
if nums[i] == target {
break;
}
i = i + 1;
}
if i == nums.len() {
-1
} else {
i as i32
}
}
spec fn step1(__hp0: Seq<i32>, __hp1: i32, outp: i32) -> bool {
(outp < __hp0.len())
&& (outp >=0 ==> __hp0[outp as int] == __hp1)
&& (outp >=0 ==> forall |i: int| 0 <= i < outp as int ==> #[trigger]__hp0[i]!= __hp1)
&& (outp < 0 ==> forall |i: int| 0 <= i < __hp0.len() as int ==> #[trigger]__hp0[i] != __hp1)
}
fn chain_driver(nums: Vec<i32>, target: i32) -> (r_final: i32)
requires
nums@.len() < 0x8000_0000,
ensures
step1(nums@, target, r_final),
{
let x1 = f1_linear_search(nums, target);
proof {
assert(step1(nums@, target, x1));
}
x1
}
} // verus!