Discrete Structures
Lecture Notes, 3 Nov 2010
Last Update: 3 November 2010
Note:
or
material is highlighted
|
Note: A username and password may be required to access certain
documents.
Please
contact
Bill Rapaport.
Index to all lecture notes
…Previous lecture
§2.3: Functions (cont'd)
- Ways to Represent Functions:
- We often represent functions using formulas:
f(x) = 2x
- But functions with formulas are not the only kind
of functions!
- There are functions without formulas for computing them.
- I.e., there are functions such that the "gears" of
their "machines" work by magic!
- There are "table look-up" functions:
- i.e., there's not necessarily any lawlike pattern relating I/P & O/P
- There are non-computable functions
- There are random functions, etc.
- Perhaps computer science can be defined as
the study of which functions do have procedures for
computing them!
- On the history of the concept of "function",
link to my webpage on functions.
- Total & Partial Functions:
- Recall the definition of "function":
- Let A,B be sets.
Then f is a function from A to B
- f is a binary relation from A to B,
- (∀a∈A)(∀b∈B)(∀b′∈B)[( (a,b) ∈
f ∧ (a,b′)
∈ f ) → b=b′]
- If we know that f is a function, then clause (b)
becomes the tautology:
(∀a∈A)(∀b∈B)(∀b′∈B)[( f(a) =
b ∧ f(a) =
b′) ) → b=b′]
- Another way to state clause (b) is to formalize the
notion of "same I/P → same O/P":
(∀a, a′ ∈ A)[(a = a′)
→ (f(a) = f(a′)]
-
We would like to distinguish between:
- domains in which some but not all
elements are mapped to elements of the co-domain
- domains in which all elements are mapped to elements of the
co-domain.
-
Def:
Let A,B be sets.
Let f : A → B.
Then:
- f is a total function on A
(∀a ∈ A)(∃b ∈
B)[f(a) = b]
- i.e., everything in the domain maps to something in the
co-domain
- f is a partial function on A
¬(f is a total function on A)
- i.e., (∃a ∈ A)(¬∃b ∈
B)[f(a) = b]
- i.e., f is undefined on a
- i.e., something in the domain fails to map to anything in the
co-domain.
- E.g.: Let f : Z → Z s.t.
f(a) = 2a.
Then f is total on Z
- E.g.: But let g : Z → Q s.t.
g(a) = 1/a.
Then g is partial on Z
- (because g(0) is undefined)
- 1–1 Functions:
- Reminder:
is a relation, but is not a function.
- Some examples of "1–1" functions before we define
them:
will be called a "1–1" function
is a function, but is not a "1–1" function.
(It's a "2–1" function.)
- g : {x | x ∈ CSE191}
→ {A, A–, … , D+, D, F}
is (usually) not 1–1, because (usually) ≥2 students
will get the same grade.
- It would be 1–1 iff ∃ 11 students, each getting
a different
one of those grades.
- f : Z → Z s.t.
f(x) = x+1 is 1–1
- because each number has a unique successor
- Ditto for h : N → N s.t.
h(n) = n+1
- which is really why the domain N of this function h
is
countable.
- Ditto for k : Z → N s.t.:
–2 |→ 4
–1 |→ 2
0 |→ 0
1 |→ 1
2 |→ 3
etc.
–2i, if i ≤ 0,
i.e., k(i) = {
2i–1, if i > 0
- which is partly why the domain Z of this function
k is countable.
- The other part of the reason is that k is a total
function.
- Def:
Let A,B be sets.
Let f : A → B.
Then f is a 1–1 (or injective)
function
(∀a ∈ A)(∀a′ ∈
A)[f(a) =
f(a′) → a =
a′]
- ≡
(∀a,a′ ∈ A)[a ≠
a′ → f(a) ≠
f(a′)]
- i.e., if 2 O/Ps are the same, then their I/Ps must have been the
same.
- or: if 2 I/Ps differ, then their O/Ps differ.
- Note:
- This is the converse of the definition of "function"
- f is a function → (x = y →
f(x) = f(y))
- i.e., same I/P → same O/P
- f is a 1–1 function → (x =
y ↔ f(x) = f(y))
- i.e., same I/P ↔ same O/P
- Onto Functions:
- Reminder: A partial function looks like this:
- Now consider functions that are "partial" in their
co-domain vs. being "total" in their co-domain:
- Def:
Let A,B be sets.
Let f : A → B.
Then f maps A onto B
or: is an onto function
or: is a surjective function
(∀b ∈ B)(∃a ∈ A)[f(a)
= b]
- i.e., everything in the co-domain "came from"
something in the domain
(or: everything in the co-domain "gets
hit by" something in the domain, which leads to the following metaphor)
-
Metaphor:
f : A → B |
A is like an archer;
B is like a target. |
function: | no archer hits >1 target |
partial function: | some archer lacks arrows |
total function: | every archer has arrows |
1–1 function: | every archer hits a different target |
onto function: | every target is hit by some archer. |
Next lecture…
Text copyright © 2010 by William J. Rapaport
(rapaport@buffalo.edu)
Cartoon links and screen-captures appear here for your enjoyment.
They are not meant to infringe on any copyrights held by the creators.
For more information on any cartoon, click on it, or contact me.
http://www.cse.buffalo.edu/~rapaport/191/F10/lecturenotes-20101103.html-20101105