Abstract
Large-scale transformer models like RoBERTa and XLNet demonstrate high performance on Natural Language Inference (NLI) benchmarks. However, these benchmarks often conflate formal logic with heuristic common-sense knowledge. This paper investigates whether transformers can master the formal logical principles underlying natural language by evaluating them on mathematically controlled fragments of English. Using synthetic datasets verified by automated theorem provers, the study reveals that while transformers achieve high accuracy on in-distribution data, they fail to generalize to longer reasoning chains or harder proofs. The results suggest that these models rely on statistical artifacts of the data generation process rather than internalizing logical rules.
Introduction
Natural Language Inference (NLI) is a cornerstone of Natural Language Processing (NLP), requiring models to determine if a hypothesis follows logically from a premise. Standard datasets like SNLI or MNLI are often "noisy," mixing linguistic nuances with world knowledge (e.g., the common-sense inference that "riding a bicycle" implies "being outdoors"). To isolate the formal reasoning component, this research utilizes "fragments" of natural language—subsets of English that are mathematically precise enough to be translated into first-order logic. The central question is whether transformers can learn the abstract rules of logic, such as syllogisms, purely from textual exposure.
Methodology
The researchers employed a rigorous, synthetic approach to evaluate reasoning capabilities across five distinct English fragments ($\mathcal{S}^+$, $\mathcal{R}$, $\mathcal{R}^+$, $\mathcal{S}_r$, $\mathcal{S}_{rn}$). These fragments range in complexity from simple syllogisms ("Every artist is a beekeeper") to complex relational statements involving relative clauses ("Every artist who is not a dentist is a carpenter").
Automated Ground Truth
Unlike human-labeled datasets, the ground truth for these fragments was established using the Vampire automated theorem prover (ATP). This provided a "gold standard" for whether a set of sentences was logically consistent (satisfiable) or contradictory. This approach allowed the authors to measure problem "hardness" based on proof length—the number of steps required to find a contradiction.
Model Training
Three state-of-the-art models—RoBERTa, XLNet, and Electra—were fine-tuned on large-scale synthetic datasets. Each fragment consisted of 60,000 training examples and 8,000 evaluation examples. Crucially, the researchers created "out-of-distribution" test sets involving longer reasoning chains and "hard" problems to determine if the models were truly learning logic or merely memorizing shortcuts.
Analysis of Reasoning Capabilities
The Illusion of Logic
On random, in-distribution test sets, the transformers performed remarkably well, often achieving accuracy between 80% and 94%. However, this performance proved brittle. When the test data shifted even slightly—such as increasing the length of the reasoning chain—accuracy plummeted. For example, in the $\mathcal{S}^+$ fragment, accuracy dropped by over 10 percentage points when models were tested on problems larger than those seen during training.
The Complexity Paradox
Models performed surprisingly well on fragments that are theoretically EXPTIME-complete. This suggests the models were not actually solving the hard logic; instead, they were likely exploiting statistical "artifacts" in how the random problems were generated, such as the ratio of nouns to sentences.
Failure to Generalize
A robust understanding of logic should be scale-invariant; a model capable of solving a 5-step problem should easily handle a 2-step problem. Transformers failed this test: models trained on "hard" problems (long proofs) often performed worse on "easy" ones (short proofs). This indicates that the models learned specific "proof templates" rather than general logical principles.
Key Results
- In-Distribution Success: Models achieved 93-94% accuracy on the $\mathcal{R}$ and $\mathcal{S}_r$ fragments when the test data matched the training distribution.
- Chain Length Sensitivity: In the $\mathcal{S}^+$ fragment, as the "chain" of reasoning grew longer than the training examples, the ability to detect contradictions degraded significantly.
- The Hard vs. Easy Gap: Models trained on "easy" problems (proof length $\le 12$) were nearly perfect on similar tasks but dropped to near-chance performance when faced with "hard" problems (proof length $\ge 42$).
Discussion and Conclusion
The findings suggest that while transformers are world-class pattern recognizers, they are not yet reliable logicians. They tend to overfit to the parameters of the data generator rather than internalizing the underlying logical structure of the language.
Future Directions: * Enhanced Supervision: Investigating whether providing the actual logical formulas or proof steps as additional signals helps models learn better. * Modular Architectures: Moving toward models that explicitly handle symbolic logic rather than relying on monolithic transformer blocks. * Scaling: Testing whether larger models (like GPT-4) exhibit these same brittle reasoning patterns.
In summary, the "logic" displayed by current transformers in NLI tasks is largely an artifact of pattern matching, highlighting a significant gap between statistical correlation and formal reasoning.
Summary updated