===============================================================
Lect 10 - October 29, 2008 - ECS 20 - Fall 2008 - Phil Rogaway
===============================================================
Today: o Finish relations
o Functions
- SCRIBE (none today, use your own notes for the class notes)
Announcements:
o MT Thursday
o Review session tonight (7:10 pm, 1150 Hart)
o No discussion section Friday, no HW next Monday
------------------------------------------
1. Review
------------------------------------------
DEF: A and B sets. Then a *relation* R is subset of A x B.
R \subseteq A x B
Defined last time:
inverse of a relation
composition of a relation
Looked at: a graphical interpretation of relations
Reflexive: x R x for all x
Symmetric: x R y -> y R x for all x,y
Transitive: x R y and y R x -> x R z for all x, y, z
if R has all three properties, R is said to be an equivalence relation
If R is an equivalence relation on A x A then [x] denotes the set
of all elements related to x:
[x] = { x': x R x'}
We call [x] the *equivalence class* (or *block*) of x.
The set of all equivalence classes of A with respect to a
relation R is denoted A/R "quotient set of A by R", or "A mod R".
I claim that ever equivalence relation
*partitions* the universe into its blocks?
What does this mean?
Define a partitioning of the set A:
Def: {A_i: i in I} is a partition of A if each A_i is nonempty,
their union is A, and they are pairwise disjoint.
------------------------------------------
2. Partitions <==> equivalence relations
------------------------------------------
........................................................
Proposition: Let R be an equivalence relation on a set A.
Then the blocks of R are a partition of A.
........................................................
Proof: -Every element x of A is in the claimed partition: x \in [x].
-Suppose that [x] and [y] intersect. I need to argue that they
are identical.
So *suppose* there exists a s.t. a \in [x] and a \in [y].
I must show that [x] = [y].
So suppose b in [x]. Must show b\in [y].
b in [x] -> x R b is true -> b R x is true
know: x R a is true -> b R a is true -> a R b is true
know a R y is true -> y R a is true -> y R b is true -> b in [y]
Suppose b in [y]. Must show b in [x].
Exactly analogous.
......................................................................
Proposition: Suppose you have a partition {A_i| i\in I} of A.
Then this determines a equivalence relation in the
natural way; x R y iff x \in A_i and y \in A_ifor some i.
......................................................................
reflexive: x R x YES, x in A_i -> x in A_i
symmetric: x R y -> x R y YES, x,y both in A_i iff y,x both in A_i
trans: x R y and y R z YES, ...
You can talk about the blocks being related
to one another by R, [x] R [y] iff x R y.
Go back to prior examples and identify the blocks:
Example 1. alpha E beta if alpha, beta regular expressions denoting the same language
--> each block is the set of regular expressions denoting the same language .
Can you think of a "canonical" name for each block?
Could use the lexicographically first regular expression in a block.
Sounds hard to find the canonical name for a block (that is, given alpha,
find the name of [alpha].
Example 3. strings x and y are equivalent if they
have the same length. YES
--> blocks are the strings of a given length. Canonical name: 0^i.
Example 6. Fix a DFA (like the one we looked at for even a's and
even b's). x~y if they go to the same state under M. YES
--> blocks: do a small example, like the DFA that checks if
inputs and outputs have the same length.
Example A: given a regular language L,
say x E y if (xz in L iff yz in L for all z)
What are the blocks??
..................................................................................
Theorem [Myhill-Nerode]:
A language L is regular (there is a DFA for it, or a regular expression
for it) iff L/E is finite.
..................................................................................
Example 5. x | y if 3 | x-y over the integers
"X modulo R" - X / R - the set of all equivalence classes of X relative
to the relation R.
What are the blocks?
Example 6: Let U be the set of people, x B y have the same birthday.
What are the blocks of U/B ?
How many elements are there in U/B (366)
Example: Let \R be the set of real number, x~y if \lfloor x \rfloor =
\lfloor y \rfloor
What are the blocks? What would be a "canonical element" (name) for each block?
Example: \Let \R be the set of real number, x~y if
x - \lfloor x \rfloor =
y - \lfloor y \rfloor
What are the blocks? What would be a "canonical element" (name) for each block?
------------------------------------------
3. Closures of Relations
------------------------------------------
Given a relation, we sometimes want to FORCE it to be
reflexive ... or symmetric ... or transitive ...
or any combination of these.
We do this by adding _just_ enough extra pairs to get
the property.
Draw a picture for the transitive closure of a directed
graph.
Draw a picture for reflexive-transitive closure.
Def: The transitive closure of a relation R on A x A
is the smallest relation R* that contains A is is transitive.
claim: this is well defined: there is a unique smallest
relation R that contains A x A and is transitive.
In fact, it is the intersection of all relations R that
are transitive and contain A.
Procedure to find the transitive closure:
"add in all shortcuts". In the graph-theoretic realization
of the relation R, just add an arc (a,c) whenever you
have an (a,b) and a (b,c) but lack an (a,c).
Example 1: Do it with a graph
Example 2: An infinite set example:
Suppose i R i+1 for all i in Z.
Transitive closure is what?
Let |- be a relation on states of your computer, where the state
captures all the contents of your machine: registers, disk contents,
etc. Assume not hooked up to the web or a keyboard so that
whatever happens next is determined by its present state
| +
|--- for the transitive closure of the above. What would this represent?
| You will go from state C to state C'. Eventually.
What would you say if C |- C? Your machine is looping.
Reflexive closure R <- R union {(x,x): x in A} (easier
Transitive closure: if (x,y) in R and (y,z) in R add (x,z) to R.
------------
4. Functions
------------
Definition: A function f is a relation on A x B such that
there is one and only one pair a R b for every in A.
We write b=f(a) to mean that (a,b) in f.
(Just one way to do it: we could have defined functions as the primitive
and used the function to define the relation, putting in a pair
(a,f(a)) for every a in A.)
- We call A the domain of f, Dom(f).
- We call B the *codomain* (or *target*) of f.
Note that this does not mean the set {b: f(a)=b for some a in A}!
That is a different (and important) st called the *Range* (or *image*)
of f. Denote it f(A).
Example 1:
Domain={1,2,3}
f(a) = a^2.
Dom(f) = {1,2,3}
f(A) = {1,4,9}
co-domain: unclear, might be \N, might be \R, ....
Example 2:
Domain = students in this class
b(x) = birthdays, encoded as {1,..,12} x {1..31}.
b(phil) = (7,31)
b(ellen) = (4,1)
Example 3:
f: \R -> \R defined by f(x) = x^2
is it a function?
Represent it as a graph
Two functions f and g are equal, f=g, if their domains and ranges are equal
and f(x) = g(x) for all x in Dom(f)
Function composition
f o g
f: A -> B, g: B -> C
the (g o f) : A -> C is defined by
(g o f)(x) = g(f(x))
Kind of "backwards" notation, but fairly tradition. Some algebrists
will reverse it, (x) (f o g) "function operates on the left"
Some computer scientists like to denote functions by "lambda expressions"
To say that f is the function that maps x to x^2 we write
f = lambda x. x^2
Here x is just a formal variable;
lambda x . x^2 = lambda y . y^2
The domain is not explicitly
Functions don't have to be defined on numbers, of course
|x| = maps \Sigma^* -> \N
hd(x) = the first character of the string x, x\ne emptystring
tl(x) = all but the first character of x (define how when x=\emptystring)?
dim(A) = the dimensions of the matrix A, regarded as a pair of natural numbers
------------------------------
5. One-to-one, Onto functions
------------------------------
Def: f:A -> B is *injective* (or *one-to-one*) if
f(x)=f(y) -> x=y
Def: f:A -> B is *surjective* (or *onto*) if // the image is the co-domain
(for all b in B) (there exists a in A) f(a)=b
Def: f:A -> B is *bijective* (1-to-1 and onto) if
f is injective and surjective.
Example:
-f(x) = x+1 on \N 1-1, not onto
-f(x) = x+1 on \Z 1-1, onto
-f(x) = 2x on \N 1-1, not onto
-f(x) = 2x on \R 1-1, onto
-f(x) = x^2 on \R not 1-1, not onto
-f(x,y) = x + y on \N x \N not 1-1, onto
-f(x) = |x| etc....
-f(x) = \lfloor x \rfloor
-f(x) = \lceil x \rceil
-f(x) = x mod n
x = an + b where a is an integer and b in [0..n-1]
-f: regular expressions -> regular expressions
f(alpha) = lex first regular expression the language of which is alpha,
not 1-1, not onto
-f(M)=1 if M is a DFA and L(M) is infinite, 0 otherwise
Sometimes a little tricky to see if a function is 1-1, onto:
-f(x) = 3x mod 4 bijective
-f(x) = 3x mod 5 not bijective
Make a table
------------------------
5. Inverse of a function
-----------------------
If f(x) = y we say that x is a *preimage* of y
Does every point in the codomain have a preimage?
No, only points in the image.
Does every point in the image have *one* preimage?
No, only if it's an injective function
Does every point the in the domain have an image?
Yes, that's required by a function.
Might it have two images?
No, only one.
So if you do have an bijective function f: A -> B,
the function f^{-1}: B -> A is well defined:
f^{-1}(y) = the unique x such that f(x) = y.
Example: f(x) = exp(x) = e^x
Draw picture.
What's the domain? \R
What's the image? (0,\infty)
Is it 1-1 on this image? YES
What's it's inverse
e^x = y
x = ln(y)
Example: f(x) = x e^x = y draw it.
On what domain does the inverse exists?
answer: [0,infinity]
Could you define a larger portion of the curve on which the
inverse exists:
Yes, [-1/e .. infinity]
Graph the function. Take its derivative to see
that it vanishes at -1, when the function takes
on the value -1/e.
How would you find the inverse f^{-1}(2), for example?
x e^x = 2.
Binary search
-------------------------------
6. Common arithmetic functions
-------------------------------
exponential functions
f(x) = 2^x,
f(x) = 3^x