_Expression

it.grypho.scala.leonardo.core._Expression
trait _Expression

Base trait of every expression tree node, shared across all domains.

The dual-evaluation contract: eval returns Right when the expression fully reduces to a concrete _Value; Left when some variable is still free and the node is returned in its most-reduced symbolic form.

children / rebuild enable generic structural traversal so algorithms that visit every node type (Substitute, Analysis, …) do not need to match each case explicitly. Binder positions (e.g. the differentiation variable) are excluded from children; rebuild carries them through unchanged.

freeVars is cached per instance — computed once from children, then O(1). New node types inherit a correct default automatically.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class _Feedback
class _Parallel
class _Series
trait _ElementWise
class _Equation
class MatSum
class Transpose
class _Matrix
class _Heaviside
trait _Value
class _Based
class _Bool
class _Complex
class _MatrixValue
class _Number
class _Rational
class _Truth
class _Variable
class _Domain
class _Comparison
class _Solve
class _SolveSystem
trait _Connective
class And
class Implies
class Not
class Or
class Xor
class _Defuzzify
trait _Membership
class GaussMF
class SigMF
class Somewhat
class TrapMF
class TriMF
class Very
class _TruthOf
class Determinant
class _MatrixIndex
class Inverse
class MatProduct
class MatScale
class ZeroMatrix
class _Expectation
class _Variance
class Acos
class Acosh
class Asin
class Asinh
class Atan
class Atanh
class Beta
class BetaI
class Binom
class Catalan
class Ci
class Cos
class Cosh
class Cot
class Coth
class Csc
class Csch
class Digamma
class Ei
class Erf
class Erfc
class Exp
class Factorial
class FresnelC
class FresnelS
class Gamma
class GammaP
class GammaQ
class Harmonic
class Li
class Ln
class LogBase
class LogGamma
class Sec
class Sech
class Si
class Sin
class Sinh
class Tanh
class Tg
class _Balanced
class _Function
class _Functional
class _ODE
class _DefIntegral
class _Derivative
class _Integral
class _Laurent
class _Limit
class _Pade
class _Tabulate
class _Taylor
class _Fourier
class _Laplace
class _ZTransform
trait _Operation
class Power
class Product
class Ratio
class Sum
class _Pattern
class _Sequence
class _ToBase
class _Regress
class _Statistic
class _Test
class _Curl
class _Div
class _Grad
class _Hessian
class _Jacobian
class _Laplacian
Show all

Members list

Value members

Abstract methods

def children: List[_Expression]

Sub-expressions subject to recursive structural traversal. Binder positions (e.g. the differentiation variable) are excluded.

Sub-expressions subject to recursive structural traversal. Binder positions (e.g. the differentiation variable) are excluded.

Attributes

def eval(env: Environment): Either[_Expression, _Value]

Reduces this expression in the given environment.

Reduces this expression in the given environment.

Value parameters

env

variable bindings and display precision

Attributes

Returns

Right(v) when all free variables resolved to concrete values; Left(e) when reduction is partial or impossible

def rebuild(newChildren: List[_Expression]): _Expression

Reconstructs the same node shape with replacement sub-expressions.

Reconstructs the same node shape with replacement sub-expressions.

Value parameters

newChildren

replacements in the same order and count as children

Attributes

Concrete fields

lazy val freeVars: Set[String]

Cached set of free variable names; O(1) after the first access.

Cached set of free variable names; O(1) after the first access.

Attributes