PeanoInt

Struct PeanoInt 

Source
#[non_exhaustive]
#[repr(transparent)]
pub struct PeanoInt(pub u64);
Expand description

A peano integer wrapping a 64-bits integer.

See the module explanation.

Tuple Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§0: u64

Implementations§

Source§

impl PeanoInt

Source

pub fn new() -> Self

Create a new peano integer with value 0.

terminates

ghost

ensures

result.0 == 0u64

Source

pub fn incr(self) -> Self

Increase the integer by one.

This method guarantees that increments cannot get optimized together, e.g. that

let mut x = PeanoInt::new();
for _ in 0..1_000_000 {
    x.incr();
}

Does not get optimized down to a single addition.

Since the backing integer is 64 bits long, no program could ever actually reach the point where the integer overflows.

terminates

ensures

result.0@ == self.0@ + 1

Source

pub fn to_u64(self) -> u64

Get the underlying integer.

terminates

ghost

ensures

result == self.0

Source

pub fn to_i64(self) -> i64

Get the underlying integer.

terminates

ghost

ensures

result@ == self.0@

Source

pub fn to_u128(self) -> u128

Get the underlying integer.

terminates

ghost

ensures

result@ == self.0@

Source

pub fn to_i128(self) -> i128

Get the underlying integer.

terminates

ghost

ensures

result@ == self.0@

Trait Implementations§

Source§

impl Clone for PeanoInt

Source§

fn clone(&self) -> Self

ensures

pub u64

1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl DeepModel for PeanoInt

Source§

fn deep_model(self) -> u64

(open, inline)

self.0

Source§

type DeepModelTy = u64

Source§

impl Default for PeanoInt

Source§

fn default() -> Self

ensures

Default

Source§

impl From<PeanoInt> for i128

Source§

fn from(val: PeanoInt) -> Self

terminates

ghost

ensures

result@ == val.0@

Source§

impl From<PeanoInt> for i64

Source§

fn from(val: PeanoInt) -> Self

terminates

ghost

ensures

result@ == val.0@

Source§

impl From<PeanoInt> for u128

Source§

fn from(val: PeanoInt) -> Self

terminates

ghost

ensures

result@ == val.0@

Source§

impl From<PeanoInt> for u64

Source§

fn from(val: PeanoInt) -> Self

terminates

ghost

ensures

result == val.0

Source§

impl Ord for PeanoInt

Source§

fn cmp(&self, other: &Self) -> Ordering

terminates

ghost

ensures

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

1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl OrdLogic for PeanoInt

Source§

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

(open, inline)

self.0.cmp_log(o.0)

Source§

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

(open, inline)

self.0.le_log(o.0)

Source§

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

(open, inline)

self.0.lt_log(o.0)

Source§

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

(open, inline)

self.0.ge_log(o.0)

Source§

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

(open, inline)

self.0.gt_log(o.0)

Source§

fn cmp_le_log(x: Self, y: Self)

(open(pub(self)), law)

ensures

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

Source§

fn cmp_lt_log(x: Self, y: Self)

(open(pub(self)), law)

ensures

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

Source§

fn cmp_ge_log(x: Self, y: Self)

(open(pub(self)), law)

ensures

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

Source§

fn cmp_gt_log(x: Self, y: Self)

(open(pub(self)), law)

ensures

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

Source§

fn refl(x: Self)

(open(pub(self)), law)

ensures

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

Source§

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

(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)

(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)

(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)

(open(pub(self)), law)

ensures

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

Source§

impl PartialEq for PeanoInt

Source§

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

terminates

ghost

ensures

result == (*self == *other)

1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for PeanoInt

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

terminates

ghost

ensures

result == Some((*self).cmp_log(*other))

Source§

fn lt(&self, other: &Self) -> bool

terminates

ghost

ensures

result == (self@ < other@)

Source§

fn le(&self, other: &Self) -> bool

terminates

ghost

ensures

result == (self@ <= other@)

Source§

fn gt(&self, other: &Self) -> bool

terminates

ghost

ensures

result == (self@ > other@)

Source§

fn ge(&self, other: &Self) -> bool

terminates

ghost

ensures

result == (self@ >= other@)

Source§

impl View for PeanoInt

Source§

fn view(self) -> u64

(open, inline)

self.0

Source§

type ViewTy = u64

Source§

impl Copy for PeanoInt

Source§

impl Eq for PeanoInt

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.