[an error occurred while processing this directive] Reading: §§ 1.5(proof methods), 1.8(functions)

Reminder on ways to construct new sets out of old:

speaking of…

Functions

Def'n: For sets X,Y, a (unary) function is an assignment from X (the ``domain'') to Y (the ``codomain'').

Examples of (unary) functions: length(); car-color(); colorname->rgb()

(partial functions: functions which throw an error on some inputs; often this is because our type system doesn't let us specify the input-set better. Formally, we might write ``f(17) = ⊥'' and add ⊥ to the codomain; may also represent inf. loop)

In java.util, there is a class which actually implements unary functions. Can you guess what it is?

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'' or ``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?

What is the type of ∫ (indefinite integral)?

Def'n: a function f:A→A is idempotent if ∀ a ∈ A, f(f(a))=f(a).
Consider an installer program: what is its input? What does idempotency mean?

Building new functions from old

More useful definitions:

Example: keybindings: Consider a program where it's possible to configure which key corresponds to which action (text editors, video games [ian: link to the appropriate lines of http://www.owlnet.rice.edu/~comp210/01fall/Assignments/Hw10/hw10-soln.ss, if public.] Discuss: Is this best described as a function, or as a relation? In each case, what is the domain/codomain? If a function: Is it 1-1, onto, invertible?
What about a keyboard-map (Qwerty, Dvorak; foreign-language glyphs)? What does it mean if a Xkeyboard map is not invertible?

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):
    1. If f is invertable, then f is 1-1.
    2. If f is invertable, then f is onto.
  1. 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:
    1. 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.
    2. 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.]
  1. Suppose f is 1-1 and onto; we'll show that f has an inverse.

    We'll construct 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''!
The word implies uniqueness and existence:

What a beautiful work of modern art — I'll marry the painter who created this!

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 ]

[an error occurred while processing this directive] [an error occurred while processing this directive]