|
smats
0.0.1
Satisfability Modulo Arithmetic Theories Symbols
|
#include <expression_cell.h>
Classes | |
struct | Private |
Public Member Functions | |
long | use_count () const |
ExpressionKind | kind () const |
virtual void | hash (DelegatingHasher &) const =0 |
const Variables & | variables () const |
bool | is_polynomial () const |
bool | is_expanded () const |
virtual bool | equal_to (const ExpressionCell< T > &o) const =0 |
virtual bool | less (const ExpressionCell< T > &o) const =0 |
void | set_expanded () |
template<template< class > class E> | |
const E< T > & | to () const |
template<template< class > class E> | |
E< T > & | to () |
Expression< T > | to_expression () const |
virtual T | evaluate (const Environment< T > &env) const =0 |
virtual Expression< T > | expand () const =0 |
virtual Expression< T > | evaluate_partial (const Environment< T > &env) const =0 |
virtual Expression< T > | substitute (const Substitution< T > &s) const =0 |
virtual Expression< T > | differentiate (const Variable &x) const =0 |
virtual std::ostream & | display (std::ostream &os) const =0 |
void | invalidate_cache () |
Protected Member Functions | |
ExpressionCell (ExpressionKind kind, bool is_expanded) | |
ExpressionCell (ExpressionKind kind, bool is_polynomial, bool is_expanded) | |
virtual void | compute_variables (std::optional< Variables > &variables) const =0 |
virtual void | compute_is_polynomial (std::optional< bool > &is_polynomial) const =0 |
Private Attributes | |
const ExpressionKind | kind_ |
The kind of the expression. | |
std::optional< Variables > | variables_ |
Cached variables in the expression. | |
std::optional< bool > | is_polynomial_ |
Cached information about whether the expression is a polynomial. | |
bool | is_expanded_ {false} |
Whether the expression is already expanded. | |
Abstract class used as the base of concrete symbolic-expression classes.
T | type of the expression evaluation |
|
protected |
Constructs ExpressionCell of kind
with is_expanded
.
kind | kind of the expression |
is_expanded | whether the expression is already expanded |
|
protected |
Constructs ExpressionCell of kind
with is_polynomial
and is_expanded
.
kind | kind of the expression |
is_polynomial | whether the expression is a polynomial |
is_expanded | whether the expression is already expanded |
|
nodiscardpure virtual |
Differentiates this symbolic expression with respect to the variable var
.
x | variable |
std::runtime_exception | if it is not differentiable. |
Implemented in smats::ExpressionAdd< T >, smats::ExpressionConstant< T >, smats::ExpressionDiv< T >, smats::ExpressionMul< T >, smats::ExpressionNaN< T >, smats::ExpressionPow< T >, and smats::ExpressionVar< T >.
|
pure virtual |
Displays the expression in a human-readable format.
os | output stream |
Implemented in smats::ExpressionAdd< T >, smats::ExpressionConstant< T >, smats::ExpressionDiv< T >, smats::ExpressionMul< T >, smats::ExpressionNaN< T >, smats::ExpressionPow< T >, and smats::ExpressionVar< T >.
|
nodiscardpure virtual |
Compare two expression cells to determine if they are equal.
o | other object to compare against |
Implemented in smats::BinaryExpressionCell< T >, smats::ExpressionAdd< T >, smats::ExpressionConstant< T >, smats::ExpressionMul< T >, smats::ExpressionNaN< T >, and smats::ExpressionVar< T >.
|
nodiscardpure virtual |
Evaluates under a given environment (by default, an empty environment).
env | environment |
std::runtime_exception | if NaN is detected during evaluation. |
Implemented in smats::BinaryExpressionCell< T >, smats::ExpressionAdd< T >, smats::ExpressionConstant< T >, smats::ExpressionMul< T >, smats::ExpressionNaN< T >, and smats::ExpressionVar< T >.
|
nodiscardpure virtual |
Returns an Expression obtained by replacing all occurrences of the variables in env
in the current expression cell with the corresponding values in env
.
env | environment |
std::runtime_exception | if NaN is detected during substitution. |
Implemented in smats::ExpressionAdd< T >, smats::ExpressionConstant< T >, smats::ExpressionDiv< T >, smats::ExpressionMul< T >, smats::ExpressionNaN< T >, smats::ExpressionPow< T >, and smats::ExpressionVar< T >.
|
nodiscardpure virtual |
Expands out products and positive integer powers in expression.
std::runtime_exception | if NaN is detected during expansion. |
Implemented in smats::ExpressionAdd< T >, smats::ExpressionConstant< T >, smats::ExpressionDiv< T >, smats::ExpressionMul< T >, smats::ExpressionNaN< T >, smats::ExpressionPow< T >, and smats::ExpressionVar< T >.
|
pure virtual |
Sends all hash-relevant bytes for this ExpressionCell type into the given hasher, per the hash_append concept, except for kind(), because Expression already sends that.
Implemented in smats::BinaryExpressionCell< T >, smats::ExpressionAdd< T >, smats::ExpressionConstant< T >, smats::ExpressionMul< T >, smats::ExpressionNaN< T >, and smats::ExpressionVar< T >.
void smats::ExpressionCell< T >::invalidate_cache | ( | ) |
Invalidate the cached information.
This will force the expression to recompute the cached information the next time they are requested. Must be called whenever the expression is modified.
|
inlinenodiscard |
Check whether the expression cell is expanded.
|
nodiscard |
Check whether the expression cell is polynomial.
|
inlinenodiscard |
Get read-only access to the kind of the expression cell.
|
nodiscardpure virtual |
Compare two expression cells to determine the order between them.
o | other object to compare against |
Implemented in smats::BinaryExpressionCell< T >, smats::ExpressionAdd< T >, smats::ExpressionConstant< T >, smats::ExpressionMul< T >, smats::ExpressionNaN< T >, and smats::ExpressionVar< T >.
|
inline |
Sets this symbolic expression as already expanded.
|
nodiscardpure virtual |
Returns an Expression obtained by replacing all occurrences of the variables in s
in the current expression cell with the corresponding expressions in s
.
s | substitution |
std::runtime_exception | if NaN is detected during substitution. |
Implemented in smats::ExpressionAdd< T >, smats::ExpressionConstant< T >, smats::ExpressionDiv< T >, smats::ExpressionMul< T >, smats::ExpressionNaN< T >, smats::ExpressionPow< T >, and smats::ExpressionVar< T >.
|
inlinenodiscard |
Casts this ExpressionCell to a subclass of ExpressionCell with the same template type.
E | subclass of ExpressionCell |
|
inlinenodiscard |
Casts this ExpressionCell to a subclass of ExpressionCell with the same template type.
E | subclass of ExpressionCell |
|
inlinenodiscard |
Create an Expression from this ExpressionCell.
|
inlinenodiscard |
Get read-only access to the reference count of the expression cell.
|
nodiscard |
Get read-only access to the variables of the expression cell.