Skip to main content

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.

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.

ghost

ensures

result == self.0

Source

pub fn to_i64(self) -> i64

Get the underlying integer.

ghost

ensures

result@ == self.0@

Source

pub fn to_u128(self) -> u128

Get the underlying integer.

ghost

ensures

result@ == self.0@

Source

pub fn to_i128(self) -> i128

Get the underlying integer.

ghost

ensures

result@ == self.0@

Trait Implementations§

Source§

impl Clone for PeanoInt

Source§

fn clone(&self) -> Self

ensures

pub u64

1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for PeanoInt

Source§

impl DeepModel for PeanoInt

Source§

fn deep_model(self) -> u64

logic(open, inline)

self.0

Source§

type DeepModelTy = u64

Source§

impl Default for PeanoInt

Source§

fn default() -> Self

ensures

Default

Source§

impl Eq for PeanoInt

Source§

impl From<PeanoInt> for u64

Source§

fn from(val: PeanoInt) -> Self

ghost

ensures

result == val.0

Source§

impl From<PeanoInt> for i64

Source§

fn from(val: PeanoInt) -> Self

ghost

ensures

result@ == val.0@

Source§

impl From<PeanoInt> for u128

Source§

fn from(val: PeanoInt) -> Self

ghost

ensures

result@ == val.0@

Source§

impl From<PeanoInt> for i128

Source§

fn from(val: PeanoInt) -> Self

ghost

ensures

result@ == val.0@

Source§

impl Ord for PeanoInt

Source§

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

ghost

ensures

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

1.21.0 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · 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 lt_log_total(self, other: Self)

logic

ensures

self < other || self == other || other < self

Source§

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

The comparison operation. Read more
Source§

impl PartialEq for PeanoInt

Source§

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

ghost

ensures

result == (*self == *other)

1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialOrd for PeanoInt

Source§

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

ghost

ensures

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

Source§

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

ghost

ensures

result == (self@ < other@)

Source§

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

ghost

ensures

result == (self@ <= other@)

Source§

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

ghost

ensures

result == (self@ > other@)

Source§

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

ghost

ensures

result == (self@ >= other@)

Source§

impl PartialOrdLogic for PeanoInt

Source§

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

logic(open, inline)

self.0 < o.0

Source§

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

logic(open, inline)

self.0 <= o.0

Source§

fn irreflexive(self)

logic

ensures

!(self < self)

Source§

fn transitive(x: Self, y: Self, z: Self)

logic

requires

x < y

requires

y < z

ensures

x < z

Source§

fn le_lt_log(self, other: Self)

logic

ensures

(self <= other) == (self < other || self == other)

Source§

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

The logical > operation. Read more
Source§

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

The logical >= operation. Read more
Source§

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

logic(open, sealed) Read more

Source§

impl View for PeanoInt

Source§

fn view(self) -> u64

logic(open, inline)

self.0

Source§

type ViewTy = u64

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.