Topological Relational Inference System · v1.0

TORIS

Meaning is not a location.
It is a relationship.

A ground-up computational substrate for machine reasoning. It replaces the neuron, the vector space, and backpropagation with three new primitives — and grounds its mathematics in algebraic topology and the notebooks of Ramanujan.

No vectors No softmax No backpropagation 9 layers 231 tests passing
▶ Try the live playground run a reasoning problem in your browser — no install
Scroll to descend the architecture
01 — The premise

For a decade we taught machines that meaning is a coordinate. Transformers perfected the geometry of averages — and called interpolation understanding.

There is a cost we rarely name. When two facts contradict, softmax averages them away — it cannot hold "A is true" and "A is false" at once, even when both are true in different contexts. When a goal changes, attention re-weights edges but never changes which relationships exist. And every token, surprising or mundane, pays the same quadratic price. The model cannot be surprised. It can only be weighted. TORIS begins from a different axiom — and follows the mathematics all the way down.

02 — What is different

Not a better transformer.
A different species.

Every axis of the architecture is re-derived from first principles. This is the line, drawn plainly.

The old way · attention
Core primitive
Artificial neuron — a weighted sum
Conceptual space
Fixed coordinates in ℝd
Learning signal
Backpropagation — a global loss
Memory / focus
Attention re-weights a frozen graph
Contradiction
held softmax averages it away
Compute
Dense — every token costs the same
The TORIS way · relations
Core primitive
The Relator — a typed, directional transformation
Conceptual space
A role distribution Π over relation types
Learning signal
The Surprise Gradient ΔS — local anomaly only
Memory / focus
The Goal Manifold warps the topology itself
Contradiction
Held as live, productive tension — never collapsed
Compute
Selective — only surprise propagates
03 — The three primitives

Three replacements for
three pillars.

Each old pillar of deep learning is swapped for a structure that carries meaning about the connection itself — not just a scalar.

R
replaces the neuron

The Relator

weighted sum →

A typed, directional, surprise-bearing transformation between concepts. A connection now knows what kind of relationship it is — causal, contradictory, analogous — not merely how strong.

F
replaces the vector space

The Relational Field

d

A context-adaptive typed hypergraph. Concepts have no coordinates; they hold roles that shift with the goal. The field physically rewires as you reason.

S
replaces backpropagation

The Surprise Gradient

global loss →

Local anomaly propagation. Confirmed predictions are suppressed at the source and cost nothing. Only what you did not expect flows forward.

R = ( τ , src , tgt , σ , κ , ε )
τ
type
the kind of relation — 12 types incl. causal, contradicts, enables, analogous
src → tgt
direction
asymmetric by default; symmetry must be explicitly declared
σ
strength ∈ [0,1]
confidence in this relation
κ
salience ∈ [0,1]
how active this relation is under the current goal
ε
surprise ∈ ℝ≥0
deviation from what was predicted
Π
role distribution
a concept is a probability simplex over the roles it can play

Surprise is topological — not Euclidean.

No cosine. No dot product. TORIS measures how the shape of knowledge changed, decomposed into three parts.

\[ \Delta S(F_{\text{pred}},F_{\text{obs}}) \;=\; \alpha\,\Delta S_{\text{structural}} \;+\; \beta\,\Delta S_{\text{type}} \;+\; \gamma\,\Delta S_{\text{strength}} \]
structural (α = 0.6): edges that appeared or vanished · type (β = 0.3): right edge, wrong kind · strength (γ = 0.1): right edge & kind, wrong confidence

A relator only propagates its surprise when ε > θ. Confirmed predictions are silenced — the formal core of selective computation.

04 — The inference loop

Inference rewrites the field
it runs on.

Not a forward pass over frozen weights. A cycle that predicts, is surprised, and physically reorganizes the graph — then warps it again toward the goal.

i

Warp Φ(G, F)

