Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Arity

From Wikipedia, the free encyclopedia
Number of arguments required by a function
"Adicity" redirects here. Not to be confused withAcidity.

Inlogic,mathematics, andcomputer science,arity (/ˈærɪti/ ) is the number ofarguments oroperands taken by afunction,operation orrelation. In mathematics, arity may also be called rank,[1][2] but this word can have many other meanings. In logic andphilosophy, arity may also be calledadicity anddegree.[3][4] Inlinguistics, it is usually namedvalency.[5]

Examples

[edit]

In general, functions or operators with a given arity follow the naming conventions ofn-basednumeral systems, such asbinary andhexadecimal. ALatin prefix is combined with the -ary suffix. For example:

Nullary

[edit]

Aconstant can be treated as the output of an operation of arity 0, called anullary operation.

Also, outside offunctional programming, a function without arguments can be meaningful and not necessarily constant (due toside effects). Such functions may have somehidden input, such asglobal variables or the whole state of the system (time, free memory, etc.).

Unary

[edit]

Examples ofunary operators in mathematics and in programming include theunary minus and plus, the increment and decrement operators inC-style languages (not in logical languages), and thesuccessor,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), andnorm functions in mathematics. In programming thetwo's complement,address reference, and thelogical NOT operators are examples of unary operators.

All functions inlambda calculus and in somefunctional programming languages (especially those descended fromML) are technically unary, but seen-ary below.

According toQuine, the Latin distributives beingsinguli,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 adjectivemonadic is sometimes used to describe aone-place relation such as 'is square-shaped' as opposed to atwo-place relation such as 'is the sister of'.

Binary

[edit]

Most operators encountered in programming and mathematics are of thebinary form. For both programming and mathematics, these include themultiplication operator, the radix operator, the often omittedexponentiation operator, thelogarithm operator, theaddition operator, and thedivision operator. Logical predicates such asOR,XOR,AND,IMP are typically used as binary operators with two distinct operands. InCISC architectures, it is common to have two source operands (and store result in one of them).

Ternary

[edit]

The computer programming languageC and its various descendants (includingC++,C#,Java,Julia,Perl, and others) provide theternary 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 asAgda, have such an evaluation strategy for all functions and consequently implementif...then...else as an ordinary function; several others, such asHaskell, can do this but for syntactic, performance or historical reasons choose to define keywords instead.

ThePython language has a ternary conditional expression,xifCelsey. InElixir the equivalent would beif(C,do:x,else:y).

TheForth 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 Unixdc calculator has several ternary operators, such as|, which will pop three values from the stack and efficiently computexymodz{\textstyle x^{y}{\bmod {z}}} witharbitrary precision.

Many (RISC)assembly language instructions are ternary (as opposed to only two operands specified in CISC); or higher, such asMOV%AX,(%BX,%CX), which will load (MOV) into registerAX the contents of a calculated memory location that is the sum (parenthesis) of the registersBX andCX.

n-ary

[edit]

Thearithmetic mean ofn real numbers is ann-ary function:x¯=1n(i=1nxi)=x1+x2++xnn{\displaystyle {\bar {x}}={\frac {1}{n}}\left(\sum _{i=1}^{n}{x_{i}}\right)={\frac {x_{1}+x_{2}+\dots +x_{n}}{n}}}

Similarly, thegeometric mean ofnpositive real numbers is ann-ary function:(i=1nai)1n= a1a2ann.{\displaystyle \left(\prod _{i=1}^{n}a_{i}\right)^{\frac {1}{n}}=\ {\sqrt[{n}]{a_{1}a_{2}\cdots a_{n}}}.} Note that alogarithm of the geometric mean is the arithmetic mean of the logarithms of itsn arguments

From a mathematical point of view, a function ofn arguments can always be considered as a function of a single argument that is an element of someproduct space. However, it may be convenient for notation to considern-ary functions, as for examplemultilinear maps (which are not linear maps on the product space, ifn ≠ 1).

The same is true for programming languages, where functions taking several arguments could always be defined as functions taking a single argument of somecomposite type such as atuple, or in languages withhigher-order functions, bycurrying.

Varying arity

[edit]

In computer science, a function that accepts a variable number of arguments is calledvariadic. In logic and philosophy, predicates or relations accepting a variable number of arguments are calledmultigrade, anadic, or variably polyadic.[8]

Terminology

[edit]

Latinate names are commonly used for specific arities, primarily based on Latindistributive numbers meaning "in group ofn", though some are based on Latincardinal numbers orordinal numbers. For example, 1-ary is based on cardinalunus, rather than from distributivesingulī that would result insingulary.

n-aryArity (Latin based)Adicity (Greek based)Example in mathematicsExample in computer science
0-arynullary (fromnūllus)niladicaconstanta function without arguments,True,False
1-aryunarymonadicadditive inverselogicalNOT operator
2-arybinarydyadicadditionlogicalOR,XOR,AND operators
3-aryternarytriadictriple product of vectorsternary conditional operator
4-aryquaternarytetradic
5-aryquinarypentadic
6-arysenaryhexadic
7-aryseptenaryhebdomadic
8-aryoctonaryogdoadic
9-arynovenary (alt. nonary)enneadic
10-arydenary (alt. decenary)decadic
more than 2-arymultary and multiarypolyadic
varyingvariadicsum; e.g., Σvariadic function,reduce

n-ary means havingn 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 achess variant with an 11×11 board, or theMillenary Petition of 1603).

The arity of arelation (orpredicate) is the dimension of thedomain in the correspondingCartesian product. (A function of arityn thus has arityn+1 considered as a relation.)

Incomputer programming, there is often asyntactical distinction betweenoperators andfunctions; syntactical operators usually have arity 1, 2, or 3 (theternary operator?: is also common). Functions vary widely in the number of arguments, though large numbers can become unwieldy. Some programming languages also offer support forvariadic functions, i.e., functions syntactically accepting a variable number of arguments.

See also

[edit]

References

[edit]
  1. ^Hazewinkel, Michiel (2001).Encyclopaedia of Mathematics, Supplement III. Springer. p. 3.ISBN 978-1-4020-0198-7.
  2. ^Schechter, Eric (1997).Handbook of Analysis and Its Foundations. Academic Press. p. 356.ISBN 978-0-12-622760-4.
  3. ^Detlefsen, Michael; McCarty, David Charles; Bacon, John B. (1999).Logic from A to Z. Routledge. p. 7.ISBN 978-0-415-21375-2.
  4. ^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.
  5. ^Crystal, David (2008).Dictionary of Linguistics and Phonetics (6th ed.). John Wiley & Sons. p. 507.ISBN 978-1-405-15296-9.
  6. ^Quine, W. V. O. (1940),Mathematical logic, Cambridge, Massachusetts: Harvard University Press, p. 13
  7. ^Robinson, Abraham (1966),Non-standard Analysis, Amsterdam: North-Holland, p. 19
  8. ^Oliver, Alex (2004). "Multigrade Predicates".Mind.113 (452):609–681.doi:10.1093/mind/113.452.609.

External links

[edit]
Look upAppendix:English arities and adicities in Wiktionary, the free dictionary.

A monograph available free online:

General
Theorems (list)
 and paradoxes
Logics
Traditional
Propositional
Predicate
Set theory
Types ofsets
Maps and cardinality
Set theories
Formal systems (list),
language and syntax
Example axiomatic
systems
 (list)
Proof theory
Model theory
Computability theory
Related
Retrieved from "https://en.wikipedia.org/w/index.php?title=Arity&oldid=1281014024"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp