pub struct GhostPersistentSubset<T> { /* private fields */ }Expand description
A resource that asserts duplicable client knowledge of a persistent subset
For the authoritative resource of the whole set, see GhostSetAuth
Implementations§
Source§impl<T> GhostPersistentSubset<T>
impl<T> GhostPersistentSubset<T>
Sourcepub open spec fn is_singleton(self) -> bool
pub open spec fn is_singleton(self) -> bool
{
&&& self@.len() == 1
&&& self@.finite()
&&& !self@.is_empty()
}Checks whether the GhostPersistentSubset refers to a single key (and thus can be converted to a
GhostPersistentPointsTo).
Sourcepub proof fn dummy() -> tracked result : GhostPersistentSubset<T>
pub proof fn dummy() -> tracked result : GhostPersistentSubset<T>
Instantiate a dummy GhostPersistentSubset
Sourcepub proof fn empty(id: int) -> tracked result : GhostPersistentSubset<T>
pub proof fn empty(id: int) -> tracked result : GhostPersistentSubset<T>
result.id() == id,result@ == Set::<T>::empty(),Instantiate an empty GhostPersistentSubset of a particular id
Sourcepub proof fn duplicate(tracked &mut self) -> tracked result : GhostPersistentSubset<T>
pub proof fn duplicate(tracked &mut self) -> tracked result : GhostPersistentSubset<T>
self.id() == result.id(),old(self).id() == self.id(),old(self)@ == self@,result@ == self@,Duplicate the GhostPersistentSubset
Sourcepub proof fn agree(tracked self: &GhostPersistentSubset<T>, tracked auth: &GhostSetAuth<T>)
pub proof fn agree(tracked self: &GhostPersistentSubset<T>, tracked auth: &GhostSetAuth<T>)
self.id() == auth.id(),ensuresself@ <= auth@,Agreement between a GhostPersistentSubset and a corresponding GhostMapAuth
Verus might not have full context of the GhostMapAuth and a corresponding GhostPersistentSubset.
However, whenever we know that they refer to the same resource (i.e., have matching ids) we
can assert that the GhostPersistentSubset is a subset of the GhostMapAuth.
proof fn test(tracked &auth: GhostMapAuth<int, int>, tracked &sub: GhostPersistentSubset<int, int>)
requires
auth.id() == sub.id(),
sub.dom().contains(1int),
sub[1int] == 1int,
ensures
auth[1int] == 1int
{
sub.agree(auth);
assert(sub@ <= auth@);
assert(auth[1int] == 1int);
}Sourcepub proof fn combine(tracked &mut self, tracked other: GhostPersistentSubset<T>)
pub proof fn combine(tracked &mut self, tracked other: GhostPersistentSubset<T>)
old(self).id() == other.id(),ensuresself.id() == old(self).id(),self@ == old(self)@.union(other@),Combining two GhostPersistentSubsets is possible.
We consume the input GhostPersistentSubset and merge it into the first.
We also learn that they agreed
Sourcepub proof fn combine_points_to(tracked &mut self, tracked other: GhostPersistentSingleton<T>)
pub proof fn combine_points_to(tracked &mut self, tracked other: GhostPersistentSingleton<T>)
old(self).id() == other.id(),ensuresself.id() == old(self).id(),self@ == old(self)@.insert(other@),Combining a GhostPersistentSingleton into GhostPersistentSubset is possible, in a similar way to the way to combine
GhostPersistentSubsets.
Sourcepub proof fn disjoint(tracked &mut self, tracked other: &GhostSubset<T>)
pub proof fn disjoint(tracked &mut self, tracked other: &GhostSubset<T>)
old(self).id() == other.id(),ensuresself.id() == old(self).id(),self@ == old(self)@,self@.disjoint(other@),When we have a GhostPersistentSubset and a GhostSubset we can prove that they have disjoint domains.
Sourcepub proof fn disjoint_singleton(tracked &mut self, tracked other: &GhostSingleton<T>)
pub proof fn disjoint_singleton(tracked &mut self, tracked other: &GhostSingleton<T>)
old(self).id() == other.id(),ensuresself.id() == old(self).id(),self@ == old(self)@,!self@.contains(other@),When we have a GhostPersistentSubset and a GhostSingleton, we can prove that they are in disjoint
domains.
Sourcepub proof fn split(tracked &mut self, s: Set<T>) -> tracked result : GhostPersistentSubset<T>
pub proof fn split(tracked &mut self, s: Set<T>) -> tracked result : GhostPersistentSubset<T>
s <= old(self)@,ensuresself.id() == old(self).id(),result.id() == self.id(),old(self)@ == self@.union(result@),result@ =~= s,self@ =~= old(self)@ - s,We can split a GhostPersistentSubset based on a set of keys in its domain.
Sourcepub proof fn split_singleton(tracked &mut self, v: T) -> tracked result : GhostPersistentSingleton<T>
pub proof fn split_singleton(tracked &mut self, v: T) -> tracked result : GhostPersistentSingleton<T>
old(self)@.contains(v),ensuresself.id() == old(self).id(),result.id() == self.id(),old(self)@ == self@.insert(result@),result@ == v,self@ =~= old(self)@.remove(v),We can separate a single value out of a GhostPersistentSubset
Sourcepub proof fn singleton(tracked self) -> tracked r : GhostPersistentSingleton<T>
pub proof fn singleton(tracked self) -> tracked r : GhostPersistentSingleton<T>
self.is_singleton(),ensuresself@ == set![r @],self.id() == r.id(),Convert a GhostPersistentSubset into a GhostPersistentSingleton