Datasets:
Download level_1/38.rs from CodeWalk/verus-proof-completion: direct link, hf CLI and curl.
- Browser
- Download file 954 Bytes
-
https://huggingface.co/datasets/CodeWalk/verus-proof-completion/resolve/main/level_1/38.rs
- Command line
-
hf download hf://datasets/CodeWalk/verus-proof-completion/level_1/38.rs
-
curl -L -o 38.rs https://huggingface.co/datasets/CodeWalk/verus-proof-completion/resolve/main/level_1/38.rs
954 Bytes
| use vstd::prelude::*; | |
| fn main() {} | |
| verus!{ | |
| fn f1_contains_consecutive_numbers(arr: &Vec<i32>) -> (is_consecutive: bool) | |
| requires | |
| arr.len() > 0, | |
| forall|i: int| 0 <= i < arr.len() ==> (0 <= arr[i] + 1 < i32::MAX), | |
| { | |
| let mut index = 0; | |
| while (index < arr.len() - 1) | |
| { | |
| if (arr[index] + 1 != arr[index + 1]) { | |
| return false; | |
| } | |
| index += 1; | |
| } | |
| true | |
| } | |
| spec fn step1(__hp0: Seq<i32>, outp: bool) -> bool { | |
| (outp == (forall|i: int, j: int| | |
| 0 <= i < j < __hp0.len() && j == i + 1 ==> (__hp0[i] + 1 == __hp0[j]))) | |
| } | |
| fn chain_driver(arr: &Vec<i32>) -> (r_final: bool) | |
| requires | |
| arr.len() > 0, | |
| forall|i: int| 0 <= i < arr.len() ==> (0 <= arr[i] + 1 < i32::MAX), | |
| ensures | |
| step1(arr@, r_final), | |
| { | |
| let x1 = f1_contains_consecutive_numbers(arr); | |
| proof { | |
| assert(step1(arr@, x1)); | |
| } | |
| x1 | |
| } | |
| } // verus! | |