Discrete Structures

Lecture Notes, 3 Nov 2010

Last Update: 3 November 2010

Note: NEW or UPDATED 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)

  1. Ways to Represent Functions:

    1. We often represent functions using formulas: f(x) = 2x

    2. But functions with formulas are not the only kind of functions!

      1. There are functions without formulas for computing them.

        • I.e., there are functions such that the "gears" of their "machines" work by magic!

        1. There are "table look-up" functions:

          • i.e., there's not necessarily any lawlike pattern relating I/P & O/P

        2. There are non-computable functions

        3. There are random functions, etc.

      2. Perhaps computer science can be defined as the study of which functions do have procedures for computing them!

    3. On the history of the concept of "function", link to my webpage on functions.

  2. Total & Partial Functions:

    1. Recall the definition of "function":

      1. Let A,B be sets.
        Then f is a function from A to B


        1. f is a binary relation from A to B,
        2. (∀a∈A)(∀b∈B)(∀b′∈B)[( (a,b) ∈ f  ∧  (a,b′) ∈ f ) → b=b′]

      2. 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′]

      3. 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′)]

    2. 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.

    3. Def:

        Let A,B be sets.
        Let f : A → B.

        1. 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

        2. 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.

    4. E.g.: Let f : ZZ s.t. f(a) = 2a.
      Then f is total on Z

    5. E.g.: But let g : ZQ s.t. g(a) = 1/a.
      Then g is partial on Z

      • (because g(0) is undefined)

  3. 1–1 Functions:

    1. Reminder:

      is a relation, but is not a function.

    2. Some examples of "1–1" functions before we define them:

      1. will be called a "1–1" function

      2. is a function, but is not a "1–1" function.
        (It's a "2–1" function.)

      3. 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.

      4. f  : ZZ s.t. f(x) = x+1 is 1–1

        • because each number has a unique successor

      5. Ditto for h : NN s.t. h(n) = n+1

        • which is really why the domain N of this function h is countable.

      6. Ditto for k : ZN s.t.:
          –2 |→ 4
          –1 |→ 2
            0 |→ 0
            1 |→ 1
            2 |→ 3

                                 –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.

    3. 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)[aa′  →  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.

    4. Note:

      • This is the converse of the definition of "function"

      1. f is a function → (x = yf(x) = f(y))

        • i.e., same I/P → same O/P

      2. f is a 1–1 function → (x = yf(x) = f(y))

        • i.e., same I/P ↔ same O/P

  4. Onto Functions:

    1. Reminder: A partial function looks like this:

    2. Now consider functions that are "partial" in their co-domain vs. being "total" in their co-domain:

    3. 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]

  5. 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.