Reading: MCS 4.3-4.5
If f:A→B and g:B→C then the composition of g and f (written g∘f)$ is the function g∘f:A→C given by (g∘f)(a):=g(f(a)).
Note: pay attention to the domains and codomains; with f and g as given, f∘g does not make sense, because g(b)∈C so f(g(b)) is not defined.
The identity function on a set A is the function idA:A→A given by idA(x):=x. We often omit A when it is clear from context.
If f:A→B and g:B→A, and g∘f=idA then we say f is a right-inverse of g and g is a left-inverse of f. The left- and right- refer to which side of the ∘ the function goes; g is a left-inverse of f because when you write it on the left of f, you get the identity.
The following claims are true:
Note: The way to remember (and prove) these is to draw yourself a picture of an injection (or surjection), draw the best inverse you can, and then see which way the composition works. If I don't draw a picture, I easily get left and right mixed up.
These are all good proofs to do as exercises. We did the first of them in class:
Claim: if f:A→B is injective and A≠∅, then f has a left-inverse.
Proof: Suppose f:A→B is injective. Note that since A≠∅, there exists some a0∈A. Let g:B→A be defined as follows. Given b∈B, if b=f(a) for some a in A, then let g(b):=a. If b is not in the image of f, then define g(b):=a0.
I claim g is a left-inverse of f. In other words, g∘f=id. In other words, ∀a∈A, g(f(a))=a. To see this, choose an arbitrary a∈A. Then f(a) is in the image of f, so by definition of g, we have g(f(a))=a′ for some a′ satisfying f(a′)=f(a). But since f is injective, we know a′=a, which is what we wanted to prove.
Note: While writing this proof, it helps to draw yourself a picture of a simple injective function, and think about how you would construct the inverse.
Claim: Suppose f:A→B has a left-inverse. Then f is injective.
Proof: Let g be a left inverse of f. Then g∘f=id. We want to show that f is injective, i.e. for all a1,a2∈A, if f(a1)=f(a2) then a1=a2. Choose arbitrary a1 and a2 and assume that f(a1)=f(a2). Applying g to both sides of the equation gives g(f(a1))=g(f(a2)). But g(f(a1))=a1 (and likewise for a2) so a1=a2.
The proofs of the remaining claims are mostly straightforward and are left as exercises. The proof of one direction of the third claim is a bit tricky:
Claim: If f:A→B is bijective, then it has a two-sided inverse.
Proof: Since f is bijective, by the previous claims we know it has a left inverse gl:B→A and a right inverse gr:B→A. I will show that gl=gr, which means that gl is a two-sided inverse.
To see this, choose an arbitrary b∈B. We want to show that gl(b)=gr(b). Consider gl(f(gr(b)). Since gl∘f=id, we have gl(f(gr(b))=gr(b). On the other hand, since f∘gr=id, we have gl(f(gr(b))=gl(b). Combining these shows gr(b)=gl(b) as required.