Discrete Mathematics for Computer Science

(Romina) #1

230 CHAPTER 4 Functions


The two examples we have given of partial functions actually reflect rather different
ways in which partial functions arise. In the postage example, the function was partial
because no rule was given for calculating the postage for items weighing more than 16 kg.
At some later time, someone may come back and extend the rule, perhaps by specifying
that items weighing (16-20] kg cost $10.89. In the computer program example, however, a
rule was given for all possible input data, but that rule failed to output anything for certain
values. The notion of a partial function gives a formal way to consider all programs-
even ones that crash or go into infinite loops. Partial functions are particularly important in
the theoretical study of computability-that is, in the study of which functions and partial
functions are computable by programs, where there is assumed to be no restriction on
computer memory or on computation time. There is no satisfactory way in this subject to
restrict attention only to functions.

Definition 5. A partial function F with domain of definition X and codomain Y is a
subset of X x Y such that for each x E X, there is, at most, one y with (x, y) E F. Such
an F is also called a partial function F from X to Y. When it is understood that F is partial,
the notation F : X --* Y is also used (but when the notation F : X -> Y is used without
any other comment, F is a function). The domain of a partial function F : X -> Y is the set

{x E X: for some y E Y, (x, y) E F}

If x E X is not in the domain of definition for F, then F(x) is undefined. Other terms,
such as range and preimage, are defined exactly as for functions.

When F is a partial function, the implication is not that there is necessarily any x in
its domain of definition where F(x) is undefined, only that there might be. Hence, every
function is a partial function. When discussing both functions and partial functions that are
not functions, functions are often referred to as total functions to emphasize the difference.

Example 14. In Example 1(a) SeatOf was presented as a (total) function. It might be
slightly more realistic to present it as a partial function, however, since some people in the
room might not be sitting in seats. For example, they might be standing or sitting on the
floor. Asking what is the seat of a standing person should get no answer.

Example 15. The following are examples of partial functions:

(a) Subtraction (-) on N is a partial function. Its domain of definition is N^2 , and its
codomain is N. For i < j, i - j is not defined on N, so the domain of subtrac-
tion is

{(i, j) E N^2 : i > j}

The range of (-) is N. To show that an arbitrary n E N is in range(-), note that

n = n -0.
(b) Division on JR is a partial function. Its domain of definition is R2, its codomain is IR,
but its domain is

{(x, y) E JR^2 : y A 0}

Its range is JR. Why?
Free download pdf