Implement BoundedArbitrary for BTreeMap and BTreeSet#4626
Open
hz2 wants to merge 2 commits into
Open
Conversation
hz2
force-pushed
the
bounded-arbitrary-btree
branch
2 times, most recently
from
July 10, 2026 14:06
41da7be to
8e142d8
Compare
hz2
marked this pull request as ready for review
July 10, 2026 14:06
Contributor
There was a problem hiding this comment.
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
feliperodri
approved these changes
Jul 11, 2026
Contributor
|
@hz2 don't forget to update the branch and address all CI issues before merging. Thanks for the contribution! 🦀 |
Add BoundedArbitrary implementations for BTreeMap<K, V> and BTreeSet<V>,
following the same pattern as the existing HashMap and HashSet impls.
BTreeMap and BTreeSet operations cause state-space explosion during
verification due to tree rebalancing internals. Providing a bounded
constructor via BoundedArbitrary gives users an idiomatic way to generate
symbolic BTree collections with controlled size.
Usage:
let map: BTreeMap<u8, bool> = kani::bounded_any::<_, 4>();
Note that duplicate arbitrary keys/values collapse cardinality, and assert the upper-bound invariant explicitly in the test harnesses.
hz2
force-pushed
the
bounded-arbitrary-btree
branch
from
July 17, 2026 20:48
8e142d8 to
afa39be
Compare
feliperodri
enabled auto-merge
July 18, 2026 06:13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BoundedArbitraryimplementations forBTreeMap<K, V>andBTreeSet<V>HashMapandHashSetimpls inlibrary/kani/src/bounded_arbitrary.rstests/expected/bounded-arbitrary/btree/Motivation
BTreeMap and BTreeSet operations cause state-space explosion during verification due to tree rebalancing internals (see #1251, #3965). Users currently have no idiomatic way to generate bounded symbolic BTree collections.
The existing
BoundedArbitraryimpls coverVec,Box<[T]>,String,HashMap, andHashSet-- butBTreeMapandBTreeSetare absent despite being commonly used in Rust codebases.This addition lets users write:
Testing
Added
tests/expected/bounded-arbitrary/btree/btree.rswith cover property checks for sizes 0, 1, and 2 on bothBTreeMapandBTreeSet, matching the structure oftests/expected/bounded-arbitrary/hash/hash.rs.Related issues: #1251, #3965