TITLE: What is the identity arrow in this category?
QUESTION [8 upvotes]: This is taken from An Introduction to Category Theory by Harold Simmons (Example 1.3.1) (slightly changed for formatting reasons).

The objects are the finite sets.  An arrow $f$ with source $A$ and target $B$ is a function $$f : A\times B \to \mathbb{R}$$ with no imposed conditions.  For each pair of arrows $f,g$ with $\text{source}(f) = A$, $\text{target}(f) = B$, $\text{source}(g) = B$, $\text{target}(g) = C$ we define $g \circ f$ to be a function $$g \circ f : A \times C \to \mathbb{R}$$ with $$(g\circ f)(a,c) = \sum_{y \in B} f(a,y)g(y,c).$$

I understand how to check that for three arrows composition is associative, but I am unsure how one would define, for example, $\text{Id}_A, \text{Id}_B$ such that $$\text{Id}_B \circ f = f = f \circ \text{Id}_A,$$
I know they would be functions from $A\times A \to \mathbb R$ and $B\times B \to \mathbb R$ but when writing down the composition I am not sure how one obtains the original $f$.

REPLY [3 votes]: $\newcommand{\id}{\mathsf{id}}$
You'd like a function $f: A\times A \rightarrow \mathbb{R}$ such that for any other function $g: A\times B \rightarrow \mathbb{R}$, you have
$$\begin{eqnarray*}
f \circ g &= g & \qquad A\times B\rightarrow \mathbb{R}\\
(f \circ g)(a,b) &= g(a,b) &\qquad \forall \,(a,b) \in A\times B\\
\sum_{y \in A} f(a, y)\cdot g(y, b) &= g(a,b) & \\
\end{eqnarray*}$$
We can define $f$ in such a way that most terms in the sum vanish. In particular, if we set $f(a,y) \equiv 0$ unless $y=a$, then the sum collapses to a single term:
$$f(a,a)\cdot g(a,b) = g(a,b)$$
Then if we define $f(a,a) = 1$, we get the desired result: $g(a,b) = g(a,b)$, so $f\circ g = g$ in general.
The definition we've arrived at is:
$$f(a,y) \equiv \begin{cases}0 & \text{if }a \neq y\\1 & \text{if }a=y\end{cases}$$
which you can prove is also a right handed identity: $h\circ f = h$.