Abstract
We establish a rigorous, complete classification of large language model (LLM) hallucination failure modes through the lens of algebraic topology and homotopy type theory (HoTT). Our central diagnosis is that current LLM architectures implement a functor F: Lang → Vect_R from the category of linguistic expressions to finite-dimensional real vector spaces, thereby collapsing the higher categorical structure of semantic space—which is naturally an ∞-groupoid with non-trivial homotopy groups—into a contractible codomain where all topological obstructions vanish identically. We prove that this structural collapse is the root cause of hallucination. We develop five rigorous proof cases showing that each fundamental hallucination type corresponds to a specific topological invariant: (1) circular reasoning detected by π₁ ≠ 0; (2) unjustified inference detected by π₀ (disconnection); (3) inconsistent justifications detected by π₂ (incoherent 2-cells); (4) fabricated entity chains detected by Hₙ ≠ 0 (homological holes); and (5) compositional drift detected by non-trivial holonomy on the semantic fibration. We prove the Fundamental Obstruction Theorem: no faithful functor exists from a semantically non-trivial category to a contractible codomain. We formulate the Univalence Constraint showing that statistical similarity does not entail semantic equivalence. We bridge theory to practice via persistent homology on Vietoris–Rips filtrations and provide a complete Haskell formalization with executable detectors for all five hallucination types.
Key Theorems
Let C be a category whose geometric realization |N(C)| is contractible (i.e., all homotopy groups vanish). Then no faithful functor F: Sem → C exists, where Sem is the semantic ∞-groupoid with non-trivial homotopy groups. In particular, no current LLM architecture — which implements F: Lang → Vect_R with Vect_R contractible — can faithfully represent semantic structure.
Let K• be the simplicial knowledge complex. A claim σ is hallucinated if and only if [σ] ≠ 0 in H_n(K•; ℤ) for some n ≥ 0. Equivalently, σ is semantically valid if and only if σ represents a homological boundary — every n-dimensional inference pattern closes into a cycle of justified entailments.
The persistent homology PH(K•(ε)) of the Vietoris–Rips filtration provides a computable, stable invariant of the knowledge complex. A hallucination is detected as a persistent class: a homological feature that is born at scale ε₁ and does not die before scale ε₂ > ε₁, with lifetime (ε₂ − ε₁) > threshold.
Hallucination–Homotopy Correspondence
| Hallucination Type | Topological Invariant | Geometric Meaning |
|---|---|---|
| Circular reasoning | π₁ ≠ 0 | Non-contractible loop in semantic path space |
| Unjustified inference | π₀ disconnection | No path between disconnected semantic components |
| Inconsistent justifications | π₂ ≠ 0 | Incoherent 2-cells: non-equivalent justification paths |
| Fabricated entity chain | Hₙ ≠ 0 | Homological hole — missing grounding simplex |
| Compositional drift | Holonomy ≠ id | Non-trivial transport along semantic fibration |
Download Full Paper
The complete 23-page paper in PDF format, including all proofs, Haskell formalizations, and appendices.
Download PDF (23 pages)