In logic, mathematics, and computer science, arity refers to the number of arguments or operands a function, operation, or relation takes. The term helps classify how many inputs a function requires to produce an output. Arity is also known as rank in mathematics, adicity or degree in logic and philosophy, and valency in linguistics.
For example, the addition operator (+) is binary because it takes two operands, while a constant value such as True or π is nullary because it takes none.
Etymology and Related Terms
The term arity derives from the Latin suffix -ary, combined with numerical prefixes that indicate quantity, such as unary (one), binary (two), or ternary (three). In philosophical and linguistic contexts, Greek-based equivalents like monadic, dyadic, and triadic are also used.
- Arity — general term describing the number of inputs
- Adicity — Greek-based equivalent, often used in logic and philosophy
- Valency — term used in linguistics to describe the number of arguments a verb takes
Examples by Arity Type
| Arity | Latin Name | Greek Equivalent | Example (Math) | Example (Programming) |
|---|---|---|---|---|
| 0 | Nullary | Niladic | A constant value | A function returning a fixed result |
| 1 | Unary | Monadic | Additive inverse | Logical NOT, increment operator |
| 2 | Binary | Dyadic | Addition | Logical AND, OR |
| 3 | Ternary | Triadic | Vector triple product | Ternary operator ?: |
| 4 | Quaternary | Tetradic | 4-input functions | Low-level processor operations |
| n | n-ary | Polyadic | n-variable mean | n-parameter function |
| Variable | Variadic | Anadic | Summation (Σ) | Functions like printf() in C |
Types of Arity
Nullary Functions
A nullary function takes no arguments. Mathematically, constants are considered nullary functions because their output is fixed.
Example: f()=2f() = 2f()=2
In programming, nullary functions may perform tasks that depend on hidden state (e.g., time or system status) rather than arguments.
Unary Functions
A unary function takes one argument. Examples include negation (−x), absolute value, factorial, and logical NOT (!x). Unary operators are fundamental in both mathematics and programming.
In philosophy, unary relations are called monadic—for instance, “is red” or “is square-shaped.”
Binary Functions
A binary function or operator requires two arguments. The majority of mathematical and programming operations—such as addition, subtraction, and comparison—fall into this category.
Binary operations follow the general form: f(x,y)=2xyf(x, y) = 2xyf(x,y)=2xy
In programming, common binary operators include +, -, *, /, &&, and ||.
Ternary Functions
A ternary function takes three arguments. The C programming language introduced the ternary conditional operator (?:), which evaluates conditions compactly:
result = (condition) ? value_if_true : value_if_false;
This design was later adopted by languages like C++, Java, and Python (x if C else y).
n-ary Functions
An n-ary function accepts n arguments, where n can be any positive integer. For example, the arithmetic mean and geometric mean both operate on n numbers: xˉ=x1+x2+⋯+xnn\bar{x} = \frac{x_1 + x_2 + \dots + x_n}{n}xˉ=nx1+x2+⋯+xn
In functional programming, functions with multiple arguments can often be represented as curried unary functions, each returning another function until all parameters are applied.
Varying Arity (Variadic Functions)
A variadic function accepts a variable number of arguments. Examples include:
- The mathematical summation operator (Σ)
- The C language function
printf() - The JavaScript function
Math.max()
In logic, relations or predicates with variable arity are called multigrade, anadic, or variably polyadic.
Arity in Logic and Mathematics
In formal logic, arity describes the number of places a predicate or relation connects. For instance:
- Monadic predicate: “is blue” → one argument
- Dyadic predicate: “is taller than” → two arguments
- Triadic predicate: “gave (giver, recipient, gift)” → three arguments
Mathematically, a relation of arity n corresponds to a subset of an n-dimensional Cartesian product. A function of arity n is thus a relation of arity n + 1, since it pairs n input values with one output.
Programming and Syntax Considerations
In computer programming:
- Operators usually have fixed arities (commonly 1, 2, or 3).
- Functions can vary widely, with some languages supporting variadic functions.
- In functional programming, functions are formally unary, with multiple arguments expressed through currying or tuple arguments.
For example, the Haskell function:
f x y = x + y
is technically unary, returning a function after each argument.
Summary
Arity is a foundational concept that unites mathematics, logic, linguistics, and programming. It specifies how many inputs a process, function, or operation requires to produce an output. Whether it’s the nullary constant π, the binary addition x + y, or the variadic sum(), arity provides a universal framework for describing the structure and behavior of functions and operations.







