# Lecture 4: more on functions

reading: MCS 4.3-4.4

- basic function definitions
- 'jectivity (injectivity, bijectivity, surjectivity)
- composition
- image
- cardinality relations

## Definitions

A function \(f : A → B\) is

**injective** (or one-to-one) if for all \(a_1, a_2 \in A\), if \(f(a_1) = f(a_2)\) then \(a_1 = a_2\). Stated another way, different inputs give different outputs.

**surjective** (or onto) if for all \(b \in B\), there is some \(a \in A\) with \(f(a) = b\).

**bijective** if it is both injective and surjective

If \(f : A → B\) and \(g : B → C\) then the **composition** of \(g\) and \(f\) (written \(g \circ f\)) is the function \(g \circ f : A → B\) given by \((g \circ f)(a) := g(f(a))\).

The **image** of \(f : A → B\) is the set of elements of \(b\) that are "hit" by \(f\), i.e. \(\{b \in B \mid ∃a ∈ A. f(a) = b\}\).

Some sources use "range" to refer to the image, while others use range to refer to the codomain. For this reason, I avoid the term range.

## Cardinality definitions

If \(A\) and \(B\) are sets, then

\(|A|\) should be read as "the cardinality of \(A\)", and thought of as the size of \(A\), but do not use this definition in proofs, since it only applies to finite sets. For now, avoid writing \(|A|\) by itself.

- We say \(|A| ≤ |B|\) if there exists an injection \(f\) from \(A\) to \(B\)
- We say \(|A| ≥ |B|\) if there exists a surjection \(f\) from \(A\) to \(B\)
We say \(|A| = |B|\) if there exists a bijection \(f\) from \(A\) to \(B\)

**Note:** these are *definitions*; however they are motivated by the intuition from finite sets.

**Note:** as always, the quantifiers are important. Students sometimes write \(|A| ≤ |B|\) if \(A\) and \(B\) is injective, or something similar. This doesn't make sense; injectivity is a property of functions. There may be many functions between \(A\) and \(B\), some of which are injections, and some of which are not.

These definitions are dangerous, in the sense that we have a lot of intuition about how \(≤\) and \(≥\) behave, and it is not clear *a priori* that these definitions match our intuition. Whenever giving new definitions for preexisting symbols, it is good to enumerate your intuitions and check that they still hold, so that you don't accidentally use false things in proofs. For example, the following are all true but not obvious:

- \(|A| ≤ |B|\) if and only if \(|B| ≥ |A|\)
- \(|A| = |B|\) if and only if \(|A| ≤ |B|\) and \(|A| ≥ |B|\)
- if \(|A| ≤ |B|\) and \(|B| ≤ |C|\) then \(|A| ≤ |C|\)
- \(|A| = |A|\)

We will prove them in coming lectures/homeworks