49

Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

  • Upload
    others

  • View
    15

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42, Discrete Mathematics

Fall 2018

Richard P. Kubelka

San Jose State University

last updated 10/10/2018 at 23:28:03

For use by students in this class only; all rights reserved.Note: some prose & some tables are taken directly from Kenneth R. Rosen, Discrete

Mathematics and Its Applications, 8th Ed., the o�cial text adopted for this course.

c© R. P. Kubelka

Page 2: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Sets�basics

De�nition

A set is an unordered collection of objects, called elements

or members of the set. A set is said to contain itselements. We write a ∈ A to denote that a is an element ofthe set A. The notation a /∈ A means that a is not anelement of the set A.

Remarks

I Unordered means that the order in which we list itemsdoes not matter. So, for example

{1, 2, 3, 4} = {4, 3, 2, 1} = {2, 1, 3, 4},

etc.

I We haven't speci�ed what objects are, or even what acollection is. This �ne print is mathematicallyimportant. But it's way beyond the level of this course.

Page 3: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Sets�descriptions

There are a number of ways of describing sets. Here are the

most common:

I Roster Method. List the elements of the set between

braces�{ and }�separated by commas. This method is

most useful when the set doesn't have very many

elements. Example: A = {red, green, blue, yellow}. Or

B = {2, granite, topology, Proust}. (Nothing says the

elements of the set must be alike in any way.)

I Ellipsis Method. When the elements of the set follow

an obvious pattern, we can list the �rst few elements

followed by an ellipsis (. . .). Example:

E = {2, 4, 6, 8, 10, . . .}.

Page 4: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Sets�descriptions

I Set Builder Notation.

Examples

I B = {x ∈ Q | x = 1/n, 0 6= n ∈ Z}= {x ∈ Q : x = 1/n, 0 6= n ∈ Z}

I C = {2n+ 1 |n ∈ Z} = {2n+ 1 : n ∈ Z}

Remarks

I Some books�like ours�use a vertical bar (|), whileothers use a colon (:). I will likely be inconsistent in thisclass, sometimes using one style, sometimes the other.

I Note the subtle di�erence between the two cases above.In the �B" case, we want all elements from a given setthat satisfy the condition stated after the vertical bar.

In the �C" case, we want all items of the form givenbefore the vertical bar.

Page 5: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Set Builder Notation

Remark

Note that repetition of elements is irrelevant. We list onlythe distinct elements of the set.

Example

{n2 |n ∈ Z} = {02, 12, (−1)2, 22, (−2)2, . . .}

= {0, 1, 1, 4, 4, . . .} = {0, 1, 4, . . .}(1)

Page 6: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Sets: standard notation

Some important sets�and their notation.

I N = {0, 1, 2, 3, . . .}, the set of natural numbers.

I Z = {. . . ,−2,−1, 0, 1, 2, . . .}, the set of integers.

I Z+ = {1, 2, 3, . . .}, the set of positive integers.

I Q = {p/q |p,q ∈ Z,q 6= 0}, the set of rational

numbers.

I R, the set of real numbers.

I R+ = {x ∈ R | x > 0}, the set of positive real

numbers.

I C = {x+ iy | x,y ∈ R}, the set of complex numbers.

Page 7: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Sets: standard notation

Some important sets of real numbers and their notation:

I (a,b) = {x ∈ R |a < x < b}

I [a,b) = {x ∈ R |a 6 x < b}

I (a,b] = {x ∈ R |a < x 6 b}

I [a,b] = {x ∈ R |a 6 x 6 b}

Remark

(a,b) is called an open interval. [a,b] is called a closed

interval. [a,b) and (a,b] are called half-open intervals.

Warning

Pay careful attention to which type of numbers you areconsidering, e.g., real numbers vs. integers.

For example, [0, 1) = {x ∈ R | 0 6 x < 1} contains in�nitelymany numbers, while {x ∈ Z | 0 6 x < 1} contains just one.

Page 8: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Equality of Sets

De�nition

Two sets are equal if and only if they have the sameelements. That is, A = B if and only if

(∀a ∈ A a ∈ B)∧ (∀b ∈ B b ∈ A)

Example

{2n |n ∈ Z} = {m ∈ Z |m is divisible by 2} (2)

To establish the truth of (2), show that any element in theleft-hand set is in the right-hand set and any element in theright-hand set is in the left-hand set.

Page 9: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Two Special Sets

De�nition

