Abstract
Large Language Models demonstrate remarkable mathematical capabilities but at the same time struggle with abstract reasoning and planning. In this study, we explore whether Transformers can learn to abstract and generalize the rules governing Elementary Cellular Automata. By training Transformers on state sequences generated with random initial conditions and local rules, we show that they can generalize across different Boolean functions of fixed arity, effectively abstracting the underlying rules. While the models achieve high accuracy in next-state prediction, their performance declines sharply in multi-step planning tasks without intermediate context. Our analysis reveals that including future states or rule prediction in the training loss enhances the models' ability to form internal representations of the rules, leading to improved performance in longer planning horizons and autoregressive generation. Furthermore, we confirm that increasing the model's depth plays a crucial role in extended sequential computations required for complex reasoning tasks. This highlights the potential to improve LLM with inclusion of longer horizons in loss function, as well as incorporating recurrence and adaptive computation time for dynamic control of model depth.
Introduction
Large Language Models (LLMs) have shown impressive performance in various domains, yet they often falter in tasks requiring multi-step reasoning and long-term planning. This study investigates whether these limitations are inherent to the Transformer architecture or a consequence of training objectives. To explore this, we utilize Elementary Cellular Automata (ECA) as a controlled environment. ECAs are discrete dynamical systems governed by simple local rules (Boolean functions). Because they require consistent logical application over time, they serve as an ideal testbed for evaluating a model's ability to infer and apply underlying "laws of physics" from observed data.
Methodology
We trained a standard Transformer encoder (4 layers, 8 heads) on sequences of ECA states. The primary objective was to determine if the model could generalize to unseen rules. We defined four distinct training tasks to probe different aspects of rule internalization:
- Orbit-State (O-S): Predicting the immediate next state ($T$) given past states ($0$ to $T-1$).
- Orbit-Orbit (O-O): Predicting multiple future states simultaneously.
- Orbit-State and Rule (O-SR): Predicting the next state and the specific Boolean rule used.
- Rule and Orbit-State (RO-S): Predicting the next state when the rule is provided as an explicit input.
The dataset consisted of $9.5 \times 10^5$ training samples and $10^5$ test samples, generated with a lattice size of $W=20$ and a neighborhood radius $r=2$. Crucially, the test set contained rules never seen during training, forcing the model to abstract the concept of rule-following rather than memorizing specific orbits.
Results and Analysis
The Transformer demonstrated a strong ability to generalize, achieving a per-bit accuracy of 0.96 for immediate next-state prediction on unseen rules. This indicates that the architecture can successfully abstract the "meta-rule" of how Boolean functions of a fixed arity operate.
The Planning Wall and Rule Internalization
A significant performance drop was observed when the model was required to "jump" multiple steps into the future without intermediate context (look-ahead planning). While $T+1$ prediction was highly accurate, accuracy for $T+3$ declined sharply. However, models trained with explicit rule-prediction objectives (O-SR) showed improved planning capabilities. This suggests that forcing the model to represent the "why" (the rule) facilitates calculating the "what" (future states).
Depth as Computation
Our analysis revealed a linear relationship between model depth and the number of reasoning steps the model could handle. Predicting future states without intermediate context requires the Transformer to perform sequential operations across its layers. For example, predicting 4 steps ahead required approximately 10 layers, whereas 1 step ahead required only 2.
Autoregressive vs. Look-ahead
Autoregressive generation—where the model predicts one step, feeds it back as input, and then predicts the next—significantly outperformed direct look-ahead planning. This underscores the Transformer's reliance on intermediate "scratchpad" states to maintain accuracy over long horizons.
Conclusion
This research demonstrates that Transformers can learn to abstract logical rules, but their capacity for multi-step reasoning is constrained by model depth and training objectives. To enhance the reasoning capabilities of LLMs, future work should focus on incorporating longer horizons into loss functions and exploring architectural modifications like recurrence or Adaptive Computation Time (ACT) to allow for dynamic depth based on task complexity.
Summary updated