pub struct GhostPersistentPointsTo<K, V> { /* private fields */ }Expand description
A resource representing duplicable client knowledge of a single key in the map.
The existence of a GhostPersistentPointsTo implies that:
- The key-value pair will remain in the map, forever;
- All other
GhostSubmap/GhostPointsTo/GhostPersistentSubmap/GhostPersistentPointsToare disjoint subsets of the domain
Implementations§
Source§impl<K, V> GhostPersistentPointsTo<K, V>
impl<K, V> GhostPersistentPointsTo<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 duplicate(tracked &mut self) -> tracked result : GhostPersistentPointsTo<K, V>
pub proof fn duplicate(tracked &mut self) -> tracked result : GhostPersistentPointsTo<K, V>
self.id() == result.id(),old(self).id() == self.id(),old(self)@ == self@,result@ == self@,Duplicate the GhostPersistentPointsTo
Sourcepub proof fn agree(tracked self: &GhostPersistentPointsTo<K, V>, tracked auth: &GhostMapAuth<K, V>)
pub proof fn agree(tracked self: &GhostPersistentPointsTo<K, V>, tracked auth: &GhostMapAuth<K, V>)
self.id() == auth.id(),ensuresauth@.contains_pair(self.key(), self.value()),Agreement between a GhostPersistentPointsTo and a corresponding GhostMapAuth
Verus might not have full context of the GhostMapAuth and a corresponding GhostPersistentPointsTo.
However, whenever we know that they refer to the same resource (i.e., have matching ids) we
can assert that the GhostPersistentPointsTo is a key-value pair in the GhostMapAuth.
proof fn test(tracked &auth: GhostMapAuth<int, int>, tracked &pt: GhostPersistentPointsTo<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: GhostPersistentPointsTo<K, V>,
) -> tracked submap : GhostPersistentSubmap<K, V>
pub proof fn combine(tracked self, tracked other: GhostPersistentPointsTo<K, V>, ) -> tracked submap : GhostPersistentSubmap<K, V>
self.id() == other.id(),ensuressubmap.id() == self.id(),submap@ == map![self.key() => self.value(), other.key() => other.value()],self.key() != other.key() ==> submap@.len() == 2,self.key() == other.key() ==> submap@.len() == 1,We can combine two GhostPersistentPointsTos into a GhostPersistentSubmap
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(),When we have a GhostPersistentPointsTo and a GhostPointsTo, we can prove that they are in disjoint
domains.
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@.contains_key(self.key()),When we have a GhostPersistentPointsTo and a GhostSubmap, we can prove that they are in disjoint
domains.
Sourcepub proof fn intersection_agrees(tracked &mut self, tracked other: &GhostPersistentPointsTo<K, V>)
pub proof fn intersection_agrees(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() ==> self.value() == other.value(),Shows that if a client has two GhostPersistentPointsTos they are either disjoint or
agreeing in values in the intersection
Sourcepub proof fn intersection_agrees_submap(tracked
&mut self,
tracked other: &GhostPersistentSubmap<K, V>,
)
pub proof fn intersection_agrees_submap(tracked &mut self, tracked other: &GhostPersistentSubmap<K, V>, )
old(self).id() == other.id(),ensuresself.id() == old(self).id(),self@ == old(self)@,other@.contains_key(self.key()) ==> other@[self.key()] == self.value(),Shows that if a GhostPersistentPointsTo and a GhostSubmap are not owning the same key
Sourcepub proof fn submap(tracked self) -> tracked r : GhostPersistentSubmap<K, V>
pub proof fn submap(tracked self) -> tracked r : GhostPersistentSubmap<K, V>
r.id() == self.id(),r@ == map![self.key() => self.value()],Convert the GhostPersistentPointsTo a GhostPersistentSubmap
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 GhostPersistentPointsTo is