The set that has no elements at all is called the empty set

(or null set) and is denoted by ∅ or {}.

There is only one empty set.

De�nition

A set that contains just one element is called a singleton

set.

{Juanita}, {0}, {∅}, {⊗} are all (distinct) singleton sets.

Page 10: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Subsets

De�nition

A set A is a subset of B if and only every element of A isalso an element of B. We denote this by A ⊆ B.

Remarks

I To show that A ⊆ B, show that if x ∈ A, then x ∈ B.I To show that A * B�i.e., that A is not a subset ofB��nd an x ∈ A such that x /∈ B.

Example

Z+ ⊆ Z ⊆ Q ⊆ R ⊆ C.

All of these inclusions are, of course, strict inclusions.

Page 11: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Subsets

Remarks

I A = B if and only if A ⊆ B and B ⊆ A.I ∅ ⊆ S for every set S.

I S ⊆ S for every set S.

I If A ⊆ B and A 6= B, we call A a proper subset of B.

Example: Is 2Q = {2q |q ∈ Q} a proper subset of Q?

Page 12: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Size of a Set

De�nition

If a set S has exactly n distinct elements, with n anonnegative integer, we say that S is a �nite set of

cardinality n. We denote that cardinality of S by |S|, so|S| = n here.

Remark

If S has in�nitely many elements, i.e., more than n elementsfor any nonnegative integer n, we call S in�nite.

We won't use the expression |S| =∞, since it turns out thatthere are di�erent sizes of in�nity.

Page 13: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

The Power Set of S

De�nition

Given a set S, the power set of S, denoted by P(S), is theset of all subsets of S.

P(∅) = {∅}P({a}) = {∅, {a}}

P({a,b}) = {∅, {a}, {b}, {a,b}}

P({a,b, c}) = {∅, {a}, {b}, {c}, {a,b}, {a, c}, {b, c}, {a,b, c}}

Remark

If |S| = n, then |P(S)| = 2n.

Page 14: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

De�nition

Given sets A1,A2, . . . ,An, the ordered n-tuple

(a1,a2, . . . ,an) is an ordered string of elements such thatai ∈ Ai for i = 1, 2, . . . ,n.

Remarks

I An ordered n-tuple is not a set. Order matters, as doesrepetition. (1, 2, 3, 3) 6= (3, 3, 2, 1) 6= (1, 2, 3)

I If n = 2, we say �ordered pair." For n = 3, �orderedtriple." For n = 4, �ordered quadruple'. . . . But forn = 21, we say �ordered 21-tuple."

De�nition

The Cartesian product of the sets A1,A2, . . . ,An, denotedby A1 ×A2 × · · · ×An, is the set of all ordered n-tuples(a1,a2, . . . ,an) such that ai ∈ Ai for i = 1, 2, . . . ,n.

Page 15: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Cartesian Products�Examples

Example

Suppose A = {red,green,blue} and B = {0, 1}. Then

A× B = {(red, 0), (red, 1), (green, 0),

(green, 1), (blue, 0), (blue, 1)}(3)

B×A = {(0, red), (1, red), (0,green),

(1,green), (0,blue), (1,blue)}(4)

As we see by comparing (3) with (4), it's not generally truethat A× B = B×A.

Page 16: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Cartesian Products�Examples

Example

Suppose A = {a,b} and B = {0, 1}, and C = {α,β}. Then

A× B× C = {(a, 0,α), (a, 0,β), (a, 1,α), (a, 1,β)

(b, 0,α), (b, 0,β), (b, 1,α), (b, 1,β)}(5)

but

(A× B)× C = {((a, 0),α), ((a, 0),β), ((a, 1),α), ((a, 1),β)

((b, 0),α), ((b, 0),β), ((b, 1),α), ((b, 1),β)}

(6)

Again, by comparing (5) with (6), we see that

A× B× C 6= (A× B)× C

Page 17: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Relations

De�nition

A subset R ⊆ A× B is called a relation from A to B. Asubset R ⊆ A×A is called a relation on A. If (a,b) ∈ Rwe write aRb; if (a,b) /∈ R we write a�Rb.

Examples

1. Let R1 = {(n,m) |n dividesm evenly} ⊆ Z+ × Z+.Then 2R16, but 3�R15. We could call this relation |

instead of R1. So 2 | 6, but 3 - 5.

