TheInfoList

OR:

Arity () is the number of arguments or
operand In mathematics, an operand is the object of a mathematical operation, i.e., it is the object or quantity that is operated on. Example The following arithmetic expression shows an example of operators and operands: :3 + 6 = 9 In the above exampl ...
s taken by a function, operation or relation in
logic Logic is the study of correct reasoning. It includes both Mathematical logic, formal and informal logic. Formal logic is the science of Validity (logic), deductively valid inferences or of logical truths. It is a formal science investigating h ...
,
mathematics Mathematics is an area of knowledge that includes the topics of numbers, formulas and related structures, shapes and the spaces in which they are contained, and quantities and their changes. These topics are represented in modern mathematics ...
, and
computer science Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to Applied science, practical discipli ...
. In mathematics, arity may also be named ''rank'', but this word can have many other meanings in mathematics. In logic and
philosophy Philosophy (from , ) is the systematized study of general and fundamental questions, such as those about existence, reason, knowledge, values, mind, and language. Such questions are often posed as problems to be studied or resolved. Some ...
, it is also called adicity and degree. In
linguistics Linguistics is the scientific study of human language. It is called a scientific study because it entails a comprehensive, systematic, objective, and precise analysis of all aspects of language, particularly its nature and structure. Linguis ...
, it is usually named valency.

# Examples

The term "arity" is rarely employed in everyday usage. 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 In mathematics and computing, the hexadecimal (also base-16 or simply hex) numeral system is a Numeral system#Positional systems in detail, positional numeral system that represents numbers using a radix (base) of 16. Unlike the decimal system ...
. One combines a
Latin Latin (, or , ) is a classical language belonging to the Italic languages, Italic branch of the Indo-European languages. Latin was originally a dialect spoken in the lower Tiber area (then known as Latium) around present-day Rome, but through ...
prefix with the -ary ending; for example: * A nullary function takes no arguments. ** Example: $f\left(\right)=2$ * A unary function takes one argument. ** Example: $f\left(x\right)=2x$ * A binary function takes two arguments. ** Example: $f\left(x,y\right)=2xy$ * A ternary function takes three arguments. ** Example: $f\left(x,y,z\right)=2xyz$ * An ''n''-ary function takes ''n'' arguments. ** Example: $f\left(x_1, x_2, \ldots, x_n\right)=2\prod_^n x_i$

## Nullary

Sometimes it is useful to consider a constant to be an operation of arity 0, and hence call it ''nullary''. Also, in non-
functional programming In computer science Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to Applied sc ...
, a function without arguments can be meaningful and not necessarily constant (due to
side effect In medicine, a side effect is an effect, whether therapeutic or adverse, that is secondary to the one intended; although the term is predominantly employed to describe adverse effects, it can also apply to beneficial, but unintended, consequence ...
s). Often, such functions have in fact some ''hidden input'' which might be global variables, including the whole state of the system (time, free memory, ...). The latter are important examples which usually also exist in "purely" functional programming languages.

## Unary

