Nullary Function
   HOME

TheInfoList



OR:

In
logic Logic is the study of correct reasoning. It includes both formal and informal logic. Formal logic is the study of deductively valid inferences or logical truths. It examines how conclusions follow from premises based on the structure o ...
,
mathematics Mathematics is a field of study that discovers and organizes methods, Mathematical theory, theories and theorems that are developed and Mathematical proof, proved for the needs of empirical sciences and mathematics itself. There are many ar ...
, and
computer science Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied science, ...
, arity () is the number of
arguments An argument is a series of sentences, statements, or propositions some of which are called premises and one is the conclusion. The purpose of an argument is to give reasons for one's conclusion via justification, explanation, and/or persua ...
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. Unknown operands in equalities of expressions can be found by equation solving. Example The following arithmetic expres ...
s taken by a
function Function or functionality may refer to: Computing * Function key, a type of key on computer keyboards * Function model, a structured representation of processes in a system * Function object or functor or functionoid, a concept of object-orie ...
,
operation Operation or Operations may refer to: Arts, entertainment and media * ''Operation'' (game), a battery-operated board game that challenges dexterity * Operation (music), a term used in musical set theory * ''Operations'' (magazine), Multi-Man ...
or
relation Relation or relations may refer to: General uses * International relations, the study of interconnection of politics, economics, and law on a global level * Interpersonal relationship, association or acquaintance between two or more people * ...
. In mathematics, arity may also be called rank, but this word can have many other meanings. In logic and
philosophy Philosophy ('love of wisdom' in Ancient Greek) is a systematic study of general and fundamental questions concerning topics like existence, reason, knowledge, Value (ethics and social sciences), value, mind, and language. It is a rational an ...
, arity may also be called adicity and degree. In
linguistics Linguistics is the scientific study of language. The areas of linguistic analysis are syntax (rules governing the structure of sentences), semantics (meaning), Morphology (linguistics), morphology (structure of words), phonetics (speech sounds ...
, it is usually named valency.


Examples

In general, functions or operators with a given arity follow the naming conventions of ''n''-based
numeral system A numeral system is a writing system for expressing numbers; that is, a mathematical notation for representing numbers of a given set, using digits or other symbols in a consistent manner. The same sequence of symbols may represent differe ...
s, such as
binary Binary may refer to: Science and technology Mathematics * Binary number, a representation of numbers using only two values (0 and 1) for each digit * Binary function, a function that takes two arguments * Binary operation, a mathematical op ...
and
hexadecimal Hexadecimal (also known as base-16 or simply hex) is a Numeral system#Positional systems in detail, positional numeral system that represents numbers using a radix (base) of sixteen. Unlike the decimal system representing numbers using ten symbo ...
. A
Latin Latin ( or ) is a classical language belonging to the Italic languages, Italic branch of the Indo-European languages. Latin was originally spoken by the Latins (Italic tribe), Latins in Latium (now known as Lazio), the lower Tiber area aroun ...
prefix is combined with the -ary suffix. For example: * A nullary function takes no arguments. ** Example: f()=2 * A
unary function In mathematics, a unary function is a function that takes one argument. A unary operator belongs to a subset of unary functions, in that its codomain coincides with its domain. In contrast, a unary function's domain need not coincide with its r ...
takes one argument. ** Example: f(x)=2x * A
binary function In mathematics, a binary function (also called bivariate function, or function of two variables) is a function that takes two inputs. Precisely stated, a function f is binary if there exists sets X, Y, Z such that :\,f \colon X \times Y \right ...
takes two arguments. ** Example: f(x,y)=2xy * A ternary function takes three arguments. ** Example: f(x,y,z)=2xyz * An ''n''-ary function takes ''n'' arguments. ** Example: f(x_1, x_2, \ldots, x_n)=2\prod_^n x_i


Nullary

A constant can be treated as the output of an operation of arity 0, called a ''nullary operation''. Also, outside of
functional programming In computer science, functional programming is a programming paradigm where programs are constructed by Function application, applying and Function composition (computer science), composing Function (computer science), functions. It is a declarat ...
, a function without arguments can be meaningful and not necessarily constant (due to
side effect In medicine, a side effect is an effect of the use of a medicinal drug or other treatment, usually adverse but sometimes beneficial, that is unintended. Herbal and traditional medicines also have side effects. A drug or procedure usually use ...
s). Such functions may have some ''hidden input'', such as
global variable In computer programming, a global variable is a variable with global scope, meaning that it is visible (hence accessible) throughout the program, unless shadowed. The set of all global variables is known as the ''global environment'' or ''global ...
s or the whole state of the system (time, free memory, etc.).


Unary

Examples of
unary operator In mathematics, a unary operation is an operation with only one operand, i.e. a single input. This is in contrast to ''binary operations'', which use two operands. An example is any function , where is a set; the function is a unary operatio ...
s in mathematics and in programming include the
unary minus In mathematics, the additive inverse of an element , denoted , is the element that when added to , yields the additive identity, 0 (zero). In the most familiar cases, this is the number 0, but it can also refer to a more generalized zero eleme ...
and plus, the increment and decrement operators in C-style languages (not in logical languages), and the
successor Successor may refer to: * An entity that comes after another (see Succession (disambiguation)) Film and TV * ''The Successor'' (1996 film), a film including Laura Girling * The Successor (2023 film), a French drama film * ''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 Reciprocal may refer to: In mathematics * Multiplicative inverse, in mathematics, the number 1/''x'', which multiplied by ''x'' gives the product 1, also known as a ''reciprocal'' * Reciprocal polynomial, a polynomial obtained from another pol ...
,
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 A ceiling is an overhead interior roof that covers the upper limits of a room. It is not generally considered a structural element, but a finished surface concealing the underside of the roof structure or the floor of a story above. Ceilings can ...
,
fractional part The fractional part or decimal part of a non‐negative real number x is the excess beyond that number's integer part. The latter is defined as the largest integer not greater than , called ''floor'' of or \lfloor x\rfloor. Then, the fractional ...
,
sign A sign is an object, quality, event, or entity whose presence or occurrence indicates the probable presence or occurrence of something else. A natural sign bears a causal relation to its object—for instance, thunder is a sign of storm, or me ...
,
absolute value In mathematics, the absolute value or modulus of a real number x, is the non-negative value without regard to its sign. Namely, , x, =x if x is a positive number, and , x, =-x if x is negative (in which case negating x makes -x positive), ...
,
square root In mathematics, a square root of a number is a number such that y^2 = x; in other words, a number whose ''square'' (the result of multiplying the number by itself, or y \cdot y) is . For example, 4 and −4 are square roots of 16 because 4 ...
(the principal square root),
complex conjugate In mathematics, the complex conjugate of a complex number is the number with an equal real part and an imaginary part equal in magnitude but opposite in sign. That is, if a and b are real numbers, then the complex conjugate of a + bi is a - ...
(unary of "one"
complex number In mathematics, a complex number is an element of a number system that extends the real numbers with a specific element denoted , called the imaginary unit and satisfying the equation i^= -1; every complex number can be expressed in the for ...
, that however has two parts at a lower level of abstraction), and
norm Norm, the Norm or NORM may refer to: In academic disciplines * Normativity, phenomenon of designating things as good or bad * Norm (geology), an estimate of the idealised mineral content of a rock * Norm (philosophy), a standard in normative e ...
functions in mathematics. In programming the
two's complement Two's complement is the most common method of representing signed (positive, negative, and zero) integers on computers, and more generally, fixed point binary values. Two's complement uses the binary digit with the ''greatest'' value as the ''s ...
, address reference, and the
logical NOT In logic, negation, also called the logical not or logical complement, is an operation (mathematics), operation that takes a Proposition (mathematics), proposition P to another proposition "not P", written \neg P, \mathord P, P^\prime or \over ...
operators are examples of unary operators. All functions in
lambda calculus In mathematical logic, the lambda calculus (also written as ''λ''-calculus) is a formal system for expressing computability, computation based on function Abstraction (computer science), abstraction and function application, application using var ...
and in some
functional programming language In computer science, functional programming is a programming paradigm where programs are constructed by applying and composing functions. It is a declarative programming paradigm in which function definitions are trees of expressions that map ...
s (especially those descended from ML) are technically unary, but see
n-ary -ary may refer to: * The arity of a function, operation, or relation ** -ary associativity, a specific rule attached to -ary functions *** -ary group, a generalization of group * The radix of a numerical representation system * The number of le ...
below. According to
Quine Quine may refer to: * Quine (computing), a program that produces its source code as output * Quine's paradox, in logic * Quine (surname), people with the surname ** Willard Van Orman Quine (1908–2000), American philosopher and logician See al ...
, the Latin distributives being ''singuli'', ''bini'', ''terni'', and so forth, the term "singulary" is the correct adjective, rather than "unary".
Abraham Robinson Abraham Robinson (born Robinsohn; October 6, 1918 – April 11, 1974) was a mathematician who is most widely known for development of nonstandard analysis, a mathematically rigorous system whereby infinitesimal and infinite numbers were reincorp ...
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 Binary may refer to: Science and technology Mathematics * Binary number, a representation of numbers using only two values (0 and 1) for each digit * Binary function, a function that takes two arguments * Binary operation, a mathematical op ...
form. For both programming and mathematics, these include the
multiplication operator In operator theory, a multiplication operator is a linear operator defined on some vector space of functions and whose value at a function is given by multiplication by a fixed function . That is, T_f\varphi(x) = f(x) \varphi (x) \quad for all ...
, the radix operator, the often omitted
exponentiation In mathematics, exponentiation, denoted , is an operation (mathematics), operation involving two numbers: the ''base'', , and the ''exponent'' or ''power'', . When is a positive integer, exponentiation corresponds to repeated multiplication ...
operator, the
logarithm In mathematics, the logarithm of a number is the exponent by which another fixed value, the base, must be raised to produce that number. For example, the logarithm of to base is , because is to the rd power: . More generally, if , the ...
operator, the
addition Addition (usually signified by the Plus and minus signs#Plus sign, plus symbol, +) is one of the four basic Operation (mathematics), operations of arithmetic, the other three being subtraction, multiplication, and Division (mathematics), divis ...
operator, and the division operator. Logical predicates such as '' OR'', ''
XOR Exclusive or, exclusive disjunction, exclusive alternation, logical non-equivalence, or logical inequality is a logical operator whose negation is the logical biconditional. With two inputs, XOR is true if and only if the inputs differ (one ...
'', ''
AND And or AND may refer to: Logic, grammar and computing * Conjunction, connecting two words, phrases, or clauses * Logical conjunction in mathematical logic, notated as "∧", "⋅", "&", or simple juxtaposition * Bitwise AND, a Boolean oper ...
'', ''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 is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
,
Julia Julia may refer to: People *Julia (given name), including a list of people with the name *Julia (surname), including a list of people with the name *Julia gens, a patrician family of Ancient Rome *Julia (clairvoyant) (fl. 1689), lady's maid of Qu ...
,
Perl Perl is a high-level, general-purpose, interpreted, dynamic programming language. Though Perl is not officially an acronym, there are various backronyms in use, including "Practical Extraction and Reporting Language". Perl was developed ...
, and others) provide the
ternary conditional operator In computer programming, the ternary conditional operator is a ternary operator that is part of the syntax for basic conditional expressions in several programming languages. It is commonly referred to as the conditional operator, conditional ...
?:. 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 In a programming language, an evaluation strategy is a set of rules for evaluating expressions. The term is often used to refer to the more specific notion of a ''parameter-passing strategy'' that defines the kind of value that is passed to the ...
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 as an ordinary function; several others, such as
Haskell Haskell () is a general-purpose, statically typed, purely functional programming language with type inference and lazy evaluation. Designed for teaching, research, and industrial applications, Haskell pioneered several programming language ...
, can do this but for syntactic, performance or historical reasons choose to define keywords instead. The
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (prog ...
language has a ternary conditional expression, . In
Elixir An elixir is a sweet liquid used for medical purposes, to be taken orally and intended to cure one's illness. When used as a dosage form, pharmaceutical preparation, an elixir contains at least one active ingredient designed to be taken orall ...
the equivalent would be . The
Forth Forth or FORTH may refer to: Arts and entertainment * ''forth'' magazine, an Internet magazine * ''Forth'' (album), by The Verve, 2008 * ''Forth'', a 2011 album by Proto-Kaw * Radio Forth, a group of independent local radio stations in Scotl ...
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 In electronics and computer science, a reduced instruction set computer (RISC) is a computer architecture designed to simplify the individual instructions given to the computer to accomplish tasks. Compared to the instructions given to a comp ...
)
assembly language In computing, assembly language (alternatively 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 bet ...
instructions are ternary (as opposed to only two operands specified in CISC); or higher, such as MOV %AX, (%BX, %CX), which will load () into register the contents of a calculated memory location that is the sum (parenthesis) of the registers and .


''n''-ary

The
arithmetic mean In mathematics and statistics, the arithmetic mean ( ), arithmetic average, or just the ''mean'' or ''average'' is the sum of a collection of numbers divided by the count of numbers in the collection. The collection is often a set of results fr ...
of ''n'' real numbers is an ''n''-ary function: \bar=\frac\left (\sum_^n\right) = \frac Similarly, the
geometric mean In mathematics, the geometric mean is a mean or average which indicates a central tendency of a finite collection of positive real numbers by using the product of their values (as opposed to the arithmetic mean which uses their sum). The geometri ...
of ''n''
positive real numbers In mathematics, the set of positive real numbers, \R_ = \left\, is the subset of those real numbers that are greater than zero. The non-negative real numbers, \R_ = \left\, also include zero. Although the symbols \R_ and \R^ are ambiguously used fo ...
is an ''n''-ary function: \left(\prod_^n a_i\right)^\frac = \ \sqrt . Note that a
logarithm In mathematics, the logarithm of a number is the exponent by which another fixed value, the base, must be raised to produce that number. For example, the logarithm of to base is , because is to the rd power: . More generally, if , the ...
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 In topology and related areas of mathematics, a product space is the Cartesian product of a family of topological spaces equipped with a natural topology called the product topology. This topology differs from another, perhaps more natural-seemi ...
. However, it may be convenient for notation to consider ''n''-ary functions, as for example
multilinear map Multilinear may refer to: * Multilinear form, a type of mathematical function from a vector space to the underlying field * Multilinear map, a type of mathematical function between vector spaces * Multilinear algebra, a field of mathematics ...
s (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 In computer science, a composite data type or compound data type is a data type that consists of programming language scalar data types and other composite types that may be heterogeneous and hierarchical in nature. It is sometimes called a struct ...
such as a
tuple In mathematics, a tuple is a finite sequence or ''ordered list'' of numbers or, more generally, mathematical objects, which are called the ''elements'' of the tuple. An -tuple is a tuple of elements, where is a non-negative integer. There is o ...
, or in languages with
higher-order function In mathematics and computer science, a higher-order function (HOF) is a function that does at least one of the following: * takes one or more functions as arguments (i.e. a procedural parameter, which is a parameter of a procedure that is itself ...
s, by
currying In mathematics and computer science, currying is the technique of translating a function that takes multiple arguments into a sequence of families of functions, each taking a single argument. In the prototypical example, one begins with a functi ...
.


Varying arity

In computer science, a function that accepts a variable number of arguments is called ''
variadic In computer science, an operator or function is variadic if it can take a varying number of arguments; that is, if its arity is not fixed. For specific articles, see: * Variadic function * Variadic macro in the C preprocessor * Variadic template ...
''. 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 spoken by the Latins (Italic tribe), Latins in Latium (now known as Lazio), the lower Tiber area aroun ...
ate names are commonly used for specific arities, primarily based on Latin
distributive number In linguistics, a distributive numeral, or distributive number word, is a word that answers "how many times each?" or "how many at a time?", such as ''singly'' or ''doubly''. They are contrasted with multipliers. In English, this part of speec ...
s meaning "in group of ''n''", though some are based on Latin
cardinal number In mathematics, a cardinal number, or cardinal for short, is what is commonly called the number of elements of a set. In the case of a finite set, its cardinal number, or cardinality is therefore a natural number. For dealing with the cas ...
s or
ordinal number In set theory, an ordinal number, or ordinal, is a generalization of ordinal numerals (first, second, th, etc.) aimed to extend enumeration to infinite sets. A finite set can be enumerated by successively labeling each element with the leas ...
s. For example, 1-ary is based on cardinal ''unus'', rather than from distributive ''singulī'' that would result in ''singulary''. ''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 A chess variant is a game related to, derived from, or inspired by chess. Such variants can differ from chess in many different ways. "International" or "Western" chess itself is one of a family of games which have related origins and could be co ...
with an 11×11 board, or the
Millenary Petition The Millenary Petition was a list of requests given to James I by Puritans in 1603 when he was travelling to London in order to claim the English throne. It is claimed, but not proven, that this petition had 1,000 signatures of Puritan minister ...
of 1603). The arity of a
relation Relation or relations may refer to: General uses * International relations, the study of interconnection of politics, economics, and law on a global level * Interpersonal relationship, association or acquaintance between two or more people * ...
(or
predicate Predicate or predication may refer to: * Predicate (grammar), in linguistics * Predication (philosophy) * several closely related uses in mathematics and formal logic: **Predicate (mathematical logic) **Propositional function **Finitary relation, o ...
) is the dimension of the
domain A domain is a geographic area controlled by a single person or organization. Domain may also refer to: Law and human geography * Demesne, in English common law and other Medieval European contexts, lands directly managed by their holder rather ...
in the corresponding
Cartesian product In mathematics, specifically set theory, the Cartesian product of two sets and , denoted , is the set of all ordered pairs where is an element of and is an element of . In terms of set-builder notation, that is A\times B = \. A table c ...
. (A function of arity ''n'' thus has arity ''n''+1 considered as a relation.) In
computer programming Computer programming or coding is the composition of sequences of instructions, called computer program, programs, that computers can follow to perform tasks. It involves designing and implementing algorithms, step-by-step specifications of proc ...
, there is often a syntactical distinction between
operators Operator may refer to: Mathematics * A symbol indicating a mathematical operation * Logical operator or logical connective in mathematical logic * Operator (mathematics), mapping that acts on elements of a space to produce elements of another ...
and functions; syntactical operators usually have arity 1, 2, or 3 (the
ternary operator In mathematics, a ternary operation is an ''n''- ary operation with ''n'' = 3. A ternary operation on a set ''A'' takes any given three elements of ''A'' and combines them to form a single element of ''A''. In computer science, a 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 In mathematics and in computer programming, a variadic function is a function of indefinite arity, i.e., one which accepts a variable number of arguments. Support for variadic functions differs widely among programming languages. The term ''var ...
, i.e., functions syntactically accepting a variable number of arguments.


See also

*
Logic of relatives Charles Sanders Peirce ( ; September 10, 1839 – April 19, 1914) was an American scientist, mathematician, logician, and philosopher who is sometimes known as "the father of pragmatism". According to philosopher Paul Weiss, Peirce was "the m ...
*
Binary relation In mathematics, a binary relation associates some elements of one Set (mathematics), set called the ''domain'' with some elements of another set called the ''codomain''. Precisely, a binary relation over sets X and Y is a set of ordered pairs ...
*
Ternary relation In mathematics, a ternary relation or triadic relation is a finitary relation in which the number of places in the relation is three. Ternary relations may also be referred to as 3-adic, 3-ary, 3-dimensional, or 3-place. Just as a binary relatio ...
* Theory of relations *
Signature (logic) In logic, especially mathematical logic, a signature lists and describes the non-logical symbols of a formal language. In universal algebra, a signature lists the operations that characterize an algebraic structure. In model theory, signatures are ...
*
Parameter A parameter (), generally, is any characteristic that can help in defining or classifying a particular system (meaning an event, project, object, situation, etc.). That is, a parameter is an element of a system that is useful, or critical, when ...
* ''p''-adic number *
Cardinality The thumb is the first digit of the hand, next to the index finger. When a person is standing in the medical anatomical position (where the palm is facing to the front), the thumb is the outermost digit. The Medical Latin English noun for thum ...
*
Valency (linguistics) In linguistics, valency or valence is the number and type of arguments and complements controlled by a predicate, content verbs being typical predicates. Valency is related, though not identical, to subcategorization and transitivity, which c ...
* ''n''-ary code * ''n''-ary group * * * Univariate and multivariate *
Finitary In mathematics and logic, an operation is finitary if it has finite arity, i.e. if it has a finite number of input values. Similarly, an infinitary operation is one with an infinite number of input values. In standard mathematics, an operat ...


References


External links

A monograph available free online: * Burris, Stanley N., and H.P. Sankappanavar, H. P., 1981.
A Course in Universal Algebra.
' Springer-Verlag. . Especially pp. 22–24. {{Mathematical logic Abstract algebra Universal algebra cs:Operace (matematika)#Arita operace