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§
Sourcespec fn op(a: Self, b: Self) -> Self
spec fn op(a: Self, b: Self) -> Self
Compose two elements
Sometimes the notation a · b is used to represent RA::op(a, b)
Sourcespec fn unit() -> Self
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
Sourceproof fn associative(a: Self, b: Self, c: Self)
proof fn associative(a: Self, b: Self, c: Self)
Self::op(a, Self::op(b, c)) == Self::op(Self::op(a, b), c),The operation is associative
Sourceproof fn commutative(a: Self, b: Self)
proof fn commutative(a: Self, b: Self)
Self::op(a, b) == Self::op(b, a),The operation is commutative
Sourceproof fn valid_op(a: Self, b: Self)
proof fn valid_op(a: Self, b: Self)
Self::op(a, b).valid(),ensuresa.valid(),The operation is closed under inclusion (i.e., if the result of the operation is valid then its parts are also valid)
Sourceproof fn op_unit(self)
proof fn op_unit(self)
Self::op(self, Self::unit()) == self,The core of an element a is, by definition, some other element x
such that a · x = a
Sourceproof fn unit_valid()
proof fn unit_valid()
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".