pub struct Int;Expand description
An unbounded, mathematical integer.
This type cannot be only be constructed in logical or ghost code.
§Integers in pearlite
Note that in pearlite, all integer literals are of type Int:
let x = 1i32;
// ↓ need to use the view operator to convert `i32` to `Int`
proof_assert!(x@ == 1);You can use the usual operators on integers: +, -, *, / and %.
Note that those operators are not available in ghost code.
Implementations§
Source§impl Int
impl Int
Source§impl Int
impl Int
Sourcepub fn new(value: i128) -> Ghost<Self>
pub fn new(value: i128) -> Ghost<Self>
Create a new Int value
The result is wrapped in a Ghost, so that it can only be access inside a
ghost! block.
You should not have to use this method directly: instead, use the int suffix
inside of a ghost block:
let x: Ghost<Int> = ghost!(1int);
ghost! {
let y: Int = 2int;
};terminates
ghost
ensures
*result == value@Sourcepub fn incr_ghost(&mut self)
pub fn incr_ghost(&mut self)
terminates
ghost
ensures
^self == *self + 1Sourcepub fn decr_ghost(&mut self)
pub fn decr_ghost(&mut self)
terminates
ghost
ensures
^self == *self - 1Trait Implementations§
Source§impl DeepModel for Int
impl DeepModel for Int
Source§fn deep_model(self) -> Self::DeepModelTy
fn deep_model(self) -> Self::DeepModelTy
(open, inline)
selftype DeepModelTy = Int
Source§impl<T> IndexLogic<Int> for [T]
impl<T> IndexLogic<Int> for [T]
Source§impl<T> IndexLogic<Int> for Seq<T>
impl<T> IndexLogic<Int> for Seq<T>
Source§impl<T, A: Allocator> IndexLogic<Int> for VecDeque<T, A>
Available on crate feature nightly only.
impl<T, A: Allocator> IndexLogic<Int> for VecDeque<T, A>
nightly only.Source§impl OrdLogic for Int
impl OrdLogic for Int
Source§fn cmp_log(self, o: Self) -> Ordering
fn cmp_log(self, o: Self) -> Ordering
(open)
if self < o { Ordering::Less } else if self == o { Ordering::Equal } else { Ordering::Greater }
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 Int
impl PartialOrd for Int
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))Source§impl WellFounded for Int
impl WellFounded for Int
Source§fn well_founded_relation(self, other: Self) -> bool
fn well_founded_relation(self, other: Self) -> bool
(open, inline)
self >= 0 && self > other