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