REL
Composition
Expr := Expr "." ExprThe meaning of R.S is x..., y... : exists(t: R(x..., t) and S(t, y...)). Note that the arguments must have at least arity 1.
For specific cases this meaning can be presented more simply.
In particular, since a variable is a singleton relation, x.R is R[x], and R.x is y... : R(y..., x).
The composition operator is sometimes called the dot join operator.
Examples:
- If
parentis a binary relation, thenparent.parentis equivalent tox, y: ∃(t: parent(x, t) and parent(t, y)). - If
playersis a binary relation andtis a unary relation, thent.playersis equivalent top: players(t, p). - If, additionally,
ageis a binary relation, thent.players.ageis equivalent tov: ∃(p: players(t, p) and age(p, v)). - If
brand_nameis a binary relation, thenbrand_name."Tesla"is equivalent tob: brand_name(b, "Tesla").
⚠
The precedence of the composition operator . is high, so an expression such as R . Q(x) is equivalent to (R . Q)(x).
If that is not what you want, you should put the relational application in parentheses: R . (Q(x)).
The same caveat applies to partial relational applications: R . Q[x] is equivalent to (R . Q)[x].
Next: Restriction
Was this doc helpful?