FracP

Enum FracP 

Source
pub enum FracP<T> {
    Unit,
    Frac(real, T),
    Invalid,
}
Expand description

The fractional protocol monoid

Variants§

§

Unit

§

Frac(real, T)

§

Invalid

Implementations§

Source§

impl<T> FracP<T>

Source

pub fn arrow_1(self) -> T

Source

pub fn arrow_0(self) -> real

Source

pub fn arrow_Frac_0(self) -> real

Source

pub fn arrow_Frac_1(self) -> T

Source§

impl<T> FracP<T>

Source

pub open spec fn frac(self) -> real

{
    match self {
        FracP::Frac(q, _) => q,
        _ => 0.0real,
    }
}
Source

pub open spec fn new(v: T) -> Self

{ FracP::Frac(1.0real, v) }
Source

pub open spec fn construct_frac(q: real, v: T) -> Self

{ FracP::Frac(q, v) }
Source

pub open spec fn value(self) -> T

recommends
self is Frac,
{
    match self {
        FracP::Frac(_, v) => v,
        _ => arbitrary(),
    }
}
Source

pub proof fn lemma_guards(self)

requires
self is Frac,
ensures
guards::<(), T, Self>(self, map![() => self.value()]),

Trait Implementations§

Source§

impl<T> Protocol<(), T> for FracP<T>

Source§

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

{
    match self {
        FracP::Frac(q, v) => (
            &&& s.contains_key(())
            &&& s[()] == v
            &&& q == 1.0real

        ),
        _ => false,
    }
}
Source§

open spec fn unit() -> Self

{ FracP::Unit }
Source§

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

Source§

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

Source§

proof fn op_unit(a: 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> 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.

§

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

§

fn obeys_from_spec() -> bool

§

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.

§

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

§

fn obeys_into_spec() -> bool

§

fn into_spec(self) -> T

§

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

§

fn obeys_into_spec() -> bool

§

fn into_spec(self) -> U

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

impl<T, VERUS_SPEC__A> TryFromSpec<T> for VERUS_SPEC__A
where VERUS_SPEC__A: TryFrom<T>,

§

fn obeys_try_from_spec() -> bool

§

fn try_from_spec( v: T, ) -> Result<VERUS_SPEC__A, <VERUS_SPEC__A as TryFrom<T>>::Error>

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

impl<T, VERUS_SPEC__A> TryIntoSpec<T> for VERUS_SPEC__A
where VERUS_SPEC__A: TryInto<T>,

§

fn obeys_try_into_spec() -> bool

§

fn try_into_spec(self) -> Result<T, <VERUS_SPEC__A as TryInto<T>>::Error>

§

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

§

fn obeys_try_into_spec() -> bool

§

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