concepts.dsl.constraint.EqualityConstraint#

class EqualityConstraint[source]#

Bases: Constraint

A special constraint for equality constraints. It is equivalent to:

Constraint(Constraint.EQUAL, [left, right], rv)

Basically, it states

(left == right) == rv

Therefore, when rv is True, it states that left and right are equal, and when rv is False, it states that left and right are not equal.

Methods

constraint_str()

Return the string representation of the constraint.

from_bool(left, right[, rv, timestamp])

Create an equality constraint from bool or optimistic values (represented as integers).

from_function(function, args, rv)

Create a constraint given a function, arguments, and return value.

replace_constants(assignments)

set_group(group)

Set the group of the constraint.

Attributes

EQUAL

Magic name for equality constraints.

is_equal_constraint

Check if the constraint is an equality constraint.

is_group_constraint

Return True if the constraint is a group constraint.

is_in_group

Check if the constraint is in a group.

function

The function identifier, which is always Constraint.EQUAL.

arguments

The arguments to the function.

rv

The expected return value of the function.

note

An optional note for the constraint.

group

The group of the constraint.

timestamp

The timestamp of the constraint.

__init__(left, right, rv=None, timestamp=0)[source]#

Initialize an equality constraint.

Parameters:
__new__(**kwargs)#
constraint_str()#

Return the string representation of the constraint.

classmethod from_bool(left, right, rv=None, timestamp=0)[source]#

Create an equality constraint from bool or optimistic values (represented as integers).

Parameters:
  • left (bool | int | OptimisticValue) – the left hand side of the equality constraint.

  • right (bool | int | OptimisticValue) – the right hand side of the equality constraint.

  • rv (bool | int | OptimisticValue | None) – the expected return value of the equality constraint. If None, it will be set to True (i.e., left == right).

  • timestamp (int) – the timestamp of the constraint.

Returns:

The created equality constraint.

Return type:

EqualityConstraint

classmethod from_function(function, args, rv)#

Create a constraint given a function, arguments, and return value.

Parameters:
Returns:

The created constraint.

Return type:

Constraint

replace_constants(assignments)#
Parameters:

assignments (Dict[int, TensorValue])

Return type:

Constraint

set_group(group)#

Set the group of the constraint.

Parameters:

group (GroupConstraint)

EQUAL = '__EQ__'#

Magic name for equality constraints.

arguments: Tuple[TensorValue | OptimisticValue, TensorValue | OptimisticValue]#

The arguments to the function.

function: str#

The function identifier, which is always Constraint.EQUAL.

group: GroupConstraint | None#

The group of the constraint. None if the constraint is not in a group.

property is_equal_constraint: bool#

Check if the constraint is an equality constraint.

property is_group_constraint: bool#

Return True if the constraint is a group constraint.

property is_in_group: bool#

Check if the constraint is in a group.

note: Any#

An optional note for the constraint.

rv: TensorValue | OptimisticValue#

The expected return value of the function.

timestamp: int#

The timestamp of the constraint.