Lecture 16 Notes

In this lecture we look at the following topics:

  • Inverses of functions and relations

  • Composition of functions and relations

  • Invertibility of functions.

Inverses

We will first talk about inverse relations. Let R subseteq A times B be a relation. Its inverse is defined as

 R^{-1} = { (b,a) | (a,b) in R } ,.

Note that R^{-1} subseteq B times A. In other words, we flip the domain and co-domain of R. We also flip the tuples in R. I.e., if (a,b) in R then (b,a) in R^{-1} and vice versa.

Example

As an example, write down the inverse of the following relation:

200

Example-2

Consider the relation R subseteq mathbb{N} times {N} defined as R = { (m,n) in mathbb{N}times mathbb{N} |  | m -n | leq 1 }. Show that R^{-1} = R.

Answer

To show that, we will first show that if (m,n) in R then (n,m) in R.

Let (m,n) in R. We have |m-n| leq 1. Therefore, |n-m| = |m-n| leq 1. Therefore, if (m,n) in R then (n,m) in R.

Now, it is easy to show that (a) R^{-1} subseteq R and (b) R subseteq R^{-1}.

Inverse of a Function

The inverse of a function is always a relation. On the other hand, the inverse of a function need not always be a function. For the figures below, say whether the function represented has an inverse or not.

400

The top left function has an inverse. The others do not.

We can look at graphs of functions to check if an inverse exists. Does the function depicted below have an inverse?

400

We will expand on these topics when we learn about one-to-one and onto functions in the next lecture.

Compositions of Relations and Functions

Given two functions or two relations, we can talk about the functional and relational compositions, respectively.

Function Composition

Let us take two functions f: A rightarrow B and g: B rightarrow C. Function composition captures the application of f followed by g to get a new function g circ f: A rightarrow C, defined by

 gcirc f (x) = g ( f ( x) )

The order of composition is important. Please note.

Examples of Function Composition

We will now do some examples.

Example 1

Take f: mathbb{N} rightarrow mathbb{N} where f (n) = n^2 and g = mathbb{N} rightarrow mathbb{N} with g(n) = n+2.

What is f circ g(n) and g circ f(n)? Explain the difference by writing them out in closed form.

Answer f circ g says that we first apply g to n and then apply f on the result. Therefore we obtain f circ g (n) = (n+2)^2.

g circ f says that we first apply f and then apply g to yield g circ f (n) = n^2 +2.

The order of composition can be really confusing.

Relation Composition

Relation composition is similar to function composition. It is an important operation in databases and is therefore called a join of two relations in database jargon.

Let R subseteq A times B and S subseteq B times C be two relations. We say that the composition S circ R of R and S is a relation  S circ R subseteq A times C such that

 S circ R = { (a,c) | exists b in B, (a,b) in R  land (b,c) in S }

The picture below provides an illustration:

400

We see that (3,A) in R and (A,X) in S. Therefore (3,X) in (S circ R). What other tuples exist in S circ R?

Answer S circ R = { (3,X), (2,Y), (4,Y), (5,Y), (6,Y) }.

Example-2

Suppose we provide a social network between people in the class in the form of the Friends relation, where (x,y) in F iff x is a friend of y. How do we find friends of friends?

Answer Simply do F circ F.

Example-3

Suppose we have a relation R on movie stars wherein (x,y) in R signifies that person x and y acted in the same film together. We wish to find out all people with six degrees of separation from Kevin Bacon. How do we do that?

The answer is to find the relation

 R cup (Rcirc R) cup (R circ R circ R) cup cdots cup (R circ R circ R circ R circ R circ R)

Invertibility of Functions

Let us now investigate the question of invertibility of functions. Suppose f: A rightarrow B is a function from A to B, under what conditions does f have an inverse function?

Informally we can say the following:

  • f cannot map many elements of A to the same element of B.

  • f cannot leave any element of B unmapped to.

400

Therefore, we define the following properties of functions:

  • f is one-to-one (injective) if f maps every element of A to a unique element in B. In other words no element of B are mapped to by two or more elements of A.

  • f is onto (surjective)if every element of B is mapped to by some element of A. In other words, nothing is left out.

  • f is one-to-one onto (bijective) if it is both one-to-one and onto. In this case the map f is also called a one-to-one correspondence.