pub struct GhostISubmap<K, V> { /* private fields */ }Expand description
A resource that asserts client ownership of a submap.
The existence of a GhostISubmap implies that:
- Those keys will remain in the map (unless the onwer of the
GhostISubmapdeletes it usingGhostIMapAuth::delete); - Those keys will remain pointing to the same values (unless the onwer of the
GhostISubmapupdates them usingGhostISubmap::update) - All other
GhostISubmap/GhostIPointsTo/GhostPersistentISubmap/GhostPersistentIPointsToare disjoint subsets of the domain
Implementations§
Source§impl<K, V> GhostISubmap<K, V>
impl<K, V> GhostISubmap<K, V>
Sourcepub open spec fn is_points_to(self) -> bool
pub open spec fn is_points_to(self) -> bool
{
&&& self@.len() == 1
&&& self.dom().finite()
&&& !self@.is_empty()
}Checks whether the GhostISubmap refers to a single key (and thus can be converted to a
GhostIPointsTo).
Sourcepub open spec fn dom(self) -> ISet<K>
pub open spec fn dom(self) -> ISet<K>
{ self@.dom() }Domain of the GhostISubmap
Sourcepub open spec fn spec_index(self, key: K) -> V
pub open spec fn spec_index(self, key: K) -> V
self.dom().contains(key),{ self@[key] }Indexing operation submap[key]
Sourcepub proof fn dummy() -> tracked result : GhostISubmap<K, V>
pub proof fn dummy() -> tracked result : GhostISubmap<K, V>
Instantiate a dummy GhostISubmap
Sourcepub proof fn empty(tracked &self) -> tracked result : GhostISubmap<K, V>
pub proof fn empty(tracked &self) -> tracked result : GhostISubmap<K, V>
result.id() == self.id(),result@ == IMap::<K, V>::empty(),Create an empty GhostISubmap
Sourcepub proof fn take(tracked &mut self) -> tracked result : GhostISubmap<K, V>
pub proof fn take(tracked &mut self) -> tracked result : GhostISubmap<K, V>
old(self).id() == final(self).id(),final(self)@.is_empty(),result == *old(self),result.id() == final(self).id(),Extract the GhostISubmap from a mutable reference, leaving behind an empty map.
Sourcepub proof fn agree(tracked self: &GhostISubmap<K, V>, tracked auth: &GhostIMapAuth<K, V>)
pub proof fn agree(tracked self: &GhostISubmap<K, V>, tracked auth: &GhostIMapAuth<K, V>)
self.id() == auth.id(),ensuresself@ <= auth@,Agreement between a GhostISubmap and a corresponding GhostIMapAuth
Verus might not have full context of the GhostIMapAuth and a corresponding GhostISubmap.
However, whenever we know that they refer to the same resource (i.e., have matching ids) we
can assert that the GhostISubmap is a submap of the GhostIMapAuth.
proof fn test(tracked &auth: GhostIMapAuth<int, int>, tracked &sub: GhostISubmap<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: GhostISubmap<K, V>)
pub proof fn combine(tracked &mut self, tracked other: GhostISubmap<K, V>)
old(self).id() == other.id(),ensuresfinal(self).id() == old(self).id(),final(self)@ == old(self)@.union_prefer_right(other@),old(self)@.dom().disjoint(other@.dom()),Combining two GhostISubmaps is possible.
We consume the input GhostISubmap and merge it into the first.
We also learn that they were disjoint.
Sourcepub proof fn combine_points_to(tracked &mut self, tracked other: GhostIPointsTo<K, V>)
pub proof fn combine_points_to(tracked &mut self, tracked other: GhostIPointsTo<K, V>)
old(self).id() == other.id(),ensuresfinal(self).id() == old(self).id(),final(self)@ == old(self)@.insert(other.key(), other.value()),!old(self)@.contains_key(other.key()),Combining a GhostIPointsTo into GhostISubmap is possible, in a similar way to the way to combine
GhostISubmaps.
Sourcepub proof fn disjoint(tracked &mut self, tracked other: &GhostISubmap<K, V>)
pub proof fn disjoint(tracked &mut self, tracked other: &GhostISubmap<K, V>)
old(self).id() == other.id(),ensuresfinal(self).id() == old(self).id(),final(self)@ == old(self)@,final(self)@.dom().disjoint(other@.dom()),When we have two GhostISubmaps we can prove that they have disjoint domains.
Sourcepub proof fn disjoint_persistent(tracked &mut self, tracked other: &GhostPersistentISubmap<K, V>)
pub proof fn disjoint_persistent(tracked &mut self, tracked other: &GhostPersistentISubmap<K, V>)
old(self).id() == other.id(),ensuresfinal(self).id() == old(self).id(),final(self)@ == old(self)@,final(self)@.dom().disjoint(other@.dom()),When we have a GhostISubmap and a GhostPersistentISubmap we can prove that they are in disjoint
domains.
Sourcepub proof fn disjoint_points_to(tracked &mut self, tracked other: &GhostIPointsTo<K, V>)
pub proof fn disjoint_points_to(tracked &mut self, tracked other: &GhostIPointsTo<K, V>)
old(self).id() == other.id(),ensuresfinal(self).id() == old(self).id(),final(self)@ == old(self)@,!final(self)@.contains_key(other.key()),When we have a GhostISubmap and a GhostIPointsTo we can prove that they are in disjoint
domains.
Sourcepub proof fn disjoint_persistent_points_to(
tracked &mut self,
tracked other: &GhostPersistentIPointsTo<K, V>,
)
pub proof fn disjoint_persistent_points_to( tracked &mut self, tracked other: &GhostPersistentIPointsTo<K, V>, )
old(self).id() == other.id(),ensuresfinal(self).id() == old(self).id(),final(self)@ == old(self)@,!final(self)@.contains_key(other.key()),When we have a GhostISubmap and a GhostPersistentIPointsTo we can prove that they are in disjoint
domains.
Sourcepub proof fn split(tracked &mut self, s: ISet<K>) -> tracked result : GhostISubmap<K, V>
pub proof fn split(tracked &mut self, s: ISet<K>) -> tracked result : GhostISubmap<K, V>
s <= old(self)@.dom(),ensuresfinal(self).id() == old(self).id(),result.id() == final(self).id(),old(self)@ == final(self)@.union_prefer_right(result@),result@.dom() =~= s,final(self)@.dom() =~= old(self)@.dom() - s,We can split a GhostISubmap based on a set of keys in its domain.
Sourcepub proof fn split_with_olddom(
tracked &mut self,
s: ISet<K>,
olddom: ISet<K>,
) -> tracked result : GhostISubmap<K, V>
pub proof fn split_with_olddom( tracked &mut self, s: ISet<K>, olddom: ISet<K>, ) -> tracked result : GhostISubmap<K, V>
olddom == old(self)@.dom(),s <= olddom,ensuresfinal(self).id() == old(self).id(),result.id() == final(self).id(),old(self)@ == final(self)@.union_prefer_right(result@),result@.dom() == s,final(self)@.dom() == olddom - s,Sourcepub proof fn split_points_to(tracked &mut self, k: K) -> tracked result : GhostIPointsTo<K, V>
pub proof fn split_points_to(tracked &mut self, k: K) -> tracked result : GhostIPointsTo<K, V>
old(self)@.contains_key(k),ensuresfinal(self).id() == old(self).id(),result.id() == final(self).id(),old(self)@ == final(self)@.insert(result.key(), result.value()),result.key() == k,final(self)@ == old(self)@.remove(k),We can separate a single key out of a GhostISubmap
Sourcepub proof fn update(tracked &mut self, tracked auth: &mut GhostIMapAuth<K, V>, m: IMap<K, V>)
pub proof fn update(tracked &mut self, tracked auth: &mut GhostIMapAuth<K, V>, m: IMap<K, V>)
m.dom() <= old(self)@.dom(),old(self).id() == old(auth).id(),ensuresfinal(self).id() == old(self).id(),final(auth).id() == old(auth).id(),final(self)@ == old(self)@.union_prefer_right(m),final(auth)@ == old(auth)@.union_prefer_right(m),When we have both the GhostIMapAuth and a GhostISubmap we can update the values for a
subset of keys in our submap.
proof fn test(tracked auth: &mut GhostIMapAuth<int, int>, tracked sub: &mut GhostISubmap<int, int>)
requires
auth.id() == sub.id(),
sub.dom() == set![1int, 2int, 3int]
ensures
auth[1int] == 9int
auth[2int] == 10int
auth[3int] == 11int
{
// need to agree on the subset
sub.agree(auth);
assert(sub@ <= auth@);
sub.update(map![1int => 9int, 2int => 10int, 3int => 11int]);
}Sourcepub proof fn points_to(tracked self) -> tracked r : GhostIPointsTo<K, V>
pub proof fn points_to(tracked self) -> tracked r : GhostIPointsTo<K, V>
self.is_points_to(),ensuresself@ == imap![r.key() => r.value()],self.id() == r.id(),Converting a GhostISubmap into a GhostIPointsTo
Sourcepub proof fn persist(tracked self) -> tracked r : GhostPersistentISubmap<K, V>
pub proof fn persist(tracked self) -> tracked r : GhostPersistentISubmap<K, V>
self@ == r@,self.id() == r.id(),Convert a GhostISubmap into a GhostPersistentISubmap
Auto Trait Implementations§
impl<K, V> Freeze for GhostISubmap<K, V>
impl<K, V> RefUnwindSafe for GhostISubmap<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for GhostISubmap<K, V>
impl<K, V> Sync for GhostISubmap<K, V>
impl<K, V> Unpin for GhostISubmap<K, V>
impl<K, V> UnsafeUnpin for GhostISubmap<K, V>
impl<K, V> UnwindSafe for GhostISubmap<K, V>where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, U> IntoSpecImpl<U> for Twhere
U: From<T>,
impl<T, U> IntoSpecImpl<U> for Twhere
U: From<T>,
Source§impl<T, VERUS_SPEC__A> TryFromSpec<T> for VERUS_SPEC__Awhere
VERUS_SPEC__A: TryFrom<T>,
impl<T, VERUS_SPEC__A> TryFromSpec<T> for VERUS_SPEC__Awhere
VERUS_SPEC__A: TryFrom<T>,
Source§exec fn obeys_try_from_spec() -> bool
exec fn obeys_try_from_spec() -> bool
Source§impl<T, VERUS_SPEC__A> TryIntoSpec<T> for VERUS_SPEC__Awhere
VERUS_SPEC__A: TryInto<T>,
impl<T, VERUS_SPEC__A> TryIntoSpec<T> for VERUS_SPEC__Awhere
VERUS_SPEC__A: TryInto<T>,
Source§exec fn obeys_try_into_spec() -> bool
exec fn obeys_try_into_spec() -> bool
Source§impl<T, U> TryIntoSpecImpl<U> for Twhere
U: TryFrom<T>,
impl<T, U> TryIntoSpecImpl<U> for Twhere
U: TryFrom<T>,
Source§open spec fn obeys_try_into_spec() -> bool
open spec fn obeys_try_into_spec() -> bool
{ <U as TryFromSpec<Self>>::obeys_try_from_spec() }