Last time we talked about sets, and introduced notation and formalisms for defining and manipulating sets. Now we talk about ways mapping from one set to other. This is done through talk of "functions".
Writing the statement:
Just to ground this discussion in several examples, we can define A as the set of students in this class, and define N as the natural numbers and define, for all x in A:
So, as the trend is in this class, we aren't so interested in specific functions, rather, we care about properties of functions. Once we are sure function "f" is a function, we can define several terms: Given f:A --> B,
Why do we have seperate terms for the co-Domain and the range? In part, to support reasoning about "Composition". Composition is a way of making a function out of two functions:
Given f: A --> B, and g: B --> C, the (g o f)(x) = g(f(x)). This composition is only valid if the domain of B is a superset or equal to the range of f. Using these terms, we can define several properties that a function may or may not have (and, you guessed it, we'll try to prove these properties!). The most important properties are:
If a function f is "bijective", then its inverse is a function. Why?
What about the inverse isn't a function if f isn't 1-1? What isn't a
function if f isn't onto?
Before we prove anything, lets do a bit of practice:
Let f(x) = 2x + 1 and g(x) = (x-3)2. For each function
defined below, answer:
So if you now accept that these properties are important, how can we
prove them for a particular function.
Examples
So why do we care about all this crap? Some of these properties are
important for reasoning about computer programs.
Prove: If f(x) = f(y), then x = y.
Assume f(x) = f(y)
2x + 1 = 2y + 1 defn of f.
2x = 2y math.
x = y math.
Therefore if f(x) = f(y), then x=y, so f is 1-1.
Prove: exists x so that f(x) = y.
Assume y is an arbitrary real number (the game is now, "show me the x!").
If we set x = (y-1)/2 , then
f(x) = 2 ((y-1)/2) + 1
f(x) = y-1 + 1
f(x) = y
so there is an x such that f(x) = (y-1)/2. This x is real because
Reals are "closed under addition and division"
Note that the above is sufficient for the proof. How could you figure
out what to make x? To do this you might solve for:
y = 2x + 1
y-1 = 2x
(y-1)/2 = x
but this isn't a necessary part of the proof.