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