Overview
Arity denotes how many arguments an operation, function, or relation takes. The concept appears across formal logic, mathematics, and programming. In logic it classifies predicates and relations; in mathematics it describes functions and algebraic operations; in computer science it helps shape function signatures and calling conventions. See treatments in logic, mathematics, and computing: logic, mathematics, computer science.
Common terms and examples
Names are often used to indicate specific arities. Typical labels include:
- Nullary (arity 0): constant values or parameterless functions.
- Unary (arity 1): functions of a single argument, e.g., negation.
- Binary (arity 2): common operations like addition or comparison.
- Ternary (arity 3) and higher: less common but used in some languages and logics.
- Variadic: accepts a variable number of arguments (often written as n-ary).
Mathematical and logical context
In mathematics and logic the arity of a relation or function is part of its formal signature. A predicate with arity n is sometimes called n-ary; this determines the number of terms it relates. Algebraic structures and formal languages record the arities of their operations when defining a signature or type. Distinctions between arity and related notions—such as cardinality of sets or degree in graph theory—are important to avoid confusion.
Computer science and programming
In programming the arity appears in function declarations and affects calling semantics and type checking. Some languages enforce fixed arity, while others support variadic functions or default parameters. Currying is a technique that transforms a function of arity n into a chain of unary functions; higher-order functions may accept or return functions with their own arities. Compilers and type systems frequently use arity information to validate calls and infer types.
History, usage, and notable points
The explicit use of arity grew as formal logic and algebra developed precise syntactic descriptions for expressions. In modern practice arity is a simple but essential attribute used in designing APIs, specifying grammars, and formulating logical theories. Remember that altering how arguments are packaged (tuples, lists, currying) can change apparent arity without changing the underlying computation.
Further reading
For introductions and deeper technical treatments consult resources on formal languages, type theory, and universal algebra. For general reference across disciplines see entries linked under mathematics and computer science.