Skip to main content

Interval

Struct Interval 

Source
pub struct Interval {
    pub lo: Bound,
    pub hi: Bound,
}
Expand description

A constant integer interval [lo, hi] over the extended integers. Produced by interval_of_invariant from a refinement predicate and propagated bottom-up through an operation body by the abstract interpreter in classify_op.

Fields§

§lo: Bound§hi: Bound

Implementations§

Source§

impl Interval

Source

pub fn unbounded() -> Interval

The whole extended integer line — the conservative “I know nothing” answer the analysis returns whenever it declines.

Source

pub fn point(k: i128) -> Interval

A single point [k, k].

Source

pub fn ge(k: i128) -> Interval

[k, +inf] — the over-approximation of n >= k.

Source

pub fn le(k: i128) -> Interval

[-inf, k] — the over-approximation of n <= k.

Source

pub fn between(lo: i128, hi: i128) -> Interval

[lo, hi] from two literal bounds.

Source

pub fn intersect(self, other: Interval) -> Interval

Intersection — used to combine the conjuncts of a compound Bool.and guard into a single two-sided interval.

Source

pub fn hull(self, other: Interval) -> Interval

Convex hull (worst-case widening join) — the merge operator for control-flow joins and the per-value worst accumulator the general range pass uses. If either operand escapes i64, so does the hull, keeping the headroom verdict sound. Public mirror of the crate-private join free fn so the bare-i64 consumer (outside this module) can widen without re-deriving the rule.

Source

pub fn fits_i64(self) -> bool

true when both bounds are finite and within the i64 range. This is the headroom test: an intermediate whose interval fits_i64 cannot overflow a raw i64 before the smart constructor’s guard re-validates it.

Source

pub fn contains_point(self, k: i128) -> bool

true when the constant k provably lies within [lo, hi]. Used by the carrier-i64 eligibility tightening: a BARE record constructor outside the smart-ctor whose carrier-field argument is a literal in the proven interval is SAFE (it cannot smuggle an out-of-bound / i64-overflowing value past the gate), so it does not demote the carrier. A non-literal argument (or a literal outside the interval) is ungated and DOES demote. Bound::le is module-private, so this containment test must live here.

Source

pub fn widen(self, next: Interval) -> Interval

Standard interval widening ∇. An endpoint that moved OUTWARD between the previous iterate self and the next iterate next jumps to the matching infinity; a stable or inward-moving endpoint is kept (as the enclosing bound of the two). ENLARGING-ONLY: the result is always a superset of next, so widening can never make an interval too narrow (soundness preserved — only precision is lost). It is the termination operator for the bare-i64 interval fixpoint: a genuinely-unbounded endpoint reaches ±inf in one widen step, capping the chain height.

Bound::le is module-private, so this MUST live in interval.rs.

Source

pub fn add(self, other: Interval) -> Interval

Saturating interval addition. (Inherent, not std::ops::Add: the operation saturates rather than panicking, so the std trait would carry the wrong contract.)

Source

pub fn sub(self, other: Interval) -> Interval

Saturating interval subtraction (a - b = a + (-b), with the endpoints flipped so lo stays the lower bound).

Source

pub fn mul(self, other: Interval) -> Interval

Saturating interval multiplication. The product range is the min/max over the four endpoint products, which is the standard sound interval-arithmetic rule and handles negative operands.

Trait Implementations§

Source§

impl Clone for Interval

Source§

fn clone(&self) -> Interval

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Interval

Source§

impl Debug for Interval

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Interval

Source§

impl PartialEq for Interval

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Interval

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V