Modifiers

Modifiers are optional and alter an relations’ behavior in some way. Currently, there are two following modifiers, which can be chained together:

Hidden Modifier

Sometimes, there are relations in rules that only define the logic structure and are not beneficial to be included in the computation graph. For those cases, there is a hidden modifier that enforces exactly that - includes relation for the logic part and excludes relation in the resulting computation graph.

For example, consider the following rule. In some instances, it might be counterproductive to include the edge relations in the resulting computation graph (e.g., they might not have any edge features), yet those edge relations cannot be removed as they define a critical part of the logic structure of the program. Including them in the computation graph will produce a side effect - offsetting the result of relations h.

Relation.h(Var.X) <= (Relation.feature(Var.Y), Relation.edge(Var.X, Var.Y))

This issue can be solved by flagging the predicate edge as hidden, ensuring that relations with such a predicate will not be included in the computation graph.

Relation.h(Var.X) <= (Relation.feature(Var.Y), Relation.hidden.edge(Var.X, Var.Y))

# can be written also as (prepended _ makes predicate hidden)

Relation.h(Var.X) <= (Relation.feature(Var.Y), Relation._edge(Var.X, Var.Y))

Special Modifier

The special modifier changes the relation’s behavior depending on its predicate name. We can utilize the following special predicates:

  • Relation.special.alldiff

    A special relation with the alldiff predicate ensures that its terms (logic variables) are substituted for different values (unique values). It’s also possible to use ... in place of terms, which is substituted for all variables declared in the current rule - no variable declared in the rule can be substituted for the same value simultaneously.

Relation.special.alldiff(Var.X, Var.Y)  # Var.X cannot equal to Var.Y

# Var.X != Var.Y != Var.Z
Relation.h(Var.X) <= (Relation.b(Var.Y, Var.Z), Relation.special.alldiff(...))
  • Relation.special.next

  • Relation.special.anypred

  • Relation.special._in

  • Relation.special.maxcard

  • Relation.special.true

  • Relation.special.false

  • Relation.special.neq

  • Relation.special.leq

  • Relation.special.geq

  • Relation.special.lt

  • Relation.special.gt

  • Relation.special.eq

  • Relation.special.add

  • Relation.special.sub

  • Relation.special.mod