The Goal Manifold recomputes salience for every relator. Edges below threshold are removed from the active topology; relevant ones amplify. Two goals yield two structurally different fields — not two attention masks.

ii

Observe & compare

Incoming structure meets the warped prediction. The topological surprise ΔS is computed per relator.

iii

Gate ε > θ

Confirmed predictions are suppressed and consume zero compute. Only surprising relators propagate forward.

iv

Rewire add · strengthen · weaken · suppress

Fast plasticity edits the topology in place: new relators are instantiated where surprise revealed a gap; perfect predictors fade into background.

v

Hold contradiction R_a ⊗ R_b

When relators contradict, they enter the Contradiction Log. A productive contradiction — where the tension itself is the answer — is never collapsed. Impossible under softmax.

Nine layers — primitives to certified surprise.

Layer 0
Primitives
Relator · ConceptState · RelationalField
Layer 1
Surprise ΔS
the topological deviation metric
Layer 2
Predictive Engine
project → observe → delta → propagate
Layer 3
Goal Manifold
the warp operator Φ and the contradiction log
Layer 4
Fast Plasticity
the field rewrites itself during inference
Layer 5
Reasoning
chains · sparse generalization · the full loop
Layer 6
Fast Surprise Dynamics
an O(n log n) approximation + a cyclic-wave propagation model
Layer 7
Analytic Surprise
contour integral, Michel parameters, a running coupling for surprise
Layer 8
Ramanujan Extension
circle method · suppression theorem · partition function
Layer 9
Exact Surprise
a Rademacher series with certified error bounds
05 — The Ramanujan significance

Why a relational AI
reaches for Ramanujan.

A relational field has a generating function. The moment you write it down, the partition theory of Srinivasa Ramanujan stops being a metaphor and becomes the exact machinery for computing surprise. Layer 8 · from the Collected Papers (1927)

The depth-d surprise of a field is a coefficient of its generating function \(Z_F(\kappa)\) — the same object form as the partition generating function \( \prod_n 1/(1-x^n) \). That single identification imports four of Ramanujan's results, each one buying a concrete computational power.

I · Circle methodHardy–Ramanujan, 1918

Saddle points of surprise

"Asymptotic Formulae in Combinatory Analysis"
The circle method extracts p(n) from dominant singularities on the unit circle. In TORIS the same contour integral extracts surprise at relational depth d from a single saddle point \( \kappa_{\text{saddle}}=\exp(\pi\sqrt{2d/3}/d) \).
O(1) per depth — vs O(|E|^d) brute-force traversal
II · Partition congruencesRamanujan, 1919

A suppression theorem

"Some Properties of p(n)"
Ramanujan saw, in MacMahon's tables, that p(5m+4) ≡ 0 (mod 5). In a field with modular structure, entire classes of surprise cancel exactly at specific depths — TORIS skips them with zero approximation error.
verified at 100% suppression accuracy (exp_11)
III · The 1/π seriesRamanujan, 1914

Goal-warp compression

"Modular Equations and Approximations to π"
His series gives eight digits of π from the first term. The Goal Manifold warp Φ(G,F) converges the same way for a coherent goal — a near-integer test auto-switches between a 3-term shortcut and full iteration.
1 term → 7.6×10⁻⁸ · 2 terms → machine precision
IV · Rogers–RamanujanRogers & Ramanujan, 1919

Closed-form field entropy

"Proof of Certain Identities in Combinatory Analysis"
Relators that contradict cannot both be active — exactly the hard-exclusion of the Baxter hard-hexagon model. For a chain contradiction structure, the count of valid field configurations is the Rogers–Ramanujan product, giving entropy in closed form.
product = q-series identity to < 0.001% (exp_13)

The Suppression Theorem

Ramanujan's three exact congruences — holding for all m — become structural zeros in relational surprise. At these depths, computation provably does nothing, so TORIS does nothing.

