Datasets:
Download level_1/47.rs from CodeWalk/verus-proof-completion: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/datasets/CodeWalk/verus-proof-completion/resolve/main/level_1/47.rs
- Command line
-
hf download hf://datasets/CodeWalk/verus-proof-completion/level_1/47.rs
-
curl -L -o 47.rs https://huggingface.co/datasets/CodeWalk/verus-proof-completion/resolve/main/level_1/47.rs
1.22 kB
| use vstd::prelude::*; | |
| fn main() {} | |
| verus!{ | |
| fn f1_interleave(s1: &Vec<i32>, s2: &Vec<i32>, s3: &Vec<i32>) -> (res: Vec<i32>) | |
| requires | |
| s1@.len() == s2@.len() && s2@.len() == s3@.len(), | |
| 0 <= (s1@.len() * 3) <= i32::MAX, | |
| { | |
| let new_seq_len = s1.len() * 3; | |
| let mut output_seq = Vec::with_capacity(new_seq_len); | |
| let mut index = 0; | |
| while index < s1.len() | |
| { | |
| output_seq.push(s1[index]); | |
| output_seq.push(s2[index]); | |
| output_seq.push(s3[index]); | |
| index += 1; | |
| } | |
| output_seq | |
| } | |
| spec fn step1(__hp0: Seq<i32>, __hp1: Seq<i32>, __hp2: Seq<i32>, outp: Seq<i32>) -> bool { | |
| (outp.len() == __hp0.len() * 3) | |
| && (forall|i: int| | |
| 0 <= i < __hp0.len() ==> (outp[3 * i] == __hp0[i] && outp[3 * i + 1] == __hp1[i] && outp[3 * i + 2] | |
| == __hp2[i])) | |
| } | |
| fn chain_driver(s1: &Vec<i32>, s2: &Vec<i32>, s3: &Vec<i32>) -> (r_final: Vec<i32>) | |
| requires | |
| s1@.len() == s2@.len() && s2@.len() == s3@.len(), | |
| 0 <= (s1@.len() * 3) <= i32::MAX, | |
| ensures | |
| step1(s1@, s2@, s3@, r_final@), | |
| { | |
| let x1 = f1_interleave(s1, s2, s3); | |
| proof { | |
| assert(step1(s1@, s2@, s3@, x1@)); | |
| } | |
| x1 | |
| } | |
| } // verus! | |