42. Anonymous notation for functions
The curly-brackets notation for sets has the advantage that it allows you to refer to a set without giving it a name. For example, you can say, “$\{ 1, 2, 3\}$ has three elements,” instead of, “The set $A$ whose elements are 1, 2 and 3 has three elements.” This is useful when you only want to refer to it once or twice. A notation which describes without naming is called anonymous notation.
The notation we have introduced for functions does not have that advantage. When the two versions of the squaring function were discussed, it was necessary to call them $S$ and $T$ in order to say anything about them.
42.1 Lambda notation
Two types of anonymous notation for functions are used in mathematics. The older one is called lambda notation and is used mostly in logic and computer science. To illustrate, the squaring function would be described as “the function $\lambda x.x^{2}$”. The format is: $\lambda$, then a letter which is the independent variable, then a period, then a formula in terms of the independent variable which gives the value of the function. In the $\lambda$-notation, the variable is bound and so can be changed without changing the function: $\lambda x.x^{2}$ and $\lambda t.t^{2}$ denote the same function.
42.1.1 Example The function defined in Example 39.3.1 is $\lambda x.(x^{2} + 2x + 5)$.
42.1.2 Example On a set $A$, the identity function $\operatorname{id}_{A}$ is $\lambda x.x$.
42.2 Barred arrow notation
The other type of anonymous notation is the barred arrow notation, which has in recent years gained wide acceptance in pure mathematics and appears in some texts on computer science, too. In this notation, the squaring function would be called the function $x \mapsto x^{2}\colon \mathrm{R} \to \mathrm{R}$, and the function in Example 39.3.1 could be written $x \mapsto x^{2} + 2x + 5$.
The barred arrow tells you what an element of the domain is changed to by the function. The straight arrow goes from domain to codomain, the barred arrow from element of the domain to element of the codomain.
42.2.1 Example On a set $A$, the identity function $\operatorname{id}_{A}$ is $x \mapsto x\colon A \to A$.
42.2.2 Other notations One would write Function[x,x^2] or #^2& in Mathematica for $x \mapsto x^{2}$ or $\lambda x.x^{2}$. The # sign stands for the variable and the & sign at the end indicates that this is a function rather than an expression to evaluate. More complicated examples require parentheses; for example, $x \mapsto x^{2} + 2x + 5$ becomes (#^2+2 #+5)&.
42.2.3 Exercise Write the following functions using $\lambda$ notation and using barred arrow notation. $A$ and $B$ are any sets.
a) $F\colon \mathrm{R} \to \mathrm{R}$ given by $F(x) = x^{3}$.
b) $p_{1}\colon A\times B \to A$.
c) Addition on $\mathrm{R}$. (Answer on page 245.)
Pages 64–65 of the book (PDF).