How can you get a pre-image from the inverse if it's not defined? From Discrete Math course notes on Inverse functions

If a function $g:\mathbb{Z}\rightarrow\mathbb{Z}$ is many-to-one, then it does not have an inverse function. This makes the notation $g^{−1}(3)$ meaningless. Nonetheless, $g^{-1}(\{3\})$ is well-defined, because it means the preimage of {3}. If $g^{−1}(\{3\})=\{1,2,5\}$, we know $g(1) = g(2) = g(5) = 3$.

Why are we allowed to say $g^{-1}(D)$ where D is a set if $g^{-1}$ is undefined? Is this just a notational sleight of hand, where $g^{-1}$ is not taken to refer to an inverse function, but rather only to the domain of $g$, when you pass in a set? It seems nonsensical to pass a parameter in to a function that does not exist.
Or is $g^{-1}$ actually defined but not as a function, but rather as a relation?
 A: It is mostly a notational sleight of hand, and a matter of definitions. Essentially, $g^{-1}$ is doing a lot of legwork here.

*

*When given a specified value and when $g$ is invertible, $g^{-1}(y)$ for that single value $y$ gives you the $x$ such that $g(x) = y$.


*Regardless of the invertibility, when we are dealing with a set $S$ (be it a singleton or otherwise), we define the symbol $g^{-1}(S)$ to be all elements of the domain which are sent into $S$ by $g$, i.e.
$$g^{-1}(S) \stackrel{\text{def}}{=} \{ x \in \mathrm{domain}(g) \mid g(x) \in S \}$$
Notice how this does not depend on invertibility. (If it is invertible, then $S$ will be the same size as the output set, loosely speaking.)

Be sure to notice a distinction: the first takes in and puts out values; the second takes in and puts out sets. Even when the function is invertible, in fact. Taking $g(x) = x^3$ and $g : \mathbb{R} \to \mathbb{R}$ as an example,
$$g^{-1}(8) = 2 \text{ whereas } g^{-1}(\{8\}) = \{2\}$$
Another example of note would be $g : \mathbb{R} \to \mathbb{R}$ with
$$
g(x) = \begin{cases}
1 & x = 0 \\
0 & x \ne 0
\end{cases}
$$
This function is not invertible (since, for instance, $g(2) = g(3) = 0$). Hence the notion of $g^{-1}(0)$ is undefined (as a single value). However, we can see that
$$
g^{-1}(\{0\}) = \mathbb{R} \setminus \{0\} \qquad
g^{-1}(\{1\}) = \{0\}
$$
because every real number except $0$ is sent to $0$, and $0$ itself is sent to $1$.

Consequently, whether it is intended for you to interpret $g^{-1}$ as a set or a value ultimately depends on the context, namely:

*

*Is $g$ invertible?

*More importantly, are you looking at a set or a single value?

Admittedly it is a bit of an overloaded notation and can cause some confusion, but I think interpreting the set case as a "generalization" of the value case makes that idea more evocative.
