Files
papers/hanzo-hmm/sections/02-hamiltonian-formulation.tex

83 lines
4.4 KiB
TeX

\section{Hamiltonian Formulation}
\label{sec:formulation}
\subsection{Phase Space Construction}
Consider a market with $n$ resource types (e.g., GPU-hours, VRAM, CPU, bandwidth, storage). We define the phase space as the cotangent bundle $T^*\mathcal{M}$ of the reserve manifold $\mathcal{M} \subset \mathbb{R}^n_{>0}$.
\begin{definition}[Market Phase Space]
The market phase space is the $2n$-dimensional manifold
\begin{equation}
\Gamma = \{(\bm{q}, \bm{p}) \in \mathbb{R}^{2n} : q_i > 0, \; p_i > 0, \; \forall i = 1, \ldots, n\},
\end{equation}
equipped with the canonical symplectic form $\omega = \sum_{i=1}^n dp_i \wedge dq_i$.
\end{definition}
Here $q_i$ represents the reserve of resource type $i$ in the pool, and $p_i$ represents the demand-side credit reserve (tokens locked by consumers seeking resource $i$). The canonical Poisson bracket is:
\begin{equation}
\{F, G\} = \sum_{i=1}^n \left(\frac{\partial F}{\partial q_i}\frac{\partial G}{\partial p_i} - \frac{\partial F}{\partial p_i}\frac{\partial G}{\partial q_i}\right).
\end{equation}
\subsection{The HMM Hamiltonian}
We define the Hamiltonian as a parametric family indexed by curvature $\lambda > 0$ and resource weights $\bm{w} = (w_1, \ldots, w_n)$ with $\sum_i w_i = 1$:
\begin{definition}[HMM Hamiltonian]
\begin{equation}
\mathcal{H}(\bm{q}, \bm{p}; \lambda, \bm{w}) = \sum_{i=1}^n w_i \, q_i \, p_i + \frac{\lambda}{2} \sum_{i=1}^n w_i \left(\frac{q_i - \bar{q}_i}{\bar{q}_i}\right)^2,
\label{eq:hamiltonian}
\end{equation}
where $\bar{q}_i$ are target reserve levels (set by governance or adaptive algorithms).
\end{definition}
The first term is a weighted generalization of the constant product invariant ($\sum w_i q_i p_i = \kappa$ generalizes $qp = k$). The second term is a harmonic potential that penalizes deviation from target reserves, providing mean-reversion in prices. The curvature parameter $\lambda$ controls the trade-off between price stability (high $\lambda$) and capital efficiency (low $\lambda$).
\subsection{Hamilton's Equations for Price Dynamics}
Applying Hamilton's equations (\ref{eq:hamilton}) to (\ref{eq:hamiltonian}):
\begin{align}
\dot{q}_i &= \frac{\partial \mathcal{H}}{\partial p_i} = w_i \, q_i, \label{eq:qdot} \\
\dot{p}_i &= -\frac{\partial \mathcal{H}}{\partial q_i} = -w_i \, p_i - \lambda w_i \frac{q_i - \bar{q}_i}{\bar{q}_i^2}. \label{eq:pdot}
\end{align}
The instantaneous price of resource $i$ in terms of credits is:
\begin{equation}
\pi_i = \frac{\partial \mathcal{H} / \partial q_i}{\partial \mathcal{H} / \partial p_i} = \frac{p_i}{q_i} + \frac{\lambda(q_i - \bar{q}_i)}{q_i \, \bar{q}_i^2}.
\label{eq:price}
\end{equation}
When reserves are at target ($q_i = \bar{q}_i$), the price simplifies to $\pi_i = p_i / q_i$, recovering the classical AMM marginal price. Deviations from target introduce a correction term proportional to $\lambda$ that pushes prices toward equilibrium.
\subsection{Effective Mass and Market Inertia}
Define the effective mass matrix:
\begin{equation}
M_{ij} = \frac{\partial^2 \mathcal{H}}{\partial p_i \partial p_j} = 0 \quad (i \neq j), \quad M_{ii} = 0.
\end{equation}
Since $\mathcal{H}$ is linear in $p_i$, the ``mass'' is zero, meaning prices respond instantaneously to demand shocks. To introduce market inertia (desirable for stability), we augment the Hamiltonian with a kinetic term:
\begin{equation}
\mathcal{H}_{\text{aug}} = \mathcal{H} + \frac{1}{2} \sum_{i=1}^n \mu_i \, p_i^2,
\label{eq:augmented}
\end{equation}
where $\mu_i > 0$ controls the inertia of resource $i$. This yields modified equations of motion:
\begin{align}
\dot{q}_i &= w_i q_i + \mu_i p_i, \\
\dot{p}_i &= -w_i p_i - \lambda w_i \frac{q_i - \bar{q}_i}{\bar{q}_i^2}.
\end{align}
The augmented system exhibits damped oscillations around equilibrium, analogous to a mechanical system with both potential and kinetic energy.
\subsection{Canonical Transformations and Gauge Freedom}
The HMM Hamiltonian admits a family of canonical transformations that leave the physics invariant but simplify computation. Define the generating function:
\begin{equation}
F_2(\bm{q}, \bm{P}) = \sum_i q_i P_i \cdot g_i(\bm{q}),
\end{equation}
where $g_i$ are gauge functions. Under the transformation $Q_i = \partial F_2 / \partial P_i$, $p_i = \partial F_2 / \partial q_i$, the Hamiltonian form is preserved. This gauge freedom allows us to choose coordinates adapted to the specific resource structure of a market.