Image and preimage of a function (source code)

= Image and preimage of a function

The <image of a function> asks which outputs a chosen <set> of inputs reaches. A <preimage> asks which inputs reach a chosen <set> of outputs. Both constructions apply to every <function>, including one that loses information by sending several inputs to the same output. Their difference is useful whenever a transformation must be followed forward or a condition on its result must be traced back.

Consider the <function> $f:A\to B$ with
$$
A=\{a,b,c,d\},\qquad B=\{0,1,2,3\},\qquad
f(a)=f(b)=0,\quad f(c)=1,\quad f(d)=2.
$$
Every input has exactly one output, but zero has two inputs and three has none. The full <image of a function> is $f(A)=\{0,1,2\}$, a proper <subset> of the <codomain> $B$. Selecting inputs $\{a,c\}$ gives image $\{0,1\}$. Selecting outputs $\{0,2\}$ instead gives <preimage> $\{a,b,d\}$.

\Image[/function-image-preimage-subset-flow.png]
{title=The same <function> sends a selected input <set> forward and pulls a selected output <set> back}
{description=The full <codomain> contains three, which is never reached. Two inputs share output zero, so a <preimage> can recover a <set> of candidates without providing a unique <inverse function>.}

The <function> is not <injective>, because $f(a)=f(b)$, and is not <surjective> onto $B$, because three is absent from its image. Restricting only the <codomain> to $\{0,1,2\}$ makes the same rule <surjective>; it remains noninjective. This separates the output set actually reached from the target set specified in the definition. The definitions of <images of a function> and <preimages>, including the distinction from an <inverse function>, are given in https://richardhammack.github.io/BookOfProof/Main.pdf[Richard Hammack, Book of Proof, §12.6: Image and Preimage].