The Geometry of Logic: Stratification Induces Semantic Structure and Robust Reasoning
Organizations: University of California, Irvine · University of California, Davis
Abstract
Transformer-based language models perform well on symbolic tasks, yet it remains unclear whether they learn generalizable rules or rely on statistical shortcuts. Mechanistic studies link algorithmic behavior to structured internal representations, motivating the hypothesis that robust reasoning benefits from separating values from the types that control their manipulation. Can making this separation an architectural primitive improve the learnability and generalization of logical mechanisms? We introduce STRAT (STratified Registers And Types), which partitions the residual stream into orthogonal Data and Type subspaces and uses Type-based attention and gating to govern Data transformations. Controlled arithmetic ablations identify three failure modes associated with data-control interference: the Linear Trap, Gradient Wall, and Open Gate Trap. Mechanistic analysis reveals interpretable logical structure, and in arithmetic, STRAT reduces median OOD error 35-fold relative to a Transformer baseline. On each of 11 datasets spanning 10 tasks, STRAT outperforms the Transformer baseline in mean accuracy, by 26 percentage points on average, with both models trained from 10 base examples per dataset using identical task-specific augmentation where applicable. Under distribution shift, STRAT's mean accuracy drops by only 2.39 percentage points, compared with 11.75 for the Transformer.
Figures & tables
| Index | Content | Functional Role |
|---|---|---|
| D0 | Value | Numerical magnitude (Payload) |
| D1–D4 | Flags | Type Indicators (IsNum, IsOp, etc.) |
| D5 | Accu | Conditional Storage |
| ID MAE (Train) | OOD MAE (Test) | |||||||
| Cfg | Strategy | Hypothesis | 25% | Med | 75% | Med | 75% | Diagnosis / Mechanism |
| Ref | Hand-Coded | Existence Proof | 0.0 | 0.0 | 0.0 | 0 | 0 | Geometric Logic |
| A | Simplified Xformer | Standard Training | 3.5 | 15.5 | 38.2 | 5,977 | 10,809 | Linear Trap |
| A s | A Scaled | Scale Invariance | 97.1 | 98.7 | 100.1 | 6,202 | 6,265 | Linear Trap |
| A ln | LayerNorm | Internal Stability | 9.6 | 16.9 | 25.9 | 8,378 | 9,856 | Feature Collapse |
| A curr | Curriculum | Complexity Sched. | 212.2 | 600.3 | 1736.1 | 2306 | 2,682 | Linear Trap |
| OOD MAE Distribution (Lower is Better) | Success Rates (Higher is Better) | ||||
| Model | 10%-ile | 25%-ile | Median | Strict ( 20) | Logic ( 100) |
| Baseline (Config A) | |||||
| STRAT Flat (2D/1H) | |||||
| STRAT Flat MH (2D/2H) | |||||
| STRAT Compact (3D/1H) | |||||
| STRAT Std (4D/1H) | |||||
| Task | Dataset | STRAT (Ours) | Transformer | ||||
| ID Acc. (%) | OOD Acc. (%) | ID Acc. (%) | OOD Acc. (%) | ID Acc. | OOD Acc. | ||
| Constraint satisfaction Sudoku solving | SATNet Sudoku ( Wang et al., 2019 ) | ( -2.78 ) | ( -17.74 ) | ||||
| Formula satisfaction classification Given-assignment satisfaction | SATBench ( Wei et al., 2025 ) | ( -1.83 ) | ( -1.16 ) | ||||
| Formula satisfaction classification Given-assignment satisfaction | SATLIB ( Hoos and Stützle, 2000 ) | ( -0.02 ) | ( -6.49 ) | ||||
| Board classification Winner detection | Tic-Tac-Toe Endgame ( Aha, 1991 ) | ( -3.54 ) | ( -20.42 ) | ||||
| State-transition prediction Next-state prediction | Game of Life ( Strandgaard, 2023 ) | ( -9.45 ) | ( -11.46 ) | ||||
Appendix figures & tables6 assets
Supplementary material from the paper’s appendix.
Appendix
| Index | Identifier | Functional Role |
|---|---|---|
| D0 | Value | Numerical magnitude (Payload) |
| D1 | Is_Num | Binary flag ( ) for numerical literals |
| D2 | Is_Add | Binary flag ( ) for the ‘+’ operator |
| D3 | Is_Sub | Binary flag ( ) for the ‘-’ operator |
| D4 | Is_Op | Generic flag ( ) for any operator |
| D5 | Accu | Reserved register for conditional storage |
| Token | D0 | D1 | D2 | D3 | D4 | D5 |
|---|---|---|---|---|---|---|
| Literal ( ) | ||||||
| Plus ( ) | ||||||
| Minus ( ) |
| Config | Name | Mechanism / Modification | Hypothesis Tested |
|---|---|---|---|
| A | Baseline | Standard Xavier initialization; Raw inputs. | Can standard GD solve it? |
| A | Scaled | Inputs/Targets scaled (max-normalized). | Is magnitude the problem? |
| A ln | LayerNorm | Internal LayerNorm | Feature Collapse (OOD Fail) |
| A curr | Curriculum | Range | Linear Trap (Locked Early) |
| B fl | Frozen Logic | Logic weights fixed to ideal; others learned. | Can gradients flow through logic? |
| B fa | Frozen Attn | Attention weights fixed to Oracle (Perfect). | Is the failure in Routing or Logic? |
| Feature | Standard (Run 1) | Mirror (Run 2) |
|---|---|---|
| Readout Sign | Positive ( ) | Negative ( ) |
| Default Operation | Addition ( ) | Subtraction ( ) |
| Active Trigger | MINUS Token | PLUS Token |
| Attention Role | Pass-through | Signal Inversion |
| Resulting Logic |
| Dataset | STRAT parameters | Transformer parameters |
|---|---|---|
| SATNet Sudoku | 396,335 | 805,349 |
| SATBench | 1,648 | 5,310 |
| SATLIB | 1,648 | 5,310 |
| Tic-Tac-Toe Endgame | 33,474 | 58,498 |
| Game of Life | 17,993 | 30,761 |
| PMLB Parity5 | 35,314 | 60,594 |
| OOD MAE | Runs below threshold | ||||
| Model | P10 | P25 | Median | MAE | MAE |
| Baseline (Config A) | 5,072 | 6,268 | 9,046 | 0% | 0% |
| LSTM-controlled NAC | 4,120 | 5,083 | 5,819 | 0% | 0.25% |
| LSTM-controlled NALU | 4,973 | 5,327 | 5,770 | 0% | 0% |
| STRAT Flat (2D/1H) | 33 | 80 | 293 | 5% | 31% |
| STRAT Flat MH (2D/2H) | 38 | 97 | 314 | 2% | 27% |
LLM Reasoning
Large language model reasoning studies how models solve multi-step problems, verify intermediate steps, and use computation or tools reliably.
See all 931 papers