On the Turing Completeness of Modern Neural Network Architectures

Jorge Pérez, Javier Marinkovic, Pablo Barceló

Introduction

In the quest to build artificial intelligence capable of algorithmic reasoning, researchers frequently ask a fundamental question: What are the absolute computational limits of a given neural architecture?

Early theoretical work in the 1990s established that Recurrent Neural Networks (RNNs) are Turing complete. However, modern deep learning has largely shifted away from traditional recurrence, favoring architectures based on attention (like Transformers) or convolutions (like Neural GPUs). While these models achieve state-of-the-art performance on complex tasks such as machine translation, their theoretical computational boundaries remained less understood.

A prevailing assumption was that achieving "universal computation" required augmenting networks with an external memory bank, akin to a Neural Turing Machine. This paper challenges that notion, providing a rigorous theoretical proof that both the Transformer and the Neural GPU are inherently Turing complete. In principle, these networks can simulate any computer algorithm using only their internal representations.

Methods for Proving Universality

The authors adopt a formal mathematical framework based on "language recognition," treating a neural network as a machine that processes a sequence of symbols to decide if it belongs to a specific formal language. To prove Turing completeness, they employ two distinct strategies for the two architectures:

1. The Transformer (Direct Simulation): The authors demonstrate how a multi-layer Transformer can be explicitly configured to act as a Turing Machine. In this setup, the network's layers implement the transition function and update the state, while attention mechanisms are used to "read" and "write" to different parts of the input sequence, effectively treating the sequence as the Turing Machine's tape.

Diagram illustrating how a Transformer network uses self-attention to simulate the transition function and tape operations of a Turing Machine.

2. The Neural GPU (Reduction): For the Neural GPU, the authors use a reduction strategy. Building on prior knowledge that specific RNNs are Turing complete, they prove that a "Uniform Neural GPU" can perfectly simulate those exact RNNs.

Crucially, both proofs rely on the assumption of arbitrary precision. The internal activations of the network are treated as rational numbers capable of scaling to whatever precision is necessary to store the required computational information. As a purely theoretical work, the paper focuses entirely on these mathematical proofs rather than empirical datasets or training benchmarks.

Key Insights and Results

The mathematical formalization yields several critical insights into how these architectures process information:

  • The Necessity of Positional Encodings: A "naked" Transformer without positional encodings is surprisingly weak. It is "proportion-invariant," meaning it only registers the ratio of symbols (e.g., the number of As versus Bs) and is entirely blind to sequence order. It cannot even solve a simple parity problem. However, once positional encodings are introduced, the Transformer gains the spatial awareness required to simulate a Turing Machine's tape.
  • Internal Memory is Sufficient: Neither the Transformer nor the Neural GPU requires a "scratchpad" or external memory module to achieve Turing completeness. They leverage the dense, high-dimensional representations of the input itself to store and manipulate information during calculation.
  • Architectural Details Matter: For the Neural GPU, "zero-padding" is essential; using circular convolution causes the model to lose its Turing completeness because it can no longer identify the boundaries of its tape. Similarly, for Transformers, residual connections are not merely a trick for training stability—they are mathematically necessary to carry information forward through layers during a multi-step computation.

Formally, the paper establishes two main theorems:

  • Theorem 3.4: The class of Transformer networks with positional encodings is Turing complete.
  • Theorem 4.1: The class of uniform Neural GPUs is Turing complete.

Limitations and Future Work

While the theoretical proofs are robust, they come with practical caveats that pave the way for future research:

  • Hard vs. Soft Attention: The Transformer proof utilizes "hard attention" (selecting exactly one discrete position) rather than the "soft attention" (weighted averages) typically used in practice. While soft attention might also be universal, it significantly complicates the formal proof.
  • The Precision Gap: The most substantial limitation is the reliance on arbitrary precision. Real-world hardware operates on finite memory and fixed precision (e.g., 32-bit floats). Under strict fixed-precision constraints, these models lose their Turing completeness. Future work must explore the computational bounds of these models under realistic finite-precision limits.
  • Non-Rational Functions: The current formalization relies on piecewise-linear approximations and forbids standard transcendental functions like sine, cosine, and softmax because they are not rational functions. Investigating the theoretical impact of these standard functions remains an open challenge.

Summary updated

BibTeX
@inproceedings{perez2019turing,
  author = {Jorge Pérez and Javier Marinkovic and Pablo Barceló},
  title = {{On the Turing Completeness of Modern Neural Network Architectures}},
  booktitle = {International Conference on Learning Representations},
  year = {2019},
  url = {https://openreview.net/forum?id=kGOKlVnA6VM},
}
Figure