2.1. Function Notation

The expression \(f: A \rightarrow B\) represents the function \(f\) that takes an element of the set \(A\) to an element of the set \(B\). For example, the function \(flip: \mathbb{R} \rightarrow \mathbb{R}\) accepts a real number (e.g. \(3.14\)) and multiplies it by \(-1\), returning another real number (e.g. \(-3.14\)).

The types \(A\) and \(B\) are allowed to represent Cartesian products of sets (e.g. \(A = A_1 \times \dots \times A_n\)), thus enabling multivariate functions. For example, the following are simple multivariate functions:

\[ \begin{align}\begin{aligned}power : \mathbb{R} \times \mathbb{N} \rightarrow \mathbb{R}\\halve : \mathbb{N} \rightarrow \mathbb{N} \times \mathbb{N}\end{aligned}\end{align} \]

where \(\mathbb{N}\) is the set of natural numbers. Invoking \(power(1.5, 2)\) results in the real number \(1.5^2 = 2.25\), whereas invoking \(halve(5)\) divides \(5\) by \(2\), returning the pair \((2, 1)\), where the first number is the quotient, and the second is the remainder.

It is conventional to use parentheses to denote the application of the function \(f\) to an argument \(x\) —i.e. \(f(x)\). To avoid cluttered expressions in this document, however, we adopt an alternative whereby the parentheses are omitted and whitespace is used to delimit the function and its argument(s):

\[ \begin{align}\begin{aligned}f(x) &\Longrightarrow f\ x\\h(g(y)) &\Longrightarrow h\ (g\ y) = h\ g\ y\end{aligned}\end{align} \]

In mathematical expressions, parentheses are then reserved in this document to specify:

  1. A tuple of arguments that serve as input to a single function invocation (e.g. \(power\ (1.5, 2)\) above) [1].

  2. The binding of user-defined algorithms to higher-order functions (see Section 2.5).

Footnotes