Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add model for vstd Set and prove its axioms #1426

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions source/rust_verify_test/tests/sets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ test_verify_one_file! {

proof fn test() {
let s: Set<nat> = set![9];
reveal_with_fuel(Set::fold, 10);
broadcast use fold::lemma_fold_insert, fold::lemma_fold_empty;
assert(s.finite());
assert(s.len() > 0);
assert(s.fold(0, |p: nat, a: nat| p + a) == 9);
assert(s.fold(|p: nat, a: nat| p + a, 0) == 9);

assert(set![].fold(0, |p: nat, a: nat| p + a) == 0);
assert(set![].fold(|p: nat, a: nat| p + a, 0) == 0);
}
} => Ok(())
}
4 changes: 2 additions & 2 deletions source/vstd/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ impl<K, V> Map<K, V> {

/// Gives a `Map<K, V>` whose domain contains every key, and maps each key
/// to the value given by `fv`.
pub open spec fn total(fv: impl Fn(K) -> V) -> Map<K, V> {
pub open spec fn total(fv: spec_fn(K) -> V) -> Map<K, V> {
Set::full().mk_map(fv)
}

/// Gives a `Map<K, V>` whose domain is given by the boolean predicate on keys `fk`,
/// and maps each key to the value given by `fv`.
pub open spec fn new(fk: impl Fn(K) -> bool, fv: impl Fn(K) -> V) -> Map<K, V> {
pub open spec fn new(fk: spec_fn(K) -> bool, fv: spec_fn(K) -> V) -> Map<K, V> {
Set::new(fk).mk_map(fv)
}

Expand Down
Loading