Recent from talks
Nothing was collected or created yet.
Arity
View on WikipediaIn 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]- Logic of relatives
- Binary relation
- Ternary relation
- Theory of relations
- Signature (logic)
- Parameter
- p-adic number
- Cardinality
- Valency (linguistics)
- n-ary code
- n-ary group
- Function prototype – Declaration of a function's name and type signature but not body
- Type signature – Defines the inputs and outputs for a function, subroutine or method
- Univariate and multivariate
- Finitary
References
[edit]- ^ Hazewinkel, Michiel (2001). Encyclopaedia of Mathematics, Supplement III. Springer. p. 3. ISBN 978-1-4020-0198-7.
- ^ Schechter, Eric (1997). Handbook of Analysis and Its Foundations. Academic Press. p. 356. ISBN 978-0-12-622760-4.
- ^ Detlefsen, Michael; McCarty, David Charles; Bacon, John B. (1999). Logic from A to Z. Routledge. p. 7. ISBN 978-0-415-21375-2.
- ^ Cocchiarella, Nino B.; Freund, Max A. (2008). Modal Logic: An Introduction to its Syntax and Semantics. Oxford University Press. p. 121. ISBN 978-0-19-536658-7.
- ^ Crystal, David (2008). Dictionary of Linguistics and Phonetics (6th ed.). John Wiley & Sons. p. 507. ISBN 978-1-405-15296-9.
- ^ Quine, W. V. O. (1940), Mathematical logic, Cambridge, Massachusetts: Harvard University Press, p. 13
- ^ Robinson, Abraham (1966), Non-standard Analysis, Amsterdam: North-Holland, p. 19
- ^ Oliver, Alex (2004). "Multigrade Predicates". Mind. 113 (452): 609–681. doi:10.1093/mind/113.452.609.
External links
[edit]A monograph available free online:
- Burris, Stanley N., and H.P. Sankappanavar, H. P., 1981. A Course in Universal Algebra. Springer-Verlag. ISBN 3-540-90578-2. Especially pp. 22–24.
Arity
View on GrokipediaFundamentals
Definition
Arity is the number of arguments or operands that a function, operation, or relation accepts in mathematics, logic, and computer science.[8] 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.[9] Unlike cardinality, 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.[8] Formally, a function has arity if it maps from the Cartesian product of domains to a codomain, denoted , where each represents an input domain.[8] In abstract terms, constant functions exhibit arity 0, as they require no arguments and yield a fixed value regardless of input.[9] The identity function, which returns its single argument unchanged, has arity 1.[10] Addition, as an operation combining two elements to produce their sum, demonstrates arity 2.[11]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 suffix "-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.[12][13] The concept of operations with a fixed number of arguments predates the term itself, appearing in early modern philosophy and mathematics. During the 19th century, ad-hoc descriptions of operation "degrees" or "valences" emerged in algebra and logic, influenced by developments in group theory and predicate calculus. Charles Sanders Peirce 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.[14] The standardization of "arity" occurred in the mid-20th century amid the formalization of mathematical logic and the rise of computer science. Alfred Tarski's work on model theory 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 lambda calculus, introduced in the 1930s, formalized functions with explicit argument counts, influencing the term's use in computability theory and type systems.[15] A key milestone was the inclusion of arity-like concepts for predicates in influential texts such as David Hilbert 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.[16] 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.[17] 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.[18] 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.[17] Binary functions operate on two arguments, such as the addition operation that combines two numbers to yield their sum, or the equality relation that compares two elements for sameness.[17] Ternary functions require three arguments and, though less prevalent than unary or binary counterparts, arise in areas like vector algebra, exemplified by the scalar triple product that computes the volume scalar from three vectors in three-dimensional space. For higher arities, the terms quaternary (4-ary) and quinary (5-ary) are used, with further terms like senary for six.[19][20] The general term for functions with a fixed arity of , where , is n-ary; when , such functions are sometimes collectively described as polyadic to emphasize their multi-argument nature beyond binary. Formally, the arity of a function is denoted as n-ary, often symbolized as , where represents the Cartesian product of copies of the set , 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.[21] 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.[21] 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.[22] 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.[23] 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.[24] These arise in category theory and set theory, 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 addition function add(x, y) becomes add(x)(y), reducing effective arity stepwise.[25] This technique originates from combinatory logic and is foundational in functional programming for enabling partial application and higher-order abstractions.[25] 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 binary relation R(x, y) has arity 2, capturing pairwise connections without producing a unique value, unlike a binary function f(x, y) that yields a single result.[1] Predicates of arity n thus specify n-place relations over a domain, essential for expressing properties in first-order logic.[1] 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.[22] 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.[26]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 algebraic structure.[27] In universal algebra, such operations are defined on a set with domain , which is a singleton set representing the empty product (often denoted as the unit set ), mapping to a single element in .[28] 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.[27] In mathematics, nullary operations appear as constant functions, such as where yields a predetermined element , equivalent to embedding constants into the algebra's signature.[28] For instance, in group theory, the identity element functions as a nullary operation, providing a fixed value that interacts with binary operations like multiplication to preserve structure.[27] Similarly, in Boolean algebras, the constants 0 and 1 serve as nullary operations, acting as absorbing and identity elements for conjunction and disjunction, respectively: and .[28] 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.[29] These predicates denote zero-place relations, modeling constant truth values such as (always true) or (always false), and integrate into first-order structures by assigning fixed interpretations in models.[30] For example, a nullary predicate in a logical system simply asserts or independently of any arguments, forming the basis for propositional atoms within predicate frameworks.[31] In computer science, nullary operations correspond to global constants or zero-parameter functions that return predefined values, often used to encapsulate immutable data without invocation arguments.[32] In programming languages like Haskell or Stan, such functions are treated as nullary, with examples including built-in constants like or , which compute and return fixed mathematical values on each call, ensuring consistency across computations.[33] These are distinct from variables, as their values remain unaltered during execution, supporting modular code design by providing reliable, side-effect-free references.[34] Nullary operations exhibit inherent idempotence, as applying the operation repeatedly yields the same constant output: if , then .[28] 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.[28] In term algebras, nullary symbols directly contribute to the universe of terms, allowing the building of complex expressions from these atomic constants.[28]Unary Operations
Unary operations, also referred to as unary functions, are mappings that take exactly one argument from a domain set to a codomain set , formally defined as functions .[35] In many algebraic contexts, particularly within universal algebra, these operations are endofunctions where , meaning they transform elements within the same set, such as the identity function that leaves every element unchanged or inversion operations like negation in suitable structures.[36] 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 mathematics, unary operations underpin foundational constructions, exemplified by the successor function in Peano arithmetic, which defines the natural numbers inductively as for each natural number , starting from 0 to generate the sequence .[37] Another ubiquitous example is the absolute value function on the real numbers, given by which maps any real number 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 , which reverses the truth value of proposition —true becomes false, and vice versa—forming the basis for expressing contradiction and enabling the construction of complex logical expressions.[38] In computer science, unary operations are prevalent in programming languages for data manipulation, including the pre-increment operator++x in C++, which evaluates to the value of 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 .[39] 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 is associative, and the identity function serves as the neutral element.[40] This structure allows unary operations to chain indefinitely, modeling sequential transformations in algorithms and automata.
Binary Operations
A binary operation is a function that takes two elements, one from each of sets and , and produces a single element in set .[41] In algebraic contexts, binary operations are often defined on a single set , mapping , ensuring the result remains within the same set, a property known as closure.[42] Key properties include commutativity, where for all , , and associativity, where for compatible elements; these properties underpin structures like groups, where the operation is associative and closed.[43] 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 , where yields true if and false otherwise.[44] In mathematics, addition exemplifies a binary operation on the real numbers , defined by , which is both commutative and associative, forming the basis for the additive group of reals.[43] Similarly, multiplication on satisfies , associative and commutative except at zero, contributing to ring structures.[45] In logic, binary connectives operate on propositions, such as conjunction , where is true only if both and are true, and implication , where is false only if is true and is false; these form the propositional calculus.[46] In computer science, subtraction on integers provides a binary operation , with computed via two's complement addition in binary representation, though it is neither commutative nor associative.[47] String concatenation, denoted on strings, appends two strings to form a new string, forming a monoid under this associative operation with the empty string as identity.[48] Closed binary operations on a set give rise to a magma, the most basic algebraic structure requiring only closure.[49] If the operation is additionally associative, the structure is a semigroup, as seen in natural numbers under addition.[50]Higher-Arity Operations
Higher-arity operations, also known as n-ary operations for , generalize binary operations by accepting three or more arguments from specified sets. Formally, an n-ary operation is a function , where each is a domain (often the same set A) and B is the codomain, mapping tuples of n elements to a single output.[51] 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.[52] In mathematics, ternary operations (n=3) include the scalar triple product in vector algebra, defined as , which computes the signed volume of the parallelepiped formed by three vectors and serves as a trilinear mapping.[19] 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.[53] 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.[16] 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, ...]).[52] 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.[54] Similarly, JavaScript's Function.prototype.apply() method invokes a function with arguments provided as an array, facilitating dynamic argument passing for varying counts.[55] In SQL, PostgreSQL's concat function is variadic, accepting zero or more string arguments to concatenate them without a fixed limit.[56]
In mathematics, variable arity manifests in operations like n-ary summation, where the summation symbol aggregates a variable number of terms, such as for any positive integer , interpreted as the standard addition over a finite sequence.[57] Another example is the generalized power mean, defined as
for any and order , allowing computation over datasets of varying size while generalizing common means like arithmetic () or geometric ().[58]
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 where can differ across contexts.[16]
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.[21]
Applications
In Mathematics
In universal algebra, the concept of arity 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.[59][60] 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.[61][62] 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 , 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 , 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.[63]In Logic
In predicate logic, the arity of a predicate denotes the number of arguments it accepts, such as a unary predicate that applies to a single term or a binary predicate that relates two terms, thereby shaping the structure of well-formed formulas in the language.[3] 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.[64] Propositional logic employs connectives of fixed low arity, including unary negation () and binary operators like conjunction () and disjunction (), 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.[65][3] These n-ary predicates enable the expression of properties and relations involving multiple objects, facilitating quantification over variables to capture inferences about domains.[66] 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.[67] 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.[68] Representative examples include the equality predicate , which is binary and asserts that two terms denote the same object, and the membership relation in set theory, also binary, indicating that one set is an element of another.[69][70] 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 determines the effective arity, allowing flexible higher-type quantification beyond first-order fixed relations.[16][71]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 , where the function takes one argument of type and returns a value of type ; binary functions use , accepting two arguments from types and to produce a result in . These type signatures extend to higher arities, such as ternary functions , and arity impacts polymorphism by allowing generic functions to operate uniformly across different argument counts, as seen in systems like System F 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 defining unary functions that bind one variable, while applications 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 , 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 complexity perspective, arity constraints affect the expressive power of computational models; notably, binary operations suffice for universal computation, as demonstrated by the fact that the SKI combinator calculus—a minimal untyped lambda calculus variant—achieves Turing completeness 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 parallel computing 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 currying or variadics, build on these foundations to support practical software engineering without sacrificing theoretical rigor.References
- https://en.wiktionary.org/wiki/Appendix:English_arities_and_adicities
