Union and Disjunction

# Union and Disjunction

``````Expr := Expr ";" Expr
| "{ ; }"``````

The semicolon is a generalized union operator.

For example:

``````// read query

def P = (1, 2); (3, 4); (5, 6)
def Q = ("a", 41, "A", 61 ); ("b", 42, "B", 62)
def output = P; Q``````

The empty set is the neutral element of the union operation, just like the number `0` in arithmetic addition. More precisely, if `R` is a relation, then the expressions `{} ; R` and `R; {}` both evaluate to `R`.

In the simplified form `{ ; }` the missing operands default to the neutral element. So the expression `{;}` is equivalent to `{{}; {}}`, that is, `{}`.

Examples:

• For any relation `p`, `{}; p` is equivalent to `p`.
• `1; 3` is equivalent to `x: x = 1 or x = 3`.
• If `p` and `q` are unary relations, then:
• `p(x); q(x)` is equivalent to `p(x) or q(x)`.
• `p; q` is equivalent to `x: p(x) or q(x)`.

The semicolon operator is equivalent to `or` when its arguments are restricted to relations of arity 0. To illustrate this, here is the table of all possible combinations of two relations with arity 0:

LeftRight`Left ; Right`
`{}``{} ``{}`
`{()}``{}``{()}`
`{}``{()}``{()}`
`{()}``{()}``{()}`

Next: Precedence