REL
Composition
Expr := Expr "." Expr
The 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
parent
is a binary relation, thenparent.parent
is equivalent tox, y: ∃(t: parent(x, t) and parent(t, y))
. - If
players
is a binary relation andt
is a unary relation, thent.players
is equivalent top: players(t, p)
. - If, additionally,
age
is a binary relation, thent.players.age
is equivalent tov: ∃(p: players(t, p) and age(p, v))
. - If
brand_name
is 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?