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 LocalUpdate<Int> for Int
impl LocalUpdate<Int> for Int
Source§fn update(self, from_auth: Int, from_frag: Int) -> (Int, Int)
fn update(self, from_auth: Int, from_frag: Int) -> (Int, Int)
(open, inline)
(from_auth + self, from_frag + self)Source§fn frame_preserving(self, from_auth: Int, from_frag: Int, frame: Option<Int>)
fn frame_preserving(self, from_auth: Int, from_frag: Int, frame: Option<Int>)
⚠
requires
self.premise(from_auth, from_frag)requires
Some(from_frag).op(frame) == Some(Some(from_auth))ensures
let (to_auth, to_frag) = LocalUpdate::update(self, from_auth, from_frag); Some(to_frag).op(frame) == Some(Some(to_auth))
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 RA for Int
impl RA for Int
Source§fn factor(self, factor: Self) -> Option<Self>
fn factor(self, factor: Self) -> Option<Self>
(open, inline)
Some(self - factor)ensures
match result { Some(c) => factor.op(c) == Some(self), None => false, }
Source§fn commutative(a: Self, b: Self)
fn commutative(a: Self, b: Self)
(law) ⚠
ensures
a.op(b) == b.op(a)Source§fn associative(a: Self, b: Self, c: Self)
fn associative(a: Self, b: Self, c: Self)
⚠
ensures
a.op(b).and_then_logic(|ab: Self| ab.op(c)) == b.op(c).and_then_logic(|bc| a.op(bc))
Source§fn core_idemp(self)
fn core_idemp(self)
⚠
ensures
let c = self.core().unwrap_logic(); c.op(c) == Some(c)
ensures
self.core().unwrap_logic().op(self) == Some(self)Source§fn core_is_maximal_idemp(self, i: Self)
fn core_is_maximal_idemp(self, i: Self)
⚠
requires
i.op(i) == Some(i)requires
i.op(self) == Some(self)ensures
match self.core() { Some(c) => i.incl(c), None => false, }
Source§fn eq(self, other: Self) -> bool
fn eq(self, other: Self) -> bool
(open, inline) Read more
Source§fn incl_eq(self, other: Self) -> bool
fn incl_eq(self, other: Self) -> bool
(open, sealed) Read more
Source§fn incl_eq_op(a: Self, b: Self, x: Self) -> bool
fn incl_eq_op(a: Self, b: Self, x: Self) -> bool
Source§fn update_nondet(self, s: Set<Self>) -> bool
fn update_nondet(self, s: Set<Self>) -> bool
Resource::update_nondet. Read moreSource§fn associative_none(a: Self, b: Self, c: Self, bc: Self)
fn associative_none(a: Self, b: Self, c: Self, bc: Self)
Source§fn associative_some(a: Self, b: Self, c: Self, ab: Self, bc: Self)
fn associative_some(a: Self, b: Self, c: Self, ab: Self, bc: Self)
Self::associative, in the case where a.op(b) and b.op(c)
are both valid. Read moreSource§fn incl_transitive(a: Self, b: Self, c: Self)
fn incl_transitive(a: Self, b: Self, c: Self)
Source§impl UnitRA for Int
impl UnitRA for Int
Source§fn unit() -> Self
fn unit() -> Self
(open, inline)
0ensures
forall<x: Self> #[trigger(x.op(result))] x.op(result) == Some(x)Source§fn core_total(self) -> Self
fn core_total(self) -> Self
(open, inline)
0ensures
self.core() == Some(result)Source§fn core_total_idemp(self)
fn core_total_idemp(self)
⚠
ensures
self.core_total().op(self.core_total()) == Some(self.core_total())ensures
self.core_total().op(self) == Some(self)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