Only Institute / Knowledge

Follow your curiosity.

AI sends your question and public excerpts to PrimeSwarm.

Try agent memory, governance, or a project name.

All Publications
whitepaper

Prime Integer Relations: The Mathematical Foundation

How Thue-Morse equilibrium detects instability across markets, neural networks, and knowledge graphs

Grigori Korotkikh 2026-08-24 16 min
PIRThue-MorseEquilibriumBalance GapPattern Area
Only Institute — Prime Integer Relations: The Mathematical Foundation

Prime Integer Relations: The Mathematical Foundation

What Is PIR?

Prime Integer Relations (PIR) treats complex systems as arithmetic/geometric structures. Instead of only looking at statistical outputs, it measures structural balance, entropy, dissonance, and coherence through integer relations and geometric transforms.

PIR is not a heuristic. It is not a machine learning model. It is a deterministic mathematical test that runs in O(n) time.

The Thue-Morse Sequence

The Thue-Morse sequence is one of the most fundamental sequences in number theory. The sign of position i is determined by the parity of the number of 1-bits in the binary representation of i.

  • Position 0: 0 bits → even → sign +1
  • Position 1: 1 bit → odd → sign -1
  • Position 2: 1 bit → odd → sign -1
  • Position 3: 2 bits → even → sign +1

This sequence has a remarkable property: it is provably balanced. No matter how far you extend it, the cumulative sum never strays far from zero. This is not a heuristic — it is a theorem.

Balance Gap

Given a sequence of values (returns, weights, tokens, observations), PIR computes the signed power-sum using Thue-Morse signs:

Balance Gap = Σ (-1)^popcount(i) × value[i]

When the balance gap is near zero, the sequence is in equilibrium — structurally sound. When the balance gap is large, the sequence has a structural imbalance — something is wrong.

Pattern Area

The pattern area is the shoelace area of the cumulative signed path. Low area means the path is well-structured (trending cleanly). High area means the path is scattered — uncertain, unstable, potentially hallucinatory.

Where PIR Is Used

PIR is domain-agnostic. The same equation is used across our entire stack:

Market Regime Detection

The PIR Evolver Engine applies balance gap to financial return sequences. When the gap spikes, a regime shift has occurred. This powers SignalO, our live signal feed product. Four regimes are classified: Bullish, Range, Transition, and Bearish — all from the same O(n) equation.

Neural Network Integrity

TPNN uses PIR balance gap to monitor the structural health of neural computation in real-time. When weight updates break equilibrium, the network is in an unstable state — potentially vulnerable to adversarial attack.

Knowledge Graph Health

Learning Trails uses PIR to measure whether a learner's understanding is in structural equilibrium. Unlike traditional platforms that track completion percentages, PIR detects knowledge gaps by measuring the balance of mastered concepts.

Cellular Automata Governance

Quilt's equilibrium cells use PIR balance gap as their convergence metric. When the grid deviates from equilibrium, these cells emit stabilizing signals that propagate through the grid.

On-Chain Coherence

OnlyState uses the Thue-Morse sequence as the public group state. The Prouhet-Tarry-Escott power-sum equations — verified by a ZK circuit — ensure membership without storing a single wallet address.

Ghost Storage

Ghost Storage uses balanced fields and higher-order moments derived from PIR for data hiding and recovery.

O(n) Cost

PIR runs in O(n) time — one pass through the sequence, one popcount per element. This means it can run on every token, every weight update, every market tick, in real time. It is not a bottleneck — it is a built-in invariant.

Why It Matters

PIR is the mathematical bedrock of every system we build. It provides the same invariant across completely different domains: if the balance gap is near zero, the system is structurally sound. If it spikes, something has changed. No parameters to tune. No training data needed. Just mathematics.

This is the foundation: safety comes from mathematical constraint, not post-hoc monitoring. PIR is how we measure that constraint.


Back to Publications

Published by Only Institute