GhostPersistentSubset

Struct GhostPersistentSubset 

Source
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>

Source

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).

Source

pub closed spec fn id(self) -> Loc

Resource location

Source

pub closed spec fn view(self) -> Set<T>

Logically underlying Set

Source

pub proof fn dummy() -> tracked result : GhostPersistentSubset<T>

Instantiate a dummy GhostPersistentSubset

Source

pub proof fn empty(id: int) -> tracked result : GhostPersistentSubset<T>

ensures
result.id() == id,
result@ == Set::<T>::empty(),

Instantiate an empty GhostPersistentSubset of a particular id

Source

pub proof fn duplicate(tracked &mut self) -> tracked result : GhostPersistentSubset<T>

ensures
self.id() == result.id(),
old(self).id() == self.id(),
old(self)@ == self@,
result@ == self@,

Duplicate the GhostPersistentSubset

Source

pub proof fn agree(tracked self: &GhostPersistentSubset<T>, tracked auth: &GhostSetAuth<T>)

requires
self.id() == auth.id(),
ensures
self@ <= 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);
}
Source

pub proof fn combine(tracked &mut self, tracked other: GhostPersistentSubset<T>)

requires
old(self).id() == other.id(),
ensures
self.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

Source

pub proof fn combine_points_to(tracked &mut self, tracked other: GhostPersistentSingleton<T>)

requires
old(self).id() == other.id(),
ensures
self.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.

Source

pub proof fn disjoint(tracked &mut self, tracked other: &GhostSubset<T>)

requires
old(self).id() == other.id(),
ensures
self.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.

Source

pub proof fn disjoint_singleton(tracked &mut self, tracked other: &GhostSingleton<T>)

requires
old(self).id() == other.id(),
ensures
self.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.

Source

pub proof fn split(tracked &mut self, s: Set<T>) -> tracked result : GhostPersistentSubset<T>

requires
s <= old(self)@,
ensures
self.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.

Source

pub proof fn split_singleton(tracked &mut self, v: T) -> tracked result : GhostPersistentSingleton<T>

requires
old(self)@.contains(v),
ensures
self.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

Source

pub proof fn singleton(tracked self) -> tracked r : GhostPersistentSingleton<T>

requires
self.is_singleton(),
ensures
self@ == set![r @],
self.id() == r.id(),

Convert a GhostPersistentSubset into a GhostPersistentSingleton

Auto Trait Implementations§

§

impl<T> Freeze for GhostPersistentSubset<T>

§

impl<T> RefUnwindSafe for GhostPersistentSubset<T>
where T: RefUnwindSafe,

§

impl<T> Send for GhostPersistentSubset<T>
where T: Send,

§

impl<T> Sync for GhostPersistentSubset<T>
where T: Sync,

§

impl<T> Unpin for GhostPersistentSubset<T>
where T: Unpin,

§

impl<T> UnwindSafe for GhostPersistentSubset<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, VERUS_SPEC__A> FromSpec<T> for VERUS_SPEC__A
where VERUS_SPEC__A: From<T>,

Source§

exec fn obeys_from_spec() -> bool

Source§

exec fn from_spec(v: T) -> VERUS_SPEC__A

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, VERUS_SPEC__A> IntoSpec<T> for VERUS_SPEC__A
where VERUS_SPEC__A: Into<T>,

Source§

exec fn obeys_into_spec() -> bool

Source§

exec fn into_spec(self) -> T

Source§

impl<T, U> IntoSpecImpl<U> for T
where U: From<T>,

Source§

open spec fn obeys_into_spec() -> bool

{ <U as FromSpec<Self>>::obeys_from_spec() }
Source§

open spec fn into_spec(self) -> U

{ U::from_spec(self) }
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.