_Comparison

it.grypho.scala.leonardo.equation._Comparison
case class _Comparison(lhs: _Expression, op: CompareOp, rhs: _Expression) extends _Expression

A comparison between two expressions: lhs < rhs and friends.

Reduces to a core._Bool when both sides are concrete and comparable, so comparisons feed the logic tier directly — x < 2 and y > 3 needs no new machinery, because the connectives take untyped operands.

Deliberately NOT _ElementWise, unlike _Equation and _EqualityCheck. That marker lets algorithms distribute over both sides, which is why 2 * (x = 1) reduces to 2x = 2 today. For an inequality that rewrite is invalid: multiplying x < 1 through by -1 gives -x < -1, which is false exactly when the original is true, because the direction has to flip. Distributing correctly would require knowing the sign of the multiplier, which in general is not available — so the marker is omitted, per the codebase rule that it may be present only when distribution is valid for every algorithm. It is one word long and both neighbouring node types carry it, so this is written down rather than left to be re-derived.

Not solvable. _Solve.eval requires an _Equation, so solve(x < 2, x) stays symbolic on its own; inequality solving would need interval-valued solutions, which the solver has no carrier for.

Value parameters

lhs

left-hand side

op

the relation

rhs

right-hand side

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait _Expression
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

override 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

Definition Classes
override 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

Definition Classes
override def rebuild(c: 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

Definition Classes
override def toString: String

Fully parenthesised, which _Equation and _EqualityCheck are not — and the difference follows directly from not being _ElementWise.

Fully parenthesised, which _Equation and _EqualityCheck are not — and the difference follows directly from not being _ElementWise.

Those two distribute, so a relation never survives inside a product: 2 * (x = 1) becomes (2 * x) = 1 before it is ever printed. A comparison does survive, so an unparenthesised x < 1 inside one renders as (2.0 * x < 1.0) — which re-parses as (2x) < 1, a different expression. The parentheses are what keep the round-trip invariant, the same reason logic._Connective prints (a and b).

Attributes

Definition Classes
Any

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product

Inherited 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

Inherited from:
_Expression