Linearizing Expression Trees for Neural Symbolic Reasoning

This direction is split into other directions: expression tree linearization. Its last version stays readable and citable here.

Version 1 of 134 papers40 conceptsfrozen 2026-10-04

Mathematical expressions are inherently hierarchical. When we write $y = 3 \times (x + 2)$, we are describing a tree where the multiplication operator sits above an addition operator. However, modern deep learning architectures—specifically Transformers—are designed to process linear sequences of tokens, not branching trees.

To bridge this gap, researchers have converged on a powerful technique: linearization. By converting hierarchical expression trees into specific sequential formats like prefix (Polish) or postfix (Reverse Polish) notation, we can treat symbolic reasoning as a standard translation or generation task.

The Syntax Barrier of Infix Notation

Standard mathematical notation (infix) is "machine-hostile" for two reasons. First, it relies on operator precedence (multiplication before addition). Second, it requires parentheses to override that precedence. For a neural model, parentheses are "structural bookkeeping" tokens that carry no numerical value but are syntactically brittle; a single missing closing bracket can render an entire generated formula invalid.

To solve this, Lei Wang, Yan Wang, and colleagues in Translating a Math Word Problem to an Expression Tree proposed representing equations as expression trees and then flattening them using postorder traversal. This approach eliminates the need for parentheses entirely, simplifying the output vocabulary and reducing structural errors in math word problem solving.

Flattening the Tree: Prefix and Postfix

The core mechanism of linearization involves traversing an expression tree in a deterministic order to create a sequence where the relationship between operators and operands is defined by their position.

  1. Prefix Notation (Polish Notation): The operator precedes its operands (e.g., + 1 2). Stéphane d'Ascoli, Guillaume Lample, and François Charton utilized this in Deep symbolic regression for recurrence prediction to predict formulas for integer sequences. By using prefix notation, they ensured that every generated sequence could be uniquely parsed back into a computational tree without ambiguity.
  2. Postfix Notation (Reverse Polish Notation): The operands precede the operator (e.g., 1 2 +). This format is particularly robust for generative tasks. Nanxu Gong and Yanjie Fu demonstrate in Evolutionary Large Language Model for Automated Feature Transformation that postfix sequences significantly reduce "hallucinations" in Large Language Models (LLMs) because the model doesn't have to "plan" for a closing parenthesis several tokens in advance.

Why Linearization Works

The intuition behind why this works lies in grammar simplification. In a linearized sequence, the "state" of the mathematical expression is always clear from the tokens seen so far.

  • Reduced Search Space: By removing parentheses, the model has fewer tokens to choose from at each step. Dongjie Wang and Meng Xiao argue in their work on Reinforcement-Enhanced Autoregressive Feature Transformation that postfix notation ensures every generated sequence is structurally valid, allowing the model to focus on the semantic quality of the math rather than the syntax.
  • Explicit Precedence: In prefix or postfix notation, the order of operations is baked into the sequence order. This allows Transformers to capture operator precedence through their standard attention mechanisms. Christopher Hahn and Markus N. Rabe found that this allows models to Generalize to the Semantics of Logics, learning the underlying rules of logic rather than just memorizing patterns.

Bridging Symbolic and Numeric Realms

Linearization also enables multi-modal learning. If an equation is a sequence of tokens, it can be projected into the same embedding space as the numerical data it describes.

Kazem Meidani and Amir Barati Farimani introduced SNIP, which uses prefix-order trees to align equations with numeric data points. This "semantic fingerprinting" allows models to recognize that the sequence sin x and the numeric plot of a sine wave represent the same concept. Similarly, Jingmin Sun and Hayden Schaeffer applied this to Partial Differential Equations, using linearized sequences to help models extrapolate to unseen physics.

Limitations and Future Directions

While linearization solves the syntax problem, it does not automatically solve the "logic" problem. Alessandro Breccia and Marco Lippi noted in their study of arithmetic rooted trees that while Transformers can learn the internal syntax of these linearized trees, they still struggle with global mathematical properties, such as predicting prime numbers.

Furthermore, Hitomi Yanaka and Koji Mineshima point out in SyGNS that even with simplified representations, models can fail when logical nesting becomes too deep, suggesting that while linearization helps the model "speak" math, the "thinking" part remains a significant challenge.

Papers in this version

History & citationVersion 1 · 2026-10-04

Split into other directions · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_linearizing_expression_trees_for_neural__3ec11905,
  title = {Linearizing Expression Trees for Neural Symbolic Reasoning},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/linearizing-expression-trees-for-neural-symbolic-reasoning/rdr_3ec119057bff4bcab2afc349b12ab9fb},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-26},
}

This exact version (version 1, frozen text):

@misc{lacuna_linearizing_expression_trees_for_neural__3ec11905_v1,
  title = {Linearizing Expression Trees for Neural Symbolic Reasoning},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/linearizing-expression-trees-for-neural-symbolic-reasoning/rdr_3ec119057bff4bcab2afc349b12ab9fb/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-11-26},
}