2. Given a set X, de�ne a relation R2 on its powerset P(X)by R2 = {(A,B) |B ⊆ A} ⊆ P(X)× P(X). Then{1, 2}R2{2}, but {1}�R2{1, 2}. We could call this relation ⊇instead of R2. So {1, 2} ⊇ {2}, but {1} + {1, 2}.

Page 18: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Storing Subsets in a Computer

Suppose we have an n-element set S = {a1,a2, . . . ,an} andwe want to store some of its subsets e�ciently in a computer.

As the book points out, we can completely describe a subset

by simply giving a string of 0's and 1's as follows:

Step 1 First list the elements in the set in a speci�corder: a1,a2, . . . ,an.

Step 2 For each subset A ⊆ S, generatek1,k2, . . . ,kn an n-digit string of 0's and 1'ssuch that ki = 1 if ai ∈ A and ki = 0 ifai /∈ A.

Example

Suppose S = {red, green, blue}. Then let a1 = red,a2 = green, a3 = blue. So the subset A = {red, blue} wouldbe stored as 101, while the subset B = {blue, green} would bestored as 011. (Note that the order in which we list items inB doesn't a�ect the way in which it's stored digitally.)

Page 19: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Cardinality of P(S)

From the preceding discussion, we can get a proof of the

conjecture we made earlier that if |S| = n, then |P(S)| = 2n.

Fact

If A1,A2, . . . ,An are all �nite sets, then

|A1 ×A2 × . . .×An| = |A1| · |A2| · · · · · |An|.

So if Ai = A for all i and |A| = m, then |A× · · ·×A| = mn.

In the example under consideration, we have Ai = {0, 1} ∀i,so the number of subsets of S�which is the number of

n-digit strings of 0's and 1's�is just

|A1 ×A2 × . . .×An| = 2n.

Page 20: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Union, Intersection, Di�erence, Complement

De�nitions

Let A and B be sets.

I The union of the sets A and B, denoted by A ∪ B, isthe set that contains those elements that are either in Aor in B, or in both.

I The intersection of the sets A and B, denoted byA ∩ B, is the set containing those elements that are inboth A and B.

I The di�erence of A and B, denoted by A− B, is theset containing those elements of A that are not in B.The di�erence of A and B is also called thecomplement of B with respect to A.

I If U is the universal set, U−A, the complement of Awith respect to U, is called simply the complement of

A. It is denoted by A.

Page 21: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Set Operations

De�nition

Two sets A and B are called disjoint if A ∩ B = ∅.

Fact

If A and B are disjoint, then

|A ∪ B| = |A|+ |B|. (7)

Remark

Since A = (A− B) ∪ (A ∩ B) and since this is a disjoint

union, i.e., the union of disjoint sets, then

|A| = |A− B|+ |A ∩ B|. (8)

Similarly, |B| = |B−A|+ |B ∩A|.

Page 22: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Cardinality of a Union

We now note that any union A ∪ B can actually be written

as a disjoint union:

A ∪ B = (A− B) ∪ B. (9)

Now we can apply (7) to (9) to get

|A ∪ B| = |A− B|+ |B|

= (|A|− |A ∩ B|) + |B|

= |A|+ |B|− |A ∩ B|.(10)

Page 23: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Set Identities�Example

Fact

If A, B, and C are sets, then

A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C) (11)

Proof.

If x ∈ A ∩ (B ∪ C), then x ∈ A and x ∈ B ∪ C. So x ∈ Aand either x ∈ B or x ∈ C. That means that either (x ∈ Aand x ∈ B) or (x ∈ A and x ∈ C). So x ∈ (A ∩ B) orx ∈ (A ∩ C), and hence x ∈ (A ∩ B) ∪ (A ∩ C). Thus theleft-hand set in (11) is contained in the right-hand set.

Now if y ∈ (A ∩ B) ∪ (A ∩ C), then either y ∈ (A ∩ B) ory ∈ (A ∩ C). In the former case, y ∈ A ∩ (B ∪ C) sinceB ⊆ (B ∪ C). In the latter case, y ∈ A ∩ (B ∪ C) sinceC ⊆ (B ∪ C). Thus in either case y ∈ A ∩ (B ∪ C), asdesired.

Page 24: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Set Identities�Example

Fact

If A and B are sets, then

(A ∪ B) = A ∩ B. (12)

Proof.

Let x ∈ (A ∪ B). Then x /∈ (A ∪ B). This implies that x /∈ Aand x /∈ B, and so x ∈ A and x ∈ B. Thus x ∈ (A ∩ B). Sothe left-hand set in (12) is contained in the right-hand set.

