use vstd::prelude::*; fn main() {} verus!{ fn f1_replace_last_element(first: &Vec, second: &Vec) -> (replaced_list: Vec) requires first.len() > 0, { let mut replaced_list = Vec::new(); let first_end = first.len() - 1; let mut index = 0; while index < first_end { replaced_list.push(first[index]); index += 1; } index = 0; while index < second.len() { replaced_list.push(second[index]); index += 1; } replaced_list } fn f2_contains(arr: &Vec, key: i32) -> (result: bool) { let mut i = 0; while i < arr.len() { if (arr[i] == key) { return true; } i += 1; } false } fn f2_any_value_exists(arr1: &Vec, arr2: &Vec) -> (result: bool) { let mut index = 0; while index < arr1.len() { if (f2_contains(arr2, arr1[index])) { return true; } index += 1; } false } spec fn step1(__hp0: Seq, __hp1: Seq, outp: Seq) -> bool { (outp == __hp0.subrange(0, __hp0.len() - 1).add(__hp1)) } spec fn step2(inp: Seq, p2_key: i32, outp: bool) -> bool { (outp == (exists|i: int| 0 <= i < inp.len() && (inp[i] == p2_key))) } fn chain_driver(first: &Vec, second: &Vec, p2_key: i32) -> (r_final: bool) requires first.len() > 0, ensures exists|v1: Seq| #[trigger] step1(first@, second@, v1) && step2(v1, p2_key, r_final), { let x1 = f1_replace_last_element(first, second); let x2 = f2_contains(&x1, p2_key); proof { assert(step1(first@, second@, x1@)); assert(step2(x1@, p2_key, x2)); } x2 } } // verus!