W h y is a F u n c t i o n Defined as a Set of O r d e r e d Pairs? Ann Q. Gates and Vladik Kreinovich Department of Computer Science The University of Texas at El Paso El Paso, Texas 79968 {agates, vladik}@cs.utep.edu Abstract In this short note, we describe the reasoning that makes the standard mathematical definition of a function (as a set of ordered pairs) more natural for students in an introduction to computer science course. Standard Definition of a Function he standard definition o f a function is not 100% intuitive. The introductory course in c o m p u t e r science typically reviews the basic mathematical definitions and relates t h e m to concepts in c o m p u t e r science (see, e.g., [1]). One of these definitions, a f u n c t i o n f f r o m the set X to the set Y, is defined as a set o f ordered pairs (x,y) such that for every x e X there exists one and only one y ¢ Y for which (x,y) ¢ f. C o m p u t e r science students usually k n o w this definition f r o m prerequisite m a t h e m a t i c s classes. M a t h e m a t i c s and c o m p u t e r science textbooks usually explain this definition using an e x a m p l e of a function f r o m real n u m b e r s (or integers) to real numbers, where the pairs (x,(x)) f o r m a graph. However, students often do not feel c o m f o r t a b l e with this definition, especially when it is applied to input data that is m o r e c o m p l i c a t e d than real n u m b e r s or integers. For instance, consider boolean functions not and, similarly, and, that can be defined as { (true,false), (false,true) } and {((true,true),true), ( ( t r u e , fal s e ) , f a l s e ) , ((false,true),false), ((false,false),false)}, respectively. In this note, we describe an additional explanation that m a k e s this definition m o r e intuitive for our students. We h o p e that this explanation will be useful to other teachers of the c o m p u t e r science introductory course. The p r o g r a m works as a black box illustrated as follows. We input x , ¢ Something occurs, but we do not know what, and ¢ f(x) appears. ¢ T To describe each computation, we can record what we see: ¢ Each input value, x, and ¢ The corresponding output value, fix). The diary (or record) of the computation process then contains two entries: x andf(x), with x being the first and f(x) the second. Thus, the diary representing each c o m p u tation constitutes an ordered pair, (x, f(x)), o f entries. Supp o s e a c o m p u t a t i o n takes a string f r o m the set {apple, atoyota, eve, axle, pop} and returns true if the string is a palindrome and false, otherwise. Then the diary will record the following: (apple,false), (atoyota,true), (eve,true), (axle,false), (pop,true). Because the function can be applied to different values x ¢ X to describe the function, we m u s t describe all possible computations; that is, all possible pairs (x,f(x)). W h e n we design a function, we do not k n o w which inputs x will be used first and which inputs will be used later. Because there is no specific order between the different pairs (x,f(x)), these pairs f o r m a set. Indeed, f r o m the c o m puter science viewpoint, it is natural to represent a function f a s a set o f ordered pairs (x,f(x)). ¢D < u. (1) ¢D e~ -o" An Intuitive Explanation In c o m p u t e r science we are m a i n l y interested in the functions that can be actually computed; that is, functions for which there exists an algorithm that transforms an arbitrary input x ¢ X into an output f(x). In other words, a function can be given as a program, a p r o g r a m function, or a p r o g r a m procedure. In s o m e cases, we k n o w the algorithm that c o m p u t e s fix) f r o m x. However, in m a n y cases we do not k n o w the algorithm (e.g., consider buying software f r o m a company). A c k n o w l e d g m e n t s : This w o r k was supported in part by the N S F under grant No. E E C - 9 3 2 2 3 7 0 and by N A S A under cooperative a g r e e m e n t N C C W - 0 0 9 . Reference [1] Bernat, A., W.J. Bradley, R.D. Cupper, and G.W. Scragg, Fundamentals of Computing I, McGraw Hill, New York, 1994. December 1997 Vol. 29 No. 4 dnro~cls SIGCSE Bulletin
/lp/association-for-computing-machinery/why-is-a-function-defined-as-set-of-ordered-pairs-r4h7y3M6KK