Skip to content
Part IA Michaelmas, Lent Term

Functions: Partial and Total

Partial Functions

Definition

A relation f:A↛Bf : A \nrightarrow B is functional (or a partial function) if:

∀a∈A.∀b1,b2∈B.(afb1∧afb2⇒b1=b2)\forall a \in A. \forall b_1, b_2 \in B. (afb_1 \land afb_2 \Rightarrow b_1 = b_2)

Each input aa is related to at most one output.

Notation

  • f(a)↓f(a)\downarrow means ff is defined at aa (there exists bb with afbafb)
  • f(a)↑f(a)\uparrow means ff is undefined at aa
  • When defined, f(a)f(a) denotes the unique bb with afbafb

Domain

The domain of partial function f:A↛Bf : A \nrightarrow B is:

dom(f)={a∈A:f(a)↓}\text{dom}(f) = \{a \in A : f(a)\downarrow\}

Total Functions

Definition

A partial function f:A↛Bf : A \nrightarrow B is total if dom(f)=A\text{dom}(f) = A.

We write f:A→Bf : A \to B for a total function from AA to BB.

Verification: For all a∈Aa \in A, there exists exactly one b∈Bb \in B with afbafb.

Examples

FunctionTotal?Notes
f:R→R,f(x)=x2f : \mathbb{R} \to \mathbb{R}, f(x) = x^2YesDefined everywhere
f:R↛R,f(x)=xf : \mathbb{R} \nrightarrow \mathbb{R}, f(x) = \sqrt{x}PartialOnly defined for x≥0x \geq 0
f:R↛R,f(x)=1/xf : \mathbb{R} \nrightarrow \mathbb{R}, f(x) = 1/xPartialUndefined at x=0x = 0

Cardinality of Function Spaces

Partial Functions

∣A↛B∣=(∣B∣+1)∣A∣|A \nrightarrow B| = (|B| + 1)^{|A|}

Each of the ∣A∣|A| inputs independently chooses one of ∣B∣|B| outputs or “undefined”.

Total Functions

∣A→B∣=∣B∣∣A∣|A \to B| = |B|^{|A|}

Each of the ∣A∣|A| inputs independently chooses one of ∣B∣|B| outputs.

Example

For A={0,1}A = \{0, 1\} and B={a,b}B = \{a, b\}:

  • ∣A→B∣=22=4|A \to B| = 2^2 = 4: constant functions x↦ax \mapsto a, x↦bx \mapsto b, swap 0↦a,1↦b0 \mapsto a, 1 \mapsto b, swap 0↦b,1↦a0 \mapsto b, 1 \mapsto a
  • ∣A↛B∣=(2+1)2=9|A \nrightarrow B| = (2+1)^2 = 9: the 4 total functions plus 5 partial ones

Composition of Functions

Partial Function Composition

Given f:A↛Bf : A \nrightarrow B and g:B↛Cg : B \nrightarrow C, define g∘f:A↛Cg \circ f : A \nrightarrow C by:

(g∘f)(a)={g(f(a))if f(a)↓ and g(f(a))↓undefinedotherwise(g \circ f)(a) = \begin{cases} g(f(a)) & \text{if } f(a)\downarrow \text{ and } g(f(a))\downarrow \\ \text{undefined} & \text{otherwise} \end{cases}

Total Function Composition

Given f:A→Bf : A \to B and g:B→Cg : B \to C, the composite g∘f:A→Cg \circ f : A \to C is always total:

∀a∈A.(g∘f)(a)=g(f(a))\forall a \in A. (g \circ f)(a) = g(f(a))

Closure Properties

  • The composite of two functional relations is functional
  • The composite of two total functions is total

Identity Function

The identity function idA:A→A\text{id}_A : A \to A is:

idA(a)=afor all a∈A\text{id}_A(a) = a \quad \text{for all } a \in A

This is total and serves as the unit for composition.

Function Application vs Relational Image

For a function f:A→Bf : A \to B and S⊆AS \subseteq A:

  • Direct image: f(S)={f(a):a∈S}⊆Bf(S) = \{f(a) : a \in S\} \subseteq B
  • Inverse image: f−1(T)={a:f(a)∈T}⊆Af^{-1}(T) = \{a : f(a) \in T\} \subseteq A

These extend relational images to the functional case.


Summary

  • A partial function f:A↛Bf : A \nrightarrow B maps each aa to at most one bb
  • A total function f:A→Bf : A \to B maps each aa to exactly one bb
  • ∣A→B∣=∣B∣∣A∣|A \to B| = |B|^{|A|} and ∣A↛B∣=(∣B∣+1)∣A∣|A \nrightarrow B| = (|B|+1)^{|A|}
  • Composition preserves functionality; total functions are closed under composition