How to model averages in category theory

140 Views Asked by At

As a business analyst, I'm trying to use category theory as a modelling language for information systems. How can I model the following situation? In the category Set of sets and functions, there is an epimorphism $f:A \to B$ where $A$ and $B$ are finite sets. There are two real-valued functions $g:A \to \mathbb{R}$ and $h:B \to \mathbb{R}$. $h(b)$ should give the average of the $g(a)$'s for the $a$'s that map to $b$.

This is my attempt:

use the singleton function to map $b$ to {$b$}
use the contravariant powerset functor to get a map $\mathcal{P}^{op}(f):\mathcal{P}(B)→\mathcal{P}(A)$ to map {$b$} to the subset of A containing the reverse image $f^{-1}(b)$
then I get stuck

1

There are 1 best solutions below

6
On BEST ANSWER

Given a set $X$ let $\mathcal{P}_f(X) = \{A\subseteq X\mid A \text{ finite}\}$ be the set of all finite subsets. We assume to have a function $\vert\bullet\vert:\mathcal{P}_f(X) \rightarrow \Bbb N, A \mapsto \vert A\vert$, sending a finite set to its cardinality. Note that the singleton function actually evaluates as $\{\bullet\}:X\rightarrow\mathcal{P}_f(X),x\mapsto\{x\}$.

Now suppose you have a surjective function $p:X\rightarrow Y$ (making each fiber $p^{-1}(\{y\})\neq\emptyset$ nonempty), such that each fiber $p^{-1}(\{y\}) \in \mathcal{P}_f(X)$ is finite. Then taking preimages gives an induced function $p^{-1}(\bullet):\mathcal{P}_f(Y)\rightarrow\mathcal{P}_f(X),B \mapsto p^{-1}(B)$.

Furthermore suppose you have a function $w:X\rightarrow \Bbb R$. Extension by zero gives us a function $w\vert_\bullet:\mathcal{P}_f(X)\rightarrow \operatorname{Map}_f(X,\Bbb R), A \mapsto w\vert_A$. Finally we have a function $\sum:\operatorname{Map}_f(X,\Bbb R) \rightarrow \Bbb R, \phi \mapsto \sum_{x\in X}\phi(x)$, which takes a function $\phi$ with finite support and takes the sum over all its (nonzero) values.

Your desired averaging function can now be obtained as the composite $$Y\overset{\{\bullet\}}{\rightarrow}\mathcal{P}_f(Y)\overset{p^{-1}(\bullet)}{\rightarrow}\mathcal{P}_f(X)\overset{(w\vert_\bullet,\vert\bullet\vert)}{\longrightarrow}\operatorname{Map}_f(X,\Bbb{R})\times \Bbb{N}_+\overset{\sum\times\operatorname{id}}{\rightarrow}\mathbb{R\times N_+}\overset{\frac{\bullet}{\bullet}}{\rightarrow}\Bbb R.$$