pub struct GroebnerSimplifier { /* private fields */ }Expand description
Simplifies expressions using Groebner basis reduction.
This struct computes a Groebner basis from constraint polynomials and uses it to reduce (simplify) product expressions.
§Safety
The simplifier validates reduced expressions to ensure:
- Coefficients don’t explode (within
MAX_COEFFICIENT_MAGNITUDE) - The reduced form is actually simpler (fewer terms)
If validation fails, it falls back to the original expression.
Implementations§
Source§impl GroebnerSimplifier
impl GroebnerSimplifier
Sourcepub fn new(constraints: Vec<Atom>, _use_grevlex: bool) -> Self
pub fn new(constraints: Vec<Atom>, _use_grevlex: bool) -> Self
Creates a simplifier from constraint atoms.
§Arguments
constraints- Atom expressions that must equal zerouse_grevlex- Use grevlex ordering (faster) vs lex (better elimination)
§Returns
A simplifier ready to reduce expressions. If constraints are empty or too numerous, returns a disabled simplifier that passes through unchanged.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Returns true if this simplifier is enabled.
Sourcepub fn reduce_atom(&self, expr: &Atom) -> Atom
pub fn reduce_atom(&self, expr: &Atom) -> Atom
Reduces an expression modulo the Groebner basis.
This is the main simplification method. It converts the expression to a polynomial, reduces it using the Groebner basis, then converts back.
§Arguments
expr- The expression to reduce
§Returns
The reduced expression, or the original if reduction fails or is disabled.
Sourcepub fn reduce_safe(&self, expr: &Atom) -> ReductionResult
pub fn reduce_safe(&self, expr: &Atom) -> ReductionResult
Reduces an expression with validation and fallback.
This method performs reduction and validates the result. If validation fails (e.g., coefficient explosion), it falls back to the original.
Auto Trait Implementations§
impl Freeze for GroebnerSimplifier
impl RefUnwindSafe for GroebnerSimplifier
impl Send for GroebnerSimplifier
impl Sync for GroebnerSimplifier
impl Unpin for GroebnerSimplifier
impl UnwindSafe for GroebnerSimplifier
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> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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