GhostPersistentSingleton

Struct GhostPersistentSingleton 

Source
pub struct GhostPersistentSingleton<T> { /* private fields */ }
Expand description

A resource that asserts duplicable client knowledge of a persistent singleton

For the authoritative resource of the whole set, see GhostSetAuth

Implementations§

Source§

impl<T> GhostPersistentSingleton<T>

Source

pub closed spec fn id(self) -> Loc

Location of the underlying resource

Source

pub closed spec fn view(self) -> T

Value known by the singleton

Source

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

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

Duplicate the GhostPersistentSingleton

Source

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

requires
self.id() == auth.id(),
ensures
auth@.contains(self@),

Agreement between a GhostPersistentSingleton and a corresponding GhostSetAuth

Verus might not have full context of the GhostSetAuth and a corresponding GhostPersistentSingleton. However, whenever we know that they refer to the same resource (i.e., have matching ids) we can assert that the GhostPersistentSingleton is a subset of the GhostSetAuth.

proof fn test(tracked &auth: GhostSetAuth<int>, tracked &pt: GhostPersistentSingleton<int>)
    requires
        auth.id() == sub.id(),
        pt@ == 1int
    ensures
        auth@.contains(1int)
{
    pt.agree(auth);
    assert(auth@.contains(1int));
}
Source

pub proof fn combine(tracked self, tracked other: GhostPersistentSingleton<T>, ) -> tracked r : GhostPersistentSubset<T>

requires
self.id() == other.id(),
ensures
r.id() == self.id(),
r@ == set![self @, other @],
self@ != other@ ==> r@.len() == 2,
self@ == other@ ==> r@.len() == 1,

We can combine two GhostPersistentSingletons into a GhostPersistentSubset

Source

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

requires
old(self).id() == other.id(),
ensures
self.id() == old(self).id(),
self@ == old(self)@,
self@ != other@,

Shows that a GhostPersistentSingleton and a GhostSingleton are not owning the same value

Source

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

requires
old(self).id() == other.id(),
ensures
self.id() == old(self).id(),
self@ == old(self)@,
!other@.contains(self@),

Shows that if a GhostPersistentSingleton and a GhostSubset are not owning the same value

Source

pub proof fn subset(tracked self) -> tracked r : GhostPersistentSubset<T>

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

Convert the GhostPersistentSingleton a GhostPersistentSubset

Auto Trait Implementations§

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.