Skip to main content

PositiveReal

Struct PositiveReal 

Source
pub struct PositiveReal(/* private fields */);
Expand description

Natural numbers, i.e., integers that are greater or equal to 0.

Implementations§

Source§

impl PositiveReal

Source

pub fn to_real(self) -> Real

logic

ensures

result > Real::from_int(0)

Source

pub fn new(n: Real) -> PositiveReal

logic

requires

n > Real::from_int(0)

ensures

result.to_real() == n

Source

pub fn ext_eq(self, other: Self) -> bool

logic(open)

let _ = Subset::<PositiveRealInner>::inner_inj;
self.to_real() == other.to_real()

ensures

result == (self == other)

Source

pub fn from_int(i: Int) -> Self

logic(open, inline)

Self::new(Real::from_int(i))

Trait Implementations§

Source§

impl AddLogic for PositiveReal

Source§

fn add(self, other: Self) -> Self

logic

ensures

result.to_real() == self.to_real() + other.to_real()

Source§

type Output = PositiveReal

Source§

impl DivLogic for PositiveReal

Source§

fn div(self, other: Self) -> Self

logic

ensures

result.to_real() == self.to_real() / other.to_real()

Source§

type Output = PositiveReal

Source§

impl MulLogic for PositiveReal

Source§

fn mul(self, other: Self) -> Self

logic

ensures

result.to_real() == self.to_real() * other.to_real()

Source§

type Output = PositiveReal

Source§

impl OrdLogic for PositiveReal

Source§

fn cmp_log(self, o: Self) -> Ordering

logic(open)

self.to_real().cmp_log(o.to_real())

Source§

fn le_log(self, o: Self) -> bool

logic(open)

self.to_real().le_log(o.to_real())

Source§

fn lt_log(self, o: Self) -> bool

logic(open)

self.to_real().lt_log(o.to_real())

Source§

fn ge_log(self, o: Self) -> bool

logic(open)

self.to_real().ge_log(o.to_real())

Source§

fn gt_log(self, o: Self) -> bool

logic(open)

self.to_real().gt_log(o.to_real())

Source§

fn cmp_le_log(x: Self, y: Self)

logic(open(pub(self)), law)

ensures

x.le_log(y) == (x.cmp_log(y) != Ordering::Greater)

Source§

fn cmp_lt_log(x: Self, y: Self)

logic(open(pub(self)), law)

ensures

x.lt_log(y) == (x.cmp_log(y) == Ordering::Less)

Source§

fn cmp_ge_log(x: Self, y: Self)

logic(open(pub(self)), law)

ensures

x.ge_log(y) == (x.cmp_log(y) != Ordering::Less)

Source§

fn cmp_gt_log(x: Self, y: Self)

logic(open(pub(self)), law)

ensures

x.gt_log(y) == (x.cmp_log(y) == Ordering::Greater)

Source§

fn refl(x: Self)

logic(open(pub(self)), law)

ensures

x.cmp_log(x) == Ordering::Equal

Source§

fn trans(x: Self, y: Self, z: Self, o: Ordering)

logic(open(pub(self)), law)

requires

x.cmp_log(y) == o

requires

y.cmp_log(z) == o

ensures

x.cmp_log(z) == o

Source§

fn antisym1(x: Self, y: Self)

logic(open(pub(self)), law)

requires

x.cmp_log(y) == Ordering::Less

ensures

y.cmp_log(x) == Ordering::Greater

Source§

fn antisym2(x: Self, y: Self)

logic(open(pub(self)), law)

requires

x.cmp_log(y) == Ordering::Greater

ensures

y.cmp_log(x) == Ordering::Less

Source§

fn eq_cmp(x: Self, y: Self)

logic(open(pub(self)), law)

ensures

(x == y) == (x.cmp_log(y) == Ordering::Equal)

Source§

impl RA for PositiveReal

Source§

fn op(self, other: Self) -> Option<PositiveReal>

logic(open, inline)

Some(self + other)

Source§

fn factor(self, factor: Self) -> Option<Self>

logic(open, inline)

let _ = PositiveReal::ext_eq;
if self.to_real() > factor.to_real() {
    Some(PositiveReal::new(self.to_real() - factor.to_real()))
} else {
    None
}

ensures

match result {
    Some(c) => factor.op(c) == Some(self),
    None => forall<c: Self> factor.op(c) != Some(self),
}
Source§

fn eq(self, other: Self) -> bool

logic(open, inline)

self.ext_eq(other)

ensures

result == (self == other)

Source§

fn commutative(a: Self, b: Self)

logic(law)

ensures

a.op(b) == b.op(a)

Source§

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

logic

ensures

a.op(b).and_then_logic(|ab: Self| ab.op(c)) == b.op(c).and_then_logic(|bc| a.op(bc))
Source§

fn core(self) -> Option<Self>

logic(open, inline)

None

Source§

fn core_idemp(self)

logic

requires

self.core() != None

ensures

let c = self.core().unwrap_logic();
c.op(c) == Some(c)

ensures

self.core().unwrap_logic().op(self) == Some(self)

Source§

fn core_is_maximal_idemp(self, i: Self)

logic

requires

i.op(i) == Some(i)

requires

i.op(self) == Some(self)

ensures

match self.core() {
    Some(c) => i.incl(c),
    None => false,
}
Source§

fn incl(self, other: Self) -> bool

Inclusion of RA. Read more
Source§

fn incl_op(self, other: Self, comb: Self)

logic(law) Read more
Source§

fn incl_eq(self, other: Self) -> bool

logic(open, sealed) Read more

Source§

fn incl_eq_op(a: Self, b: Self, x: Self) -> bool

logic(open, sealed) Read more
Source§

fn update(self, x: Self) -> bool

Ensures that we can go from self to x without making composition with the frame invalid. Read more
Source§

fn update_nondet(self, s: Set<Self>) -> bool

Source§

fn associative_none(a: Self, b: Self, c: Self, bc: Self)

Specialized version of Self::associative, in the case where a.op(b) == None. Read more
Source§

fn associative_some(a: Self, b: Self, c: Self, ab: Self, bc: Self)

Specialized version of Self::associative, in the case where a.op(b) and b.op(c) are both valid. Read more
Source§

fn incl_transitive(a: Self, b: Self, c: Self)

RA::incl is transitive. Read more

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