pub enum FracP<T> {
Unit,
Frac(real, T),
Invalid,
}Expand description
The fractional protocol monoid
Variants§
Implementations§
Source§impl<T> FracP<T>
impl<T> FracP<T>
pub fn arrow_1(self) -> T
pub fn arrow_0(self) -> real
pub fn arrow_Frac_0(self) -> real
pub fn arrow_Frac_1(self) -> T
Source§impl<T> FracP<T>
impl<T> FracP<T>
Sourcepub open spec fn construct_frac(q: real, v: T) -> Self
pub open spec fn construct_frac(q: real, v: T) -> Self
{ FracP::Frac(q, v) }Sourcepub open spec fn value(self) -> T
pub open spec fn value(self) -> T
recommends
self is Frac,{
match self {
FracP::Frac(_, v) => v,
_ => arbitrary(),
}
}Sourcepub proof fn lemma_guards(self)
pub proof fn lemma_guards(self)
requires
self is Frac,ensuresguards::<(), T, Self>(self, map![() => self.value()]),Trait Implementations§
Source§impl<T> Protocol<(), T> for FracP<T>
impl<T> Protocol<(), T> for FracP<T>
Source§open spec fn op(self, other: Self) -> Self
open spec fn op(self, other: Self) -> Self
{
match (self, other) {
(FracP::Unit, x) => x,
(x, FracP::Unit) => x,
(FracP::Frac(q1, v1), FracP::Frac(q2, v2)) => {
if v1 == v2 && 0.0real < q1 && 0.0real < q2 && q1 + q2 <= 1.0real {
FracP::Frac(q1 + q2, v1)
} else {
FracP::Invalid
}
}
_ => FracP::Invalid,
}
}Source§open spec fn rel(self, s: Map<(), T>) -> bool
open spec fn rel(self, s: Map<(), T>) -> bool
{
match self {
FracP::Frac(q, v) => (
&&& s.contains_key(())
&&& s[()] == v
&&& q == 1.0real
),
_ => false,
}
}Source§proof fn commutative(a: Self, b: Self)
proof fn commutative(a: Self, b: Self)
Source§proof fn associative(a: Self, b: Self, c: Self)
proof fn associative(a: Self, b: Self, c: Self)
Auto Trait Implementations§
impl<T> Freeze for FracP<T>where
T: Freeze,
impl<T> RefUnwindSafe for FracP<T>where
T: RefUnwindSafe,
impl<T> Send for FracP<T>where
T: Send,
impl<T> Sync for FracP<T>where
T: Sync,
impl<T> Unpin for FracP<T>where
T: Unpin,
impl<T> UnwindSafe for FracP<T>where
T: 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
Mutably borrows from an owned value. Read more