A function f from a set A to a set B is an assignment of exactly one element of B to each element of
A. More generally, we write f : A → B to mean f ∈ A → B.
Example:
- Suppose I’m teaching a class with 5 students, S = {Alice, Bob, Carroll, David, Eve }. At the end
of the class, I need to assign marks from 1 to 10 to each student. More precisely, this
determines a function
We write marks(x) = y when a student x is assigned the mark y by the marks function. Crucially, each
student is assigned a single grade. This rules out situations such as: marks(Alice) = 7 and
marks(Alice) = 10. Furthermore, the marks function should assign a mark to every student. That is,
for each student s in S, there is a mark m in {1..10} such that marks(s) = m. A function A → B must
map every element a ∈ A to a single element b ∈ B. In other words f maps each element a of A to an
element b = f(a), which we will also denote by f : a -> b. So there won’t be a output where 2 numbers
are associated with it.
It is possible for a function f : A -> B to assign the same value from B to two different values of A. So
marks(Bob) = 8 and marks(Carroll) = 8.
Given a function f : A → B we introduce the following terminology:
- We call the set A the domain of the function;
- The set B is the codomain of the function;
- If f(a) = b we refer to a as an argument of the function f, and to b as the value of the
function f on argument a.
- If a function takes more than one argument, f : A1 × A2 × A3 … An we refer to the number of
arguments as the arity. Example: f: A x B x C has 3 numbers of arguments
- A function with two arguments is sometimes called a binary function; often we use infix
notation, writing x + y rather than +(x,y).
- The range of f is the subset of B that f can produce: range(f) = {f(a)|a ∈ A}