Following a Set Through Two Functions
The previous tutorial compared images and preimages for one function. Composition allows us to extend that comparison to a sequence of functions. Suppose \(f:A\to B\) and \(g:B\to C\). The composition \(g\circ f:A\to C\) first applies \(f\), then applies \(g\), so $$ (g\circ f)(x)=g(f(x)) \qquad (x\in A). $$ The output of \(f\) lies in \(B\), which is exactly the domain of \(g\), so the second evaluation is defined.
For a set \(S\subseteq A\), there are two natural ways to find the outputs reached after both steps. We can form the composite and take \((g\circ f)[S]\), or first take \(f[S]\) and then take \(g[f[S]]\). These procedures describe the same outputs. For a target set \(T\subseteq C\), the corresponding preimage calculation also has a natural order: first identify the \(B\)-values that \(g\) sends into \(T\), then identify the \(A\)-values that \(f\) sends into that set.
These identities are useful because they let us work with a composite without repeatedly expanding its formula. They are also a careful test of notation: every image or preimage must be applied to a set in the appropriate domain or codomain.
Images Under a Composition
Let \(S\subseteq A\). By definition, an element \(z\) belongs to \((g\circ f)[S]\) exactly when there is some \(x\in S\) such that \(z=(g\circ f)(x)\). Since \((g\circ f)(x)=g(f(x))\), the intermediate value \(f(x)\) belongs to \(f[S]\), and \(z\) belongs to \(g[f[S]]\). The membership condition therefore leads to an exact identity.
Theorem (Image of a Set Under a Composition). Let \(f:A\to B\), \(g:B\to C\), and \(S\subseteq A\). Then $$ (g\circ f)[S]=g[f[S]]. $$
Proof. We prove equality by showing that an arbitrary object belongs to one set if and only if it belongs to the other. Let \(z\) be any object. By the definition of image, $$ z\in(g\circ f)[S] \quad\Longleftrightarrow\quad \text{there exists }x\in S\text{ such that }z=(g\circ f)(x). $$ By the definition of composition, this is equivalent to the existence of \(x\in S\) such that \(z=g(f(x))\). For such an \(x\), the definition of image gives \(f(x)\in f[S]\), and \(z=g(f(x))\) then gives \(z\in g[f[S]]\).
Conversely, suppose \(z\in g[f[S]]\). By the definition of image, there exists \(y\in f[S]\) such that \(z=g(y)\). Since \(y\in f[S]\), there exists \(x\in S\) such that \(y=f(x)\). Substitution gives \(z=g(f(x))=(g\circ f)(x)\). Thus \(z\in(g\circ f)[S]\). Membership holds in both directions, so equality follows by the Equality of Condition-Defined Sets Theorem. \(\square\)
Notice that no injectivity or surjectivity assumption is required. The theorem only uses the definitions of image and composition. It also works when \(S\) is empty: both sides are empty, since no input in the empty set can produce an image value.
Worked Example: A Finite Set Passed Through Two Maps
Let \(A=\{1,2,3,4\}\), \(B=\{a,b,c\}\), and \(C=\{0,1\}\). Define \(f:A\to B\) by $$ f(1)=a,\quad f(2)=b,\quad f(3)=a,\quad f(4)=c, $$ and define \(g:B\to C\) by \(g(a)=1\), \(g(b)=0\), and \(g(c)=1\). Take \(S=\{2,3,4\}\). First, $$ f[S]=\{a,b,c\}, \qquad g[f[S]]=\{0,1\}. $$ The composite sends \(2\) to \(0\), \(3\) to \(1\), and \(4\) to \(1\), so $$ (g\circ f)[S]=\{0,1\}=g[f[S]]. $$ The values in the image are outputs, not the number of inputs that produce them: although \(3\) inputs are in \(S\), the image contains only the two distinct outputs \(0\) and \(1\).
Preimages Under a Composition
For preimages, start with a target \(T\subseteq C\). An input \(x\in A\) belongs to \((g\circ f)^{-1}[T]\) when \(g(f(x))\in T\). This condition says first that \(f(x)\) belongs to \(g^{-1}[T]\); it then says that \(x\) belongs to the preimage of that set under \(f\). The order of functions is reversed when applying preimages.
Theorem (Preimage Under a Composition). Let \(f:A\to B\), \(g:B\to C\), and \(T\subseteq C\). Then $$ (g\circ f)^{-1}[T]=f^{-1}[g^{-1}[T]]. $$
Proof. Let \(x\) be any object. By the definition of preimage and composition, $$ x\in(g\circ f)^{-1}[T] \quad\Longleftrightarrow\quad x\in A\text{ and }g(f(x))\in T. $$ The condition \(g(f(x))\in T\), together with \(f(x)\in B\), means by the definition of preimage that \(f(x)\in g^{-1}[T]\). Therefore the displayed condition is equivalent to $$ x\in A\text{ and }f(x)\in g^{-1}[T], $$ which is exactly the condition \(x\in f^{-1}[g^{-1}[T]]\). The membership conditions are equivalent for every object \(x\), so the sets are equal by the Equality of Condition-Defined Sets Theorem. \(\square\)
The notation on the right can be read from the inside out: \(g^{-1}[T]\) is a subset of \(B\), and its preimage under \(f\) is a subset of \(A\). This is not the inverse-function operation from the theory of bijections. Here each \(f^{-1}[\cdot]\) denotes the preimage of a set, which is defined for every function.
Worked Example: A Target Set for Two Real Functions
Define \(f:\mathbb R\to\mathbb R\) by \(f(x)=x+1\) and \(g:\mathbb R\to\mathbb R\) by \(g(y)=y^2\). Their composite is $$ (g\circ f)(x)=(x+1)^2. $$ Let \(T=[1,4]\). To find the preimage under the composite, solve $$ 1\leq (x+1)^2\leq4. $$ Equivalently, \(x+1\in[-2,-1]\cup[1,2]\), so $$ (g\circ f)^{-1}[T]=[-3,-2]\cup[0,1]. $$ Now compute by taking preimages in reverse order. Since \(g(y)=y^2\), $$ g^{-1}[T]=[-2,-1]\cup[1,2]. $$ Under \(f(x)=x+1\), the preimage of the first interval is \([-3,-2]\), and the preimage of the second is \([0,1]\). Thus $$ f^{-1}[g^{-1}[T]]=[-3,-2]\cup[0,1]=(g\circ f)^{-1}[T], $$ as the theorem predicts.
Keeping the Order and the Types Straight
The image and preimage identities have different orders because the operations answer different questions. To find where a set of inputs goes, start at the input set and move forward. To find which inputs reach a target set, start at the target and move backward. The following table summarizes the domains and codomains involved.
| Operation | Set calculation | Where the result lies |
|---|---|---|
| Image under the composite | \((g\circ f)[S]=g[f[S]]\) | Subset of \(C\) |
| Preimage under the composite | \((g\circ f)^{-1}[T]=f^{-1}[g^{-1}[T]]\) | Subset of \(A\) |
| First image step | \(f[S]\) | Subset of \(B\) |
| First preimage step | \(g^{-1}[T]\) | Subset of \(B\) |
A common error is to write \(g^{-1}[f^{-1}[T]]\) for the preimage of \(T\) under \(g\circ f\). That expression starts by applying \(f^{-1}\) to \(T\), even though \(T\subseteq C\) and a preimage under \(f:A\to B\) requires a subset of \(B\). It is not generally a well-typed expression. The correct order begins with \(g^{-1}[T]\), which lies in \(B\), and then applies \(f^{-1}\).
The composition identities also work together with earlier results about images and preimages. For example, the Image of a Union Theorem can be applied to either stage of \(g[f[S]]\), and the Preimages of Unions and Intersections Theorem can be applied to either stage of \(f^{-1}[g^{-1}[T]]\). These earlier results need no new assumptions beyond having the indicated sets in the appropriate domains and codomains.
Worked Example: A Composition with Different Intermediate Values
Let \(A=\{p,q,r\}\), \(B=\{u,v,w\}\), and \(C=\{\alpha,\beta,\gamma\}\). Define \(f:A\to B\) by \(f(p)=u\), \(f(q)=v\), and \(f(r)=u\). Define \(g:B\to C\) by \(g(u)=\alpha\), \(g(v)=\beta\), and \(g(w)=\gamma\). If \(S=\{p,r\}\), then $$ f[S]=\{u\} \quad\text{and}\quad g[f[S]]=\{\alpha\}. $$ The composite sends both \(p\) and \(r\) to \(\alpha\), so \((g\circ f)[S]=\{\alpha\}\), in agreement with the image identity.
For the preimage calculation, take \(T=\{\alpha,\gamma\}\). First, $$ g^{-1}[T]=\{u,w\}. $$ But \(f\) never takes the value \(w\), so $$ f^{-1}[g^{-1}[T]]=f^{-1}[\{u,w\}]=\{p,r\}. $$ Directly, the composite takes \(p\) and \(r\) to \(\alpha\), and \(q\) to \(\beta\); hence \((g\circ f)^{-1}[T]=\{p,r\}\). The intermediate value \(w\) creates no extra input because it is not attained by \(f\).
A Reliable Method for Composition Problems
When proving or calculating an identity involving sets and composed functions, it helps to make each stage explicit. Writing a membership condition usually removes ambiguity: image membership introduces an existentially chosen input, while preimage membership states that a function value lies in a target set. Then the definition of composition replaces one function value with two successive evaluations.
Check Your Understanding
- If \(f:A\to B\) and \(g:B\to C\), what condition makes the composition \(g\circ f\) well-defined?
- State the identity for the image of \(S\subseteq A\) under \(g\circ f\).
- State the identity for the preimage of \(T\subseteq C\) under \(g\circ f\), including the order of the preimage operations.
- Let \(f(x)=x-2\) and \(g(y)=3y\), both on \(\mathbb R\). Find \((g\circ f)(x)\), then compute \((g\circ f)[\{1,4\}]\) by applying the two functions in stages.
- For the same functions, find \((g\circ f)^{-1}[\{0,6\}]\) by first computing \(g^{-1}[\{0,6\}]\), then taking its preimage under \(f\).