Datasets:
Download level_1/2.rs from CodeWalk/verus-proof-completion: direct link, hf CLI and curl.
- Browser
- Download file 712 Bytes
-
https://huggingface.co/datasets/CodeWalk/verus-proof-completion/resolve/main/level_1/2.rs
- Command line
-
hf download hf://datasets/CodeWalk/verus-proof-completion/level_1/2.rs
-
curl -L -o 2.rs https://huggingface.co/datasets/CodeWalk/verus-proof-completion/resolve/main/level_1/2.rs
712 Bytes
| use vstd::prelude::*; | |
| fn main() {} | |
| verus!{ | |
| fn f1_find_even_numbers(arr: &Vec<u32>) -> (even_numbers: Vec<u32>) | |
| { | |
| let mut even_numbers: Vec<u32> = Vec::new(); | |
| let input_len = arr.len(); | |
| let mut index = 0; | |
| while index < arr.len() | |
| { | |
| if (arr[index] % 2 == 0) { | |
| even_numbers.push(arr[index]); | |
| } | |
| index += 1; | |
| } | |
| even_numbers | |
| } | |
| spec fn step1(__hp0: Seq<u32>, outp: Seq<u32>) -> bool { | |
| (outp == __hp0.filter(|x: u32| x % 2 == 0)) | |
| } | |
| fn chain_driver(arr: &Vec<u32>) -> (r_final: Vec<u32>) | |
| ensures | |
| step1(arr@, r_final@), | |
| { | |
| let x1 = f1_find_even_numbers(arr); | |
| proof { | |
| assert(step1(arr@, x1@)); | |
| } | |
| x1 | |
| } | |
| } // verus! | |