Skip to main content

Module hash

Module hash 

Source
Expand description

This code adds specifications for the standard-library types std::collections::HashMap and std::collections::HashSet.

Most of the specification only applies if you use HashMap<Key, Value> or HashSet<Key>. If you use some custom build hasher, e.g., withHashMap<Key, Value, CustomBuildHasher>, the specification won’t specify much unless you assume builds_valid_hashers<CustomBuildHasher>().

Likewise, the specification is only meaningful when eq_spec faithfully models executable equality; executable equality is reflexive, symmetric, and transitive; hashing is deterministic; executable-equal keys hash identically; and cloning, when supported, preserves structural identity and executable equality. We have an axiom that all primitive types and Boxes thereof obey this model. But if you want to use some other key type MyKey, you need to explicitly state your assumption that it does so with assume(vstd::std_specs::hash::obeys_key_model::<MyKey>());. In the future, we plan to devise a way for you to prove that it does so, so that you don’t have to make such an assumption.

The assumed specs don’t assume that executable equality matches structural equality, or that executable equality matches deep_view equality. But we provide broadcast lemmas that derive stronger properties for when either of those do match.

Borrowed-key lookups also require borrowed_key_hashing_matches::<Key, Q>() and use the model in BorrowSpec. Their postconditions additionally require Q to obey the hashing and equality models. Compatibility is supplied for identity, reference, Box, and String borrowing.

By default, the Verus standard library brings useful axioms about the behavior of HashMap and HashSet into the ambient reasoning context by broadcasting the group vstd::std_specs::hash::group_hash_axioms.

Structs§

ExDefaultHasher
Specifications for the behavior of std::collections::hash_map::DefaultHasher.
ExEntry
ExHashMap
Specifications for the behavior of std::collections::HashMap.
ExHashSet
Specifications for the behavior of std::collections::HashSet.
ExKeys
Specifications for the behavior of std::collections::hash_map::Keys.
ExMapIntoIter
ExMapIter
ExOccupiedEntry
ExRandomState
Specifications for the behavior of std::hash::RandomState.
ExSetIter
ExVacantEntry
ExValues
Specifications for the behavior of std::collections::hash_map::Values.

Traits§

DefaultHasherAdditionalSpecFns
EntrySpecFns
Specification for an Entry. Contains the current key for the entry, and prophesies the final value after this instantiation of the entry API is complete.
ExBuildHasher
HashMapAdditionalSpecFns
OccupiedEntrySpecFns
Specification for an OccupiedEntry. Contains the current key and value in the entry, and prophesies the final value after this instantiation of the entry API is complete. The final value is optional, since the user might choose to remove the entry.
VacantEntrySpecFns
Specification for a VacantEntry. Contains the current key for the entry, and prophesies the final value after this instantiation of the entry API is complete. The final value is optional, since the user may or may not choose to insert a value.

Functions§

