Skip to main content

RA

Trait RA 

Source
pub trait RA: Sized {
    // Required methods
    spec fn valid(self) -> bool;
    spec fn op(a: Self, b: Self) -> Self;
    spec fn unit() -> Self;
    proof fn associative(a: Self, b: Self, c: Self);
    proof fn commutative(a: Self, b: Self);
    proof fn valid_op(a: Self, b: Self);
    proof fn op_unit(self);
    proof fn unit_valid();
}
Expand description

A unital Resource Algebra (also known as a Partial Commutative Monoid) on the carrier type Self.

This construction is based off the Iris from the Ground Up report.

A striking difference is that we do not need a core for elements (the core is interesting in Iris because of the persistent modality, which Verus does not have). Instead, we require a single unit element, which serves as the core of every element.

Note that “partiality” is modeled with the validity predicate, since Verus does not support partial functions.

See Resource for more information.

Corresponds to the VerusRA record in verus-belt.

Required Methods§

Source

spec fn valid(self) -> bool

Whether an element is valid

Source

spec fn op(a: Self, b: Self) -> Self

Compose two elements

Sometimes the notation a · b is used to represent RA::op(a, b)

Source

spec fn unit() -> Self

The unit of the monoid, i.e., the carrier value that composed with any other carrier value yields the identity function

Source

proof fn associative(a: Self, b: Self, c: Self)

ensures
Self::op(a, Self::op(b, c)) == Self::op(Self::op(a, b), c),

The operation is associative

Source

proof fn commutative(a: Self, b: Self)

ensures
Self::op(a, b) == Self::op(b, a),

The operation is commutative

Source

proof fn valid_op(a: Self, b: Self)

requires
Self::op(a, b).valid(),
ensures
a.valid(),

The operation is closed under inclusion (i.e., if the result of the operation is valid then its parts are also valid)

Source

proof fn op_unit(self)

ensures
Self::op(self, Self::unit()) == self,

The core of an element a is, by definition, some other element x such that a · x = a

Source

proof fn unit_valid()

ensures
Self::unit().valid(),

The unit is always a valid element

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<P: PCM> RA for P

Every PCM is an RA in the sense of the trusted interface.