In mathematics, a partial function from a set to a set is a function from a subset of (possibly the whole itself) to . The subset , that is, the domain of viewed as a function, is called the domain of definition or natural domain of . If equals , that is, if is defined on every element in , then is said to be a total function.
In other words, a partial function is a binary relation over two sets that associates to every element of the first set at most one element of the second set; it is thus a univalent relation. This generalizes the concept of a (total) function by not requiring every element of the first set to be associated to an element of the second set.
A partial function is often used when its exact domain of definition is not known, or is difficult to specify. However, even when the exact domain of definition is known, partial functions are often used for simplicity or brevity. This is the case in calculus, where, for example, the quotient of two functions is a partial function whose domain of definition cannot contain the zeros of the denominator; in this context, a partial function is generally simply called a .
In computability theory, a general recursive function is a partial function from the integers to the integers; no algorithm can exist for deciding whether an arbitrary such function is in fact total.
When arrow notation is used for functions, a partial function <math>f</math> from <math>X</math> to <math>Y</math> is sometimes written as <math>f : X \rightharpoonup Y,</math> <math>f : X \nrightarrow Y,</math> or <math>f : X \hookrightarrow Y.</math> However, there is no general convention, and the latter notation is more commonly used for inclusion maps or embeddings.
Specifically, for a partial function <math>f : X \rightharpoonup Y,</math> and any <math>x \in X,</math> one has either:
- <math>f(x) = y \in Y</math> (it is a single element in ), or
- <math>f(x)</math> is undefined.
For example, if <math>f</math> is the square root function restricted to the integers
defined by:
then <math>f(n)</math> is only defined if <math>n</math> is a perfect square (that is, <math>0, 1, 4, 9, 16, \ldots</math>). So <math>f(25) = 5</math> but <math>f(26)</math> is undefined.
Basic concepts
{| align="right"
|-
|thumb|200px|An example of a partial function that is [[injective.]]
|-
|thumb|200px|An example of a [[#Function|function that is not injective.]]
|}
A partial function arises from the consideration of maps between two sets and that may not be defined on the entire set . A common example is the square root operation on the real numbers <math>\mathbb{R}</math>: because negative real numbers do not have real square roots, the operation can be viewed as a partial function from <math>\mathbb{R}</math> to <math>\mathbb{R}.</math> The domain of definition of a partial function is the subset of on which the partial function is defined; in this case, the partial function may also be viewed as a function from to . In the example of the square root operation, the set consists of the nonnegative real numbers <math>[0, +\infty).</math>
The notion of partial function is particularly convenient when the exact domain of definition is unknown or even unknowable. For a computer-science example of the latter, see Halting problem.
In case the domain of definition is equal to the whole set , the partial function is said to be total. Thus, total partial functions from to coincide with functions from to .
Many properties of functions can be extended in an appropriate sense of partial functions. A partial function is said to be injective, surjective, or bijective when the function given by the restriction of the partial function to its domain of definition is injective, surjective, or bijective, respectively.
Because a function is trivially surjective when restricted to its image, the term partial bijection denotes a partial function which is injective.
An injective partial function may be inverted to an injective partial function, and a partial function which is both injective and surjective has an injective function as inverse. Furthermore, a function which is injective may be inverted to a bijective partial function.
The notion of transformation can be generalized to partial functions as well. A partial transformation is a function <math>f : A \rightharpoonup B,</math> where both <math>A</math> and <math>B</math> are subsets of some set <math>X.</math> One textbook notes that "This formal completion of sets and partial maps by adding “improper,” “infinite” elements was reinvented many times, in particular, in topology (one-point compactification) and in theoretical computer science."
The category of sets and partial bijections is equivalent to its dual. It is the prototypical inverse category.
In abstract algebra
Partial algebra generalizes the notion of universal algebra to partial operations. An example would be a field, in which the multiplicative inversion is the only proper partial operation (because division by zero is not defined).
The set of all partial functions (partial transformations) on a given base set, <math>X,</math> forms a regular semigroup called the semigroup of all partial transformations (or the partial transformation semigroup on <math>X</math>), typically denoted by <math>\mathcal{PT}_X.</math> The set of all partial bijections on <math>X</math> forms the symmetric inverse semigroup.