_verus_external_fn_specification_778_DefaultHasher_32__58__58__32_new⚠
_verus_external_fn_specification_779_DefaultHasher_32__58__58__32_write⚠
_verus_external_fn_specification_780_DefaultHasher_32__58__58__32_finish⚠
_verus_external_fn_specification_781_HashMap_32__58__58__32__60__32_Key_44__32_Value_44__32_S_44__32_A_32__62__32__58__58__32_iter⚠
_verus_external_fn_specification_782_HashMap_32__58__58__32__60__32_Key_44__32_Value_44__32_S_44__32_A_32__62__32__58__58__32_into__iter⚠
_verus_external_fn_specification_783_HashMap_32__58__58__32__60__32_Key_44__32_Value_44__32_S_44__32_A_32__62__32__58__58__32_len⚠
_verus_external_fn_specification_784_HashMap_32__58__58__32__60__32_Key_44__32_Value_44__32_S_44__32_A_32__62__32__58__58__32_capacity⚠
_verus_external_fn_specification_785_HashMap_32__58__58__32__60__32_Key_44__32_Value_44__32_S_44__32_A_32__62__32__58__58__32_is__empty⚠
_verus_external_fn_specification_786__60__32_HashMap_32__58__58__32__60__32_K_44__32_V_44__32_S_44__32_A_44__32__62__32_as_32_Clone_32__62__32__58__58__32_clone⚠
_verus_external_fn_specification_787_HashMap_32__58__58__32__60__32_Key_44__32_Value_32__62__32__58__58__32_new⚠
_verus_external_fn_specification_788__60__32_HashMap_32__60__32_K_44__32_V_44__32_S_44__32__62__32_as_32_core_32__58__58__32_default_32__58__58__32_Default_32__62__32__58__58__32_default⚠
_verus_external_fn_specification_789_HashMap_32__58__58__32__60__32_Key_44__32_Value_32__62__32__58__58__32_with__capacity⚠
_verus_external_fn_specification_790_HashMap_32__58__58__32__60__32_Key_44__32_Value_44__32_S_32__62__32__58__58__32_with__hasher⚠
_verus_external_fn_specification_791_HashMap_32__58__58__32__60__32_Key_44__32_Value_44__32_S_44__32_A_44__32__62__32__58__58__32_reserve⚠
_verus_external_fn_specification_792_HashMap_32__58__58__32__60__32_Key_44__32_Value_44__32_S_44__32_A_44__32__62__32__58__58__32_insert⚠
_verus_external_fn_specification_793_HashMap_32__58__58__32__60__32_Key_44__32_Value_44__32_S_44__32_A_32__62__32__58__58__32_contains__key_32__58__58__32__60__32_Q_32__62_⚠
_verus_external_fn_specification_794_HashMap_32__58__58__32__60__32_Key_44__32_Value_44__32_S_44__32_A_32__62__32__58__58__32_get_32__58__58__32__60__32_Q_32__62_⚠
_verus_external_fn_specification_795_HashMap_32__58__58__32__60__32_Key_44__32_Value_44__32_S_44__32_A_32__62__32__58__58__32_remove_32__58__58__32__60__32_Q_32__62_⚠
_verus_external_fn_specification_796_HashMap_32__58__58__32__60__32_Key_44__32_Value_44__32_S_44__32_A_32__62__32__58__58__32_clear⚠
_verus_external_fn_specification_797_HashMap_32__58__58__32__60__32_Key_44__32_Value_44__32_S_44__32_A_32__62__32__58__58__32_keys⚠
_verus_external_fn_specification_798_HashMap_32__58__58__32__60__32_Key_44__32_Value_44__32_S_44__32_A_32__62__32__58__58__32_values⚠
_verus_external_fn_specification_799_HashSet_32__58__58__32__60__32_Key_44__32_S_44__32_A_32__62__32__58__58__32_len⚠
_verus_external_fn_specification_800_HashSet_32__58__58__32__60__32_Key_44__32_S_44__32_A_32__62__32__58__58__32_is__empty⚠
_verus_external_fn_specification_801_HashSet_32__58__58__32__60__32_Key_32__62__32__58__58__32_new⚠
_verus_external_fn_specification_802__60__32_HashSet_32__60__32_T_44__32_S_44__32__62__32_as_32_core_32__58__58__32_default_32__58__58__32_Default_32__62__32__58__58__32_default⚠
_verus_external_fn_specification_803_HashSet_32__58__58__32__60__32_Key_32__62__32__58__58__32_with__capacity⚠
_verus_external_fn_specification_804_HashSet_32__58__58__32__60__32_Key_44__32_S_32__62__32__58__58__32_with__hasher⚠
_verus_external_fn_specification_805_HashSet_32__58__58__32__60__32_Key_44__32_S_32__62__32__58__58__32_with__capacity__and__hasher⚠
_verus_external_fn_specification_806_HashSet_32__58__58__32__60__32_Key_44__32_S_44__32_A_44__32__62__32__58__58__32_reserve⚠
_verus_external_fn_specification_807_HashSet_32__58__58__32__60__32_Key_44__32_S_44__32_A_44__32__62__32__58__58__32_insert⚠
_verus_external_fn_specification_808_HashSet_32__58__58__32__60__32_Key_44__32_S_44__32_A_32__62__32__58__58__32_contains⚠
_verus_external_fn_specification_809_HashSet_32__58__58__32__60__32_Key_44__32_S_44__32_A_32__62__32__58__58__32_get_32__58__58__32__60__32_Q_32__62_⚠
_verus_external_fn_specification_810_HashSet_32__58__58__32__60__32_Key_44__32_S_44__32_A_32__62__32__58__58__32_remove_32__58__58__32__60__32_Q_32__62_⚠
_verus_external_fn_specification_811_HashSet_32__58__58__32__60__32_Key_44__32_S_44__32_A_32__62__32__58__58__32_clear⚠
_verus_external_fn_specification_812_HashSet_32__58__58__32__60__32_Key_44__32_S_44__32_A_32__62__32__58__58__32_iter⚠
_verus_external_fn_specification_813_HashMap_32__58__58__32__60__32_Key_44__32_Value_44__32_S_44__32_A_44__32__62__32__58__58__32_entry⚠
_verus_external_fn_specification_814_Entry_32__58__58__32_key⚠
_verus_external_fn_specification_815_Entry_32__58__58__32_or__insert⚠
_verus_external_fn_specification_816_Entry_32__58__58__32_insert__entry⚠
_verus_external_fn_specification_817_OccupiedEntry_32__58__58__32_remove__entry⚠
_verus_external_fn_specification_818_OccupiedEntry_32__58__58__32_get⚠
_verus_external_fn_specification_819_OccupiedEntry_32__58__58__32_get__mut⚠
_verus_external_fn_specification_820_OccupiedEntry_32__58__58__32_into__mut⚠
_verus_external_fn_specification_821_OccupiedEntry_32__58__58__32_insert⚠
_verus_external_fn_specification_822_OccupiedEntry_32__58__58__32_remove⚠
_verus_external_fn_specification_823_VacantEntry_32__58__58__32_into__key⚠
_verus_external_fn_specification_824_VacantEntry_32__58__58__32_insert⚠
_verus_external_fn_specification_825_VacantEntry_32__58__58__32_insert__entry⚠
axiom_bool_obeys_hash_table_key_model
axiom_borrowed_key_hashing_matches_box
axiom_borrowed_key_hashing_matches_ref
axiom_borrowed_key_hashing_matches_self
axiom_borrowed_key_hashing_matches_string
axiom_box_bool_obeys_hash_table_key_model
axiom_box_integer_type_obeys_hash_table_key_model
axiom_has_resolved_entry
axiom_has_resolved_occupied_entry
axiom_has_resolved_vacant_entry
axiom_hashmap_decreases
axiom_hashset_decreases
axiom_i8_obeys_hash_table_key_model
axiom_i16_obeys_hash_table_key_model
axiom_i32_obeys_hash_table_key_model
axiom_i64_obeys_hash_table_key_model
axiom_i128_obeys_hash_table_key_model
axiom_isize_obeys_hash_table_key_model
axiom_key_model_implies_obeys_eq
axiom_random_state_builds_valid_hashers
axiom_spec_hash_map_len
axiom_spec_hash_set_len
axiom_str_obeys_hash_table_key_model
axiom_string_obeys_hash_table_key_model
axiom_u8_obeys_hash_table_key_model
axiom_u16_obeys_hash_table_key_model
axiom_u32_obeys_hash_table_key_model
axiom_u64_obeys_hash_table_key_model
axiom_u128_obeys_hash_table_key_model
axiom_usize_obeys_hash_table_key_model
borrowed_key_hashing_matches
builds_valid_hashers
group_hash_axioms
hash_map_contains_key_ensures
hash_map_deep_view_impl
hash_map_entry_ensures
hash_map_get_ensures
hash_map_insert_ensures
hash_map_inv
hash_map_remove_ensures
hash_set_contains_ensures
hash_set_get_ensures
hash_set_insert_ensures
hash_set_inv
hash_set_remove_ensures
into_iter
into_iter_entries
into_iter_hash_keys
into_iter_keys
into_iter_values
lemma_hash_map_contains_key_ensures_if_obeys_concrete_eq
lemma_hash_map_contains_key_ensures_if_obeys_deep_eq
lemma_hash_map_entry_ensures_if_obeys_concrete_eq
lemma_hash_map_entry_ensures_if_obeys_deep_eq
lemma_hash_map_get_ensures_if_obeys_concrete_eq
lemma_hash_map_get_ensures_if_obeys_deep_eq
lemma_hash_map_insert_ensures_if_obeys_concrete_eq
lemma_hash_map_insert_ensures_if_obeys_deep_eq
lemma_hash_map_remove_ensures_if_obeys_concrete_eq
lemma_hash_map_remove_ensures_if_obeys_deep_eq
lemma_hash_set_contains_ensures_if_obeys_concrete_eq
lemma_hash_set_contains_ensures_if_obeys_deep_eq
lemma_hash_set_get_ensures_if_obeys_concrete_eq
lemma_hash_set_get_ensures_if_obeys_deep_eq
lemma_hash_set_insert_ensures_if_obeys_concrete_eq
lemma_hash_set_insert_ensures_if_obeys_deep_eq
lemma_hash_set_remove_ensures_if_obeys_concrete_eq
lemma_hash_set_remove_ensures_if_obeys_deep_eq
lemma_hashmap_deepview_dom
lemma_hashmap_deepview_properties
lemma_hashmap_deepview_values
lemma_key_model_implies_obeys_eq
obeys_key_model
spec_hash_map_len
spec_hash_set_len