Arity

From Free net encyclopedia

In logic, mathematics, and computer science, the arity of a relation is the number of domains in the corresponding cartesian product. In the special case of a function or operator, it is conventional to say that the arity of the function is the number of specifically functional domains, roughly speaking, the number of arguments or operands that the function takes.

In linguistics, arity is sometimes referred to as valency, not to be confused with valency in mathematics.

Although arity is an important concept, the word "arity" is rarely used in everyday practice. For example, rather than saying "the arity of the addition operation is 2" or "addition is an operation of arity 2" one usually says "addition is a binary operation". In general, the naming of functions or operators with a given arity follows a convention similar to the one used for n-based numeral systems such as binary and hexadecimal. One combines a Latin prefix with the -ary ending; for example:

  • A nullary function takes no arguments.
  • A unary function takes one argument.
  • A binary function takes two arguments.
  • A ternary function takes three arguments.
  • An n-ary function takes n arguments.

In particular, an n-ary operation f on a set S is the same as a function f : Sn → S.

Contents

Examples

Nullary

Sometimes it is useful to consider a constant as a function or an operator of arity 0, and hence call it nullary.

Unary

Examples of unary operators in math and in programming include the unary minus and plus, the add-one or subtract-one operator in C-style languages, not in logical languages and the factorial function in math. Also, the two's complement operator and the address reference operators are examples of unary operators in math and programming.

Binary

Most operators encountered in programming are of the binary form. For both programming and math these can be the multiplication operator, the addition operator, the division operator. Logical predicates such as OR, XOR, AND, IMP are typically used as binary operators with two distinct operands.

Ternary

From C, [[C++]], C#, Java, Perl and variants comes the ternary operator  ?: , which is a so-called conditional operator, taking three parameters.


Other names

  • Nullary means zero parameters.
  • Unary means one parameter.
  • Binary means two parameters.
  • Ternary means three parameters.
  • Quaternary means four parameters.
  • Quinary means five parameters.
  • Sestary means six parameters.
  • k-ary means k parameters.

An alternative nomenclature is derived in a similar fashion from the corresponding Greek roots, for example, medadic, monadic, dyadic, triadic, and so on. Hence derive the alternative terms adicity and adinity for the Latin derived arity.

Arities above quaternary are rarely found in math- or programming-related literature; already quaternary operations are more often called 4-ary. However, these words are often used to describe anything related to that number (i.e. undenary chess is a chess variant with an 11x11 board, or the Millenary Petition of 1603).

See also

eo:Loknombro es:Aridad et:Aarsus fr:Arité io:Arito nl:Ariteit pl:Arność ru:Арность sv:Aritet