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

Fix spec of FMap::get_mut_ghost #1253

Merged
merged 2 commits into from
Nov 27, 2024

Conversation

arnaudgolfouse
Copy link
Collaborator

It was too weak: in particular, you could not prove that the domain of the map stays the same after the call.

@@ -291,11 +291,12 @@ impl<K, V: ?Sized> FMap<K, V> {
#[ensures(if self.contains(*key) {
match result {
None => false,
Some(r) => *(*self).lookup_unsized(*key) == *r &&
Some(r) => (^self).contains(*key) &&
*(*self).lookup_unsized(*key) == *r &&
*(^self).lookup_unsized(*key) == ^r,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't contains be implied by that?

Copy link
Collaborator Author

@arnaudgolfouse arnaudgolfouse Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so... First the following function

#[requires(map.contains(*key))]
#[ensures((^map).contains(*key))]
pub fn foo<K, V>(map: &mut FMap<K, V>, key: &K) {
    let _ = map.get_mut_ghost(key);
}

cannot be proved automatically with the current spec.

But beyond that, lookup_unsized does not make the assumption that the key is present in the map, it just specify the behavior in the case it is present.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But beyond that, lookup_unsized does not make the assumption that the key is present in the map, it just specify the behavior in the case it is present.

Right then your spec makes sense 👍

@arnaudgolfouse arnaudgolfouse merged commit 839cc9f into creusot-rs:master Nov 27, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants