Skip to content

Commit

Permalink
Add Resolve impls in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jhjourdan committed Dec 5, 2024
1 parent c3fc666 commit a080553
Show file tree
Hide file tree
Showing 54 changed files with 3,718 additions and 1,114 deletions.
1,099 changes: 880 additions & 219 deletions creusot/tests/should_succeed/hashmap.coma

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions creusot/tests/should_succeed/hashmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ impl<K: DeepModel, V> List<(K, V)> {
}
}


impl<K: DeepModel, V> Resolve for List<(K, V)> {
#[open(self)]
#[predicate(prophetic)]
fn resolve(self) -> bool {
// FIXME: we don't resolve keys because we only have access to their deep model.
pearlite! {
forall<k: K::DeepModelTy> resolve(&self.get(k))
}
}

#[open(self)]
#[logic(prophetic)]
#[requires(structural_resolve(self))]
#[ensures((*self).resolve())]
fn resolve_coherence(&self) {}
}

// A slightly simplified version of the Rust hashing mechanisms, this sufficiently captures the behavior though
trait Hash: DeepModel {
#[ensures(result@ == Self::hash_log(self.deep_model()))]
Expand Down Expand Up @@ -80,6 +98,25 @@ impl<K: Hash, V> View for MyHashMap<K, V> {
|k| self.bucket(k).get(k)
}
}

impl<K: Hash, V> Resolve for MyHashMap<K, V> {
#[open(self)]
#[predicate(prophetic)]
fn resolve(self) -> bool {
// FIXME: we don't resolve keys because we only have access to their deep model.
pearlite! {
forall<k: K::DeepModelTy> resolve(&self@.get(k))
}
}

#[open(self)]
#[logic(prophetic)]
#[requires(inv(self))]
#[requires(structural_resolve(self))]
#[ensures((*self).resolve())]
fn resolve_coherence(&self) {}
}

impl<K: Hash, V> MyHashMap<K, V> {
#[logic]
fn bucket(self, k: K::DeepModelTy) -> List<(K, V)> {
Expand Down
76 changes: 48 additions & 28 deletions creusot/tests/should_succeed/hashmap/why3session.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified creusot/tests/should_succeed/hashmap/why3shapes.gz
Binary file not shown.
Loading

0 comments on commit a080553

Please sign in to comment.