# 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, then `parent.parent` is equivalent to `x, y: ∃(t: parent(x, t) and parent(t, y))`.
• If `players` is a binary relation and `t` is a unary relation, then `t.players` is equivalent to `p: players(t, p)`.
• If, additionally, `age` is a binary relation, then `t.players.age` is equivalent to `v: ∃(p: players(t, p) and age(p, v))`.
• If `brand_name` is a binary relation, then `brand_name."Tesla"` is equivalent to `b: 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