Now if y ∈ (A ∩ B), then y ∈ A and y ∈ B. So y /∈ A and

y /∈ B, and therefore y /∈ (A ∪ B). Hence y ∈ (A ∪ B), asdesired.

Page 25: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

De�nition of a Function

De�nition

A function f : X→ Y consists of

1. A set X of inputs of the function; X is called thedomain of the function.

2. A set Y of potential outputs of the function; Y is calledthe codomain of the function.

3. A rule that associates to each element x of the domaina unique element f(x) of the codomain.

Examples

1. f1 : R→ R given by f1(x) = x2.

2. f2 : R+ → R given by f2(x) = x2.

3. f3 : R+ → R+ given by f3(x) = x2.

4. f4 : Z+ → Z+ given by f4(x) = x2.

5. f5 : R+ → R+ given by f5(x) = x3.

Page 26: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Functions

De�nition

Two functions f and g are called equal if

1. domain(f)=domain(g)

2. codomain(f)=codomain(g)

3. f(x) = g(x) for all x ∈ domain(f) = domain(g).

Remark

None of the functions f1, . . . , f5 above is equal to any other.

Page 27: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Images & Preimages

De�nitions

Given a function f : X→ Y

I If f(x) = y, we call y the image of x under f.

I If f(x) = y, we call x a preimage of y (under f).

I If A ⊆ X, we de�ne f(A), the image of the subset A,by

f(A) = {f(x) | x ∈ A}

I f(X), the set of all outputs of f, is called the range ofthe function.

Note that we say the image of x but a preimage of y. That's

because images are unique but preimages might not be.

Page 28: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Preimages of Sets

De�nition

Given a function f : X→ Y and B ⊆ Y, de�ne f−1(B), theinverse image (or preimage) of B by

f−1(B) = {x ∈ X : f(x) ∈ B}.

Warning

The notation �f−1(B)" does not in any way imply theexistence of an inverse for the function f. Just like a red

herring is neither red nor a herring, the f−1 in f−1(B) isjust a part of the notation. In particular, f−1(B) is de�nedfor any function f, whether or not it is invertible.

Page 29: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Preimages of Sets

Fact

Given a function f : X→ Y and B1,B2 ⊆ Y, then

f−1(B1 ∩ B2) = f−1(B1) ∩ f−1(B2). (13)

Proof.

x ∈ f−1(B1 ∩ B2)⇔ f(x) ∈ B1 ∩ B2 ⇔f(x) ∈ B1 ∧ f(x) ∈ B2 ⇔ x ∈ f−1(B1) ∧ x ∈ f−1(B2)

⇔ x ∈ f−1(B1) ∩ f−1(B2)

(14)

On an exam, don't use �⇔.� Instead, �rst showf−1(B1 ∩ B2) ⊆ f−1(B1) ∩ f−1(B2) and then showf−1(B1) ∩ f−1(B2) ⊆ f−1(B1 ∩ B2).

Page 30: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

One-to-One Functions

De�nition

A function f : X→ Y is called one-to-one (written 1-1) iff(x1) = f(x2) implies x1 = x2. Equivalently, f is 1-1 ifx1 6= x2 implies f(x1) 6= f(x2).

A one-to-one function is called an injection or injective.

Symbolically, f is one-to-one if

∀x1 ∀x2 (f(x1) = f(x2)→ x1 = x2). (15)

Example

Referring to the examples above f1 is not 1-1, but f2, . . . , f5are all 1-1.

Page 31: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

One-to-One Functions

De�nition

Suppose we are given a function f : R→ R. The function fis called increasing if f(x) 6 f(y) whenever x < y; we call fstrictly increasing if f(x) < f(y) whenever x < y.Decreasing and strictly decreasing functions are de�nedsimilarly.

Fact

If f : R→ R is strictly increasing (resp., strictly decreasing)then f is 1-1.

Proof.

We need to show that if x1 6= x2 then f(x1) 6= f(x2). Butsince we're dealing with real numbers, if x1 6= x2 then either

x1 < x2 or x2 < x1. Assume that x1 < x2. Then �f strictly

increasing� implies that f(x1) < f(x2), and so f(x1) 6= f(x2).The proofs in the other cases proceed similarly.

Page 32: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Onto Functions

De�nition

