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