\documentclass{article}
\usepackage{amsmath,amssymb}
% \usepackage{tikz-cd}  % not available
\usepackage{booktabs}

\title{Factor Maps as Patterns on $U^2$}
\author{Hutter RNN Project}
\date{2026-01-31}

\begin{document}
\maketitle

\section{The Universal Model}

Recall:
\[
U = (E, T, P, f, \omega)
\]

\begin{itemize}
\item $E$ = event space
\item $T \subseteq \mathbb{N}^{|E|}$ = thought vectors (log-space)
\item $P$ = patterns (transition structure)
\item $f: T \times E \to T$ = integration
\item $\omega$ = prior over patterns
\end{itemize}

\section{Factor Maps}

\subsection{Definition}

A \textbf{factor map} is a morphism $\pi: U \to U'$ where $U' = (E', T', P', f', \omega')$ is a coarser model.

Concretely, $\pi$ consists of:
\begin{enumerate}
\item $\pi_E: E \to E'$ (event projection)
\item $\pi_T: T \to T'$ (thought projection)
\item Compatibility: $\pi_T(f(t, e)) = f'(\pi_T(t), \pi_E(e))$
\end{enumerate}

\subsection{Example: ES Projection}

\[
\pi_{ES}: \text{Bytes} \to \text{ES} = \{\text{Digit, Punct, Vowel, White, Other}\}
\]

\begin{align}
\pi_{ES}(\text{'a'}) &= \text{Vowel} \\
\pi_{ES}(\text{' '}) &= \text{White} \\
\pi_{ES}(\text{'7'}) &= \text{Digit}
\end{align}

This induces a factor map on the full model.

\section{$U^2$: The Product Model}

\subsection{Construction}

Given $U = (E, T, P, f, \omega)$, define:
\[
U^2 = U \times U = (E \times E, T \times T, P^2, f^2, \omega^2)
\]

where:
\begin{itemize}
\item $E \times E$ = pairs of events (joint event space)
\item $T \times T$ = pairs of thoughts
\item $P^2$ = patterns on pairs
\item $f^2((t_1, t_2), (e_1, e_2)) = (f(t_1, e_1), f(t_2, e_2))$
\end{itemize}

\subsection{Patterns on $U^2$}

A \textbf{pattern on $U^2$} is an element of $P^2$, representing a relationship between two events.

In log-space:
\[
p_{(e_1, e_2) \to (e_1', e_2')} \in \mathbb{N}
\]

This is the log-support for the joint transition.

\section{Factor Maps as Patterns}

\subsection{Key Insight}

A factor map $\pi: U \to U'$ \textbf{is} a pattern on $U^2$.

\begin{verbatim}
    U  --π-->  U'
    |          |
    f          f'
    |          |
    v          v
    U  --π-->  U'
\end{verbatim}
The diagram commutes: $\pi \circ f = f' \circ \pi$.

The factor map $\pi$ relates:
\begin{itemize}
\item $(e, \pi(e)) \in E \times E'$ — event and its image
\item $(t, \pi(t)) \in T \times T'$ — thought and its image
\end{itemize}

\subsection{Pattern Representation}

Encode the factor map as a pattern matrix:
\[
\Pi_{e, e'} = \begin{cases}
1 & \text{if } \pi(e) = e' \\
0 & \text{otherwise}
\end{cases}
\]

In log-space ($\mathbb{N}$):
\[
\Pi_{e, e'} = \begin{cases}
\infty & \text{if } \pi(e) = e' \\
0 & \text{otherwise}
\end{cases}
\]

(Infinite support for valid mappings, zero for invalid.)

\subsection{Soft Factor Maps}

For probabilistic/learned factor maps:
\[
\Pi_{e, e'} = \log P(e' | e)
\]

This is exactly the embedding construction from earlier!

\section{Composition}

\subsection{Factor Map Composition}

Given $\pi_1: U \to U'$ and $\pi_2: U' \to U''$:
\[
\pi_2 \circ \pi_1: U \to U''
\]

In pattern notation:
\[
(\Pi_2 \circ \Pi_1)_{e, e''} = \max_{e'} \min(\Pi_1[e, e'], \Pi_2[e', e''])
\]

This is tropical matrix multiplication (max-min in log-space).

\subsection{The Factor Lattice}

Factor maps form a lattice:
\begin{verbatim}
              U
           /  |  \
      π_ES  π_byte  π_pos
        /     |      \
     U_ES   U_byte   U_pos
        \     |      /
          \   |   /
           U_top
\end{verbatim}

where:
\begin{itemize}
\item $U_{ES}$ = 5-event ES model
\item $U_{byte}$ = identity (256 events)
\item $U_{pos}$ = positional model
\item $U_\top$ = trivial 1-event model
\end{itemize}

\section{Learning Factor Maps}

\subsection{From Data}

Given observations, learn the soft factor map:
\[
\hat{\Pi}_{e, e'} = \log \frac{\text{count}(e, e')}{\text{count}(e)}
\]

This is the conditional log-probability (the embedding).

\subsection{From Hidden States}

For an RNN with hidden state $h$:
\[
\Pi_{h \to e} = W_{out} \cdot h
\]

The output weights define a (soft) factor map from hidden space to event space.

\section{Summary}

\begin{center}
\begin{tabular}{ll}
\toprule
Concept & Representation \\
\midrule
Factor map $\pi: U \to U'$ & Pattern on $U \times U'$ \\
Hard projection & Binary pattern matrix \\
Soft/learned projection & Log-probability matrix \\
Composition & Tropical matrix multiply \\
Embedding & Row of factor map matrix \\
\bottomrule
\end{tabular}
\end{center}

\textbf{Punchline:} Factor maps, embeddings, and patterns are all the same thing viewed differently. They all live in $U^2$.

\end{document}
