|
Hi all, disclaimer: I'm totally new to formal verification and creusot, so bear with me 😄 I try to verify a simple With this "toy example" I want to verify, if creusot is the right tool for this (suitable for verifying HashMap operations). I've read that verifying HashMap operations is generally very hard for the SMT solver, so am I going down the wrong path here? What follows is the toy example I'm trying to verify and the output of why3 IDE: Code to verifyuse ::std::collections::HashMap;
use creusot_contracts::{View, ensures, logic, open};
struct Foo(HashMap<u64, u8>);
impl View for Foo {
type ViewTy = <HashMap<u64, u8> as View>::ViewTy; //FMap<Int, u8>;
#[logic]
#[open]
fn view(self) -> Self::ViewTy {
self.0.view()
}
}
impl Foo {
pub fn new() -> Self {
Self(HashMap::new())
}
#[ensures((^self)@.get(num@) == Some(bar))]
pub fn add(&mut self, num: u64, bar: u8) {
*self.0.entry(num).or_insert(bar) = bar;
}
}Output of why3Command: Versions:
|
Replies: 2 comments 5 replies
|
Hi @janriemer, and think you for trying Creusot ! Unfortunately, we have not yet spend enough time in giving a formal specification to However, there should not be any fundamental difficulty here. You are welcome to contribute! |
|
(That being said, you are calling unspecified functions |

Hi @janriemer, and think you for trying Creusot !
Unfortunately, we have not yet spend enough time in giving a formal specification to
HashMapoperations, which explains why your goal is not provable. The main difficulty here is to give theHashtrait a formal specification, which is both sound and not too tedious to use.However, there should not be any fundamental difficulty here. You are welcome to contribute!