A function f : X→ Y is called onto if for each y ∈ Y, thereexists an x ∈ X with f(x) = y.

An onto function is called a surjection or surjective.

Symbolically, f is onto if

∀y ∈ Y ∃x ∈ X f(x) = y. (16)

Example

Referring to the examples above f3 and f5 are onto, but theothers are not.

Page 33: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Refuting Injectivity

We can use (15) to determine when a function fails to be

one-to-one.

I f is not 1-1 if

¬∀x1 ∀x2 (f(x1) = f(x2)→ x1 = x2)

≡ ∃x1 ∃x2 ¬(f(x1) = f(x2)→ x1 = x2)

≡ ∃x1 ∃x2 ¬(f(x1) 6= f(x2)∨ x1 = x2)≡ ∃x1 ∃x2 (f(x1) = f(x2)∧ x1 6= x2)

(17)

That is, f is not 1-1 if there exist x1 6= x2 with

f(x1) = f(x2).

Page 34: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Refuting Surjectivity

We can use (16) to determine when a function fails to be

onto.

I f is not onto if

¬∀y ∈ Y ∃x ∈ X f(x) = y≡ ∃y ∈ Y ∀x ∈ X ¬(f(x) = y)

≡ ∃y ∈ Y ∀x ∈ X f(x) 6= y(18)

That is, f is not onto if there exists a y ∈ Y such that

the equation f(x) = y has no solution.

Page 35: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

An Interesting Function

Let us de�ne a function ϕ : Z+ → Z by

ϕ(n) =

