1.3.7: Partial Functions
It is sometimes useful to relax the definition of function so that it is not required that the output of the function is defined for all possible inputs. Such mappings are called partial functions .
A partial function \(f \colon A \pto B\) is a mapping which assigns to every element of \(A\) at most one element of \(B\) . If \(f\) assigns an element of \(B\) to \(x \in A\) , we say \(f(x)\) is defined , and otherwise undefined . If \(f(x)\) is defined, we write \(f(x) \fdefined\) , otherwise \(f(x) \fundefined\) . The domain of a partial function \(f\) is the subset of \(A\) where it is defined, i.e., \(\dom{f} = \Setabs{x \in A}{f(x) \fdefined}\) .
Every function \(f\colon A \to B\) is also a partial function. Partial functions that are defined everywhere on \(A\) —i.e., what we so far have simply called a function—are also called total functions.
The partial function \(f \colon \Real \pto \Real\) given by \(f(x) = 1/x\) is undefined for \(x = 0\) , and defined everywhere else.
Given \(f\colon A \pto B\) , define the partial function \(g\colon B \pto A\) by: for any \(y \in B\) , if there is a unique \(x \in A\) such that \(f(x) = y\) , then \(g(y) = x\) ; otherwise \(g(y) \fundefined\) . Show that if \(f\) is injective, then \(g(f(x)) = x\) for all \(x \in \dom{f}\) , and \(f(g(y)) = y\) for all \(y \in \ran{f}\) .
Let \(f\colon A \pto B\) be a partial function. The graph of \(f\) is the relation \(R_f \subseteq A \times B\) defined by \[R_f = \Setabs{\tuple{x,y}}{f(x) = y}.\nonumber\]
Suppose \(R \subseteq A \times B\) has the property that whenever \(Rxy\) and \(Rxy'\) then \(y = y'\) . Then \(R\) is the graph of the partial function \(f\colon X \pto Y\) defined by: if there is a \(y\) such that \(Rxy\) , then \(f(x) = y\) , otherwise \(f(x) \fundefined\) . If \(R\) is also serial , i.e., for each \(x \in X\) there is a \(y \in Y\) such that \(Rxy\) , then \(f\) is total.
Proof. Suppose there is a \(y\) such that \(Rxy\) . If there were another \(y' \neq y\) such that \(Rxy'\) , the condition on \(R\) would be violated. Hence, if there is a \(y\) such that \(Rxy\) , that \(y\) is unique, and so \(f\) is well-defined. Obviously, \(R_f = R\) and \(f\) is total if \(R\) is serial. ◻