Skip to main content

ExprPool

Struct ExprPool 

Source
pub struct ExprPool { /* private fields */ }
Expand description

Owns all expression nodes. Every ExprId is valid only within its pool.

ExprPool is Send + Sync.

Read operations (with, get, len) are fully lock-free — they index into a boxcar::Vec via a single atomic load with no lock acquisition. Write operations (intern) use a per-shard lock (parallel mode) or a Mutex (non-parallel mode) only during new-node insertion.

Implementations§

Source§

impl ExprPool

Source

pub fn new() -> Self

Source

pub fn intern(&self, data: ExprData) -> ExprId

Intern data, returning a shared ExprId. Identical structures always return the same id; structural equality ⟺ id equality.

Source

pub fn with<R, F: FnOnce(&ExprData) -> R>(&self, id: ExprId, f: F) -> R

Borrow a node by id and apply f without cloning. Lock-free.

Source

pub fn get(&self, id: ExprId) -> ExprData

Clone and return the ExprData for id.

Source

pub fn len(&self) -> usize

Number of distinct expressions interned so far. Lock-free.

Source

pub fn is_empty(&self) -> bool

Source

pub fn symbol(&self, name: impl Into<String>, domain: Domain) -> ExprId

Free symbol; multiplication treats it as commuting with every other factor (default).

Source

pub fn symbol_commutative( &self, name: impl Into<String>, domain: Domain, commutative: bool, ) -> ExprId

Free symbol with explicit commutative flag (V3-2). commutative: false is for matrix or operator generators where A*B and B*A must remain distinct.

Source

pub fn integer(&self, n: impl Into<Integer>) -> ExprId

Source

pub fn rational( &self, numer: impl Into<Integer>, denom: impl Into<Integer>, ) -> ExprId

Source

pub fn float(&self, value: f64, prec: u32) -> ExprId

Source

pub fn add(&self, args: Vec<ExprId>) -> ExprId

Source

pub fn mul(&self, args: Vec<ExprId>) -> ExprId

Source

pub fn pow(&self, base: ExprId, exp: ExprId) -> ExprId

Source

pub fn func(&self, name: impl Into<String>, args: Vec<ExprId>) -> ExprId

Source

pub fn piecewise( &self, branches: Vec<(ExprId, ExprId)>, default: ExprId, ) -> ExprId

Build a Piecewise expression.

Branches are (cond, value) pairs where cond must be a Predicate node. The default value is used when no condition matches.

Source

pub fn predicate(&self, kind: PredicateKind, args: Vec<ExprId>) -> ExprId

Build a Predicate node (symbolic boolean condition).

Source

pub fn pred_lt(&self, a: ExprId, b: ExprId) -> ExprId

Source

pub fn pred_le(&self, a: ExprId, b: ExprId) -> ExprId

Source

pub fn pred_gt(&self, a: ExprId, b: ExprId) -> ExprId

Source

pub fn pred_ge(&self, a: ExprId, b: ExprId) -> ExprId

Source

pub fn pred_eq(&self, a: ExprId, b: ExprId) -> ExprId

Source

pub fn pred_ne(&self, a: ExprId, b: ExprId) -> ExprId

Source

pub fn pred_and(&self, args: Vec<ExprId>) -> ExprId

Source

pub fn pred_or(&self, args: Vec<ExprId>) -> ExprId

Source

pub fn pred_not(&self, a: ExprId) -> ExprId

Source

pub fn pred_true(&self) -> ExprId

Source

pub fn pred_false(&self) -> ExprId

Source

pub fn forall(&self, var: ExprId, body: ExprId) -> ExprId

∀ var . body

Source

pub fn exists(&self, var: ExprId, body: ExprId) -> ExprId

∃ var . body

Source

pub fn big_o(&self, arg: ExprId) -> ExprId

O(arg) — symbolic big-O bound used in truncated series (V2-15).

Source

pub fn pos_infinity(&self) -> ExprId

Canonical +∞ symbol for limits at infinity (V2-16).

Source

pub fn display(&self, id: ExprId) -> ExprDisplay<'_>

Source§

impl ExprPool

Source

pub fn checkpoint(&self, path: impl AsRef<Path>) -> Result<(), IoError>

V1-14 — write the current pool to path atomically. Equivalent to save_to.

Source

pub fn open_persistent(path: impl AsRef<Path>) -> Result<Self, IoError>

V1-14 — load a persisted pool, or return a fresh one if the file does not exist. Equivalent to open_persistent.

Trait Implementations§

Source§

impl Default for ExprPool

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Send for ExprPool

Source§

impl Sync for ExprPool

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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
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<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.