# Ternary Gamma Semirings: From Neural Implementation to Categorical Foundations

arXiv: https://arxiv.org/abs/2603.19317 · HTML: https://mlsanity.com/paper/2603.19317/

## Key facts

- No citing papers in the map yet (data through 14 Oct 2026).
- Builds on 10 of its 42 references that are in the map.
- First posted on arXiv 15 Mar 2026.

## Builds on (most cited first, 10 of 10)

- [Relational inductive biases, deep learning, and graph networks](https://mlsanity.com/paper/1806.01261/) (2018)
- [A simple neural network module for relational reasoning](https://mlsanity.com/paper/1706.01427/) (2017)
- [Measuring Compositional Generalization: A Comprehensive Method on Realistic Data](https://mlsanity.com/paper/1912.09713/) (2019)
- [Compositionality decomposed: how do neural networks generalise?](https://mlsanity.com/paper/1908.08351/) (2019)
- [Deep Learning: A Critical Appraisal](https://mlsanity.com/paper/1801.00631/) (2018)
- [Categorical Foundations of Gradient-Based Learning](https://mlsanity.com/paper/2103.01931/) (2021)
- [Category-Theoretical and Topos-Theoretical Frameworks in Machine Learning: A Survey](https://mlsanity.com/paper/2408.14014/) (2024)
- [Scalable Evaluation and Neural Models for Compositional Generalization](https://mlsanity.com/paper/2511.02667/) (2025)
- [Computational and Categorical Frameworks of Finite Ternary Gamma-Semirings: Foundations, Algorithms, and Industrial Modeling Applications](https://mlsanity.com/paper/2511.12323/) (2025)
- [A Ternary Gamma Semiring Framework for Solving Multi-Objective Network Optimization Problems](https://mlsanity.com/paper/2511.18099/) (2025)

## Abstract (arXiv)

This paper establishes a theoretical framework connecting neural network learning with abstract algebraic structures. We first present a minimal counterexample demonstrating that standard neural networks completely fail on compositional generalization tasks (0% accuracy). By introducing a logical constraint -- the Ternary Gamma Semiring -- the same architecture learns a perfectly structured feature space, achieving 100% accuracy on novel combinations. We prove that this learned feature space constitutes a finite commutative ternary Gamma-semiring, whose ternary operation implements the majority vote rule. Comparing with the recently established classification of Gokavarapu et al., we show that this structure corresponds precisely to the Boolean-type ternary Gamma-semiring with |T|=4, |Gamma|=1, which is unique up to isomorphism in their enumeration. Our findings reveal three profound conclusions: (i) the success of neural networks can be understood as an approximation of mathematically ``natural'' structures; (ii) learned representations generalize because they internalize algebraic axioms (symmetry, idempotence, majority property); (iii) logical constraints guide networks to converge to these canonical forms. This work provides a rigorous mathematical framework for understanding neural network generalization and inaugurates the new interdisciplinary direction of Computational Gamma-Algebra.