Examples of unary operators in mathematics and in programming include the unary minus and plus, the increment and decrement operators in C-style languages (not in logical languages), and the successor,
factorial In mathematics, the factorial of a non-negative denoted is the Product (mathematics), product of all positive integers less than or equal The factorial also equals the product of n with the next smaller factorial: \begin n! &= n \times ...
, reciprocal,
floor A floor is the bottom surface of a room or vehicle. Floors vary from wikt:hovel, simple dirt in a cave to many layered surfaces made with modern technology. Floors may be stone, wood, bamboo, metal or any other material that can support the ex ...
, ceiling, fractional part, sign,
absolute value In mathematics, the absolute value or modulus of a real number x, is the non-negative value without regard to its sign (mathematics), sign. Namely, , x, =x if is a positive number, and , x, =-x if x is negative number, negative (in which cas ...
, square root (the principal square root), complex conjugate (unary of "one" complex number, that however has two parts at a lower level of abstraction), and norm functions in mathematics. The two's complement, address reference and the logical NOT operators are examples of unary operators in math and programming. All functions in lambda calculus and in some functional programming languages (especially those descended from ML) are technically unary, but see n-ary below. According to Quine, the Latin distributives being ''singuli, bini, terni,'' and so forth, the term "singulary" is the correct adjective, rather than "unary." Abraham Robinson follows Quine's usage. In philosophy, the adjective ''monadic'' is sometimes used to describe a one-place relation such as 'is square-shaped' as opposed to a two-place relation such as 'is the sister of'.

## Binary

Most operators encountered in programming and mathematics are of the binary form. For both programming and mathematics, these include the multiplication operator, the radix operator, the often omitted
exponentiation Exponentiation is a mathematics, mathematical operation (mathematics), operation, written as , involving two numbers, the ''Base (exponentiation), base'' and the ''exponent'' or ''power'' , and pronounced as " (raised) to the (power of) ". W ...
operator, the
logarithm In mathematics, the logarithm is the inverse function to exponentiation. That means the logarithm of a number  to the base  is the exponent to which must be raised, to produce . For example, since , the ''logarithm base'' 10 of ...
operator, the addition operator, and the division operator. Logical predicates such as '' OR'', '' XOR'', '' AND'', ''IMP'' are typically used as binary operators with two distinct operands. In CISC architectures, it is common to have two source operands (and store result in one of them).

## Ternary

The computer programming language C and its various descendants (including C++, C#,
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's List ...
, Julia,
Perl Perl is a family of two high-level, general-purpose, interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it also referred to its redesigned "sister language", Perl 6, before the latter's name was offi ...
, and others) provide the ternary conditional operator ?:. The first operand (the condition) is evaluated, and if it is true, the result of the entire expression is the value of the second operand, otherwise it is the value of the third operand. The Python language has a ternary conditional expression, x if C else y. The Forth language also contains a ternary operator, */, which multiplies the first two (one-cell) numbers, dividing by the third, with the intermediate result being a double cell number. This is used when the intermediate result would overflow a single cell. The Unix dc calculator has several ternary operators, such as , , which will pop three values from the stack and efficiently compute $x^y \bmod z$ with arbitrary precision. Many ( RISC)
assembly language In computer programming, assembly language (or assembler language, or symbolic machine code), often referred to simply as Assembly and commonly abbreviated as ASM or asm, is any low-level programming language with a very strong correspondence be ...
instructions are ternary (as opposed to only two operands specified in CISC); or higher, such as MOV %AX, (%BX, %CX), which will load (MOV) into register the contents of a calculated memory location that is the sum (parenthesis) of the registers and .

## ''n''-ary

From a mathematical point of view, a function of ''n'' arguments can always be considered as a function of one single argument which is an element of some product space. However, it may be convenient for notation to consider ''n''-ary functions, as for example multilinear maps (which are not linear maps on the product space, if ). The same is true for programming languages, where functions taking several arguments could always be defined as functions taking a single argument of some composite type such as a tuple, or in languages with higher-order functions, by currying.

## Varying arity

In computer science, a function accepting a variable number of arguments is called '' variadic''. In logic and philosophy, predicates or relations accepting a variable number of arguments are called '' multigrade'', anadic, or variably polyadic.

# Terminology

Latin Latin (, or , ) is a classical language belonging to the Italic languages, Italic branch of the Indo-European languages. Latin was originally a dialect spoken in the lower Tiber area (then known as Latium) around present-day Rome, but through ...
ate names are commonly used for specific arities, primarily based on Latin distributive numbers meaning "in group of ''n''", though some are based on Latin
cardinal number In mathematics Mathematics is an area of knowledge that includes the topics of numbers, formulas and related structures, shapes and the spaces in which they are contained, and quantities and their changes. These topics are represented ...
s or ordinal numbers. For example, 1-ary is based on cardinal ''unus'', rather than from distributive ''singulī'' that would result in ''singulary''. ''n''-''ary'' means ''n'' operands (or parameters), but is often used as a synonym of "polyadic". These words are often used to describe anything related to that number (e.g., undenary chess is a chess variant with an 11×11 board, or the Millenary Petition of 1603). The arity of a relation (or predicate) is the dimension of the domain in the corresponding
Cartesian product In mathematics, specifically set theory, the Cartesian product of two Set (mathematics), sets ''A'' and ''B'', denoted ''A''×''B'', is the set of all ordered pairs where ''a'' is in ''A'' and ''b'' is in ''B''. In terms of set-builder notatio ...
. (A function of arity ''n'' thus has arity ''n''+1 considered as a relation.) In
computer programming Computer programming is the process of performing a particular computation (or more generally, accomplishing a specific computing result), usually by designing and building an executable computer program. Programming involves tasks such as anal ...
, there is often a syntactical distinction between operators and functions; syntactical operators usually have arity 0, 1, or 2 (the ternary operator ?: is also common). Functions vary widely in the number of arguments, though large numbers can become unwieldy. Some programming languages also offer support for variadic functions, i.e., functions syntactically accepting a variable number of arguments.