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.

Likewise, the specification is only meaningful when the Key obeys our hash table model, i.e., (1) Key::hash is deterministic, (2) any two Keys are identical if and only if the executable == operator considers them equal, and (3) Key::clone produces a result equal to its input. 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.

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.
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
ExHasher
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_411_DefaultHasher_32__58__58__32_new
_verus_external_fn_specification_412_DefaultHasher_32__58__58__32_write
_verus_external_fn_specification_413_DefaultHasher_32__58__58__32_finish
_verus_external_fn_specification_414_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_415_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_416_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_417__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_418_HashMap_32__58__58__32__60__32_Key_44__32_Value_32__62__32__58__58__32_new
_verus_external_fn_specification_419__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_420_HashMap_32__58__58__32__60__32_Key_44__32_Value_32__62__32__58__58__32_with__capacity
_verus_external_fn_specification_421_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_422_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_423_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_424_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_425_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_426_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_427_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_428_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_429_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_430_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_431_HashSet_32__58__58__32__60__32_Key_32__62__32__58__58__32_new
_verus_external_fn_specification_432__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_433_HashSet_32__58__58__32__60__32_Key_32__62__32__58__58__32_with__capacity
_verus_external_fn_specification_434_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_435_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_436_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_437_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_438_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_439_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_440_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_441_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_442_Entry_32__58__58__32_key
_verus_external_fn_specification_443_Entry_32__58__58__32_or__insert
_verus_external_fn_specification_444_Entry_32__58__58__32_insert__entry
_verus_external_fn_specification_445_OccupiedEntry_32__58__58__32_remove__entry
_verus_external_fn_specification_446_OccupiedEntry_32__58__58__32_get
_verus_external_fn_specification_447_OccupiedEntry_32__58__58__32_get__mut
_verus_external_fn_specification_448_OccupiedEntry_32__58__58__32_into__mut
_verus_external_fn_specification_449_OccupiedEntry_32__58__58__32_insert
_verus_external_fn_specification_450_OccupiedEntry_32__58__58__32_remove
_verus_external_fn_specification_451_VacantEntry_32__58__58__32_into__key
_verus_external_fn_specification_452_VacantEntry_32__58__58__32_insert
_verus_external_fn_specification_453_VacantEntry_32__58__58__32_insert__entry
axiom_bool_obeys_hash_table_key_model
axiom_box_bool_obeys_hash_table_key_model
axiom_box_integer_type_obeys_hash_table_key_model
axiom_box_key_removed
axiom_contains_box
axiom_contains_deref_key
axiom_deref_key_removed
axiom_has_resolved_entry
axiom_has_resolved_occupied_entry
axiom_has_resolved_vacant_entry
axiom_hashmap_decreases
axiom_hashmap_deepview_borrow
axiom_hashmap_view_finite_dom
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_maps_box_key_to_value
axiom_maps_deref_key_to_value
axiom_random_state_builds_valid_hashers
axiom_set_box_key_removed
axiom_set_box_key_to_value
axiom_set_contains_box
axiom_set_contains_deref_key
axiom_set_deref_key_removed
axiom_set_deref_key_to_value
axiom_spec_hash_keys_iter
axiom_spec_hash_map_iter
axiom_spec_hash_map_len
axiom_spec_hash_set_len
axiom_spec_keys_iter
axiom_spec_values_iter
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_removed
builds_valid_hashers
contains_borrowed_key
group_hash_axioms
hash_map_deep_view_impl
into_iter
into_iter_hash_keys
into_iter_keys
into_iter_values
lemma_hashmap_deepview_dom
lemma_hashmap_deepview_properties
lemma_hashmap_deepview_values
maps_borrowed_key_to_value
obeys_key_model
set_contains_borrowed_key
sets_borrowed_key_to_key
sets_differ_by_borrowed_key
spec_hash_keys_iter
spec_hash_map_iter
spec_hash_map_len
spec_hash_set_len
spec_keys_iter
spec_values_iter