pub struct GhostSingleton<T> { /* private fields */ }Expand description
A resource that has client ownership of a singleton
The existence of a GhostSingleton implies that:
- The value will remain in the set;
- All other
GhostSubset/GhostSingletonare disjoint subsets of the domain
Implementations§
Source§impl<T> GhostSingleton<T>
impl<T> GhostSingleton<T>
Sourcepub proof fn agree(tracked self: &GhostSingleton<T>, tracked auth: &GhostSetAuth<T>)
pub proof fn agree(tracked self: &GhostSingleton<T>, tracked auth: &GhostSetAuth<T>)
self.id() == auth.id(),ensuresauth@.contains(self@),Agreement between a GhostSingleton and a corresponding GhostSetAuth
Verus might not have full context of the GhostSetAuth and a corresponding GhostSingleton.
However, whenever we know that they refer to the same resource (i.e., have matching ids) we
can assert that the GhostSingleton is a subset of the GhostSetAuth.
proof fn test(tracked &auth: GhostSetAuth<int>, tracked &pt: GhostSingleton<int>)
requires
auth.id() == sub.id(),
pt@ == 1int
ensures
auth@.contains(1int)
{
pt.agree(auth);
assert(auth@.contains(1int));
}Sourcepub proof fn combine(tracked self, tracked other: GhostSingleton<T>) -> tracked r : GhostSubset<T>
pub proof fn combine(tracked self, tracked other: GhostSingleton<T>) -> tracked r : GhostSubset<T>
self.id() == other.id(),ensuresr.id() == self.id(),r@ == set![self @, other @],self@ != other@,We can combine two GhostSingletons into a GhostSubset
We also learn that they were disjoint.
Sourcepub proof fn disjoint(tracked &mut self, tracked other: &GhostSingleton<T>)
pub proof fn disjoint(tracked &mut self, tracked other: &GhostSingleton<T>)
old(self).id() == other.id(),ensuresself.id() == old(self).id(),self@ == old(self)@,self@ != other@,Shows that if a two GhostSingletons are not owning the same value
Sourcepub proof fn disjoint_persistent(tracked &mut self, tracked other: &GhostPersistentSingleton<T>)
pub proof fn disjoint_persistent(tracked &mut self, tracked other: &GhostPersistentSingleton<T>)
old(self).id() == other.id(),ensuresself.id() == old(self).id(),self@ == old(self)@,self@ != other@,Shows that if a GhostSingleton and a GhostPersistentSingleton are not owning the same value
Sourcepub proof fn disjoint_subset(tracked &mut self, tracked other: &GhostSubset<T>)
pub proof fn disjoint_subset(tracked &mut self, tracked other: &GhostSubset<T>)
old(self).id() == other.id(),ensuresself.id() == old(self).id(),self@ == old(self)@,!other@.contains(self@),Shows that if a GhostSingleton and a GhostSubset are not owning the same value
Sourcepub proof fn disjoint_persistent_subset(tracked &mut self, tracked other: &GhostPersistentSubset<T>)
pub proof fn disjoint_persistent_subset(tracked &mut self, tracked other: &GhostPersistentSubset<T>)
old(self).id() == other.id(),ensuresself.id() == old(self).id(),self@ == old(self)@,!other@.contains(self@),Shows that if a GhostSingleton and a GhostPersistentSubset are not owning the same value
Sourcepub proof fn subset(tracked self) -> tracked r : GhostSubset<T>
pub proof fn subset(tracked self) -> tracked r : GhostSubset<T>
r.id() == self.id(),r@ == set![self @],Convert the GhostSingleton a GhostSubset
Sourcepub proof fn persist(tracked self) -> tracked r : GhostPersistentSingleton<T>
pub proof fn persist(tracked self) -> tracked r : GhostPersistentSingleton<T>
self@ == r@,self.id() == r.id(),Converting a GhostSingleton into a GhostPersistentSingleton