p(5m+4) ≡ 0 (mod 5)
depths ≡ 4 (mod 5)
p(7m+5) ≡ 0 (mod 7)
depths ≡ 5 (mod 7)
p(11m+6) ≡ 0 (mod 11)
depths ≡ 6 (mod 11)

Critical points — the Heegner analogy

Ramanujan's constant \( e^{\pi\sqrt{163}} \) is almost an integer because 163 is a Heegner number. TORIS borrows the idea: a field whose partition function is nearly an integer sits at a critical configuration — maximum modular coherence, where all four results converge fastest.

e^(π√163) = 262 537 412 640 768 743.999 999 999 999 25…
differs from an integer by ≈ 10⁻¹². In TORIS, |ZF(κ) − round(ZF)| < 10⁻⁴ flags a critical relational configuration.

Layers 7 and 9 extend this further — an analytic surprise functional with a running coupling (asymptotic freedom for surprise), and an exact Rademacher series that computes surprise to arbitrary precision with certified error bounds. The mathematics is not decoration. It is the engine.

06 — Validation

Tested on what transformers
structurally cannot do.

Not GLUE. Not MMLU. TORIS is evaluated on five behaviors that are impossible for attention-based models — and demonstrated end to end.

231
tests passing
9
layers implemented
16
experiments
5/5
criteria met
0
transformer ops
1
Contradiction retention
two incompatible relators held, both shaping the conclusion — never averaged
exp_01 · PASS
2
Goal-warp sensitivity
changing the goal changes which edges are active — not just their weights
exp_02 · PASS
3
Sparse generalization
4 seed relators → an 8-hop conclusion with calibrated uncertainty
exp_03 · PASS
4
Surprise selectivity
20 relators, 3 surprising → >70% of compute concentrated on those 3
exp_04 · PASS
5
Structural drift
the field at t=50 is measurably different from the field at t=0
exp_05 · PASS
07 — A use case it would otherwise flatten

The contradiction a transformer
cannot keep.

CAUSAL σ.9 ENABLES σ.8 NEGATES σ.4 EVIDENCES σ.7 fire smoke evac alarm smoke ENABLES evac ⊗ smoke NEGATES evac → PRODUCTIVE contradiction
EMERGENCY REASONING · PRODUCTIVE CONTRADICTION

Smoke enables evacuation — it triggers the alarm and signals danger. And smoke negates evacuation — dense smoke blocks the exit corridor. Both are true. The tension is the knowledge.

A transformer softmaxes this into one muddy probability and loses the structure of why. TORIS logs the ENABLES ⊗ NEGATES pair as a productive contradiction — both relators stay live.

When the goal warps the field — "is the corridor passable?" — the relevant side amplifies while the other is held in reserve, not deleted. The same machinery serves legal reasoning, medical differentials, and contradictory scientific evidence.

08 — Run it

Pure Python. No GPU.
No training run.

Built on networkx · numpy · scipy. Clone it and watch all five criteria pass in under two seconds.

bash · install & verifycopy
# clone, install, and run the full demonstration
git clone https://github.com/infinitule/TORIS.git
cd TORIS
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"

pytest tests/                                 # 231 tests
python experiments/exp_toris_full_demo.py     # all 5 criteria, end to end
python · a reasoning field that holds contradictioncopy
from toris.primitives.relator import Relator
from toris.primitives.relation_types import RelationType as T
from toris.field.relational_field import RelationalField
from toris.goal.manifold import GoalManifold, Goal
from toris.reasoning.inference import InferenceLoop

field = RelationalField()
# smoke ENABLES evacuation … and also NEGATES it — a real contradiction
field.add_relator(Relator(T.ENABLES, smoke, evac, sigma=0.7, kappa=0.6))
field.add_relator(Relator(T.NEGATES, smoke, evac, sigma=0.4, kappa=0.3))

manifold = GoalManifold(primary=Goal(description='ensure_safety'))
loop = InferenceLoop(field, manifold)
rec  = loop.step([...])
print(rec.delta_s, len(manifold.contradiction_log))   # the tension survives →  1