pub struct GhostPointsTo<K, V> { /* private fields */ }Expand description
A resource that asserts client ownership over a single key in the map.
The existence of a GhostPointsTo implies that:
- Those key will remain in the map (unless the onwer of the
GhostPointsTodeletes it usingGhostMapAuth::delete_points_to); - Those key will remain pointing to the same value (unless the onwer of the
GhostPointsToupdates them usingGhostPointsTo::update) - All other
GhostSubmap/GhostPointsTo/GhostPersistentSubmap/GhostPersistentPointsToare disjoint subsets of the domain
Implementations§
Source§impl<K, V> GhostPointsTo<K, V>
impl<K, V> GhostPointsTo<K, V>
Sourcepub open spec fn view(self) -> (K, V)
pub open spec fn view(self) -> (K, V)
{ (self.key(), self.value()) }Key-Value pair underlying the points to relationship
Sourcepub proof fn agree(tracked self: &GhostPointsTo<K, V>, tracked auth: &GhostMapAuth<K, V>)
pub proof fn agree(tracked self: &GhostPointsTo<K, V>, tracked auth: &GhostMapAuth<K, V>)
self.id() == auth.id(),ensuresauth@.contains_pair(self.key(), self.value()),Agreement between a GhostPointsTo and a corresponding GhostMapAuth
Verus might not have full context of the GhostMapAuth and a corresponding GhostPointsTo.
However, whenever we know that they refer to the same resource (i.e., have matching ids) we
can assert that the GhostPointsTo is a key-value pair in the GhostMapAuth.
proof fn test(tracked &auth: GhostMapAuth<int, int>, tracked &pt: GhostPointsTo<int, int>)
requires
auth.id() == sub.id(),
pt@ == (1int, 1int)
ensures
auth[1int] == 1int
{
pt.agree(auth);
assert(auth[1int] == 1int);
}Sourcepub proof fn combine(tracked self, tracked other: GhostPointsTo<K, V>) -> tracked r : GhostSubmap<K, V>
pub proof fn combine(tracked self, tracked other: GhostPointsTo<K, V>) -> tracked r : GhostSubmap<K, V>
self.id() == other.id(),ensuresr.id() == self.id(),r@ == map![self.key() => self.value(), other.key() => other.value()],self.key() != other.key(),We can combine two GhostPointsTos into a GhostSubmap
We also learn that they were disjoint.
Sourcepub proof fn disjoint(tracked &mut self, tracked other: &GhostPointsTo<K, V>)
pub proof fn disjoint(tracked &mut self, tracked other: &GhostPointsTo<K, V>)
old(self).id() == other.id(),ensuresself.id() == old(self).id(),self@ == old(self)@,self.key() != other.key(),Shows that if a two GhostPointsTos are not owning the same key
Sourcepub proof fn disjoint_submap(tracked &mut self, tracked other: &GhostSubmap<K, V>)
pub proof fn disjoint_submap(tracked &mut self, tracked other: &GhostSubmap<K, V>)
old(self).id() == other.id(),ensuresself.id() == old(self).id(),self@ == old(self)@,!other.dom().contains(self.key()),Shows that if a GhostPointsTo and a GhostSubmap are not owning the same key
Sourcepub proof fn disjoint_persistent_submap(tracked
&mut self,
tracked other: &GhostPersistentSubmap<K, V>,
)
pub proof fn disjoint_persistent_submap(tracked &mut self, tracked other: &GhostPersistentSubmap<K, V>, )
old(self).id() == other.id(),ensuresself.id() == old(self).id(),self@ == old(self)@,!other.dom().contains(self.key()),Shows that if a GhostPointsTo and a GhostPersistentSubmap are not owning the same key
Sourcepub proof fn disjoint_persistent(tracked &mut self, tracked other: &GhostPersistentPointsTo<K, V>)
pub proof fn disjoint_persistent(tracked &mut self, tracked other: &GhostPersistentPointsTo<K, V>)
old(self).id() == other.id(),ensuresself.id() == old(self).id(),self@ == old(self)@,self.key() != other.key(),Shows that if a GhostPointsTo and a GhostPersistentPointsTo are not owning the same key
Sourcepub proof fn update(tracked &mut self, tracked auth: &mut GhostMapAuth<K, V>, v: V)
pub proof fn update(tracked &mut self, tracked auth: &mut GhostMapAuth<K, V>, v: V)
old(self).id() == old(auth).id(),ensuresself.id() == old(self).id(),auth.id() == old(auth).id(),self.key() == old(self).key(),self@ == (self.key(), v),auth@ == old(auth)@.union_prefer_right(map![self.key() => v]),Update pointed to value
Sourcepub proof fn submap(tracked self) -> tracked r : GhostSubmap<K, V>
pub proof fn submap(tracked self) -> tracked r : GhostSubmap<K, V>
r.id() == self.id(),r@ == map![self.key() => self.value()],Convert the GhostPointsTo a GhostSubmap
Sourcepub proof fn lemma_view(self)
pub proof fn lemma_view(self)
self@ == (self.key(), self.value()),Can be used to learn what the key-value pair of GhostPointsTo is
Sourcepub proof fn persist(tracked self) -> tracked r : GhostPersistentPointsTo<K, V>
pub proof fn persist(tracked self) -> tracked r : GhostPersistentPointsTo<K, V>
self@ == r@,self.id() == r.id(),Convert a GhostPointsTo into a GhostPersistentPointsTo