An operation \(f\) on a set \(S\) is a function that takes some values from \(S\) and produces a new value. An operation can take any number of values from \(S\), including zero (in which case \(f\) is simply a constant) or infinitely many (in which case we call \(f\) an “infinitary operation”). Common operations take a finite non-zero number of parameters. Operations often produce a value that is also in \(S\) (in which case we say \(S\) is closed under \(f\)), but that is not always the case.

For example, the function \(+\) is a binary operation on \(\mathbb N\), meaning it takes two values from \(\mathbb N\) and produces another. Because \(+\) produces a value that is also in \(\mathbb N\), we say that \(\mathbb N\) is closed under \(+\).

The function \(\operatorname{neg}\) that maps \(x\) to \(-x\) is a unary operation on \(\mathbb Z\): It takes one value from \(\mathbb Z\) as input, and produces an output in \(\mathbb Z\) (namely, the negation of the input). \(\operatorname{neg}\) is also a unary operation on \(\mathbb N\), but \(\mathbb N\) is not closed under \(\operatorname{neg}\) (because \(\operatorname{neg}(3)=-3\) is not in \(\mathbb N\)).

The number of values that the operator takes as input is called the arity of the operator. For example, the function \(\operatorname{zero}\) which takes no inputs and returns \(0\) is a zero-arity operator; and the operator \(f(a, b, c, d) = ac - bd\) is a four-arity operator (which can be used on any ring, if we interpret multiplication and subtraction as ring operations).