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