Is there a difference between $g(x): x \mapsto f(x)$ and $g(x):=f(x)$?

78 Views Asked by At

Assume that $f$, $f_1$, and $f_2$ are arbitrary functions.

I have looked at several different scenarios to see if $g: x \mapsto f(x)$ would ever be syntactically preferable, to no avail:

$$ g: x \mapsto f(x) \quad\equiv\quad g(x):=f(x) \\ g: x,y \mapsto f(x,y) \quad\equiv\quad g(x,y):=f(x,y) \\ g: \begin{cases} x \mapsto f_1(x) \\ y \mapsto f_2(y) \end{cases} \mid x \in X \land y \in Y \quad\equiv\quad g(x):=\begin{cases} f_1(x) & x \in X \\ f_2(x) & x \in Y \end{cases} \\ g: \begin{cases} X \to Z \\ x \mapsto f(x) \end{cases} \quad\equiv\quad g(x):=f(x) \mid x \in X \land f(x) \in Z $$

None of these cases make the first option seem preferable... not even the last one, considering that $X$ and $Z$ must be predefined for it to not be ugly:

$$ g: \begin{cases} \left\{n \mid n \in \Bbb Z \land n \gt 10\right\} \to \left\{f(n) \mid n \in \Bbb Z \land n \gt 10\right\} \\ x \mapsto 2x+1 \end{cases} \quad\equiv\quad \\ g: \begin{cases} X \to Y \\ x \mapsto 2x+1 \end{cases} \mid X,Y := \left\{ n, f(n) \mid n \in \Bbb Z \land n \gt 10 \right\} \quad\equiv\quad \\ g(x):=2x+1 \mid x \in \Bbb Z \land x > 10 $$

So it doesn't make sense to me why the first option even exists.


Wikipedia, says that...

  • $A:B$ should be interpreted as "$A$ is defined by $B$"
  • $A:=B$ should be interpreted as "$A$ is defined as equal to $B$"

But I don't see any functional difference between the two. Am I missing something?


Edit: here's a much simpler explanation of my question. I don't understand why the parallel between $\to$ and $\mapsto$ is so flawed:

  • Given a function $f : a \mapsto b$...
    • Domain: $x = a$
    • Codomain: $y = b$
    • Range: $f(x) = f(a)$
  • Given a function $f : A \to B$...
    • Domain: $X = \left\{ a \mid a \in A \right\}$
    • Codomain: $Y = \left\{ b \mid b \in B \right\}$
    • Range: $f[X] = \left\{ f(x) \mid x \in X \right\} = f[A] = \left\{ f(a) \mid a \in A \right\}$
1

There are 1 best solutions below

6
On BEST ANSWER

Ported from comments:

Anonymous functions are often used in function arguments, especially computer science. For example, define $f:g\mapsto(x\mapsto g(g(x)))$ and then write $f(x\mapsto\sin(x))(x)=\sin(\sin(x))$. Of course, such writing is usually simply for the sake of convenience.

Another example of when it may be cumbersome to write it with $g(x)=f(x)$ is if you want to refer to $g$ as it's own stand-alone object. It is, imo, clearer to write $g:x\mapsto x^2$, and then write something such as $g\circ g\ne\operatorname{id}$, opposed to writing $g(x)=x^2$ and $g(g(x))\ne x$, since the latter is not actually true for $x=0,1$. Or, perhaps, when currying a function, it is a bit cleaner.

In programming the latter case occurs more often than one may think at first. Many languages support functions, which are defined somewhat like $g(x)=f(x)$, but then it is impossible to reference $g$ alone. The alternative is usually called a lambda function or similar. You can find many programming examples of when these are preferable to use just by asking Google.