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: BoundImplementations§
Source§impl Interval
impl Interval
Sourcepub fn unbounded() -> Interval
pub fn unbounded() -> Interval
The whole extended integer line — the conservative “I know nothing” answer the analysis returns whenever it declines.
Sourcepub fn intersect(self, other: Interval) -> Interval
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.
Sourcepub fn hull(self, other: Interval) -> Interval
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.
Sourcepub fn fits_i64(self) -> bool
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.
Sourcepub fn contains_point(self, k: i128) -> bool
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.
Sourcepub fn widen(self, next: Interval) -> Interval
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.
Sourcepub fn add(self, other: Interval) -> Interval
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.)
Trait Implementations§
impl Copy for Interval
impl Eq for Interval
impl StructuralPartialEq for Interval
Auto Trait Implementations§
impl Freeze for Interval
impl RefUnwindSafe for Interval
impl Send for Interval
impl Sync for Interval
impl Unpin for Interval
impl UnsafeUnpin for Interval
impl UnwindSafe for Interval
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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.