Skip to content

Commit b85a7c2

Browse files
authored
vstd: update_nondeterministic axiom -> proof (verus-lang#2431)
1 parent 9bf4bf1 commit b85a7c2

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

source/vstd/resource/pcm.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,29 @@ impl<P: PCM> Resource<P> {
142142

143143
/// This is a more general version of [`update`](Self::update).
144144
// GHOST-UPDATE rule
145-
pub axiom fn update_nondeterministic(tracked self, new_values: Set<P>) -> (tracked out: Self)
145+
pub proof fn update_nondeterministic(tracked self, new_values: Set<P>) -> (tracked out: Self)
146146
requires
147147
frame_preserving_update_nondeterministic(self.value(), new_values),
148148
ensures
149149
out.loc() == self.loc(),
150150
new_values.contains(out.value()),
151-
;
151+
{
152+
let tracked u = Self::create_unit(self.loc());
153+
PCM::op_unit(self.value());
154+
assert(set_op(new_values, u.value()) =~= new_values) by {
155+
assert forall|x|
156+
set_op(new_values, u.value()).contains(x) <==> #[trigger] new_values.contains(
157+
x,
158+
) by {
159+
PCM::op_unit(x);
160+
if set_op(new_values, u.value()).contains(x) {
161+
let q = choose|q| #[trigger] new_values.contains(q) && x == P::op(q, u.value());
162+
PCM::op_unit(q);
163+
}
164+
}
165+
};
166+
self.update_nondeterministic_with_shared(&u, new_values)
167+
}
152168

153169
// VERIFIED
154170
/// Update a resource to a new value. This can only be done if the update is frame preserving

0 commit comments

Comments
 (0)