An op­er­a­tion \(f\) on a set \(S\) is a func­tion that takes some val­ues from \(S\) and pro­duces a new value. An op­er­a­tion can take any num­ber of val­ues from \(S\), in­clud­ing zero (in which case \(f\) is sim­ply a con­stant) or in­finitely many (in which case we call \(f\) an “in­fini­tary op­er­a­tion”). Com­mon op­er­a­tions take a finite non-zero num­ber of pa­ram­e­ters. Oper­a­tions of­ten pro­duce a value that is also in \(S\) (in which case we say \(S\) is closed un­der \(f\)), but that is not always the case.

For ex­am­ple, the func­tion \(+\) is a bi­nary op­er­a­tion on \(\mathbb N\), mean­ing it takes two val­ues from \(\mathbb N\) and pro­duces an­other. Be­cause \(+\) pro­duces a value that is also in \(\mathbb N\), we say that \(\mathbb N\) is closed un­der \(+\).

The func­tion \(\operatorname{neg}\) that maps \(x\) to \(-x\) is a unary op­er­a­tion on \(\mathbb Z\): It takes one value from \(\mathbb Z\) as in­put, and pro­duces an out­put in \(\mathbb Z\) (namely, the nega­tion of the in­put). \(\operatorname{neg}\) is also a unary op­er­a­tion on \(\mathbb N\), but \(\mathbb N\) is not closed un­der \(\operatorname{neg}\) (be­cause \(\operatorname{neg}(3)=-3\) is not in \(\mathbb N\)).

The num­ber of val­ues that the op­er­a­tor takes as in­put is called the ar­ity of the op­er­a­tor. For ex­am­ple, the func­tion \(\operatorname{zero}\) which takes no in­puts and re­turns \(0\) is a zero-ar­ity op­er­a­tor; and the op­er­a­tor \(f(a, b, c, d) = ac - bd\) is a four-ar­ity op­er­a­tor (which can be used on any ring, if we in­ter­pret mul­ti­pli­ca­tion and sub­trac­tion as ring op­er­a­tions).