Skip to main content

hash_map_insert_ensures

Function hash_map_insert_ensures 

Source
pub open spec fn hash_map_insert_ensures<Key: Eq + Hash, Value, S: BuildHasher, A: Allocator>(
    old_m: &HashMap<Key, Value, S, A>,
    final_m: &HashMap<Key, Value, S, A>,
    k: Key,
    v: Value,
    result: Option<Value>,
) -> bool
Expand description
{
    ({
        &&& obeys_key_model::<Key>()
        &&& builds_valid_hashers::<S>()
        &&& hash_map_inv(old_m)

    })
        ==> {
            &&& hash_map_inv(final_m)
            &&& match result {
                Some(old_value) => {
                    exists |stored_key: Key| {
                        &&& #[trigger] old_m@.contains_key(stored_key)
                        &&& k.eq_spec(&stored_key)
                        &&& old_value == old_m@[stored_key]
                        &&& final_m@ == old_m@.insert(stored_key, v)

                    }
                }
                None => (
                    &&& forall |stored_key: Key| (
                        #[trigger] old_m@.contains_key(stored_key)
                            ==> !k.eq_spec(&stored_key)
                    )
                    &&& final_m@ == old_m@.insert(k, v)

                ),
            }

        }
}