Reading: 1.5(proof methods),1.8(functions)
Reminder on ways to construct new sets out of old:
set-difference
intersect, union
big-union (indexed) ... index set!
may not be integers:
∪{p \in PPG} p.enemies() (where PPG is the set of all powerpuff-girls objects in my program)
the union of a set-of-sets.
power set
cross product;
(as a segue:)
function spaces
f: X → Y
speaking of...
Functions
Def'n: an assignment from X to Y.
(partial functions: throw an error on some inputs;
often this is because our type system doesn't let us
specify the input-set better, but sometimes it's necessary.
Formally, we might write
f(17) = ⊥
and add ⊥ to the codomain; may represent inf. loop)
examples: length; car-color; colorname->rgb
This is actually another method of constructing new sets from old:
A → B is a set. Really, the ":" should be "∈" symbol.
It is also a type, in computer languages
(which you write down in the function's contract).
In programming languages, "contract"/"type"
is sometimes also called "signature"
(well, technically the signature includes the name of the function too).
What is the type of the function deriv?
(ℜ→ℜ) → (ℜ→ℜ)
Other functions in this set?
integrate [from 7 to 19]; identity;
Given a stock over time,
return a function: the historical doubling time:
from when you invested $1, to how long until you have $2.
Actually this function is ℜ→(union ℜ +inf.0)
Def'n: a function f:A→A is idempotent if ∀ a ∈ A, f(f(a))=f(a).
Sum,product of functions:
(f+g), (f*g), (fg).
When do these make sense?
Only when +,* defined on their domains
(well, the cross-prod of their domains)
Composing functions. Commutative? (What's the signature of "compose"?)
Conversely, Extending functions from elements onto sets:
If A = {2,3,5}, then 4*A = {8,12,20}.
Really, "4*" is just a function which happens to be defined
on the elements of A; consider also:
A = {Barland,Cooper,Gillis}; numKids(A) = { 0, 2 }.
In general, what is f(A)?
"We can extend f:A → B to f*: P(A) → P(B),
where f*(a*) = { b | exists a ∈ a* such that f(a)=b }
Equivalently: f*(a*) = ∪a∈a* {f(a)}.
[What is the code for this? (Btw, for list-represent, Cf. map)]
What about binary functions?
{2,3,5} ^ {-1,2} = {1/2,1/3,1/5, 4,9,25}.
What is size of A^B ? Not |A|^|B|, certainly! Beware 22 vs 41?
We can phrase "are rationals closed under addition" as "Q+Q in? Q"
"Is the set {Jan,Apr,Jul,Oct} closed under tax-refund-return-month ?"
Image, f(S), codomain; the term "range" is deprecated these days.
How might we define "pre-image"?
A set A is "closed under f" if f:A→A and f*(A) ⊆ A.
def'n onto: (everything gets mapped to at least once)
for each y ∈ Y, there is some x ∈ X s.t. f(x)=y
Equivalently: f's image = f's entire co-domain.
def'n 1-1, or into: f(x)=f(y) iff x=y. (nothing is mapped to more than once)
Inverse (def'n):
A function f: X → Y is invertable iff:
there exists some function g such that
for any x ∈ X, g(f(x)) = x ["g is a left-inverse of f"], and
for any y ∈ Y, f(g(y)) = y ["g is a right-inverse of f"].
Not ∈ text:
Th'm: f: X → Y is invertable, iff f is 1-1,onto.
Proof: Outline: prove two directions (one of which as two parts):
( I) (a) If f is invertable, then f is 1-1.
(b) If f is invertable, then f is onto.
(II) If f is 1-1 and onto, then it's invertable.
Each of these parts is straightforward,
but we'll keep reminding ourselves where we are and what we're trying to show:
( I) (a) Suppose g is the inverse of f. We'll show f is 1-1:
That is, we'll show: if f(xa) = f(xb), then xa = xb (for arbitray xa, xb).
If f(xa) = f(xb), then g(f(xa)) = g(f(xb)) (apply g to equal things gives equal output).
But because g is a (left) inverse, g(f(xa)) = xa and g(f(xb)) = xb,
so we have that xa = xb, which completes the requirement for 1-1.
(b) Suppose g is the inverse of f. We'll show f is onto:
That is, we'll show that for any y0 ∈ Y, there is
some x0 ∈ X such that f(x0) = y0.
Given an arbitrary y0, which x0 ∈ X will do the trick?
g(y0) will!, since f(g(y0)) = y0.
[Note that g(y0) is indeed an element of X, since g: Y → X.]
[Interesting, a nice symmetry: this used g being a right-inverse of f.]
(II) Suppose f is 1-1 and onto; we'll show that f has an inverse.
We'll constrcut a function g:Y → X as follows, and then confirm that this
particular g really does meet the requirements of "inverse of f".
For any y0 ∈ Y, we define g(y0) as: the element x0 such that f maps x0 to y0
-- such an x0 exists because f is onto!
Is this function g really an inverse of f? Let's look at the def'n of inverse:
for any x ∈ X, what is g(f(x))? g(f(x)) is the element of X which f maps to f(x); this is x.
So g(f(x)) = x, and our constructed function g is indeed a left-inverse to f.
Similarly: for any y ∈ Y, what is f(g(y))? Well by our construction of g,
g(y) is thing which f maps to y, so therefore f(g(y)) = y.
Woo-hoo! Um, wait a minute -- in this second part, we used f being
onto, but we didn't prove that f is 1-1. What gives? We'll use our
debugging skills: Have we proven something stronger -- that if f is
onto, then it's invertable? If so, can we come up with a
test-input? That is, make a function that is onto but not 1-1; does
it have an inverse? Why not? What was the bug in our proof?
Upshot: In english, Beware the "the"!
In english, the word entails uniqueness and existence:
"What a beautiful work of modern art -- I'll marry the painter who created this!"
What if the work had been created by a team of several people ["the painter" non-unique]
What if a bucket had just been tipped over by the wind? ["the painter" non-existent]
[Unless of course the artist set up the bucket in a windy area,
anticipating nature to complete their vision for them ...
or, they consider chance as "art", when you let it evoke an emotional reaction.]
For example, in our proof that 90=100, we
glibly said "let C be the point where two lines intersect";
technically we needed to add that such a point exists (easy to show
the lines were non-parallel), and such a point is unique (clear, since
two lines only intersect at most once, at least in Euclidean
geometry.)
A few numeric functions:
floor, ceiling; round-to-even; truncate-towards-0.
Reducing functions to sets: graphs!
Which is more fundamental: sets, or functions?
Between graphs and indicator functions: either!
[well okay -- in a graph you need to lookup ]