# Lecture 4

Given two functions $f:A\rightarrow B$ and $g:B\rightarrow C$, we can define their *composite* $g\circ f:A\rightarrow C$ by the rule: $(g\circ f)(x) = g(f(x)).$

Functions don’t have to be described by formulae (as they are in the examples, and non-examples, above).

For example, if the domain is finite we can define them pictorially. Accordingly, here is a function from the set $T$ of Teletubbies, as considered earlier, to the set of colours:

Now we’re well-equipped to describe functions, we can start describing their properties.

Here are some useful words.

**Definition:** A function $f:A\rightarrow B$ is said to be *injective* if, for any two elements $a_1,a_2\in A$ with $a_1\neq a_2$, then $f(a_1)\neq
f(a_2)$. I think of this as saying that “nothing is hit twice”, or equivalently that “no two elements of the domain have the same image”.

**Definition:** A function $f:A\rightarrow B$ is said to be *surjective* if, for every element $b\in B$, there is some element $a\in A$ with $f(a)=b$. I think of this as saying that “every element of the codomain is hit at least once”.

**Definition:** A function $f:A\rightarrow B$ is said to be *bijective* if it is both injective and surjective. I think of this as saying that “every element of the codomain is hit exactly once”.

For example, let’s consider our function assigning colours to Teletubbies.

It is injective, because each one of the Teletubbies has a different colour.

However, it is not surjective, because there are no pink Teletubbies in all of Teletubbyland. Hence it is also not bijective.

Also, note that these properties (injective, surjective, bijective) don’t just depend on the rule that defines it: they depend on the domain and codomain.

For example, consider the rule $f(n)=n^2$. Is this injective, considered as a function $f:\mathbb{N}\rightarrow\mathbb{N}$?

Yes! Every natural number has a different square.

Is it injective as a function $f:\mathbb{Z}\rightarrow\mathbb{Z}$?

No; $f(3) = f(-3)$.

Similarly, consider the rule $g(n) = n+100$. Is this surjective, considered as a function $g:\mathbb{N}\rightarrow\mathbb{N}$?

No; there is no $a\in\mathbb{N}$ with $g(a)=50$.

Is it surjective as a function $g:\mathbb{Z}\rightarrow\mathbb{Z}$?

Yes it is! For any $n$ we have $g(n-100)=n$.

Note that that function also has an *inverse*, a function which undoes $g$. Namely, we can take the inverse $g^{-1}:\mathbb{Z}\rightarrow\mathbb{Z}$ to be $g^{-1}(n) = n-100$.

You’ll see a lot more about inverses next semester.

By the way, I’d like you to try to remove phrases like “one-to-one” from your vocabulary: it’s never clear whether “$f$ is one-to-one” means “$f$ is injective”, “$f$ is bijective”, or simply “$f$ is a function”, and many people who use it treat this as an excuse for not explaining which they mean.

# Logic

Now we’ll briefly move on to another building block of mathematics: logic. Logic studies the properties of statements, which can be either *true* or *false*.

## Implication

Much of logic involves deductive reasoning. Here’s the definition that encapsulates that:

**Definition:** Let $A$ and $B$ be statements. We say that *$A$ implies $B$*, written $A\Rightarrow B$, to mean “if $A$ is true, then $B$ also has to be true”.

There are many common ways of saying the same thing, used by mathematicians. These include:

$A$ implies $B$;

$A\Rightarrow B$;

If $A$, then $B$;

$A$ only if $B$;

$A$ is sufficient for $B$;

$B$ is necessary for $A$.

Notice that $A\Rightarrow B$ cannot be used to mean “$A$ is true, and so $B$ is also true”.

For example, let $A$ be the statement “I visited Cardiff last week”, and $B$ be the statement “I’ve been to Wales this month”. We can all agree that $A\Rightarrow B$ is true, which says

“If I visited Cardiff last week, then I must have been to Wales in the last month.”

However, as it happens, neither of these is true: in fact, I haven’t been in Wales for a while longer than that.

As such, it is quite different to saying “$A$ is true, and therefore $B$ is also true”. Beginning students often get these confused.

The implication $A\Rightarrow B$ only says something interesting about $B$ if $A$ happens to be true! If $A$ is false, then we have $A\Rightarrow B$ no matter whether $B$ is true or false.

For example, it’s correct to say

“If $2+2=337$, then this course is lectured by Dr Cranch”.

or indeed

“If $2+2=337$, then this course is lectured by Robert de Niro”.

This may be a surprise if you’re basing your intuition on ordinary English, where people use the words “if…then” in several different ways, sometimes slightly ambiguously.

Another important point is that if $A\Rightarrow B$ does not say that $B$ is true *only* if $A$ is true (that would be $B\Rightarrow A$, in fact).

So it’s correct to say

If it rains next Wednesday, then $2+2=4$.

In fact, it’s true that $2+2=4$ no matter whether it rains next Wednesday, but that’s not a problem. Whether or not it’s *helpful* to say that is another question!

We can sum up the comments above by giving a *truth table* for implication. We write $0$ for false and $1$ for true.

First off, note that if $Q$ is true, then $P\Rightarrow Q$ is definitely true no matter whether $P$ is true.

Also, if $P$ is false, then $P\Rightarrow Q$ is true no matter whether $Q$ is true.

In fact, it’s only if $P$ is true and $Q$ is false that $P\Rightarrow Q$ is false.

$P$ | $Q$ | $P\Rightarrow Q$ |
---|---|---|

0 | 0 | 1 |

0 | 1 | 1 |

1 | 0 | 0 |

1 | 1 | 1 |