{n2 if n is even

−n−12 if n is odd

I Show that ϕ is 1-1.

I Show that ϕ is onto.

De�nition

A function f : X→ Y is called a one-to-one

correspondence (or a bijection) if it is both one-to-one andonto.

So ϕ is a bijection between the positive integers and all of

the integers. Thus there are just as many positive integers

as there are integers altogether!

Page 36: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Inverses of Functions

Suppose f : X→ Y is a bijection, i.e., a one-to-one and onto

function. We can de�ne a new function g : Y → X as follows:

1. The domain of g will be Y, the codomain of f; the

codomain of g will be X, the domain of f. So all we

need now to complete the de�nition of g is a rule that

assigns to each element of Y a unique element of X.

2. So take y ∈ Y. Since f is onto, there exists an x ∈ Xsuch that f(x) = y. But since f is one-to-one, for each

y ∈ Y there is only one such x ∈ X. We de�ne

g(y) = x, i.e., that x, the one such that y = f(x).

Remark

The function g de�ned as above is called an inverse of f.

Page 37: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Compositions of functions

De�nition

Suppose k : X→ Y and h : Y → Z are two functions. Wede�ne the function h ◦ k : X→ Z, the composition of the

functions h and k, by

(h ◦ k)(x) = h(k(x)) for x ∈ X. (19)

Remark

Note that the de�nition given by (19) makes sense becausefor each x ∈ X, k(x) ∈ Y, the domain of the function h.

Page 38: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Inverses of Functions

Recall that, given a bijection f : X→ Y, we de�ned a

function g : Y → X such that g(y) = x, where f(x) = y. In

other words,

f(g(y)) = y (20)

for all y ∈ Y.

De�nition

For any set A, de�ne the identity function ιA : A→ A bysetting ιA(a) = a, ∀a ∈ A.

Using this de�nition, we can rewrite (20) as

f ◦ g = ιY (21)

Page 39: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Inverses of Functions

So what about g(f(x))? To �nd the value of g at a certain

input, we need the element of X that gets sent by f to that

input. So what element in X gets sent to f(x)? x gets sent

to f(x)!

So

g(f(x)) = x (22)

for all x ∈ X.

And, as above, we can interpret (22) as

g ◦ f = ιX. (23)

Page 40: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Uniqueness of Inverses

Fact

If f : X→ Y has an inverse g : Y → X�i.e., g satis�es (20)

and (22)�then g is unique.

Proof.

Suppose g1 : Y → X and g2 : Y → X are two functions

satisfying (20) and (22) and suppose g1 6= g2. That means

that there exists some y0 ∈ Y with g1(y0) 6= g2(y0).But now applying (20) to both g1 and g2, we get

f(g1(y0)) = y0 = f(g2(y0)). (24)

But (24) and the assumption that g1(y0) 6= g2(y0)contradict the assumption that f is one-to-one, a necessary

condition for f's having an inverse.

Page 41: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Finding an Inverse � Example

Given the function f(x) = x−3x+1 , �nd its inverse if you can. If

you can't, tell why not.

Remark

I said �Given the function. . .," but I didn't say anythingabout the domain and codomain of f.

In mathematics, especially when dealing with real functions,we often get lazy and give only the rule of assignment for thefunction, usually by giving a formula. In that case, we takethe domain of the function to be the set of all real numbersfor which the formula makes sense.

In that case, what would the domain of this f be?

domain(f) = {x ∈ R | x 6= −1}

Page 42: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Finding an Inverse � Example

How do we �nd an inverse for a function f? We write

y = f(x) and try to solve for x in terms of y.

y =x− 3

x+ 1

⇒y(x+ 1) = x− 3

⇒yx+ y = x− 3

⇒y+ 3 = x− yx

⇒y+ 3 = x(1 − y)

⇒3 + y

1 − y= x

(25)

Page 43: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Finding an Inverse � Example

Claim

g(y) = x =3 + y

1 − yis the inverse for f.

Remarks

I Note that we haven't yet proven that this g is aninverse for f. We assumed that f had an inverse. Whyis that justi�ed? It isn't! The g that we found is whatany inverse must look like, but that doesn't mean that gis actually an inverse. We've only discovered necessaryconditions on an inverse; they may not be su�cient.

I To prove that g is an inverse for f we must verify that(20) and (22) both hold, i.e., that f(g(y)) = y for ally ∈ Y and g(f(x)) = x for all x ∈ X.

Page 44: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Finding an Inverse � Example

Remarks

I Once again, we're being lazy. We need to specify thedomain Y and codomain X for g.

And once again, we take the domain of g to consist ofall those real numbers y for which the formula makessense.

SoY = domain(g) = {y |y 6= 1} = R− {1}.

But this time we take the codomain of g to beX = R− {−1}.

Page 45: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Finding an Inverse � Example

We �rst verify (20):

f(g(y)) =g(y) − 3

g(y) + 1

=

3 + y

1 − y− 3

3 + y

1 − y+ 1

=(3 + y) − 3(1 − y)

(3 + y) + (1 − y)

=4y

4= y,

(26)

as desired.

Page 46: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Finding an Inverse � Example

Now verify (22):

g(f(x)) =3 + f(x)

1 − f(x)

=3 + x−3

x+1

1 − x−3x+1

=3(x+ 1) + (x− 3)

(x+ 1) − (x− 3)

=4x

4= x,

(27)

as desired.

Page 47: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Finding an Inverse � Example

Remarks

I Another way to see that g is an inverse for f is to notethat all the steps in the derivation (25) except that lastare reversible. And even the last step is reversible aslong as y 6= 1.

I The fact that the last step in the derivation is notreversible when y = 1 reveals that the original functionf : R− {−1}→ R is not actually onto: 1 /∈ f(R− {−1}).

I So in order to claim that f is invertible�has aninverse�we must modify its codomain so that

f : (R− {−1})→ (R− {1})

Page 48: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Finding an Inverse � Example

Find the inverse of f : [0,∞)→ R if f(x) =√x.

y =√x

⇒y2 = x

(28)

But is g : R→ [0,∞) with g(y) = y2 really an inverse for f?

Check (22):

g(f(x)) = (f(x))2 = (√x)2 = x (29)

for all x ∈ [0,∞).

What about (20)?

f(g(y)) =√g(y) =

√y2 = |y| 6= y (30)

if y < 0. So g is not an inverse for f. (f is not onto.)

Page 49: Math 42, Discrete Mathematicskubelka/xtra42/DiscreteMathCh2-handouts.pdf · Math 42, Discrete Mathematics Richard .P Kubelka San Jose State University Sets Set Operations Functions

Math 42,Discrete

Mathematics

Richard P.Kubelka

San Jose StateUniversity

Sets

Set Operations

Functions

c© R. P. Kubelka

Finding an Inverse � Example

Remark

If we were to modify the codomain of f, changing it to[0,∞) from R, then g : [0,∞)→ [0,∞) given by g(y) = y2

would be an inverse for f because both (20) and (22) holdfor the new f and the new g. With the modi�ed codomain,f : [0,∞)→ [0,∞) is now onto as well as one-to-one.

Of course technically we changed f to a new function whenwe changed its codomain�even though the rule f(x) =

√x

stays the same. But sometimes we use the samename�f�after we make such a change.