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