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