Hubbry Logo
ArityArityMain
Open search
Arity
Community hub
Arity
logo
7 pages, 0 posts
0 subscribers
Be the first to start a discussion here.
Be the first to start a discussion here.
Arity
Arity
from Wikipedia

In logic, mathematics, and computer science, arity (/ˈærɪti/ ) is the number of arguments or operands taken by a function, operation or relation. In mathematics, arity may also be called rank,[1][2] but this word can have many other meanings. In logic and philosophy, arity may also be called adicity and degree.[3][4] In linguistics, it is usually named valency.[5]

Examples

[edit]

In general, functions or operators with a given arity follow the naming conventions of n-based numeral systems, such as binary and hexadecimal. A Latin prefix is combined with the -ary suffix. For example:

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

Nullary

[edit]

A constant can be treated as the output of an operation of arity 0, called a nullary operation.

Also, outside of functional programming, a function without arguments can be meaningful and not necessarily constant (due to side effects). Such functions may have some hidden input, such as global variables or the whole state of the system (time, free memory, etc.).

Unary

[edit]

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, reciprocal, floor, ceiling, fractional part, sign, absolute value, 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. In programming the two's complement, address reference, and the logical NOT operators are examples of unary operators.

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".[6] Abraham Robinson follows Quine's usage.[7]

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

[edit]

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 operator, the logarithm 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

[edit]

