Relations and predicates
Relations construct symbolic formulas. They are distinct from host-language truth queries.
Relations#
Relation nodes are used as equations for solve/solveset, as piecewise
conditions, and as boolean-valued results.
Each relation is also a method of the left operand: x.less_than(1) builds the
same node as context.less_than(x, 1). In Python, <, <=, >, and >=
build the strict and non-strict order relations, so x < 1 is the relation
x < 1. == and != are deliberately not relation builders: they compare
two expressions structurally, which keeps expressions usable as dictionary keys
and set members; build an equation value with equation. A relation has no Python truth
value — its truth is three-valued, so bool(x < 1) raises, and so does a
chained comparison such as 0 < x < 1. Ask for the verdict with
evaluate_truth.
equal#
Explicit context
fun equal(
left: UniffiExpression,
right: UniffiExpression,
): UniffiExpressionCalling forms
Expression method: UniffiExpression.equal
fun equal(other: UniffiExpression): UniffiExpressionequation#
Explicit context
fun equation(
left: UniffiExpression,
right: UniffiExpression,
): UniffiExpressionCalling forms
Expression method: UniffiExpression.equation
fun equation(other: UniffiExpression): UniffiExpressionConstructs an equation value without evaluating it as a Boolean relation. Its two sides remain available for sidewise arithmetic and exact source-preserving solving.
transform_equation#
Explicit context
fun transformEquation(
left: UniffiExpression,
right: UniffiExpression,
operation: UniffiEquationOperation,
): UniffiEquationTransformationApplies operation — "add", "subtract", "multiply", or "divide" — to an equation and a
scalar, or adds or subtracts two equations, threading the operation over both sides. At least
one operand must be an equation; two equations cannot be multiplied or divided, an equation
cannot be a divisor, and a truth value beside an equation is refused.
The result says how the new equation relates to the old one, because not every side-wise operation preserves solutions. Adding or subtracting a scalar, multiplying by a factor proved nonzero, and dividing are equivalences: the new equation holds exactly where the old one does. Multiplying by a factor not proved nonzero, and combining two equations, give only a consequence: every solution of the input solves the result, but also holds at , where does not.
The relation is claimed under a condition on the free symbols. It records where a scalar
operand is defined, because automatic simplification can cancel a pole out of the result —
multiplying by builds , and only the condition still shows the lost
point — and, for a divisor not proved nonzero, that the divisor is nonzero: dividing by
gives under . A condition of true admits every point; false means the
operand's domain could not be described and no claim is made.
The arithmetic operators and the add, subtract, multiply, and divide operations thread
over equations the same way but return only the equation, so they refuse a multiplication or
division that would need a guard to stay honest.
EquationTransformation#
Not exposed by the Kotlin bindings. Available as EquationTransformation in Python, api::EquationTransformation in Rust.
What transform_equation returns:
| Member | Meaning |
|---|---|
equation |
The transformed equation |
relation |
equivalence or consequence |
condition |
The Boolean condition under which the relation is claimed |
transformation_equation#
UniffiEquationTransformation method
fun equation(): UniffiExpressionGetter on EquationTransformation: the transformed equation.
transformation_relation#
UniffiEquationTransformation method
fun relation(): UniffiEquationRelationGetter on EquationTransformation: whether the transformed equation is equivalent to its input
or only implied by it.
transformation_condition#
UniffiEquationTransformation method
fun condition(): UniffiExpressionGetter on EquationTransformation: the Boolean condition on the free symbols under which the
relation is claimed.
not_equal#
Explicit context
fun notEqual(
left: UniffiExpression,
right: UniffiExpression,
): UniffiExpressionCalling forms
Expression method: UniffiExpression.notEqual
fun notEqual(other: UniffiExpression): UniffiExpressionless_than#
Explicit context
fun lessThan(
left: UniffiExpression,
right: UniffiExpression,
): UniffiExpressionCalling forms
Expression method: UniffiExpression.lessThan
fun lessThan(other: UniffiExpression): UniffiExpressionless_than_or_equal#
Explicit context
fun lessThanOrEqual(
left: UniffiExpression,
right: UniffiExpression,
): UniffiExpressionCalling forms
Expression method: UniffiExpression.lessThanOrEqual
fun lessThanOrEqual(other: UniffiExpression): UniffiExpressiongreater_than#
Explicit context
fun greaterThan(
left: UniffiExpression,
right: UniffiExpression,
): UniffiExpressionCalling forms
Expression method: UniffiExpression.greaterThan
fun greaterThan(other: UniffiExpression): UniffiExpressiongreater_than_or_equal#
Explicit context
fun greaterThanOrEqual(
left: UniffiExpression,
right: UniffiExpression,
): UniffiExpressionCalling forms
Expression method: UniffiExpression.greaterThanOrEqual
fun greaterThanOrEqual(other: UniffiExpression): UniffiExpression