#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.0: u64Implementations§
Source§impl PeanoInt
impl PeanoInt
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new peano integer with value 0.
terminates
ghost
ensures
result.0 == 0u64Sourcepub fn incr(self) -> Self
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@ + 1Sourcepub fn to_u64(self) -> u64
pub fn to_u64(self) -> u64
Get the underlying integer.
terminates
ghost
ensures
result == self.0Sourcepub fn to_i64(self) -> i64
pub fn to_i64(self) -> i64
Get the underlying integer.
terminates
ghost
ensures
result@ == self.0@Trait Implementations§
Source§impl DeepModel for PeanoInt
impl DeepModel for PeanoInt
Source§fn deep_model(self) -> u64
fn deep_model(self) -> u64
(open, inline)
self.0type DeepModelTy = u64
Source§impl Ord for PeanoInt
impl Ord for PeanoInt
Source§fn cmp(&self, other: &Self) -> Ordering
fn cmp(&self, other: &Self) -> Ordering
terminates
ghost
ensures
result == (*self).cmp_log(*other)1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl OrdLogic for PeanoInt
impl OrdLogic for PeanoInt
Source§fn cmp_le_log(x: Self, y: Self)
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)
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)
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)
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 trans(x: Self, y: Self, z: Self, o: Ordering)
fn trans(x: Self, y: Self, z: Self, o: Ordering)
(open(pub(self)), law) ⚠
requires
x.cmp_log(y) == orequires
y.cmp_log(z) == oensures
x.cmp_log(z) == oSource§fn antisym1(x: Self, y: Self)
fn antisym1(x: Self, y: Self)
(open(pub(self)), law) ⚠
requires
x.cmp_log(y) == Ordering::Lessensures
y.cmp_log(x) == Ordering::GreaterSource§impl PartialOrd for PeanoInt
impl PartialOrd for PeanoInt
Source§fn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
terminates
ghost
ensures
result == Some((*self).cmp_log(*other))