Skip to main content

hash_set_insert_ensures

Function hash_set_insert_ensures 

Source
pub open spec fn hash_set_insert_ensures<Key: Eq + Hash, S: BuildHasher, A: Allocator>(
    old_m: &HashSet<Key, S, A>,
    final_m: &HashSet<Key, S, A>,
    k: Key,
    result: bool,
) -> bool
Expand description
{
    ({
        &&& obeys_key_model::<Key>()
        &&& builds_valid_hashers::<S>()
        &&& hash_set_inv(old_m)

    })
        ==> {
            &&& hash_set_inv(final_m)
            &&& if result {
                &&& forall |stored_key: Key| (
                    #[trigger] old_m@.contains(stored_key) ==> !k.eq_spec(&stored_key)
                )
                &&& final_m@ == old_m@.insert(k)

            } else {
                &&& exists |stored_key: Key| (
                    #[trigger] old_m@.contains(stored_key) && k.eq_spec(&stored_key)
                )
                &&& final_m@ == old_m@

            }

        }
}