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