NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Learning to Add, Multiply, and Execute Algorithmic Instructions Exactly with Neural Networks

Artur Back de Luca, George Giapitzakis, Kimon Fountoulakis

Neural networks excel at approximating smooth, continuous functions—like recognizing a cat in a blurry photo—but they notoriously struggle with the "crisp," discrete logic required for arithmetic or symbolic manipulation. While a network might achieve 99% accuracy on addition tasks, in the algorithmic world, anything less than 100% is a failure.

Because gradient descent is designed for continuous landscapes, converging on the sharp, discontinuous rules of binary logic is inherently difficult. This paper asks a fundamental question: Can we mathematically guarantee that a neural network will learn to execute binary-encoded instructions exactly?

By breaking algorithms down into bit-level "templates" and training an ensemble of infinite-width networks, researchers have developed a theoretical framework proving that simple neural networks can indeed learn to execute complex algorithms with 100% accuracy, requiring only a logarithmic amount of training data.

Methodology: Templates and the NTK Framework

To tackle this challenge, the researchers utilize the Neural Tangent Kernel (NTK) framework, which describes the training dynamics of infinitely wide neural networks. Their approach relies on two primary innovations:

  1. Algorithmic Template Representation: Instead of training a network on full input-output examples (e.g., $123 + 456 = 579$), the algorithm is broken down into "templates"—local, bit-level rules. For addition, a template describes how two specific bits and a carry bit interact to produce a sum bit.
  2. Provable Exact Learnability: The authors demonstrate that structuring these templates to be orthonormal (mathematically independent and normalized) prevents interference between different rules during learning.
Overview of the framework translating an algorithm into template representations and executing it iteratively.

Crucially, execution is not a single-shot process. The network operates iteratively in a loop. At each step, it matches the current state against its learned templates to produce the next state. To guarantee 100% accuracy in finite, real-world settings, the method uses an ensemble of independently trained networks, averages their outputs, and rounds the result to the nearest binary value.

Datasets and Efficiency

The paper evaluates this framework using synthetic datasets designed for four fundamental algorithmic tasks:

  • Binary Permutations: Reordering bits.
  • Binary Addition: Standard ripple-carry addition.
  • Binary Multiplication: The shift-and-add algorithm.
  • Subtract and Branch if Negative (SBN): A "One-Instruction Set Computer" (OISC) protocol.

Remarkably, the number of training examples required scales logarithmically relative to the total number of possible inputs. For instance, learning to add two 10-bit numbers (which has over a million possible combinations) requires only about 40 template-based training examples.

Key Insights

  • Locality is the Secret Sauce: Algorithms are typically composed of small, repeating local rules. By training on these local templates rather than global input-output pairs, the network learns the underlying "laws" of the algorithm rather than merely memorizing examples.
Breaking down binary addition into local, bit-level templates applied to specific blocks of the input.
  • Turing Completeness: The inclusion of the SBN instruction is highly significant. Because SBN is Turing-complete, proving that a network can learn it implies that this framework could theoretically be used to learn any computable function.
  • The Decision Margin: The authors identify a critical "signal-to-interference" ratio. As long as unwanted correlations (conflicting rules) remain below a specific threshold, the network's signal will be strong enough to produce the correct binary output after rounding.

Key Results

  • The NTK Predictor (Theorem 5.1): The authors mathematically prove that the mean prediction of the infinite-width network always points in the correct binary direction (positive for 1, negative/zero for 0), provided the unwanted correlation assumption holds.
  • Ensemble Complexity: The paper provides a concrete formula for the required ensemble size to guarantee perfect accuracy with high probability. For binary addition, the number of models scales as $O(\ell^2)$, where $\ell$ is the number of bits.
  • Empirical Validation: The theory was verified by training ensembles of networks with 50,000 hidden units. These networks achieved 100% accuracy on unseen test cases, perfectly following the predicted scaling laws.

Limitations and Future Work

While groundbreaking, the framework has current limitations that pave the way for future research:

  • Data Orthogonality: The mathematical proofs currently rely on the training data being orthonormal, whereas real-world data is often messy and highly correlated.
  • Explicit Templates: Currently, the network is explicitly fed the templates. A major next step is determining if a network can discover these local templates autonomously from raw, noisy input-output traces.
  • Fixed Memory: The model operates in a "bounded memory" setting, meaning it cannot automatically generalize to inputs longer than its training length without retraining.
  • Architectural Expansion: While this study focuses on Multi-Layer Perceptrons (MLPs), extending these proofs to Transformers or Graph Neural Networks (GNNs) could allow for handling more complex, variable-length data structures.

Summary updated

BibTeX
@inproceedings{luca2025learning,
  author = {Artur Back de Luca and George Giapitzakis and Kimon Fountoulakis},
  title = {{Learning to Add, Multiply, and Execute Algorithmic Instructions Exactly with Neural Networks}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=j3pkYPmbot},
}
Figure