The computer programming language C and its various descendants (including C++, C#, Java, Julia, Perl, 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. This operator has a lazy or 'shortcut' evaluation strategy that does not evaluate whichever of the second and third arguments is not used. Some functional programming languages, such as Agda, have such an evaluation strategy for all functions and consequently implement if...then...else as an ordinary function; several others, such as Haskell, can do this but for syntactic, performance or historical reasons choose to define keywords instead.

The Python language has a ternary conditional expression, x if C else y. In Elixir the equivalent would be if(C, do: x, 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 with arbitrary precision.

Many (RISC) assembly language 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 AX the contents of a calculated memory location that is the sum (parenthesis) of the registers BX and CX.

n-ary

[edit]

The arithmetic mean of n real numbers is an n-ary function:

Similarly, the geometric mean of n positive real numbers is an n-ary function: Note that a logarithm of the geometric mean is the arithmetic mean of the logarithms of its n arguments

From a mathematical point of view, a function of n arguments can always be considered as a function of a single argument that 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 n ≠ 1).

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

[edit]

In computer science, a function that accepts 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.[8]

Terminology

[edit]

Latinate 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 numbers or ordinal numbers. For example, 1-ary is based on cardinal unus, rather than from distributive singulī that would result in singulary.

n-ary Arity (Latin based) Adicity (Greek based) Example in mathematics Example in computer science
0-ary nullary (from nūllus) niladic a constant a function without arguments, True, False
1-ary unary monadic additive inverse logical NOT operator
2-ary binary dyadic addition logical OR, XOR, AND operators
3-ary ternary triadic triple product of vectors ternary conditional operator
4-ary quaternary tetradic
5-ary quinary pentadic
6-ary senary hexadic
7-ary septenary hebdomadic
8-ary octonary ogdoadic
9-ary novenary (alt. nonary) enneadic
10-ary denary (alt. decenary) decadic
more than 2-ary multary and multiary polyadic
varying variadic sum; e.g., Σ variadic function, reduce

n-ary means having 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. (A function of arity n thus has arity n+1 considered as a relation.)

In computer programming, there is often a syntactical distinction between operators and functions; syntactical operators usually have arity 1, 2, or 3 (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.

See also

[edit]

References

[edit]
[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
In logic, , and , arity refers to the number of arguments or operands that a function, operation, or relation accepts. For instance, a function symbol or predicate symbol is assigned a specific arity, which determines how many inputs it requires, with arity zero corresponding to constants that take no arguments. This concept is fundamental in formal systems, where the arity of each symbol is explicitly defined in the language's to ensure well-formed expressions. Common designations for arity include nullary or arity zero for operations with no arguments, such as constants; unary for those taking one argument, like in logic; binary for two arguments, as in or conjunction; and ternary for three, with higher arities denoted as n-ary for general n. In predicate logic, the arity distinguishes relations, such as unary predicates like "is even" or binary ones like "less than," ensuring precise semantic interpretation. Arity also applies to algebraic structures, where operations like group multiplication are typically binary, influencing the structure's properties and theorems. In , arity extends to programming languages and type systems, where functions may have fixed arity—requiring an exact number of parameters—or variable arity, allowing flexible counts, as seen in procedures like mapping over that accept two or more inputs. This flexibility supports higher-order functions and generics, enabling across different data structures while maintaining . Mismatches in arity often lead to compilation errors, underscoring its role in enforcing operational correctness.

Fundamentals

Definition

Arity is the number of arguments or operands that a function, operation, or relation accepts in , logic, and . This concept specifies the fixed number of inputs required for the entity to produce an output or evaluate to true or false, distinguishing it from other structural properties in formal systems. Unlike , which measures the size or number of elements in a set, arity focuses exclusively on the count of inputs to a computational or logical construct. Formally, a function ff has arity kk if it maps from the of kk domains to a , denoted f:A1×A2××AkBf: A_1 \times A_2 \times \cdots \times A_k \to B, where each AiA_i represents an input domain. In abstract terms, constant functions exhibit arity 0, as they require no arguments and yield a fixed value regardless of input. The identity function, which returns its single argument unchanged, has arity 1. Addition, as an operation combining two elements to produce their sum, demonstrates arity 2.

Historical Origins

The term "arity" derives from the English suffix "-ary," as used in mathematical terms like "unary," "binary," and "ternary" to denote the number of arguments or operands, combined with the noun-forming "-ity" to express the property or measure of that number. This etymology is attested in linguistic resources tracing the word's formation to mid-20th-century mathematical and logical contexts, where it standardized discussions of function and relation ranks; the earliest known use is from 1968 in Fundamenta Mathematicae. The concept of operations with a fixed number of arguments predates the term itself, appearing in and mathematics. During the , ad-hoc descriptions of operation "degrees" or "valences" emerged in and logic, influenced by developments in group theory and predicate calculus. developed the first general logic for relations of arbitrary number of arguments in his 1870 paper "Description of a Notation for the Logic of Relatives," marking a shift toward formalizing multi-argument relations and bridging 19th-century relational logic to 20th-century systems. The standardization of "arity" occurred in the mid-20th century amid the formalization of and the rise of . Alfred Tarski's work on and semantics in the 1930s and 1940s emphasized the role of predicate arities in logical structures, contributing to the term's adoption in rigorous treatments of syntax. Similarly, Alonzo Church's , introduced in the 1930s, formalized functions with explicit argument counts, influencing the term's use in and type systems. A key milestone was the inclusion of arity-like concepts for predicates in influential texts such as and Wilhelm Ackermann's Grundzüge der theoretischen Logik (1928, with revised editions through the 1940s), which discussed the "order" or degree of relations in axiomatic systems, paving the way for the modern term's widespread acceptance. This evolution reflected a broader transition from descriptive classifications in classical algebra to precise, standardized notation in formal logics.

Terminology

Standard Classifications

In mathematics and logic, the standard classifications of arity refer to the conventional terms used to describe functions, operations, or relations based on their fixed number of arguments, providing a systematic way to categorize them according to their structure. These terms originate from numerical prefixes and are essential for defining signatures in algebraic and logical systems. Nullary functions, or 0-ary functions, accept zero arguments and invariably produce a constant value, making them equivalent to constants in a given domain since their output does not depend on any input variables. Unary functions take exactly one argument; representative examples include the negation operation, which inverts a logical value, or the successor function, which increments a natural number by one. Binary functions operate on two arguments, such as the operation that combines two numbers to yield their sum, or the equality relation that compares two elements for sameness. Ternary functions require three arguments and, though less prevalent than unary or binary counterparts, arise in areas like vector algebra, exemplified by the scalar that computes the volume scalar from three vectors in . For higher arities, the terms (4-ary) and (5-ary) are used, with further terms like for six. The general term for functions with a fixed arity of nn, where n0n \geq 0, is n-ary; when n>2n > 2, such functions are sometimes collectively described as polyadic to emphasize their multi-argument nature beyond binary. Formally, the arity of a function ff is denoted as n-ary, often symbolized as f(n):AnAf^{(n)} : A^n \to A, where AnA^n represents the Cartesian product of nn copies of the set AA, clarifying the input structure.

Variations and Extensions

Varying arity, also known as variable arity or polymorphism in this context, refers to functions that can accept a differing number of arguments depending on the invocation, enabling flexible behavior across multiple arities. This concept is prevalent in programming languages, where it supports uniform operations over variable inputs; for instance, the addition function in Scheme can sum any finite number of integers, treating excess arguments as a rest parameter. Similarly, the printf function in C uses variadic arguments to format and print an arbitrary number of values based on a format string, accessed via the ellipsis notation and stdarg macros. In functional programming, fold functions like foldl or foldr generalize binary reduction operations to process lists of variable length by iteratively applying a combining function. Infinite arity extends the notion of operations to conceptual cases where an operation accepts infinitely many inputs, a rare but theoretically significant variation in advanced mathematical frameworks. In infinitary algebraic theories, operations of arbitrary infinite arity are permitted, such as the supremum over κ-many elements for any cardinal κ in suplattices. These arise in and , where infinite products represent objects as products over infinite index sets, allowing structures like complete lattices with infinitary joins. Currying provides a way to decompose a function of fixed arity n into a sequence of n unary functions, each accepting one argument and returning the next function until fully applied; for example, a binary function add(x, y) becomes add(x)(y), reducing effective arity stepwise. This technique originates from and is foundational in for enabling and higher-order abstractions. In logic, arity for relations differs from that of functions in that it denotes the number of variables in a predicate rather than inputs to an output mapping. A R(x, y) has arity 2, capturing pairwise connections without producing a unique value, unlike a f(x, y) that yields a single result. Predicates of arity n thus specify n-place relations over a domain, essential for expressing properties in . Notation for variations in arity adapts standard symbols to convey flexibility. In programming, variable arguments are often denoted by ellipsis (...) as the final parameter, as in C's printf(const char *format, ...), or by starred parameters like *args in Python for collecting extras into a tuple. In algebra, n-ary operations are typically written as f(a_1, \dots, a_n), with symbols like \oplus sometimes generalized for n-ary sums in structures such as n-ary groups, where associativity extends across multiple operands.

Examples

Nullary Operations

A nullary operation, also known as a 0-ary operation, is a function that takes no arguments and produces a fixed output from a given set, effectively serving as a constant within an . In , such operations are defined on a set AA with domain A0A^0, which is a singleton set representing the (often denoted as set {()}\{()\}), mapping to a single element in AA. This distinguishes nullary operations from higher-arity ones by their lack of input dependency, making them foundational elements that single out specific values without variation. In , nullary operations appear as functions, such as c:A0Ac: A^0 \to A where c()c() yields a predetermined element cAc \in A, equivalent to embedding constants into the algebra's . For instance, in group , the ee functions as a nullary operation, providing a fixed value that interacts with binary operations like to preserve structure. Similarly, in algebras, the constants 0 and 1 serve as nullary operations, acting as absorbing and identity elements for conjunction and disjunction, respectively: x0=0x \land 0 = 0 and x1=1x \lor 1 = 1. In logic, nullary operations manifest as nullary predicates, which are propositions that evaluate to true or false without variables, akin to atomic sentences in propositional logic. These predicates denote zero-place relations, modeling constant truth values such as \top (always true) or \bot (always false), and integrate into first-order structures by assigning fixed interpretations in models. For example, a nullary predicate PP in a logical system simply asserts PP or ¬P\neg P independently of any arguments, forming the basis for propositional atoms within predicate frameworks. In , nullary operations correspond to global constants or zero-parameter functions that return predefined values, often used to encapsulate immutable data without invocation arguments. In programming languages like or Stan, such functions are treated as nullary, with examples including built-in constants like π()\pi() or e()e(), which compute and return fixed mathematical values on each call, ensuring consistency across computations. These are distinct from variables, as their values remain unaltered during execution, supporting modular code design by providing reliable, side-effect-free references. Nullary operations exhibit inherent , as applying the operation repeatedly yields the same constant output: if f() =cf()\ = c, then f(f())=cf(f()) = c. This property arises naturally from their constant nature, simplifying compositions in algebraic expressions. Furthermore, arity 0 operations are foundational for constructing higher-arity structures, as they form the base terms in free algebras and enable the universal mapping property through term generation via composition with variables and other operations. In term algebras, nullary symbols directly contribute to the of terms, allowing the building of complex expressions from these atomic constants.

Unary Operations

Unary operations, also referred to as unary functions, are mappings that take exactly one argument from a domain set AA to a set BB, formally defined as functions f:ABf: A \to B. In many algebraic contexts, particularly within , these operations are endofunctions where A=BA = B, meaning they transform elements within the same set, such as the id(a)=a\mathrm{id}(a) = a that leaves every element unchanged or inversion operations like in suitable structures. This single-input nature distinguishes unary operations by their simplicity, enabling straightforward applications in building more complex structures without requiring interactions between multiple elements. In , unary operations underpin foundational constructions, exemplified by the in Peano arithmetic, which defines the s inductively as S(n)=n+1S(n) = n + 1 for each nn, starting from 0 to generate the sequence 0,1,2,0, 1, 2, \dots. Another ubiquitous example is the function on the real numbers, given by x={xif x0,xif x<0,|x| = \begin{cases} x & \text{if } x \geq 0, \\ -x & \text{if } x < 0, \end{cases} which maps any real number xx to its non-negative distance from zero, preserving magnitude while discarding sign information. These operations highlight the transformative role of unary functions in arithmetic and analysis, where they facilitate inductive definitions and metric properties without additional arguments. In propositional logic, unary operations manifest as unary connectives that operate on a single proposition to yield another, such as negation ¬P\neg P, which reverses the truth value of proposition PP—true becomes false, and vice versa—forming the basis for expressing contradiction and enabling the construction of complex logical expressions. In computer science, unary operations are prevalent in programming languages for data manipulation, including the pre-increment operator ++x in , which evaluates to the value of xx after increasing it by 1, and the built-in length function len(s) in Python, which returns the number of elements in a sequence like string ss. A key property of unary endofunctions is their composability: the set of all functions from a set to itself forms a monoid under function composition, where (fg)(x)=f(g(x))(f \circ g)(x) = f(g(x)) is associative, and the identity function serves as the neutral element. This structure allows unary operations to chain indefinitely, modeling sequential transformations in algorithms and automata.

Binary Operations

A binary operation is a function f:A×BCf: A \times B \to C that takes two elements, one from each of sets AA and BB, and produces a single element in set CC. In algebraic contexts, binary operations are often defined on a single set SS, mapping S×SSS \times S \to S, ensuring the result remains within the same set, a property known as closure. Key properties include commutativity, where f(a,b)=f(b,a)f(a, b) = f(b, a) for all aAa \in A, bBb \in B, and associativity, where f(a,f(b,c))=f(f(a,b),c)f(a, f(b, c)) = f(f(a, b), c) for compatible elements; these properties underpin structures like groups, where the operation is associative and closed. Binary operations also play a foundational role in defining binary relations, which can be viewed as operations mapping pairs to truth values, such as the equality relation == on a set SS, where =(a,b)=(a, b) yields true if a=ba = b and false otherwise. In mathematics, addition exemplifies a binary operation on the real numbers R\mathbb{R}, defined by +(a,b)=a+b+(a, b) = a + b, which is both commutative and associative, forming the basis for the additive group of reals. Similarly, multiplication \cdot on R\mathbb{R} satisfies (a,b)=ab\cdot(a, b) = ab, associative and commutative except at zero, contributing to ring structures. In logic, binary connectives operate on propositions, such as conjunction \land, where PQP \land Q is true only if both PP and QQ are true, and implication \to, where PQP \to Q is false only if PP is true and QQ is false; these form the propositional calculus. In computer science, subtraction on integers provides a binary operation :Z×ZZ-: \mathbb{Z} \times \mathbb{Z} \to \mathbb{Z}, with aba - b computed via two's complement addition in binary representation, though it is neither commutative nor associative. String concatenation, denoted ++ on strings, appends two strings s1+s2s_1 + s_2 to form a new string, forming a monoid under this associative operation with the empty string as identity. Closed binary operations on a set SS give rise to a magma, the most basic algebraic structure requiring only closure. If the operation is additionally associative, the structure is a semigroup, as seen in natural numbers under addition.

Higher-Arity Operations

Higher-arity operations, also known as n-ary operations for n3n \geq 3, generalize binary operations by accepting three or more arguments from specified sets. Formally, an n-ary operation is a function f:A1××AnBf: A_1 \times \cdots \times A_n \to B, where each AiA_i is a domain (often the same set A) and B is the codomain, mapping tuples of n elements to a single output. In formal systems, such operations are often abbreviated using tuple notation or reduced through currying, which transforms an n-ary function into a sequence of unary functions, facilitating composition and partial application. In mathematics, ternary operations (n=3) include the scalar triple product in vector algebra, defined as [u,v,w]=u(v×w)[ \mathbf{u}, \mathbf{v}, \mathbf{w} ] = \mathbf{u} \cdot (\mathbf{v} \times \mathbf{w}), which computes the signed volume of the parallelepiped formed by three vectors and serves as a trilinear mapping. For higher n, symmetric multilinear maps represent n-ary operations that are linear in each argument and invariant under permutation of inputs, commonly used in tensor analysis and representation theory to model interactions among multiple variables while preserving symmetry. In logic, higher-arity operations manifest as n-ary predicates in first-order languages, where a ternary predicate like "between(x, y, z)" asserts that y lies between x and z on a linear order, enabling the expression of complex relations beyond pairwise connections. In computer science, higher-arity functions appear in programming languages for tasks involving multiple data structures, such as the ternary zipWith3 operation in functional programming, which applies a three-argument function element-wise to three lists, producing a list of combined results (e.g., zipWith3 f [a1,a2,...] [b1,b2,...] [c1,c2,...] yields [f a1 b1 c1, f a2 b2 c2, ...]). Higher-arity operations introduce challenges in formal systems due to increased complexity, as the number of possible argument combinations grows factorially with n, leading to a combinatorial explosion that complicates computation, proof search, and implementation; this is often mitigated by currying to binary equivalents or bundling arguments into tuples.

Variable Arity

Variable arity refers to functions or operations that accept a varying number of arguments, providing flexibility beyond fixed-arity structures while building on principles of n-ary operations for n ≥ 3. This adaptability is achieved through mechanisms that allow dynamic argument collection, such as argument lists or rest parameters in programming languages. For instance, in Python, the *args syntax collects additional positional arguments into a tuple, enabling functions to process an arbitrary number of inputs after fixed parameters. Similarly, JavaScript's Function.prototype.apply() method invokes a function with arguments provided as an array, facilitating dynamic argument passing for varying counts. In SQL, PostgreSQL's concat function is variadic, accepting zero or more string arguments to concatenate them without a fixed limit. In mathematics, variable arity manifests in operations like n-ary summation, where the summation symbol \sum aggregates a variable number of terms, such as i=1kxi\sum_{i=1}^k x_i for any positive integer kk, interpreted as the standard addition over a finite sequence. Another example is the generalized power mean, defined as Mp(x1,,xk)=(1ki=1kxip)1/pM_p(x_1, \dots, x_k) = \left( \frac{1}{k} \sum_{i=1}^k x_i^p \right)^{1/p} for any k1k \geq 1 and order pp, allowing computation over datasets of varying size while generalizing common means like arithmetic (p=1p=1) or geometric (p0p \to 0). In logic, higher-order logic supports variable-arity quantifiers by allowing quantification over function and relation variables of arbitrary fixed arities, enabling expressions that bind predicates or operators with varying numbers of arguments, such as f:αnβ\forall f: \alpha^n \to \beta where nn can differ across contexts. While variable arity enhances expressiveness—permitting concise implementations of operations like summation or mapping over dynamic inputs—it introduces trade-offs in type checking and optimization. In typed languages, handling variable arguments often requires specialized polymorphism, such as dotted type variables, complicating inference and potentially limiting optimizations like inlining due to imprecise arity information at compile time.

Applications

In Mathematics

In universal algebra, the concept of is fundamental to defining algebraic structures through a signature, which consists of a set of operation symbols each assigned a specific arity, specifying the number of arguments the operation takes. For instance, the signature for a group typically includes a single binary operation symbol for multiplication, reflecting the group's defining operation that combines two elements to produce another. This arity ensures that homomorphisms between groups preserve the binary structure of the operation. Similarly, the signature for a ring comprises two binary operations—addition and multiplication—a unary operation for additive inverse, along with a constant for the zero element, capturing the structure of ring operations. In category theory, arity plays a key role in the study of categories with arities, where objects often represent finite cardinals that denote possible arities, and morphisms are operations of specified arity between these. Functors in such categories preserve arities by mapping objects and morphisms while maintaining the arity specifications, enabling the formalization of algebraic theories as categories where arrows correspond to operations of fixed arity. This framework allows for the abstraction of universal algebraic constructions, such as varieties of algebras, where the signature's arities determine the category's structure. Within vector spaces over a field, multilinear maps exemplify n-ary operations that are linear in each argument separately, with the arity n indicating the number of vector inputs. For example, a bilinear form on a vector space V is a binary operation (n=2) from V × V to the base field, linear in both components, used to define inner products or quadratic forms. More generally, the space of all n-linear maps from (V)^n to another vector space W forms itself a vector space, with dimension depending on the dimensions of the input spaces, highlighting how arity structures multilinear algebra. In polynomial rings, arity refers to the number of indeterminates or variables, distinguishing it from the degree, which measures the highest total power of those variables in the terms. A polynomial in one variable, such as f(x)=adxd++a0f(x) = a_d x^d + \cdots + a_0, has arity 1 as a unary function, while its degree d quantifies the polynomial's "complexity" independently of the input count. For multivariate cases, like a polynomial in two variables g(x,y)=i,jaijxiyjg(x,y) = \sum_{i,j} a_{ij} x^i y^j, the arity is 2, reflecting its binary operation nature when evaluated, whereas the degree is the maximum of i + j over non-zero coefficients; this separation allows arity to classify polynomial functions by input dimensionality in algebraic contexts.

In Logic

In predicate logic, the arity of a predicate denotes the number of arguments it accepts, such as a unary predicate P(x)P(x) that applies to a single term or a binary predicate R(x,y)R(x, y) that relates two terms, thereby shaping the structure of well-formed formulas in the language. This arity requirement ensures that predicates are applied correctly to form atomic formulas, which serve as the building blocks for more complex expressions involving quantifiers and connectives. Propositional logic employs connectives of fixed low arity, including unary negation (¬\neg) and binary operators like conjunction (\land) and disjunction (\lor), alongside nullary atomic propositions that stand alone without arguments; in contrast, first-order predicate logic extends this framework by incorporating n-ary relation symbols for predicates of arbitrary finite arity greater than zero. These n-ary predicates enable the expression of properties and relations involving multiple objects, facilitating quantification over variables to capture inferences about domains. In model theory, a signature defines the syntax of a logical structure by specifying the arities of its function symbols (for operations) and predicate symbols (for relations), ensuring that models interpret these symbols consistently with their designated argument counts. This formal specification allows for the precise characterization of theories and their interpretations across different structures, where the arity constrains how elements from the domain are mapped to truth values or outputs. Representative examples include the equality predicate ==, which is binary and asserts that two terms denote the same object, and the membership relation \in in set theory, also binary, indicating that one set is an element of another. In higher-order logic, lambda abstractions permit the construction of predicates and functions with variable arity, as the number of bound variables in expressions like λx1xn.ϕ\lambda x_1 \dots x_n . \phi determines the effective arity, allowing flexible higher-type quantification beyond first-order fixed relations.

In Computer Science

In computer science, arity refers to the number of arguments a function or operation accepts, playing a fundamental role in type systems, formal semantics, and language design. This concept influences how functions are typed, composed, and implemented, ensuring type safety and computational expressiveness. For instance, in type theory, unary functions are represented by types of the form ABA \to B, where the function takes one argument of type AA and returns a value of type BB; binary functions use (A×B)C(A \times B) \to C, accepting two arguments from types AA and BB to produce a result in CC. These type signatures extend to higher arities, such as ternary functions (A×B×C)D(A \times B \times C) \to D, and arity impacts polymorphism by allowing generic functions to operate uniformly across different argument counts, as seen in systems like where polymorphic types quantify over arity variations. In the lambda calculus, a foundational model for computation, terms are classified by their arity, with abstractions like λx.M\lambda x. M defining unary functions that bind one variable, while applications MNM N consume arguments according to the term's structure. Fixed-arity terms maintain consistent argument counts during evaluation, and beta-reduction—the core substitution rule—preserves arity by substituting arguments without altering the overall function signature. Variable arity can emerge through currying, where a multi-argument function is transformed into a chain of unary functions, enabling partial application and higher-order abstractions. This preservation ensures that lambda terms remain well-typed and computationally equivalent under reduction. Programming languages operationalize arity through function signatures and overloading mechanisms. In Haskell, functions are curried by default, so a binary operation like addition is typed as Num aaaa\text{Num } a \Rightarrow a \to a \to a, appearing as a unary function returning another unary function, which facilitates composition and point-free style. Arity overloading allows multiple functions with the same name but different argument counts, as in Java's method resolution, where the compiler selects based on the number of provided arguments. For variable arity, Python employs the *args syntax in function definitions, packing excess positional arguments into a tuple, enabling flexible invocation like def sum_all(*args): return sum(args), which handles any number of numeric inputs at runtime. Similarly, C++ uses template metaprogramming to parameterize on arity, such as in variadic templates (introduced in C++11) like template<typename... Args> void print(Args... args), allowing compile-time expansion for type-safe handling of arbitrary argument lists. From a perspective, arity constraints affect the expressive power of computational models; notably, binary operations suffice for universal computation, as demonstrated by the fact that the —a minimal untyped variant—achieves using combinators of arity up to three (S of arity 3, K of 2, I of 1), and there exist combinatory systems using only binary combinators that are also Turing-complete. Higher arities can optimize certain algorithms, such as in where multi-argument reductions reduce communication overhead, but binary primitives are foundational for proving completeness in models like register machines or cellular automata. Mechanisms for varying arity, such as or variadics, build on these foundations to support practical without sacrificing theoretical rigor.

References

  1. https://en.wiktionary.org/wiki/Appendix:English_arities_and_adicities
Add your contribution
Related Hubs
User Avatar
No comments yet.