[guided]We now show that two functions satisfying the same primitive-recursion equations must agree at every [natural number](/page/Natural%20Number). Let
\begin{align*}
f,g : \mathbb{N}_0 \to C
\end{align*}
be two such functions. Since the equations are assumed propositionally, we record the witnesses. The base witnesses are
\begin{align*}
p_0^f : f(0)=c_0
\end{align*}
and
\begin{align*}
p_0^g : g(0)=c_0.
\end{align*}
For every $n : \mathbb{N}_0$, the successor witnesses are
\begin{align*}
p_S^f(n) : f(S(n)) = s(n,f(n))
\end{align*}
and
\begin{align*}
p_S^g(n) : g(S(n)) = s(n,g(n)).
\end{align*}
The predicate for induction is pointwise equality of the two functions. For terms $a,b : C$, the notation $\operatorname{Id}_C(a,b)$ denotes the identity type of paths from $a$ to $b$ in $C$. Define
\begin{align*}
Q : \mathbb{N}_0 \to \mathsf{Type}
\end{align*}
by
\begin{align*}
Q(n)=\operatorname{Id}_C(f(n),g(n)).
\end{align*}
Thus proving $\prod_{n:\mathbb{N}_0}Q(n)$ means proving $f(n)=g(n)$ for each natural number $n$.
For the base case, both $f(0)$ and $g(0)$ are equal to $c_0$. The path $p_0^f$ goes from $f(0)$ to $c_0$, while $p_0^g$ goes from $g(0)$ to $c_0$. Using symmetry and transitivity of identity paths, as supplied by the identity-type rules and justified by [citetheorem:9633], we compose $p_0^f$ with the inverse of $p_0^g$ and obtain
\begin{align*}
q_0 : f(0)=g(0).
\end{align*}
This is exactly an element of $Q(0)$.
For the successor step, fix $n : \mathbb{N}_0$ and assume the induction hypothesis
\begin{align*}
q_n : Q(n).
\end{align*}
Unfolding $Q$, this says
\begin{align*}
q_n : f(n)=g(n).
\end{align*}
We must prove
\begin{align*}
f(S(n))=g(S(n)).
\end{align*}
The recursion equations reduce the left and right sides to expressions involving the same step function $s$:
\begin{align*}
p_S^f(n) : f(S(n)) = s(n,f(n))
\end{align*}
and
\begin{align*}
p_S^g(n) : g(S(n)) = s(n,g(n)).
\end{align*}
The only remaining issue is to compare $s(n,f(n))$ and $s(n,g(n))$. For this fixed $n$, define the map
\begin{align*}
s_n : C \to C
\end{align*}
by
\begin{align*}
s_n(y)=s(n,y).
\end{align*}
By [citetheorem:9635], [congruence of functions](/theorems/9635) applied to $s_n$ and the path $q_n$ gives a path denoted by $\operatorname{ap}_{s_n}(q_n)$. Here $\operatorname{ap}_{s_n}$ is the operation that sends an identity path in the domain of $s_n$ to the induced identity path between the corresponding values of $s_n$:
\begin{align*}
\operatorname{ap}_{s_n}(q_n) : s(n,f(n)) = s(n,g(n)).
\end{align*}
Now we concatenate the three paths: first $p_S^f(n)$ from $f(S(n))$ to $s(n,f(n))$, then $\operatorname{ap}_{s_n}(q_n)$ from $s(n,f(n))$ to $s(n,g(n))$, and finally the inverse of $p_S^g(n)$ from $s(n,g(n))$ to $g(S(n))$. This yields
\begin{align*}
q_{S(n)} : f(S(n))=g(S(n)).
\end{align*}
We have produced a base term $q_0 : Q(0)$ and a successor operation taking $q_n : Q(n)$ to $q_{S(n)} : Q(S(n))$. Therefore the [citetheorem:9620] gives
\begin{align*}
q : \prod_{n:\mathbb{N}_0} f(n)=g(n).
\end{align*}
This is pointwise equality of $f$ and $g$.[/guided]