Struct creusot_contracts::logic::Int
source · pub struct Int(/* private fields */);
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
sourcepub fn new(value: i128) -> GhostBox<Self>
pub fn new(value: i128) -> GhostBox<Self>
Create a new Int
value
The result is wrapped in a GhostBox
, 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: GhostBox<Int> = ghost!(1int);
ghost! {
let y: Int = 2int;
};
pure
ensures
*result == value@
sourcepub fn div_euclid(self, d: Int) -> Int
pub fn div_euclid(self, d: Int) -> Int
sourcepub fn rem_euclid(self, d: Int) -> Int
pub fn rem_euclid(self, d: Int) -> Int
Compute the remainder of the euclidean division of self
by d
.
§Example
proof_assert!(10.rem_euclid(3) == 1);
logic ⚠
Trait Implementations§
source§impl DeepModel for Int
impl DeepModel for Int
source§fn deep_model(self) -> Self::DeepModelTy
fn deep_model(self) -> Self::DeepModelTy
logic
self
type 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 OrdLogic for Int
impl OrdLogic for Int
source§fn cmp_log(self, o: Self) -> Ordering
fn cmp_log(self, o: Self) -> Ordering
logic
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)
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)
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)
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)
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)
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)
fn antisym1(x: Self, y: Self)
law
requires
x.cmp_log(y) == Ordering::Less
ensures
y.cmp_log(x) == Ordering::Greater
impl Copy for Int
impl WellFounded for Int
Auto Trait Implementations§
impl Freeze for Int
impl RefUnwindSafe for Int
impl !Send for Int
impl !Sync for Int
impl Unpin for Int
impl UnwindSafe for Int
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> MakeSized for Twhere
T: ?Sized,
impl<T> MakeSized for Twhere
T: ?Sized,
source§fn make_sized(&self) -> Box<T>
fn make_sized(&self) -> Box<T>
logic ⚠
ensures
*result == *self