EGG-SR: Embedding Symbolic Equivalence into Symbolic Regression via Equality Graph

## Abstract

Abstract Symbolic regression seeks to uncover physical laws from experimental data by searching for closed-form expressions, which is an important task in AI-driven scientific discovery. Yet the exponential growth of the search space of expression renders the task computationally challenging.
A promising yet underexplored direction for reducing the effective search space
and accelerating training lies in symbolic equivalence : many
expressions, although syntactically different, define the same function – for example, log ⁡ ( x 1 2 ​ x 2 3 ) \log(x_{1}^{2}x_{2}^{3}) , log ⁡ ( x 1 2 ) + log ⁡ ( x 2 3 ) \log(x_{1}^{2})+\log(x_{2}^{3}) , and 2 ​ log ⁡ ( x 1 ) + 3 ​ log ⁡ ( x 2 ) 2\log(x_{1})+3\log(x_{2}) .
Existing algorithms treat such variants as distinct outputs, leading to redundant exploration and slow learning.
We introduce EGG-SR, a unified framework that integrates equality graphs (e-graphs) into diverse symbolic regression algorithms, including Monte Carlo Tree Search (MCTS), deep reinforcement learning (DRL), and large language models (LLMs).
EGG-SR compactly represents equivalent expressions through the proposed EGG module, enabling more efficient learning by:
(1) pruning redundant subtree exploration in EGG-MCTS,
(2) aggregating rewards across equivalence classes in EGG-DRL, and
(3) enriching feedback prompts in EGG-LLM.
Under mild assumptions, we show that embedding e-graphs tightens the regret bound of MCTS and reduces the variance of the DRL gradient estimator.
Empirically, EGG-SR consistently enhances multiple baselines across challenging benchmarks, discovering equations with lower normalized mean squared error than state-of-the-art methods. Code implementation is available at: https://www.github.com/jiangnanhugo/egg-sr.

## 1 Introduction

Symbolic regression aims to automatically discover physical laws from experimental data and has been widely used in scientific domains (doi:10.1126/science.1165893; journal/2020/aifrynman; cory2024evolving; doi:10.1073/pnas.2413441122).
Many contemporary algorithms for symbolic regression formulate the search for optimal expressions as a sequential decision-making process.
In literature, existing models learn to predict the optimal sequence of grammar rules (DBLP:conf/iclr/Sun0W023), the pre-order traversal sequence for expression trees (DBLP:conf/iclr/PetersenLMSKK21; DBLP:conf/nips/KamiennydLC22), or directly executable strings that follow Python syntax (DBLP:journals/iclr/llmsr25; DBLP:conf/iclr/ZhangCXB025). This task remains computationally challenging due to its NP-hard nature (journal/tmlr/virgolin2022), that is, the search space of candidate expressions grows exponentially with the data dimension.

A promising yet underexplored direction for reducing the effective search space and accelerating discovery is the integration of symbolic equivalence into learning algorithms. For example, these expressions $\log(x_{1}^{2}x_{2}^{3})$, $\log(x_{1}^{2})+\log(x_{2}^{3})$, and $2\log(x_{1})+3\log(x_{2})$ all represent the same math function and are therefore symbolically equivalent.
Ideally, a well-trained model would recognize such equivalences and assign identical probabilities, rewards, or losses to the corresponding predicted expressions (DBLP:conf/icml/AllamanisCKS17), since these expressions produce identical functional outputs and attain the same prediction error on the dataset.
In the literature, existing algorithms treat these expressions as distinct outputs, leading to redundant exploration of the search space and slow convergence.
The main challenge of this direction is: how to represent equivalent expressions and embed them into modern learning models in a unified and scalable manner?

Since the number of equivalent variants grows exponentially with expression length, explicitly representing the full set of equivalent expressions quickly becomes both time-consuming and memory-intensive.
To address this challenge, a line of recent works introduced the equality graph (e-graph), a data structure that compactly encodes the set of equivalent variants by storing shared sub-expressions only once (DBLP:journals/pacmpl/NandiWZWSASGT21; DBLP:journals/pacmpl/WillseyNWFTP21; DBLP:journals/pacmpl/KurashigeJGBNIJ24).
E-graphs have since been successfully applied to diverse tasks, including program optimization (DBLP:journals/corr/abs-2407-12794), dataset generation of equivalent expressions (DBLP:conf/naacl/ZhengWGK25), duplicate detection (DBLP:conf/gecco/olivetti25), and expression simplification (DBLP:conf/gecco/FrancaK23).
Despite these advances, we find that a general framework that enables diverse symbolic regression algorithms to interact with e-graphs for accelerating the discovery remains missing.

We present a unified framework, Egg-SR, that integrates symbolic equivalence into learning algorithms using e-graphs, to accelerate a broad range of symbolic regression methods. Our framework encompasses Egg-enhanced Monte Carlo Tree Search (Egg-MCTS), Egg-enhanced Deep Reinforcement Learning (Egg-DRL), and Egg-enhanced Large Language model (Egg-LLM). The core idea is to leverage e-graphs to efficiently sample multiple equivalent variants of expressions and compute a new equivalence-aware learning objective. Specifically,
(1) in search tree–based methods, Egg-MCTS prunes redundant exploration over equivalent subtrees;
(2) in reward-driven learning, Egg-DRL aggregates rewards over equivalent expressions, stabilizing training;
(3) in LLM-based approaches, Egg-LLM enriches the feedback prompt with multiple equivalent expressions to better guide next round generation. Under mild theoretical assumptions, we show the benefit of embedding symbolic equivalence into learning:
(1) Egg-MCTS offers a tighter regret bound than standard MCTS (DBLP:conf/iclr/Sun0W023), and
(2) The gradient estimator of Egg-DRL exhibits a lower variance than that of standard DRL (DBLP:conf/iclr/PetersenLMSKK21).

In experiments, we evaluate Egg-SR with a wide class of symbolic regression baselines across several challenging benchmarks. We demonstrate its advantages over existing approaches using Egg than without. The e-graph module consistently improves performance across diverse frameworks, including MCTS, DRL, and LLM. Egg helps to discover symbolic expressions with lower normalized mean squared error than baseline methods.

## 2 Preliminaries

Symbolic Expression.
Let $\mathbf{x}=(x_{1},\ldots,x_{n})$ denote input variables and $\mathbf{c}=(c_{1},\ldots,c_{m})$ be coefficients.
A symbolic expression $\phi$ connects these variables and coefficients using mathematical operators such as addition, multiplication, and logarithms.
For example, $\phi=3\log x_{1}+2\log x_{2}$ is a symbolic expression composed of variables $\{x_{1},x_{2}\}$, operators $\{+,\log\}$, and coefficients $\{c_{1}=3,c_{2}=2\}$. Symbolic expressions can be represented as binary trees (DBLP:conf/gecco/olivetti25), pre-order traversal sequences of the tree (DBLP:conf/iclr/PetersenLMSKK21), or sequences of production rules defined by a context-free grammar (DBLP:conf/iclr/Sun0W023).

To uniformly handle all symbolic objects in this work, we use a context-free grammar to represent symbolic expressions.
The grammar is defined by the tuple $\langle V,\Sigma,R,S\rangle$ where
(1) $V$ is a set of non-terminal symbols representing arbitrary sub-expressions, such as $V=\{A\}$;
(2) $\Sigma$ is a set of terminal symbols, including input variables and coefficients, i.e., $\{x_{1},\dots,x_{n}\}\cup\{\mathtt{const}\}$;
(3) $R$ is a set of production rules representing mathematical operations, such as addition or multiplication. For example, $A\to A\times A$ denotes multiplication, and the semantics is to replace the left-hand side with the right-hand side;
(4) $S$ is the start symbol, typically set to $S=A$.

By applying a sequence of production rules from the start symbol, each rule sequentially replaces the first non-terminal symbol in the expression. The resulting expression, free of non-terminals, corresponds to a valid expression. Consider an example rule sequence $(A\to A\times A,A\to\texttt{const},A\to\log(x_{1}))$. The first multiplication rule $A\to A\times A$ expands the start symbol $\phi=A$ to $\phi=A\times A$. Applying the second rule $A\to\texttt{const}$ yields $\phi=c_{1}\times A$. Finally, we obtain $\phi=c_{1}\log(x_{1})$.

Symbolic Equivalence under a Rewrite System.
Rewrite rules are employed to simplify, rearrange, and reformulate expressions in tasks, such as code optimization and automated theorem proving (huet1980equations; DBLP:journals/pacmpl/NandiWZWSASGT21). A rewrite system provides a systematic procedure for transforming expressions by replacing sub-expressions according to predefined patterns.

Formally, a rewrite rule $r_{i}$ is written as “$\mathtt{LHS}\leadsto\mathtt{RHS}$”, where the left-hand side ($\mathtt{LHS}$) specifies a match pattern and the right-hand side ($\mathtt{RHS}$) specifies its replacement.
Given a set of rules $\mathcal{R}=\{r_{1},\ldots,r_{L}\}$, the *symbolic equivalence* relation $\equiv_{\mathcal{R}}$ induced by $\mathcal{R}$ is defined as follows: for two symbolic expressions $\phi_{1}$ and $\phi_{2}$,

$$ $\phi_{1}\equiv_{\mathcal{R}}\phi_{2}\qquad\Longleftrightarrow\qquad\phi_{1}\to^{*}\phi_{2}\;\text{ or }\;\phi_{2}\to^{*}\phi_{1},$ (1) $$

where $\phi_{1}\to^{*}\phi_{2}$ denotes that $\phi_{1}$ can be transformed into $\phi_{2}$ through a finite sequence of applications of rules in $\mathcal{R}$. In other words, two expressions are equivalent under $\mathcal{R}$ if one can be rewritten into the other by repeated application of these rules. In this work, we systematically encode known mathematical identities as rewrite rules $\mathcal{R}$ to generate equivalent variants of symbolic expressions.

Figure: Figure 1: Applying the rewrite rule $\log(a\times b)\leadsto\log(a)+\log(b)$ to an e-graph representing expression $\log(x_{1}^{3}x_{2}^{2})$. (a) The initialized e-graph consists of *e-classes* (dashed boxes), each containing equivalent *e-nodes* (solid boxes). Edges connect e-nodes to their child e-classes. (b) The matching step identifies the e-nodes that match the $\mathtt{LHS}$ of the rule. (c) The substitution step adds new e-classes and edges corresponding to the $\mathtt{RHS}$ to the e-graph. (d) The merging step consolidates equivalent e-classes. The final e-graph in (d) compactly represents two equivalent expressions.
Refer to caption: x1.png

For example, consider the rewrite rule $r_{1}=\log(a\times b)\leadsto\log(a)+\log(b)$, where $a$ and $b$ are placeholders for arbitrary sub-expressions. In our grammar-based representation, $\mathtt{LHS}$ corresponds to the rule sequence $(A\to\log(A),\ A\to A\times A,\ A\to a,\ A\to b)$, and $\mathtt{RHS}$ corresponds to $(A\to A+A,\ A\to\log(A),\ A\to a,\ A\to\log(A),\ A\to b)$.
Applying $r_{1}$ to $\phi_{1}=\log(x_{1}^{3}x_{2}^{2})$ yields $\phi_{2}=\log(x_{1}^{3})+\log(x_{2}^{2})$. Thus $\phi_{1}$ and $\phi_{2}$ are *symbolically equivalent* under $r_{1}$.

Symbolic Regression searches for a closed-form expression from the experimental data, which are widely applied in diverse scientific domains (doi:10.1126/sciadv.abq0279). Given a dataset ${D}=\{(\mathbf{x}_{i},y_{i})\}_{i=1}^{N}$, the task searches for the optimal expression $\phi^{*}$, that minimizes the averaged loss on the dataset:

$$ $\phi^{*}\leftarrow\arg\min_{\phi\in\Phi}\;\frac{1}{N}\sum\nolimits_{i=1}^{N}\ell(\phi(\mathbf{x}_{i},\mathbf{c}),y_{i}),$ $$

where $\Phi$ denotes the search space containing all expressions;
the loss function $\ell$ measures the distance between the output of the candidate expression $\phi(\mathbf{x}_{i},\mathbf{c})$ and the ground truth $y_{i}$.
The coefficient $\mathbf{c}$ within expression $\phi$ are optimized on training data ${D}$ using optimizers, like BFGS (fletcher2000practical).
Since the search space of expressions $\Phi$ is exponentially large in the data dimension, finding the optimal expression is challenging. In fact, this task has been proven NP-hard (journal/tmlr/virgolin2022). Recent works to mitigate this challenge are reviewed in section [4](https://arxiv.org/html/2511.05849v1#S4).

## 3 Methodology

### 3.1 Egg : Equality graph for Grammar-based Symbolic Expression

Enumerating all equivalent variants of a symbolic expression is combinatorially expensive. Storing these variants explicitly (e.g., in an array) is highly space-inefficient. To mitigate this challenge, we adopt the recently proposed Equality graph (i.e, e-graph) data structure (DBLP:journals/pacmpl/WillseyNWFTP21; DBLP:journals/jar/WaldmannTRB22), which compactly represents the set of equivalent expressions by sharing common subexpressions. We extend e-graphs to support grammar-based symbolic expressions, noted as Egg, facilitating seamless integration with symbolic regression algorithms.

Definition.
An e-graph consists of a collection of equivalence classes, called e-classes. Each e-class contains a set of e-nodes representing symbolically equivalent sub-expressions (DBLP:journals/pacmpl/WillseyNWFTP21). Each e-node encodes a mathematical operation and references a list of child e-classes corresponding to its operands. Edges always point from an e-node to e-classes.

Figure [1](https://arxiv.org/html/2511.05849v1#S2.F1)(d) shows an example e-graph. The color-highlighted part is an e-class (in dashed box) containing two e-nodes (in solid boxes): “$A\to\log(A)$” and “$A\to A+A$”. The two e-nodes represent logarithmic operation and addition, respectively. The e-node “$A\to\log(A)$” has a single edge to its child e-class “$A\to A\times A$”, because $\log$-operator involves one operand.

Construction. An e-graph is initialized with a sequence of production rules, representing an input expression. A predefined set of mathematical laws is formatted as rewrite rules (as defined in section [2](https://arxiv.org/html/2511.05849v1#S2)).
Each rule is applied by matching its left-hand side ($\mathtt{LHS}$) pattern against the current e-graph, which involves traversing all e-classes to identify subexpressions that match $\mathtt{LHS}$.
For every successful match, new e-classes and e-nodes corresponding to the right-hand side ($\mathtt{RHS}$) of the rule are created. A merge operation is applied to incorporate the new e-class into the matched e-class, thereby preserving the structure of known equivalences. This process, known as equality saturation, iteratively applies pattern matching and merging until either no further rules can be applied or a maximum number of iterations is reached.

Figure [1](https://arxiv.org/html/2511.05849v1#S2.F1) shows an example of e-graph construction with the rewrite rule $\log(a\times b)\leadsto\log(a)+\log(b)$, where $a$ and $b$ are placeholders for arbitrary sub-expressions. The e-graph in initialized with an expression $\phi=\log(x_{1}^{3}x_{2}^{2})$ in Figure [1](https://arxiv.org/html/2511.05849v1#S2.F1)(a). The $\mathtt{LHS}$ is matched against the color-highlighted e-classes in Figure [1](https://arxiv.org/html/2511.05849v1#S2.F1)(b), where $a=x_{1}^{3}$ and $b=x_{2}^{2}$.
The substitute step first constructs e-classes and e-nodes that represent $\mathtt{RHS}$, which are color-highlighted in Figure [1](https://arxiv.org/html/2511.05849v1#S2.F1)(c). One e-class is merged with the matched e-class in Figure [1](https://arxiv.org/html/2511.05849v1#S2.F1)(d). The resulting e-graph represents the set of two equivalent expressions: $\log(x_{1}^{3}x_{2}^{2})$ and $\log(x_{1}^{3})+\log(x_{2}^{2})$.
The e-graph in Figure [1](https://arxiv.org/html/2511.05849v1#S2.F1)(d) is space-efficient, because two sub-expressions $x_{1}^{3}$ and $x_{2}^{2}$ are stored only once in the e-graph.
Additional Egg visualizations on more complex expressions—including those involving trigonometric and partial-derivative rewrite rules—are provided in Appendix [F.1](https://arxiv.org/html/2511.05849v1#A6.SS1).

Extraction.
After the e-graph is saturated, an extraction step is performed to obtain $K$ representative expressions (DBLP:journals/pacmpl/GoharshadyLP24).
Because an e-graph encodes up to an exponential number of equivalent expressions, exhaustive enumeration is computationally infeasible.
We therefore adopt two practical strategies:
(1) *cost-based extraction*, which selects several simplified expressions by minimizing a user-defined cost function over operators and variables, and
(2) *random-walk sampling*, which generates a batch of expressions by stochastically traversing the e-graph.
The detailed procedure is provided in Appendix [A.4](https://arxiv.org/html/2511.05849v1#A1.SS4).

Implementation.
Most existing e-graph implementations are either in Haskell (DBLP:journals/pacmpl/WillseyNWFTP21) or provided as Python wrappers (shanabrook2024egglogpythonpythoniclibrary), neither of which is well-suited for symbolic regression. We therefore implement Egg in Python, following the algorithmic pipeline in (DBLP:journals/pacmpl/WillseyNWFTP21). Our implementation supports grammar-based expressions and integrates seamlessly with the sequential decision-making process, which is essential for integration with modern learning algorithms. Egg incorporates a wide class of rewrite rules, including those for logarithmic, trigonometric, and differential operators.
Implementation details are provided in Appendix [A](https://arxiv.org/html/2511.05849v1#A1).

### 3.2 Egg -SR: Embed Symbolic Equivalence into Symbolic Regression via Egg

Figure: Figure 2: Execution pipeline of our Egg-MCTS. (a) Starting at the root of the tree, the algorithm selects the child with the highest UCT score (in equation [2](https://arxiv.org/html/2511.05849v1#S3.E2)) until reaching a leaf. (b) The selected leaf is expanded by applying all applicable production rules, producing new child nodes. (c) For each child, several simulations are run to complete the expression template by sampling additional rules. The resulting expressions are fitted to the data to estimate their coefficients. (d) Rewards and visit counts from evaluated children are back-propagated up the tree. Updates are applied to the selected and also equivalent paths (highlighted in two colors), enabled by our Egg module.
Refer to caption: x2.png

Embedding Egg into Monte Carlo Tree Search.
MCTS (DBLP:conf/iclr/Sun0W023) maintains a search tree to explore optimal expressions. Each edge is labeled with a production rule, and the label of a node is determined by the sequence of edge labels from the root. By construction, the node label corresponds to either a valid or a partially complete expression. A node representing a partially complete expression can be further expanded by extending its children using production rules.

During learning, the MCTS algorithm executes the following four steps (DBLP:journals/kbs/BrenceTD21):
(1) Selection. Starting from the root node, successively select the production rule with the highest Upper Confidence Bound for Trees (UCT) (DBLP:conf/ecml/KocsisS06) to reach a leaf node $s$:

$$ $\mathtt{UCT}(s,a)=\mathtt{Reward}(s,a)+c\sqrt{{\log(\mathtt{visits}(s))}/{\mathtt{visits}(s,a)}}$ (2) $$

where $\mathtt{Reward}(s,a)$ is the average reward obtained by applying production rule $a$ at node $s$, $\mathtt{visits}(s)$ is the total visits to node $s$, and $\mathtt{visits}(s,a)$ is the number of times rule $a$ has been selected at $s$. The constant $c$ is used to balance exploration and exploitation.
(2) Expansion. At the selected leaf node $s$, expand the search tree by applying all applicable production rules to generate its child nodes.
(3) Simulation. For each child of $s$, conduct a fixed number of rollouts. In each rollout, generate a valid expression $\phi$ by randomly applying production rules. Then, estimate the optimal coefficients in $\phi$ and evaluate its fitness on the training data $D$. The reward for this rollout is typically defined as ${1}/{(1+\mathtt{NMSE}(\phi))}$.
(4) Backpropagation. Update the rewards and visit counts for node $s$ and all its ancestors up to the root node. After the final iteration, the expression with the highest fitness score, encountered during rollouts, is returned as the best expression.

Egg-based Backpropagation.
At the backpropagation step, we obtain the path from the root to the selected node $s$ along with the estimated reward. Using Egg, we identify equivalent paths and update their estimated rewards simultaneously. This procedure effectively propagates information as if rollouts had been performed on all equivalent subtrees.
Our approach is related to prior work on equivalence-aware search in MCTS (DBLP:conf/acml/LeurentM20; DBLP:conf/aips/CzechKK21). Concretely, the path—representing a partially completed expression—is first converted into an initial e-graph. The e-graph is then saturated by repeatedly applying the set of rewrite rules.
From this saturated e-graph, we sample several distinct equivalent sequences and check if the tree contains corresponding paths.
If so, we apply backpropagation to all of them. In this way, equivalent expressions share the same reward information, used to avoid redundant search.
Theorem [3.1](https://arxiv.org/html/2511.05849v1#S3.Thmtheorem1) shows that Egg-MCTS accelerates learning by reducing the effective branching factor compared with standard MCTS, meaning fewer child nodes are explored at each learning iteration.

An example execution pipeline of Egg-MCTS is provided in Figure [2](https://arxiv.org/html/2511.05849v1#S3.F2).
In Figure [2](https://arxiv.org/html/2511.05849v1#S3.F2)(d), we examine two distinct paths within the search tree maintained by the algorithm:

$$ $\displaystyle\text{Path }1:$ $\displaystyle\;(A\to\log(A),A\to A\times A,A\to x_{1}),\!$ $\displaystyle\text{Node }1:$ $\displaystyle\;s_{1}=\log(x_{1}\times A).$ $\displaystyle\text{Path }2:$ $\displaystyle\;(A\to A+A,A\to\log(A),A\to x_{1},A\to\log(A)),\!$ $\displaystyle\text{Node }2:$ $\displaystyle\;s_{2}=\log(x_{1})+\log(A).$ $$

Here, each path is a sequence of edge labels from the root to the leaf node $s_{i}$. Based on the grammar definition in section [2](https://arxiv.org/html/2511.05849v1#S2), node $s_{1}$ corresponds to the partially completed expression $\log(x_{1}\times A)$, while node $s_{2}$ represents $\log(x_{1})+\log(A)$. The two nodes are equivalent under the rewrite rule $\log(ab)\leadsto\log a+\log b$. Consequently, their rewards, estimating the averaged goodness-of-fit of expressions on the dataset, should be approximately equal:

$$ $\displaystyle\mathtt{Reward}(s_{1},a)\approx\mathtt{Reward}(s_{2},a),\qquad\forall\text{ rule }a\in\text{ the set of available rules}$ $$

Exploring sub-trees of $s_{1}$ and $s_{2}$ independently leads to redundant computation, as MCTS repeatedly traverses equivalent regions of the search space, slowing down learning.
With Egg-MCTS, the visit counts and reward estimates of both paths are updated simultaneously, eliminating the need for additional rollouts on the green leaf in Figure [2](https://arxiv.org/html/2511.05849v1#S3.F2)(d) in future rounds.

Embedding Egg into Deep Reinforcement Learning.
DRL employs a neural network-based sequential decoder to predict a sequence of production rules, which are then converted into valid expressions according to the grammar. The reward function assigns high values to predicted expressions that fit the training data well. The model is trained to maximize the expected reward of generated expressions evaluated on the training data (DBLP:journals/corr/abs-1801-03526; DBLP:conf/iclr/PetersenLMSKK21; landajuelaunified; ijcai2024p651).

At each step, a neural network-based sequential decoder samples the next production rule from a probability distribution over all available rules, conditioned on the previously generated sequence. The model emits a sequence $\tau$ with probability $p_{\theta}(\tau)$. The reward function is typically defined as
$\mathtt{reward}(\tau)={1}/{(1+\mathtt{NMSE}(\phi))}$.
The learning objective is to maximize the expected reward: $J(\theta):=\mathbb{E}_{\tau\sim p_{\theta}}\left[\mathtt{reward}(\tau)\right]$, whose gradient is $\mathbb{E}_{\tau\sim p_{\theta}}\left[\mathtt{reward}(\tau)\nabla_{\theta}\log p_{\theta}(\tau)\right]$.
In practice, the expectation is approximated via Monte Carlo. Drawing $N$ sequences $\{\tau_{1},\ldots,\tau_{N}\}$ from the decoder, we obtain the policy gradient estimator:

$$ $g(\theta)\approx\frac{1}{N}\sum\nolimits_{i=1}^{N}(\mathtt{reward}(\tau_{i})-b)\nabla_{\theta}\log p_{\theta}(\tau_{i}),$ (3) $$

where $b$ is a baseline to reduce estimator variance (DBLP:conf/uai/WeaverT01). Recently, (DBLP:conf/iclr/PetersenLMSKK21) proposes to use the Top-$25\%$ quantile of samples to replace the classic empirical mean.

Egg-based Policy Gradient Estimator.
For each sampled sequence $\tau_{i}$, we construct an e-graph that compactly encodes all of its equivalent expressions. From this e-graph, we extract $K-1$ equivalent sequences $\{\tau_{i}^{(2)},\ldots,\tau_{i}^{(K)}\}$. The estimator is then revised to

$$ $g_{\mathtt{egg}}(\theta)\approx\frac{1}{N}\sum\nolimits_{i=1}^{N}\big(\mathtt{reward}(\tau_{i})-b^{\prime}\big)\nabla_{\theta}\log\left[\sum\nolimits_{k=1}^{K}p_{\theta}(\tau_{i}^{(k)})\right],$ (4) $$

where $\tau_{i}^{(1)}$ is the original sequence $\tau_{i}$ and $b^{\prime}$ is the corresponding baseline, and $\sum_{k=1}^{K}p_{\theta}(\tau_{i}^{(k)})$ aggregates the probabilities of all equivalent sequences that share the same reward. The pipeline of DRL and Egg-DRL is presented in Figure [7](https://arxiv.org/html/2511.05849v1#A4.F7).
Theorem [3.2](https://arxiv.org/html/2511.05849v1#S3.Thmtheorem2) shows that Egg-DRL achieves a lower-variance estimator compared to the estimator in standard DRL (DBLP:conf/iclr/PetersenLMSKK21).

Embed Egg into Large-Language Model.
LLM is applied to search for optimal symbolic expressions with prompt tuning (DBLP:journals/iclr/llmsr25; DBLP:conf/acl/MerlerHDM24). The procedure consists of three key steps:
(1) Hypothesis Generation: The LLM generates multiple candidate expressions based on a prompt describing the problem background and the definitions of each variable.
(2) Data-Driven Evaluation: Each candidate expression is evaluated based on its fitness on the training dataset.
(3) Experience Management: In subsequent iterations, the LLM receives feedback in the form of previously predicted expressions and their corresponding fitness scores, allowing it to refine future generations. High-fitness expressions are retained and updated over multiple rounds of iteration.

Egg-based Feedback Prompt. Since LLMs typically generate Python functions rather than symbolic expressions directly, we introduce a wrapper that parses the generated Python code into symbolic expressions. These expressions are then transformed into e-graphs using a set of rewrite rules. From each e-graph, we extract semantically equivalent expressions and summarize them into a concise message, which is incorporated into the prompt for the next round. This augmentation enables the LLM to observe a richer set of functionally equivalent expressions, potentially improving the quality and accuracy of subsequent predictions.

### 3.3 Theoretical Insight on Egg -SR Accelerating Learning

Theorem [3.1](https://arxiv.org/html/2511.05849v1#S3.Thmtheorem1) establishes that augmenting MCTS with Egg yields an asymptotically tighter regret bound than standard MCTS, as the effective branching factor satisfies $\kappa_{\infty}\leq\kappa$.
Also, Theorem [3.2](https://arxiv.org/html/2511.05849v1#S3.Thmtheorem2) shows that embedding Egg into DRL produces an unbiased gradient estimator while strictly reducing gradient variance, ensuring more stable and efficient policy updates.

###### Theorem 3.1 .

Consider the MCTS learning framework augmented with Egg. As defined in Definitions [1](https://arxiv.org/html/2511.05849v1#Thmdefinition1) and [3](https://arxiv.org/html/2511.05849v1#Thmdefinition3),
let $T$ denote the total number of learning iterations, $\gamma\in(0,1)$ the discount factor of the corresponding Markov decision process,
$\kappa$ be the near-optimal branching factor of standard MCTS, and $\kappa_{\infty}$ the corresponding branching factor of Egg-MCTS. Then the regret bounds satisfy

$$ $\mathtt{regret}(T)\;=\;\widetilde{\mathcal{O}}\left(n^{-\frac{\log(1/\gamma)}{\log\kappa}}\right),\qquad\mathtt{regret}_{\mathtt{egg}}(T)\;=\;\widetilde{\mathcal{O}}\left(n^{-\frac{\log(1/\gamma)}{\log\kappa_{\infty}}}\right),\qquad\text{with }\kappa_{\infty}\leq\kappa$ $$

###### Proof Sketch.

Our proof builds on part of the analysis of (DBLP:conf/acml/LeurentM20, Theorem 16), which employs a graph structure to replace the search tree to aggregate identical states.
Their proof requires *unrolling* the graph into a tree that contains every path traversable in the graph.
The search tree in our Egg-MCTS behaves almost identically to this unrolled tree. Following their regret analysis of the unrolled tree, we obtain the final regret bounds.
A full proof is provided in Appendix [B](https://arxiv.org/html/2511.05849v1#A2).
∎

###### Theorem 3.2 .

Consider embedding Egg into the DRL framework.
Let $N$ samples be drawn from the distribution $p_{\theta}$, and Egg module provides additional $K-1$ equivalent variants for each sample.
(1) Unbiasedness.
The expectation of the standard estimator $g(\theta)$ equals that of the Egg-based estimator $g_{\mathtt{egg}}(\theta)$: $\mathbb{E}_{\tau\sim p_{\theta}}\big[g(\theta)\big]=\mathbb{E}_{\tau\sim p_{\theta}}\big[g_{\mathtt{egg}}(\theta)\big]$.
(2) Variance Reduction.
The variance of the proposed estimator is smaller than that of the standard estimator: $\mathrm{Var}_{\tau\sim p_{\theta}}\big[g_{\mathtt{egg}}(\theta)\big]\leq\mathrm{Var}_{\tau\sim p_{\theta}}\big[g(\theta)\big]$.

###### Proof Sketch.

To show unbiasedness, we follow the definition of the estimators to verify that the expected value of $g_{\mathtt{egg}}(\theta)$ equals that of $g(\theta)$. The key idea behind the variance reduction is that Egg groups together equivalent sequences that share the same reward. Grouping sequences with identical rewards leads to lower within-group variance. Full proof is provided in Appendix [C](https://arxiv.org/html/2511.05849v1#A3).
∎

###### Theorem 3.1 .

###### Proof Sketch.

###### Theorem 3.2 .

###### Proof Sketch.

## 4 Related Works

Symbolic Equivalence is a core concept in program synthesis and mathematical reasoning (DBLP:journals/pacmpl/WillseyNWFTP21). In SQL query optimization, it enables rewriting queries into equivalent but more efficient forms (DBLP:journals/corr/abs-2407-12794).
In hardware synthesis, it supports cost-aware rewrites such as optimized matrix multiplications (DBLP:conf/fccm/UstunSYYZ22). In formal methods, it accelerates automated theorem proving via normalization and equivalence checking (DBLP:journals/pacmpl/KurashigeJGBNIJ24).
In mathematical language processing, it enables the generation of paraphrased forms of mathematical expressions (DBLP:conf/naacl/ZhengWGK25). In symbolic regression, DBLP:conf/gecco/FrancaK23 leverages e-graphs to mitigate over-parameterization of candidate expressions. DBLP:conf/gecco/olivetti25 incorporates e-graphs into genetic programming to detect and eliminate redundant individuals. In contrast, our approach employs e-graphs not only for simplified variants but also to generate a richer set of equivalent variants, enabling easy integration into many symbolic regression algorithms.

Knowledge-Guided Scientific Discovery.
Recent efforts have explored incorporating physical and domain-specific knowledge to accelerate the symbolic discovery process. AI-Feynman (journal/2020/aifrynman; DBLP:conf/nips/UdrescuTFNWT20; keren2023computational; cornelio2023combining) constrained the search space to expressions that exhibit compositionality, additivity, and generalized symmetry. Similarly, DBLP:journals/corr/abs-2303-03192 encoded physical unit constraints into learning to eliminate physically impossible solutions. Other works further constrained the search space by integrating user-specified hypotheses and prior knowledge, offering a more guided approach to symbolic regression (DBLP:conf/icml/BendinelliBK23; kamienny:tel-04391194; DBLP:journals/iclr/llmsr25; taskin2025knowledge). DBLP:conf/iclr/ZhangCXB025 propose using retrieval-augmented generation to acquire new, informative data that accelerates the overall learning process.
Our Egg presents a new idea in knowledge-guided learning that is orthogonal to existing approaches.
An interesting direction for future work is to investigate whether Egg can be combined with these knowledge-guided strategies to further improve symbolic discovery.

Equivalence-aware Learning. Equivalence and symmetry have long been recognized as crucial for improving efficiency in search and learning. In MCTS, transposition tables exploit graph equivalence by merging nodes that represent the same underlying state, avoiding redundant rollouts and accelerating convergence (DBLP:conf/cig/ChildsBK08). More recent extensions explicitly leverage symmetries to prune symmetric branches of the search space (DBLP:journals/kbs/SaffidineCM12; DBLP:conf/acml/LeurentM20).
In reinforcement learning, symmetries in the state–action space have been used to accelerate convergence (grimm2020value).
Large Language Models (LLMs) also benefit from equivalence-awareness, particularly in code generation (sharma2025assessing).

## 5 Experiments

We show that (1) Egg enhances existing learning algorithms in discovering expressions with smaller Normalized MSEs.
(2) In case studies, Egg consistently exhibits both time and space efficiency.

### 5.1 Experiment Settings

Choice of Datasets We consider the Trigonometric dataset (DBLP:conf/pkdd/JiangX23), where each group contains 10 randomly sampled expressions. Also, we select 10 challenging equations from the Feynman dataset (DBLP:conf/nips/UdrescuTFNWT20).
In terms of baselines,

Evaluation Metrics. The goodness-of-fit indicates how well the learning algorithms perform in discovering underlying expressions. We use the normalized mean-squared error (NMSE) of the best-predicted expression by each algorithm, on a separately-generated testing dataset. Given a testing dataset ${D}_{\text{test}}=\{(\mathbf{x}_{i},y_{i})\}_{i=1}^{n}$ generated from the ground-truth expression, we measure the goodness-of-fit of a predicted expression $\phi$, by evaluating the normalized-mean-squared-error (NMSE):

$$ $\text{NMSE}(\phi)=\frac{1}{n\sigma_{y}^{2}}\sum_{i=1}^{n}(y_{i}-\phi(\mathbf{x}_{i}))^{2}$ (5) $$

The empirical variance $\sigma_{y}=\sqrt{\frac{1}{n}\sum_{i=1}^{n}\left(y_{i}-\frac{1}{n}\sum_{i=1}^{n}y_{i}\right)^{2}}$.
We use the NMSE as the main criterion for comparison in the experiments and present the results on the remaining metrics in the case studies.
The main reason is that the Normalized-MSE is less impacted by the output range. The exact experimental configuration details are provided in Appendix [E](https://arxiv.org/html/2511.05849v1#A5).

### 5.2 Overall Benchmarks

Impact of Egg on MCTS.
We conduct two analyses to evaluate the impact of integrating Egg into standard MCTS:
(1) the median normalized MSE of the TopK ($K=10$) expressions identified at the end of training, and
(2) the growth of the search tree, measured by the number of explored nodes over learning iterations. The dataset is selected from (DBLP:conf/pkdd/JiangX23) as the expressions contain $\sin,\cos$ operators, which contain many symbolic-equivalence variants. The detailed experimental setups, including the rewrite rules and datasets used in each comparison, are provided in Appendix [E](https://arxiv.org/html/2511.05849v1#A5).

Figure: Figure 3: On the “sincos(3,2,2)” dataset, we show (Left) Search tree size over learning iterations for MCTS and Egg-MCTS, and also (Right) Empirical mean and standard deviation of the estimated quantity for DRL and Egg-DRL.
Refer to caption: x3.png

Table [1](https://arxiv.org/html/2511.05849v1#S5.T1) shows that Egg-MCTS consistently discovers expressions with lower normalized quantile scores compared to standard MCTS. Figure [3](https://arxiv.org/html/2511.05849v1#S5.F3)(Left) illustrates that Egg-MCTS maintains a broader and deeper search tree, indicating exploration of a larger and more diverse search space.
Across various datasets, augmenting MCTS with Egg improves symbolic expression accuracy. This improvement is primarily due to the effectiveness of our rewrite rules, which cover a rich set of trigonometric identities and enable efficient exploration of symbolic variants in trigonometric expression spaces.

**Table 1: On Trigonometric datasets, median NMSE values of the best-predicted expressions found by all the algorithms. The 3-tuples at the top $(\cdot,\cdot,\cdot)$ indicate the number of free variables, singular terms, and cross terms in the ground-truth expressions generating the dataset. The set of operators is $\{\sin,\cos,+,-,\times\}$. The best result in each column is underlined.**
|  | Noiseless Setting | Noisy Setting |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
|  | $(2,1,1)$ | $(3,2,2)$ | $(4,4,6)$ | $(5,5,5)$ | $(2,1,1)$ | $(3,2,2)$ | $(4,4,6)$ | $(5,5,5)$ |
| Egg-MTCS | $<$1E-6 | $<$1E-6 | 0.006 | 0.009 | $\underline{0.005}$ | $\underline{0.012}$ | $\underline{0.091}$ | $\underline{0.121}$ |
| MTCS | 0.006 | 0.033 | 0.144 | 0.147 | $0.015$ | $0.007$ | $0.138$ | 0.150 |
| Egg-DRL | 0.020 | 0.161 | 2.381 | 2.168 | $\underline{0.07}$ | $\underline{0.35}$ | ${5.09}$ | $\underline{5.67}$ |
| DRL | 0.030 | 0.277 | 2.990 | 2.903 | $0.09$ | $0.44$ | $\underline{2.46}$ | $14.44$ |

**Table 2: Comparison of LLM, and Egg-LLM models on different scientific benchmark problems measured by the NMSE metric. The best result in each column is underlined.**
|  | Oscillation I | Oscillation II | Bacterial growth | Stress-Strain |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
|  | IID$\downarrow$ | OOD$\downarrow$ | IID$\downarrow$ | OOD$\downarrow$ | IID$\downarrow$ | OOD$\downarrow$ | IID$\downarrow$ | OOD$\downarrow$ |
| Egg-LLM (GPT3.5) | $<$1E-6 | $\underline{0.0004}$ | $<$1E-6 | $<$1E-6 | $\underline{0.0121}$ | $\underline{0.0198}$ | $\underline{0.0202}$ | $\underline{0.0419}$ |
| LLM-SR (GPT-3.5) | $<$1E-6 | $0.0005$ | $<$1E-6 | $3.81\text{E-}5$ | $0.0214$ | $0.0264$ | $0.0210$ | $0.0516$ |
| Egg-LLM (Mistral) | $<$1E-6 | $0.0002$ | $\underline{0.0021}$ | $\underline{0.0114}$ | $0.0101$ | ${0.0107}$ | $\underline{0.0133}$ | $\underline{0.0754}$ |
| LLM-SR (Mixtral) | $<$1E-6 | $0.0002$ | ${0.0030}$ | ${0.0291}$ | $\underline{0.0026}$ | $\underline{0.0037}$ | $0.0162$ | $0.0946$ |

Impact of Egg on DRL.
Table [1](https://arxiv.org/html/2511.05849v1#S5.T1) reports the median NMSE values of the best-predicted expressions discovered by Egg-DRL and standard DRL, under identical experiment settings. Expressions returned by Egg-DRL achieve a smaller NMSE value on noiseless and noisy settings. It shows that embedding Egg into DRL helps to discover expressions with better NMSE.
In Figure [3](https://arxiv.org/html/2511.05849v1#S5.F3) (Right), we plot the estimated objective, defined as $R(\tau_{i})\log p_{\theta}(\tau_{i})$ where each trajectory $\tau_{i}$ is sampled from the sequential decoder with probability $p_{\theta}(\tau_{i})$ (see Equation [3](https://arxiv.org/html/2511.05849v1#S3.E3)).
We plot the empirical mean and standard deviation of this objective over training iterations.
The observed reduction in variance is primarily due to the symbolic variants generated via the e-graph, which enable averaging over multiple equivalent expressions and thus yield more stable gradients.

Impact of Egg on LLM.
We evaluate the impact of augmenting LLMs with richer feedback prompts that incorporate equivalent expressions generated by Egg.
Following the dataset and experimental setup from the original paper (DBLP:journals/iclr/llmsr25), we summarize the results in Table [2](https://arxiv.org/html/2511.05849v1#S5.T2). The result of LLM-SR directly uses the reported result in (DBLP:journals/iclr/llmsr25).
The results show that integrating Egg enables the LLM to discover higher-quality expressions under the same experimental conditions.

### 5.3 Case Analysis

Space Efficiency of Egg.
We evaluate the space efficiency of the e-graph representation in comparison to a traditional array-based approach. The array-based method explicitly stores each expression variant as a unique sequence, leading to exponential memory growth. In contrast, the e-graph compactly encodes multiple equivalent expressions by sharing common sub-expressions.

We benchmark the memory consumption of storing all equivalent variants of input expressions under two settings:
(1) $\phi=\log(x_{1}\times\ldots\times x_{n})$, using the logarithmic identity $\log(ab)\leadsto\log a+\log b$, and
(2) $\phi=\sin(x_{1}+\ldots+x_{n})$, using the trigonometric identity $\sin(a+b)\leadsto\sin(a)\cos(b)+\sin(b)\cos(a)$.
Both settings yield $2^{n-1}$ equivalent variants.

Figure [5](https://arxiv.org/html/2511.05849v1#S5.F5) presents the memory consumption as a function of the input variable size
$n$. The results show that the e-graph representation achieves significantly lower memory usage compared to the array-based approach. Figure [5](https://arxiv.org/html/2511.05849v1#S5.F5)(right) visualizes two sample e-graphs, which illustrate how shared sub-expressions are stored only once, contributing to the space efficiency of Egg. The corresponding e-graphs for $n=2,3,4$ are visualized in Appendix Figures [13](https://arxiv.org/html/2511.05849v1#A6.F13) and [14](https://arxiv.org/html/2511.05849v1#A6.F14).

Figure: Figure 4: Egg uses less memory than the array-based approach for two settings: (Left) $\log\left(x_{1}\times\ldots x_{n}\right)$ rewritten using $\log(ab)\leadsto\log a+\log b$. (Right) $\sin\left(x_{1}+\ldots x_{n}\right)$ rewritten using $\sin(a+b)\leadsto\sin a\cos b+\sin a\cos b$.
Refer to caption: x5.png

Time Efficiency of Egg with DRL.
As shown in Figure [5](https://arxiv.org/html/2511.05849v1#S5.F5), we benchmark the runtime of the four main computations in Egg-DRL on the selected “sincos(3,2,2)” dataset:
(1) sampling sequences of rules from the sequential decoder,
(2) fitting coefficients in symbolic expressions to the training data,
(3) generating equivalent expressions via Egg, and
(4) computing the loss, gradients, and updating the neural network parameters.
We consider two settings for the sequential decoder: a 3-layer LSTM with hidden dimension 128, and a decoder-only Transformer with 6 attention heads and hidden dimension 128. The Egg module contributes minimal computational overhead relative to more expensive steps such as coefficient fitting and network updates. This highlights the practicality of incorporating Egg into DRL-based symbolic regression frameworks.

Additional E-graph Visualizations.
To further demonstrate the effectiveness of the proposed Egg module, we present several additional e-graph visualizations generated using our implemented API on selected complex expressions from the Feynman dataset (journal/2020/aifrynman), each highlighting different rewrite rules (see Appendix [F.2](https://arxiv.org/html/2511.05849v1#A6.SS2)).

## 6 Conclusion

In this paper, we introduced Egg-DR, a unified framework that integrates symbolic equivalence into symbolic regression through equality graphs (e-graphs) to accelerate the discovery of optimal expressions.
Our theoretical analysis establishes the advantages of Egg-MCTS over standard MCTS and Egg-DRL over conventional DRL algorithms.
Extensive experiments further demonstrate that Egg consistently enhances the ability of existing methods to uncover high-quality governing equations from experimental data. Currently, the collection of rewrite rules relies on manual effort.
In future work, we plan to develop systematic approaches for discovering more rewrite rules and to extend the proposed method to related tasks, such as code optimization and program synthesis.

## Acknowledgments

This research was supported by NSF grant
CCF-1918327, NSF Career Award IIS-2339844, DOE – Fusion Energy Science grant: DE-SC0024583.

Contents

Availability of Egg, Baselines and Dataset
Please find our code repository at:
[https://www.github.com/jiangnanhugo/egg-sr](https://www.github.com/jiangnanhugo/egg-sr)

- •
Egg. The implementation of our Egg module is located in the folder “
src/equality_graph/”.
- •
Datasets. The list of datasets used in our experiments can be found in
“datasets/scibench/scibench/data/”.
- •
Baselines. The implementations of several baseline algorithms, along with our adapted versions, are provided in the ”algorithms/” folder. Execution scripts for running each algorithm are also included.

We also provide a README.md file with instructions for installing the required Python packages and dependencies.

We summarize the supplementary material as follows:
Section [A](https://arxiv.org/html/2511.05849v1#A1) provides implementation details of the proposed Egg.
Sections [B](https://arxiv.org/html/2511.05849v1#A2) and [C](https://arxiv.org/html/2511.05849v1#A3) present a detailed theoretical analysis of the proposed method.
Section [E](https://arxiv.org/html/2511.05849v1#A5) describes the experimental setup and configurations.
Finally, Section [F](https://arxiv.org/html/2511.05849v1#A6) presents additional experimental results.

## Appendix A Implementation of Egg Module

In what follows, we present the implementation of a unified framework that employs a context-free grammar to represent symbolic expressions, rewrite rules, and e-graphs.

### A.1 Context-free Grammar Definition for Symbolic Expression

The context-free grammar for symbolic regression is defined in Section [2](https://arxiv.org/html/2511.05849v1#S2). Figure [6](https://arxiv.org/html/2511.05849v1#A1.F6) further illustrates how an expression such as $\phi=c_{1}\log(x_{1})$ can be constructed from the start symbol by sequentially applying grammar rules. We begin with the multiplication rule $A\to A\times A$, which expands the initial symbol $A$ in $\phi=A$ to yield $\phi=A\times A$. Continuing this process, each non-terminal symbol is recursively expanded using the appropriate grammar rules until we obtain the valid expression $\phi=c_{1}\log(x_{1})$.

Figure: Figure 6: Transforming a sequence of grammar rules into a valid expression. At each step, the first non-terminal symbol inside the squared box is expanded. The expanded parts are color-highlighted.
Refer to caption: x8.png

The next step is to determine the optimal coefficient $c_{1}$ in the expression $\phi=c_{1}\log(x_{1})$. More generally, suppose the expression contains $m$ free coefficients. Given training data $D=\{(\mathbf{x}_{i},y_{i})\}_{i=1}^{N}$, we optimize these coefficients using a gradient-based method such as BFGS by solving

$$ $\mathbf{c}^{*}\leftarrow\arg\min_{\mathbf{c}\in\mathbb{R}^{m}}\frac{1}{N}\sum_{i=1}^{N}\ell(\phi(\mathbf{x}_{i},\mathbf{c}),y_{i}),$ $$

where the loss function $\ell$ is typically the normalized mean squared error (NMSE), which is defined in Equation [5](https://arxiv.org/html/2511.05849v1#S5.E5).

### A.2 Implementation of Rewrite Rules

The following snippet defines the Python implementation of a rewrite rule from a known mathematical identity. The function rules_to_s_expr converts the input list representation into an internal symbolic expression tree:

Each rule encodes one direction of applying a mathematical identity. Prior research (DBLP:conf/gecco/olivetti25) has primarily used rewrite rules to simplify expressions, typically rewriting a longer expression into a shorter one. In contrast, our work considers *both* directions of each identity, enabling us to systematically generate the complete set of symbolically equivalent expressions.

**Table 3: The list of rewrite rules for trigonometric functions, each derived from a known trigonometric law.**
| Category | rewrite rules |
| --- | --- |
| Sum-to-Product Identities | $\sin(a)+\sin(b)\leadsto 2\sin\left(\frac{a+b}{2}\right)\cos\left(\frac{a-b}{2}\right)$ |
| $\cos(a)+\cos(b)\leadsto 2\cos\left(\frac{a+b}{2}\right)\cos\left(\frac{a-b}{2}\right)$ |  |
| Product-to-Sum Identities | $\sin(a)\cos(b)\leadsto\frac{1}{2}\left[\sin(a+b)+\sin(a-b)\right]$ |
| $\cos(a)\cos(b)\leadsto\frac{1}{2}\left[\cos(a+b)+\cos(a-b)\right]$ |  |
| $\sin(a)\sin(b)\leadsto\frac{1}{2}\left[\cos(a-b)-\cos(a+b)\right]$ |  |
| Double Angle Formulas | $\sin(a+a)\leadsto 2\sin(a)\cos(a)$ |
| $\cos(a+a)\leadsto\cos^{2}(a)-\sin^{2}(a)$ |  |
| $\cos(a+a)\leadsto 2\cos^{2}(a)-1$ |  |
| $\cos(a+a)\leadsto 1-2\sin^{2}(a)$ |  |
|  | $\tan(a+a)\leadsto\frac{2\tan(a)}{1-\tan^{2}(a)}$ |
| Pythagorean Identities | $\sin^{2}(a)+\cos^{2}(a)\leadsto 1$ |
| $\sec^{2}(a)-\tan^{2}(a)\leadsto 1$ |  |
| $\csc^{2}(a)-\cot^{2}(a)\leadsto 1$ |  |
| Half-Angle Formulas | $\sin^{2}\left(\frac{a}{2}\right)\leadsto\frac{1-\cos(a)}{2}$ |
| $\cos^{2}\left(\frac{a}{2}\right)\leadsto\frac{1+\cos(a)}{2}$ |  |
| $\tan^{2}\left(\frac{a}{2}\right)\leadsto\frac{1-\cos(a)}{1+\cos(x)}.$ |  |
| Sum and Difference Formulas | $\sin(a\pm b)\leadsto\sin(a)\cos(b)\pm\cos(a)\sin(b)$ |
| $\cos(a\pm b)\leadsto\cos(a)\cos(b)\mp\sin(a)\sin(b)$ |  |
| $\tan(a\pm b)\leadsto\left(\tan(a)\pm\tan(b)\right)/\left(1\mp\tan(a)\tan(b)\right)$ |  |

We define several types of rewrite rules based on well-known mathematical identities: Let $a,b$ denote arbitrary variables, coefficients, or sub-expressions.

- 1.
Commutative law. $a+b=b+a$ or $a*b=b*a$ will be converted into rules: $a+b\leadsto b+a,a*b\leadsto b*a$.
[⬇](data:text/plain;base64,CiMgQ29tbXV0YXRpdmUgbGF3cwpSdWxlKGxocz1bJ0EtPihBK0EpJywgJ0EtPmEnLCAnQS0+YiddLCByaHM9WydBLT4oQStBKScsICdBLT5iJywgJ0EtPmEnXSkKUnVsZShsaHM9WydBLT5BKkEnLCAnQS0+YScsICdBLT5iJ10sIHJocz1bJ0EtPkEqQScsICdBLT5iJywgJ0EtPmEnXSkK)
# Commutative laws
Rule(lhs=[’A->(A+A)’, ’A->a’, ’A->b’], rhs=[’A->(A+A)’, ’A->b’, ’A->a’])
Rule(lhs=[’A->A*A’, ’A->a’, ’A->b’], rhs=[’A->A*A’, ’A->b’, ’A->a’])
- 2.
Distributive laws: $(a+b)^{2}\leadsto a^{2}+2ab+b^{2}$.
- 3.
Factorization. Expressions can be decomposed into simpler components: $a^{2}-b^{2}\leadsto(a-b)(a+b)$.
- 4.
Exponential and logarithmic identities: $\exp(a+b)\leadsto\exp(a)\times\exp(b)$, $\log(ab)\leadsto\log(a)+\log(b)$, and also $\log(a^{b})\leadsto b\log a$,
- 5.
The rewrite rules for trigonometric identities are summarized in Table [3](https://arxiv.org/html/2511.05849v1#A1.T3).
For example, The rule $\sin(a+b)\leadsto\sin(a)\cos(b)+\sin(b)\cos(a)$ is implemented as follow:
[⬇](data:text/plain;base64,ClJ1bGUoCmxocz1bJ0EtPnNpbihBKScsJ0EtPihBK0EpJywgJ0EtPmEnLCAnQS0+YiddLApyaHM9WydBLT4oQStBKScsICdBLT5BKkEnLCAnQS0+c2luKEEpJywnQS0+YScsJ0EtPmNvcyhBKScsICdBLT5iJywKJ0EtPmNvcyhBKScsJ0EtPmEnLCdBLT5zaW4oQSknLCAnQS0+YiddKQo=)
Rule(
lhs=[’A->sin(A)’,’A->(A+A)’, ’A->a’, ’A->b’],
rhs=[’A->(A+A)’, ’A->A*A’, ’A->sin(A)’,’A->a’,’A->cos(A)’, ’A->b’,
’A->cos(A)’,’A->a’,’A->sin(A)’, ’A->b’])
A visualization of this rule being applied to an expression is shown in Figure [11](https://arxiv.org/html/2511.05849v1#A6.F11).

### A.3 Implementation of E-Graph Functionalities

Here we provide the implementation of the Egg data structure proposed in Section [3.1](https://arxiv.org/html/2511.05849v1#S3.SS1).
An e-graph consists of two core components: e-nodes and e-classes. The following snippet presents the skeleton structure of these two components:

The e-graph structure is implemented in the following class. The dictionary hashcons stores all the edges from an e-node to an e-class. The API supports the key operations of (1) adding new expressions to the e-graph by calling add_enode, and (2) merging two e-classes into one:

Construction The e-graph is built by repeatedly applying a set of rewrite rules to the e-graph.
Each rewrite rule consists of a left-hand side (LHS) and a right-hand side (RHS) expression. The function apply_rewrite_rules determines which new subgraphs to construct and where to merge them within the existing e-graph.

Specifically, the LHS pattern of each rule is matched against the e-graph using the ematch function, which identifies all subexpressions that match the pattern. For each match, the RHS is instantiated using the extracted variable bindings, and the resulting expression is inserted into the e-graph and merged with the corresponding e-class. The equality_saturation function invokes apply_rewrite_rules for a fixed number of iterations until saturation is reached.

We employ the Graphviz API to visualize the e-classes, e-nodes, and their connections. Several visualization example is shown in section [F](https://arxiv.org/html/2511.05849v1#A6).

### A.4 Expression Extraction

Cost-based extraction retrieves a simplified expression by minimizing a user-defined cost over operators. The procedure returns an expression tree with the lowest total cost, where the cost is computed across all operators. Each e-class is assigned a cost equal to that of its cheapest e-node, and the cost of an e-node is defined recursively as

$$ $\text{cost(enode)}=\text{cost(operator)}+\sum_{\text{child e-classes}}\text{cost(child)}.$ (6) $$

The algorithm iteratively updates costs for all e-nodes until convergence, i.e., when no further changes occur. This method correctly handles shared subexpressions and potential cycles within the e-graph.

(1) Cost-based extraction, which retrieves a simplified expression by minimizing a user-defined cost function over operators;

(2) Random walk-based sampling, which draws a batch of expressions randomly from the e-graph. Starting from an e-class with no incoming edges, we randomly select an e-node within the current e-class and transition to the e-classes connected to that e-node. This process continues until an e-node with no outgoing edges is reached. The obtained sequence of visited e-nodes corresponds to drawing a valid expression from the constructed e-graph.

### A.5 Implementation Remark

Our implementation builds upon an existing code snippet(^1^11[https://colab.research.google.com/drive/1tNOQijJqe5tw-Pk9iqd6HHb2abC5aRid](https://colab.research.google.com/drive/1tNOQijJqe5tw-Pk9iqd6HHb2abC5aRid)).
The most relevant prior implementation we identified is available in Haskell(^2^22[https://github.com/folivetti/eggp](https://github.com/folivetti/eggp)), the language in which e-graphs were originally developed. However, this choice complicates integration with Python-based environments, especially when interfacing with learning algorithms implemented in Python. A Python wrapper for Haskell egglog also exists(^3^33[https://github.com/egraphs-good/egglog-python](https://github.com/egraphs-good/egglog-python)), but its API is cumbersome and lacks clarity, limiting its usability for practical applications.

While packages such as SymPy provide APIs like simplify and factor, these functions map expressions to a fixed canonical form and do not support the richer class of rewrites and transformations. These APIs can return a smaller set of symbolically equivalent expressions than our Egg framework. Hence, they are not used in our implementation.

## Appendix B Proof of Theoroem 3.1

### B.1 Problem settings

Necessary Definitions of Markov Decision Process
Consider a deterministic, finite-horizon Markov Decision Process (MDP) with
state space $\mathcal{S}$ and action space $\mathcal{A}$.
At each stage $t\in\{0,1,\dots,H-1\}$ the agent observes its current state
$s_{t}\in\mathcal{S}$, selects an action $a_{t}\in\mathcal{A}$,
and deterministically transitions to the next state
$s_{t+1}=f(s_{t},a_{t})$ while receiving a bounded reward
$r_{t}\in[0,1]$. Let $H$ denote the maximum planning horizon.
The total discounted reward over the $H$-step horizon is $\sum_{t=0}^{H-1}\gamma^{t}r_{t}$, where $\gamma\in(0,1)$ is the discount factor. For any state–action pair $(s,a)$, the *state–action value* is defined as $Q(s,a)\coloneqq\max_{\pi}\mathbb{E}_{\tau\sim\pi}\!\left[\sum_{t=0}^{H-1}\gamma^{t}r_{t}\middle|s_{0}=s,\,a_{0}=a\right]$,
where $\pi$ is any policy and
$\tau=(s_{0},a_{0},\dots,s_{H-1},a_{H-1})$ is a trajectory generated by following $\pi$.
Because the MDP is deterministic, the expectation is taken only over the agent’s
policy-induced action sequence.
The *optimal value* of a state $s$ is $V(s)\coloneqq\max_{a\in\mathcal{A}}Q(s,a)$.

Connection to Symbolic Regression.
In our symbolic regression setting, a state corresponds to a sequence of
production rules that define a partially constructed expression,
or equivalently, to the class of mathematical expressions that can be
generated by completing this partial structure.
An action represents the selection of an available production rule that
extends the current expression. The state space is the set of all possible expressions of maximum length $H$, and the action space is the set of production rules.

A *planning algorithm* is any procedure that, given a model of the MDP
and a limited computational budget, uses simulated rollouts to estimate the value
of available actions and to recommend a single action for execution.
Suppose that after $n$ simulations of a planning algorithm, the agent recommends an
action $a_{T}$ to execute at the current state $s$.
Its estimated value is $Q(s,a_{T})$, obtained by evaluating the discounted return
that results from first taking $a_{T}$ and then following an optimal policy
for the remaining steps.
The *simple regret* of this recommendation is

$$ $\mathtt{regret}(T)\coloneqq V(s)-Q(s,a_{T}),$ (7) $$

which quantifies the loss in discounted return incurred by choosing $a_{T}$
instead of the truly optimal action.
A smaller $\mathtt{regret}(n)$ indicates that the planning algorithm used its limited simulation
Budget more effectively to identify a near-optimal action.

Planning involves selecting promising transitions to simulate at each iteration, in order to recommend actions that minimize regret $\mathtt{regret}(n)$. A popular strategy is the *optimism in the face of uncertainty* (OFU) principle, which explores actions by maximizing an upper confidence bound on the value function $V$.

In the context of symbolic regression, the planning task is therefore to sequentially apply production rules
so as to construct a complete expression whose predicted outputs best
match the target data, while respecting the grammar and structural
constraints of the search space.

###### Definition 1 (Difficulty measure) .

The *near-optimal branching factor* $\kappa$ of an MDP is defined as

$$ $\kappa\coloneqq\limsup_{h\to\infty}|T_{h}^{\infty}|^{1/h}\in[1,K],$ (8) $$

where $T_{h}^{\infty}\coloneqq\Big\{a\in\mathcal{A}^{h}:V^{*}-V(a)\leq\tfrac{\gamma^{h}}{1-\gamma}\Big\}$ is the set of near-optimal nodes at depth $h$.

In standard MCTS, the root of the search tree corresponds to the initial state $s_{0}\in S$.
A node at depth $h$ represents an action sequence $a=(a_{1},\ldots,a_{h})\in\mathcal{A}^{h}$, which leads to a terminal state $s(a)$. The search tree at iteration $n$ is denoted $\mathtt{tree}(T)$, and its maximum expanded depth is $d_{n}$.

Historical research has shown that the UCT principle suffers from a theoretical worst case in which it is difficult to derive meaningful regret bounds, making it unsuitable for analyzing the benefit of Egg over standard MCTS. Therefore, we assume that MCTS operates under the Optimistic Planning for Deterministic Systems (OPD) framework (DBLP:conf/acml/LeurentM20) rather than the UCT principle.

###### Theorem B.1 (Regret bound of MCTS ( DBLP:journals/ftml/Munos14 , chapter 5)) .

Let $\mathtt{regret}(n)$ denote the simple regret after $n$ iterations of OPD used in MCTS. Then, we have:

$$ $\mathtt{regret}(T)=\widetilde{\mathcal{O}}\!\left(n^{-\frac{\log(1/\gamma)}{\log\kappa}}\right).$ (9) $$

Here, the soft-O version of big-O notation is defined as: $f_{n}=\widetilde{\mathcal{O}}(n^{-\alpha})$ means that decays at least as fast as $n^{-\alpha}$, up to a polylog factor.

When $\kappa$ is small, only a limited number of nodes must be explored at each depth,
allowing the algorithm to plan deeper, given a budget of $n$ simulations.
The quantity $\kappa$ represents the branching factor of the subtree of near-optimal nodes
that can be sampled by the OPD algorithm, serving as an *effective* branching factor
in contrast to the true branching factor $K$.
Hence, $\kappa$ directly governs the achievable simple regret of OPD (and its variants) on a given MDP.

The theoretical analysis of Egg-MCTS is built on top of the analysis procedure in (DBLP:conf/acml/LeurentM20).
Unlike their analysis, which requires unrolling the graph into a tree and addressing potentially infinite-length paths induced by cycles, our analysis starts from the unrolled tree derived from the graph in (DBLP:conf/acml/LeurentM20).

###### Definition 2 (Upper and Lower bounds of the Value function) .

Let $\mathtt{tree}(T)$ be the search tree after $T$ expansions.
Each node corresponds to an action sequence $(a_{0},a_{1},\dots,a_{H-1})$ from the root, and let $s$ denote the MDP state reached by executing this sequence from the root state $s_{0}$.
The true value associated with this node is the optimal value of the reached state, denoted by $V(s)$.
A pair of functions $(L_{T},U_{T})$ is said to provide
*lower and upper bounds* for $V$ on $\mathtt{tree}(T)$ if

$$ $L_{T}\leq V(s)\leq U_{T},\qquad\text{ for internal node $s$ in the tree }\mathtt{tree}(T)$ $$

###### Definition 3 (Finer Difficulty Measure) .

We define the *near-optimal branching factor* associated with bounds $(L_{T},U_{T})$ as

$$ $\kappa(L_{T},U_{T})\coloneqq\limsup_{h\to\infty}\big|T_{h}^{\infty}(L_{T},U_{T})\big|^{1/h}\in[1,K],$ (10) $$

where $T_{h}^{\infty}(L,U)\coloneqq\Big\{a\in\mathcal{A}^{h}:V^{*}-V(a)\leq\gamma^{h}\big(U(a)-L(a)\big)\Big\}$.

Since $(L_{T},U_{T})$ tighten with $T$, the sequence of bounds $\bigl(L_{T},U_{T}\bigr)_{T\geq 0}$ is non-increasing, i.e.,

$$ $\displaystyle 0\leq\cdots\leq L_{T-1}\leq L_{T}\leq V\leq U_{T}\leq U_{T-1}\leq\cdots\leq V_{\max}$ $$

they will finally converges to a limit $\kappa_{\infty}=\lim_{n\to\infty}\kappa(L_{T},U_{T})$.

###### Theorem B.2 (Regret Bound of Egg -MCTS) .

Let $\kappa_{T}=\kappa(L_{T},U_{T})$, and define $\kappa_{\infty}=\lim_{n\to\infty}\kappa(L_{T},U_{T})\in[1,K]$.
Then Egg-MCTS achieves the regret bound

$$ $\mathtt{regret}(T)=\widetilde{\mathcal{O}}\!\left(n^{-\frac{\log(1/\gamma)}{\log\kappa_{\infty}}}\right),\qquad\text{ where }\kappa_{\infty}\leq\kappa$ (11) $$

###### Proof.

The analysis is similar to that of DBLP:conf/acml/LeurentM20.
In their approach, the graph is *unrolled* into a tree to leverage the analysis of Theorem [B.1](https://arxiv.org/html/2511.05849v1#A2.Thmtheorem1).
This unrolled tree contains every action sequence that can be traversed in $G_{n}$. There would exist a path of infinite length if the graph contains cycles.
The behavior of the graph $G_{n}$ is therefore analyzed through its corresponding unrolled tree $\mathtt{UnrollTree}(T)$.

Our Egg-MCTS behaves almost identically to this unrolled tree, except that it contains no paths of infinite length, since our algorithm cannot empirically generate or update along an infinite action sequence.
Transporting the graph-based value bounds $(L_{T},U_{T})$ to the unrolled tree
and applying the depth–regret argument of DBLP:conf/acml/LeurentM20
yields the rate in equation [11](https://arxiv.org/html/2511.05849v1#A2.E11).
The detailed derivation is therefore omitted here for brevity.
∎

###### Remark 1 .

For a class of symbolic regression problems where a large set of mathematical identities is applicable, the resulting overlaps among action paths can be extensive.
In this case, the effective branching factor $\kappa_{\infty}$ can be much smaller than the nominal branching factor $\kappa$,
leading to substantially tighter regret guarantees.

###### Definition 1 (Difficulty measure) .

###### Theorem B.1 (Regret bound of MCTS ( DBLP:journals/ftml/Munos14 , chapter 5)) .

###### Definition 2 (Upper and Lower bounds of the Value function) .

###### Definition 3 (Finer Difficulty Measure) .

###### Theorem B.2 (Regret Bound of Egg -MCTS) .

###### Proof.

###### Remark 1 .

## Appendix C Proof of Theorem 3.2

### C.1 Notation and Assumptions

Let $\tau$ be a sequence of production rules sampled from a sequential decoder with probability $p_{\theta}(\tau)$.
$\phi$ is the expression constructed by $\tau$ following grammar definition.
Let $\mathcal{S}_{\phi}\subseteq\Pi$ be the equivalence class (under the rewrite system $\mathcal{R}$) of sequences that deterministically construct $\phi$ or can be rewritten into $\phi$ by applying rewrite rules in $\mathcal{R}$.
For notation simplicity and clarity, we define the probability over the set of sequences $\mathcal{S}_{\phi}$

$$ $q_{\theta}(\phi)\;\coloneqq\;\sum_{\tau\in\mathcal{S}_{\phi}}p_{\theta}(\tau).$ (12) $$

The reward of the expression $\phi$ is defined as the goodness-of-fit on the dataset $D$.

### C.2 Proof of Unbiasedness

###### Lemma 1 (Key identity) .

For any $\phi\in\Phi$ with $q_{\theta}(\phi)>0$, $\mathbb{E}_{\tau\sim p_{\theta}}\left[\,\nabla_{\theta}\log p_{\theta}(\tau)|\phi\right]=\nabla_{\theta}\log q_{\theta}(\phi)$.

###### Proof.

By the definition of conditional probability, $\mathbb{P}(\tau|\phi)=\frac{p_{\theta}(\tau)}{q_{\theta}(\phi)}$,
for $\tau\in\mathcal{S}_{\phi}$ and 0 otherwise.
Hence,

$$ $\displaystyle\mathbb{E}\;\left[\,\nabla_{\theta}\log p_{\theta}(\tau)\,\middle|\,\phi\right]=\sum_{\tau\in\mathcal{S}_{\phi}}\nabla_{\theta}\log p_{\theta}(\tau)\;\frac{p_{\theta}(\tau)}{q_{\theta}(\phi)}=\frac{1}{q_{\theta}(\phi)}\sum_{\tau\in\mathcal{S}_{\phi}}\nabla_{\theta}p_{\theta}(\tau)$ $\displaystyle=\frac{1}{q_{\theta}(\phi)}\nabla_{\theta}\sum_{\tau\in\mathcal{S}_{\phi}}p_{\theta}(\tau)$ $\displaystyle=\frac{\nabla_{\theta}q_{\theta}(\phi)}{q_{\theta}(\phi)}$ $\displaystyle=\nabla_{\theta}\log q_{\theta}(\phi).$ $$

∎

###### Proposition 1 (Unbiasedness) .

$\mathbb{E}_{\tau\sim p_{\theta}}\left[g(\theta)\right]=\mathbb{E}_{\tau\sim p_{\theta}}\left[g_{\mathtt{egg}}(\theta)\right]$.

###### Proof.

First, for the Egg-based estimator,

$$ $\displaystyle\mathbb{E}\;\left[g_{\mathtt{egg}}(\theta)\right]=\sum_{\tau\in\Pi}\mathtt{reward}(\phi)\,\nabla_{\theta}\log q_{\theta}(\phi)\;p_{\theta}(\tau)$ $\displaystyle=\sum_{\phi\in\Phi}\sum_{\tau\in\mathcal{S}_{\phi}}\mathtt{reward}(\phi)\,\nabla_{\theta}\log q_{\theta}(\phi)\;p_{\theta}(\tau)$ $\displaystyle=\sum_{\phi\in\Phi}\mathtt{reward}(\phi)\,\nabla_{\theta}\log q_{\theta}(\phi)\underbrace{\sum_{\tau\in\mathcal{S}_{\phi}}p_{\theta}(\tau)}_{=\,q_{\theta}(\phi)}$ $\displaystyle=\sum_{\phi\in\Phi}\mathtt{reward}(\phi)\,\nabla_{\theta}q_{\theta}(\phi)$ $\displaystyle=\nabla_{\theta}\sum_{\phi\in\Phi}\mathtt{reward}(\phi)\,q_{\theta}(\phi).$ $$

For the standard estimator,

$$ $\displaystyle\mathbb{E}\;\left[g(\theta)\right]=\sum_{\tau\in\Pi}\mathtt{reward}(\tau)\,\nabla_{\theta}\log p_{\theta}(\tau)\;p_{\theta}(\tau)$ $\displaystyle=\sum_{\tau\in\Pi}\mathtt{reward}(\tau)\,\nabla_{\theta}p_{\theta}(\tau)$ $\displaystyle=\nabla_{\theta}\sum_{\tau\in\Pi}\mathtt{reward}(\tau)\,p_{\theta}(\tau)$ $\displaystyle=\nabla_{\theta}\sum_{\phi\in\Phi}\sum_{\tau\in\mathcal{S}_{\phi}}\mathtt{reward}(\phi)\,p_{\theta}(\tau)$ $\displaystyle=\nabla_{\theta}\sum_{\phi\in\Phi}\mathtt{reward}(\phi)\,q_{\theta}(\phi),$ $$

where we used class-invariance of the reward and equation [12](https://arxiv.org/html/2511.05849v1#A3.E12). This equals the expression obtained for $g_{\mathtt{egg}}$, proving unbiasedness.
∎

###### Lemma 1 (Key identity) .

###### Proof.

###### Proposition 1 (Unbiasedness) .

###### Proof.

### C.3 Proof of Variance Reduction

Define the $\sigma$-field generated by the expression $\phi$ as $\sigma(\phi)$.
Consider the random variable

$$ $Z\coloneqq\mathtt{reward}(\tau)\,\nabla_{\theta}\log p_{\theta}(\tau)=\mathtt{reward}(\phi)\,\nabla_{\theta}\log p_{\theta}(\tau),$ $$

where the equality uses reward invariance within each $\mathcal{S}_{\phi}$.
By Lemma [1](https://arxiv.org/html/2511.05849v1#Thmlemma1),

$$ $\mathbb{E}\;\left[\,Z\mid\phi\right]=\mathtt{reward}(\phi)\,\mathbb{E}\;\left[\,\nabla_{\theta}\log p_{\theta}(\tau)\mid\phi\right]=\mathtt{reward}(\phi)\,\nabla_{\theta}\log q_{\theta}(\phi)=g_{\mathtt{egg}}(\theta).$ $$

Thus, $g_{\mathtt{egg}}(\theta)$ is the *Rao–Blackwellization* of $g(\theta)$ with respect to $\sigma(\phi)$ (8a19a051-2be1-32f8-8b83-075ff1f85473).

###### Proposition 2 (Variance reduction) .

$\mathrm{Var}\left(g_{\mathtt{egg}}(\theta)\right)\;\leq\;\mathrm{Var}\left(g(\theta)\right)$.

###### Proof.

By the law of total variance,

$$ $\displaystyle\mathrm{Var}(Z)=\mathrm{Var}\big(\mathbb{E}[Z\mid\phi]\big)\;+\;\mathbb{E}\big[\mathrm{Var}(Z\mid\phi)\big]\;\geq\;\mathrm{Var}\;\big(\mathbb{E}[Z\mid\phi]\big).$ $$

Substituting $Z=g(\theta)$ and $\mathbb{E}[Z\mid\phi]=g_{\mathtt{egg}}(\theta)$ yields

$$ $\displaystyle\mathrm{Var}\left(g(\theta)\right)\geq\mathrm{Var}\left(g_{\mathtt{egg}}(\theta)\right).$ $$

∎

Combining Propositions [1](https://arxiv.org/html/2511.05849v1#Thmproposition1) and [2](https://arxiv.org/html/2511.05849v1#Thmproposition2) proves Theorem [3.2](https://arxiv.org/html/2511.05849v1#S3.Thmtheorem2).

Remark on baselines.
If a baseline $b(\cdot)$ independent of the sampled action (sequence) is included, both estimators remain unbiased, and the Rao–Blackwell argument applies to the centered variable as well, so the variance reduction still holds (and can be further improved by an appropriate baseline choice).

###### Proposition 2 (Variance reduction) .

###### Proof.

## Appendix D Implementation of Egg -embedded Symbolic Regression

### D.1 Implementation of Egg -MCTS

The algorithmic procedure of Egg-MCTS is described in Section [3.2](https://arxiv.org/html/2511.05849v1#S3.SS2). The code implementation is adapted from existing MCTS frameworks (^4^44[https://github.com/isds-neu/SymbolicPhysicsLearner](https://github.com/isds-neu/SymbolicPhysicsLearner)).

Connection to Existing Research.
In many applications, multiple action sequences may lead to the same state, resulting in duplicate nodes within the search tree.
To mitigate this redundancy, DBLP:journals/kbs/SaffidineCM12 proposed the use of a transposition table in the context of Go, enabling the reuse of information from previous updates.
Similarly, DBLP:conf/acml/LeurentM20 introduced *Monte Carlo Graph Search* (MCGS), which replaces the tree structure with a graph that merges identical states.
In MCGS, nodes correspond to unique states $s\in\mathcal{S}$ and edges represent state transitions, with the root node corresponding to the initial state $s_{0}$.
At iteration $n$, if executing action $a$ from state $s$ leads to a successor state $s^{\prime}$ that already exists in the graph, no new node is created.

Our Egg-MCTS adopts the same principle of detecting identical states during search but avoids explicit graph construction.
Instead, it simultaneously updates all paths in the tree that lead to the selected state.
This design preserves compatibility with standard MCTS implementations while achieving a theoretical acceleration comparable to that of DBLP:conf/acml/LeurentM20.

### D.2 Implementation of Egg -DRL

Expression generation begins with the decoder sampling a sequence of grammar rules in an autoregressive manner. The sequential decoder can be implemented using various architectures, such as RNNs (salehinejad2017recent), GRUs (chung2014empirical), LSTMs (greff2016lstm), or decoder-only Transformers (vaswani2017attention). The input and output vocabularies for the decoder consist of grammar rules that encode variables, coefficients, and mathematical operators. Figure [7](https://arxiv.org/html/2511.05849v1#A4.F7)(a) illustrates an example of the output vocabulary.

At each time step, the model predicts a categorical distribution over the next rule, conditioned on the previously generated tokens. At the $t$-th step, the decoder (denoted $\mathtt{SequentialDecoder}$) takes the previously generated rules $(\tau_{1},\dots,\tau_{t})$ and the hidden state $\mathbf{h}_{t}$, and computes:

$$ $\displaystyle\mathbf{z}_{t}$ $\displaystyle=\mathtt{SequentialDecoder}(\tau_{t},\mathbf{h}_{t}),$ $\displaystyle p_{\theta}(\tau_{t+1}\mid\tau_{1},\dots,\tau_{t})$ $\displaystyle=\mathtt{softmax}(\mathbf{z}_{t}W_{o}+b_{o}),$ $$

where $W_{o}\in\mathbb{R}^{d\times|V|}$ is the output weight matrix, $b_{o}\in\mathbb{R}^{|V|}$ is the bias vector, and $|V|$ is the size of the vocabulary. The next rule $\tau_{t+1}$ is then sampled from this distribution: $\tau_{t+1}\sim p(\tau_{t+1}\mid\tau_{1},\dots,\tau_{t}).$
The sampled rule is fed into the decoder as input for the next step, until the sequence is completed. After $L$ steps, the full sequence $\tau=(\tau_{1},\ldots,\tau_{L})$ is generated with probability $p_{\theta}(\tau)=\prod_{t=1}^{L-1}p_{\theta}(\tau_{t+1}\mid\tau_{1},\dots,\tau_{t})$.

Figure: Figure 7: Framework of DRL and our Egg-DRL. (a) The sequential decoder autoregressively samples grammar rules according to the modeled probability distribution. (b) In classic DRL, the sampled expressions are directly used to compute the policy gradient estimator $g(\theta)$. While Egg-DRL constructs e-graphs from the sampled expressions, extracts symbolic variants, and computes the revised estimator $g_{\mathtt{egg}}(\theta)$.
Refer to caption: x9.png

Each sequence $\tau$ is then converted into an expression following the grammar definition in Section [2](https://arxiv.org/html/2511.05849v1#S2). If the sequence terminates prematurely, grammar rules for variables or constants are appended at random to complete the expression. Conversely, if a valid expression is obtained before the sequence ends, the remaining rules are discarded. In both cases, the probability $p_{\theta}(\tau)$ is updated consistently with the applied modifications.

Finally, the model parameters are updated using gradient-based optimization (e.g., the Adam optimizer) with either the classic policy gradient estimator $g(\theta)$ or the proposed Egg-based estimator $g_{\mathtt{egg}}(\theta)$. The whole pipeline is visualized in Figure [7](https://arxiv.org/html/2511.05849v1#A4.F7).

Connection to Existing Research.
Several techniques have been introduced to reduce the variance of policy gradient estimates. One widely used approach is the control variate method, where a baseline is subtracted from the reward to stabilize the gradient (DBLP:conf/uai/WeaverT01). Another idea is Rao-Blackwellization (8a19a051-2be1-32f8-8b83-075ff1f85473). Other approaches, such as reward reshaping (DBLP:conf/nips/ZhengOS18), modify rewards for specific state-action pairs. Inspired by stochastic variance-reduced gradient methods (johnson2013accelerating; DBLP:conf/iclr/0002FKLL21), (DBLP:conf/icml/PapiniBCPR18) proposed a variance-reduction technique tailored for policy gradients.

Unlike these existing methods, our proposed Egg is the first to reduce variance through the domain knowledge of the symbolic regression application, and show a seamless integration into the learning framework and attain reduced variance.

### D.3 Implementation of Egg -LLM

Our Egg is adopted on top of the original LLM-SR (DBLP:journals/iclr/llmsr25).

- (a)
Hypothesis Generation. The LLM generates multiple candidate expressions based on a prompt describing the problem background and the definitions of each variable.
- (b)
Data-driven Evaluation. Each candidate expression is evaluated based on its fitness on the training dataset.
- (c)
Inferring Equivalent Expressions. For ease of integration with the e-graph system, we convert the generated Python functions into lambda expressions. This simplifies their manipulation and evaluation during equivalence analysis.
[⬇](data:text/plain;base64,CiMgT3JpZ2luYWwgZnVuY3Rpb24gZm9ybWF0CmRlZiBoeXBvdGhlc2lzKHgxLCB4MiwgY29lZmZzKToKZXhwciA9IHgxICogY29lZmZzWzBdICsgeDIgKiBjb2VmZnNbMF0KcmV0dXJuIGV4cHIKXHBhciMgQ29udmVydGVkIGludG8gbGFtYmRhIGZvcm1hdApoeXBvdGhlc2lzID0gbGFtYmRhIHgxLCB4MiwgY29lZmZzOiB4MSAqIGNvZWZmc1swXSArIHgyICogY29lZmZzWzBdCg==)
# Original function format
def hypothesis(x1, x2, coeffs):
expr = x1 * coeffs[0] + x2 * coeffs[0]
return expr
\par# Converted into lambda format
hypothesis = lambda x1, x2, coeffs: x1 * coeffs[0] + x2 * coeffs[0]
This conversion allows us to transform the hypothesized Python function into an expression tree directly. For each fitted expression, we construct an e-graph and apply a predefined set of rewrite rules until reaching a fixed iteration limit. From the resulting e-graph, we sample $K$ unique equivalent expressions. Each sampled expression is then converted back into a Python function to facilitate further interaction with the LLM.
[⬇](data:text/plain;base64,CiMgb2J0YWluZWQgZXF1aXZhbGVudCBleHByZXNzaW9uCmVxdWl2YV9zZXEgPSBbIkEtPmxvZyhBKSIsICJBLT5BKkEiLCAiQS0+eDEiLCAiQS0+eDIiXQojIENvbnZlcnRlZCBmdW5jdGlvbiBmb3JtYXQKZGVmIGVxdWl2YV9oeXBvdGhlc2lzKHgxLCB4MiwgY29lZmZzKToKcmV0dXJuIHgxICogeDIK)
# obtained equivalent expression
equiva_seq = ["A->log(A)", "A->A*A", "A->x1", "A->x2"]
# Converted function format
def equiva_hypothesis(x1, x2, coeffs):
return x1 * x2
- (d)
Egg-based Feedback. In subsequent iterations, the LLM receives feedback consisting of previously generated expressions along with their fitness scores. Our feedback is enriched with both the original hypotheses and their equivalent expressions derived via Egg module, enabling the model to refine future generations. High-performing expressions are retained and further updated over multiple rounds.

Figure: Figure 8: Pipeline of Egg-LLM. (a) Hypothesis Generation. The LLM receives prompts derived from the problem specification and predicts multiple candidate expressions. (b) Data-Driven Evaluation. The coefficients of each candidate are fitted to the dataset and then evaluated on a separate validation set to compute a goodness-of-fit score. (c) EGG-Based Feedback. The proposed Egg module generates symbolically equivalent variants, which are fed back into step (a) to guide the next round of hypothesis generation.
Refer to caption: x10.png

### D.4 Final Remark

The E2E-Transformer framework (DBLP:conf/nips/KamiennydLC22) is structurally very similar to the neural network used in the DRL model, with the main difference being that it is trained using a cross-entropy loss function. A straightforward way to integrate the Egg module into E2E-Transformer is through data augmentation, where additional training examples are generated using Egg.

To date, only one work has explored the use of a text-based diffusion model for symbolic regression (bastiani2025diffusion). However, its implementation has not been released publicly. Moreover, the proposed pipeline relies on multiple interconnected components, which makes it difficult to reproduce or isolate for independent evaluation. For these reasons, we do not include a comparison between the text-based diffusion approach and Egg in this paper.

Several extensions of the baseline considered in this study offer empirical improvements but lack theoretical guarantees.
For example, DBLP:conf/nips/MundhenkLGSFP21 employ genetic programming to refine the predictions of the DRL model, and DBLP:journals/corr/abs-2303-03192 introduce unit constraints in physical systems to eliminate infeasible expressions.
Integrating Egg with these variants is an interesting direction that we leave for future investigation.

## Appendix E Experiment Settings

### E.1 Baselines and Hyper-parameters Configurations

The representative baselines are selected as they all regard the search for the optimal expression as a sequential decision-making process.
A detailed description of each method is provided below:

MCTS.
(DBLP:conf/iclr/Sun0W023) propose to use the Monte Carlo tree search algorithm to explore the space of symbolic expressions defined by a context-free grammar (described in Section [A](https://arxiv.org/html/2511.05849v1#A1)) to find high-performing expressions. Despite being implemented similarly, this method appears under various names in previous works (DBLP:conf/icml/TodorovskiD97; DBLP:conf/dis/GanzertGSK10; DBLP:journals/kbs/BrenceTD21; DBLP:conf/iclr/Sun0W023; DBLP:conf/icml/KamiennyLLV23). We choose the implementation (^5^55[https://github.com/isds-neu/SymbolicPhysicsLearner](https://github.com/isds-neu/SymbolicPhysicsLearner)) from DBLP:conf/iclr/Sun0W023 and serve as a representative of this family of methods.

DRL. (DBLP:conf/iclr/PetersenLMSKK21) propose to use a recurrent neural network (RNN) trained via a (risk-seeking) reinforcement learning objective. The RNN sequentially generates candidate expressions and is optimized using a risk-seeking policy gradient to encourage the discovery of high-quality expressions. We chose this implementation (^6^66[https://github.com/dso-org/deep-symbolic-optimization](https://github.com/dso-org/deep-symbolic-optimization)). We use three types of sequential decoders for the time benchmark setting. The major configurations are listed in Table [4](https://arxiv.org/html/2511.05849v1#A5.T4).

**Table 4: Hyperparameters for the DRL Model with different types of neural network. This configuration is also used in Figure [5](https://arxiv.org/html/2511.05849v1#S5.F5).**
| General Parameters |  |  |
| --- | --- | --- |
| max length of output sequence | 20 |  |
| batch size of generated sequence | 1024 |  |
| total learning iterations | 200 |  |
| Reward function | $\frac{1}{1+\mathtt{NMSE}(\phi)}$ |  |
| Optimizer Hyperparameters |  |  |
| optimizer | Adam |  |
| learning rate | 0.009 |  |
| entropy weight | 0.03 |  |
| entropy gamma | 0.7 |  |
| Decoder-relevant Hyperparameters |  |  |
| choice of decoder | LSTM | Decoder-only Transformer |
| num of layers | 3 | 3 |
| hidden size | 128 | 128 |
| dropout rate | 0.5 | / |
| number of head | / | 6 |

LLM-SR. (DBLP:journals/iclr/llmsr25) leverage pretrained large language models, such as GPT4o, to generate symbolic expressions based on task-specific prompts. The expressions are evaluated and iteratively refined over multiple rounds. We choose their implementation at (^7^77[https://github.com/deep-symbolic-mathematics/LLM-SR](https://github.com/deep-symbolic-mathematics/LLM-SR)).

For each baseline, we adopted the most straightforward implementation. Only minimal modifications were made to ensure that all baselines use the same input data and problem configurations, and are compatible with the proposed Egg module. We also rename the abbreviation of each method, to clearly present the core idea in each method and uniformly present the adaptation of our Egg on top of these baselines.

**Table 5: Hyper-parameter configurations for symbolic expression computation.**
| Expressions and Dataset |  |
| --- | --- |
| training dataset size | 2048 |
| validation and testing dataset size | 2048 |
| coefficient fitting optimizer | BFGS |
| maximum allowed coefficients | 20 |
| optimization termination criterion | error is less than $1e-6$ |

Expression-related Configurations

When fitting the values of open constants in each expression, we sample a batch of data with batch size $1024$ from the data Oracle. The open constants in the expressions are fitted on the data using the BFGS optimizer(^8^88[https://docs.scipy.org/doc/scipy/reference/optimize.minimize-bfgs.html](https://docs.scipy.org/doc/scipy/reference/optimize.minimize-bfgs.html)). We use a multi-processor library to fit multiple expressions using 8 CPU cores in parallel. This greatly reduced the total training time.

An expression containing a placeholder symbol $A$ or containing more than 20 open constants is not evaluated on the data; its fitness score is $-\infty$.

The normalized mean-squared error metric is further defined in Equation [5](https://arxiv.org/html/2511.05849v1#S5.E5).

To ensure fairness, we use an interface, called dataOracle, which returns a batch of (noisy) observations of the ground-truth equations.
To fast evaluate the obtained expression is evaluated using the Sympy library, and the step for fitting open constants in the expression with the dataset uses the optimizer provided in the Scipy library(^9^99[https://docs.scipy.org/doc/scipy/tutorial/optimize.html](https://docs.scipy.org/doc/scipy/tutorial/optimize.html)).

During testing, we ensure that all predicted expressions are evaluated on the same testing dataset by configuring the dataOracle with a fixed random seed, which guarantees that the same dataset is returned for evaluation.

We further summarize all the above necessary configurations in Table [5](https://arxiv.org/html/2511.05849v1#A5.T5).

### E.2 Evaluation Metrics

We mainly consider two evaluation criteria for the learning algorithms tested in our work: 1) the goodness-of-fit measure and 2) the total running time of the learning algorithms.

The goodness-of-fit indicates how well the learning algorithms perform in discovering unknown symbolic expressions. Given a testing dataset $D_{\text{test}}=\{(\mathbf{x}_{i},y_{i})\}_{i=1}^{n}$ generated from the ground-truth expression $\phi$, we measure the goodness-of-fit of a predicted expression $\phi_{\mathtt{pred}}$, by evaluating the mean-squared-error (MSE) and normalized-mean-squared-error (NMSE):

$$ MSE $\displaystyle=\frac{1}{n}\sum_{i=1}^{n}(y_{i}-\phi_{\mathtt{pred}}(\mathbf{x}_{i}))^{2},\qquad\quad\text{NMSE}=\frac{\frac{1}{n}\sum_{i=1}^{n}(y_{i}-\phi_{\mathtt{pred}}(\mathbf{x}_{i}))^{2}}{\sigma_{y}^{2}}$ (13) RMSE $\displaystyle=\sqrt{\frac{1}{n}\sum_{i=1}^{n}(y_{i}-\phi_{\mathtt{pred}}(\mathbf{x}_{i}))^{2}},\qquad\text{NRMSE}=\frac{1}{\sigma_{y}}\sqrt{\frac{1}{n}\sum_{i=1}^{n}(y_{i}-\phi_{\mathtt{pred}}(\mathbf{x}_{i}))^{2}}$ $$

where the empirical variance $\sigma_{y}=\sqrt{\frac{1}{n}\sum_{i=1}^{n}\left(y_{i}-\frac{1}{n}\sum_{i=1}^{n}y_{i}\right)^{2}}$. Note that the coefficient of determination ($R^{2}$) metric (nagelkerke1991note; DBLP:conf/nips/CavaOBFVJKM21) is equal to $(1-\text{NMSE})$ and therefore omitted in the experiments.

## Appendix F Extra Experimental Results

### F.1 Visualization of Egg Construction

We summarize the list of example expressions, their symbolic-equivalent variants, and the visualized EGG in Table [6](https://arxiv.org/html/2511.05849v1#A6.T6).

**Table 6: Summary of expressions, their symbolic-equivalent variants, and the visualized o it visualization of more e-graphs obtained via Egg.**
| ID | Original equation | Symbolic-equivalent variant | E-graph |
| --- | --- | --- | --- |
| visualization |  |  |  |
| 1 | $\log(x_{1}^{3}x_{2}^{2})$ | $3\log(x_{1})+2\log(x_{2})$ | Figure [9](https://arxiv.org/html/2511.05849v1#A6.F9) |
| 2 | $\exp(c_{1}x_{1}+x_{2})$ | $\exp(c_{1}x_{1})\exp(x_{2})$ | Figure [10](https://arxiv.org/html/2511.05849v1#A6.F10) |
| 3 | $\sin(x_{1}+x_{2})$ | $\sin(x_{1})\cos(x_{2})+\cos(x_{1})\sin(x_{1})$ | Figure [11](https://arxiv.org/html/2511.05849v1#A6.F11) |
| 4 | $\log(x_{1}\times\ldots x_{n})$ | $\log(x_{1})+\ldots\log(x_{n})$ | Figure [13](https://arxiv.org/html/2511.05849v1#A6.F13) |
| 5 | $\sin(x_{1}+\ldots+x_{n})$ | omitted | Figure [14](https://arxiv.org/html/2511.05849v1#A6.F14) |
| (a) Example symbolic regressions |  |  |  |
| ID | Original equation | Symbolic-equivalent variant | E-graph |
| visualization |  |  |  |
| I.15.3x | $\frac{x_{0}-x_{1}x_{2}}{\sqrt{c^{2}-x_{1}^{2}}}$ | $\frac{x_{0}-x_{1}x_{2}}{\sqrt{c+x_{1}}\sqrt{c-x_{1}}}$ | Figure [15](https://arxiv.org/html/2511.05849v1#A6.F15) |
| I.30.3 | $x_{0}\frac{\sin^{2}(x_{1}x_{2}/2)}{\sin^{2}(x_{2}/2)}$ | $x_{0}\left(\frac{\sin(x_{1}x_{2}/2)}{\sin(x_{2}/2)}\right)^{2}$ | Figure [16](https://arxiv.org/html/2511.05849v1#A6.F16) |
| I.44.4 | $c_{1}x_{0}x_{1}\log(x_{2}/x_{3})$ | $c_{1}x_{0}x_{1}(\log(x_{2})-\log(x_{3}))$ | Figure [17](https://arxiv.org/html/2511.05849v1#A6.F17) |
| I.50.26 | $x_{0}(\cos(x_{1}x_{2})+x_{3}\cos^{2}(x_{1}x_{2}))$ | $x_{0}\cos(x_{1}x_{2})\left(1+x_{3}\cos(x_{1}x_{2})\right)$ | Figure [18](https://arxiv.org/html/2511.05849v1#A6.F18) |
| II.6.15b | $\frac{3x_{0}}{4\pi}\frac{3\cos x_{1}\sin x_{1}}{x_{2}^{3}}$ | $\frac{3x_{0}}{8\pi}\frac{\sin(2x_{1})}{x_{2}^{3}}$ | Figure [19](https://arxiv.org/html/2511.05849v1#A6.F19) |
| II.35.18 | $\frac{x_{0}}{\exp(x_{1}x_{2}/x_{3})+\exp(-x_{1}x_{2}/x_{3})}$ | $\frac{x_{0}}{2\cosh\left(x_{1}x_{2}/x_{3}\right)}$ | Figure [20](https://arxiv.org/html/2511.05849v1#A6.F20) |
| II.35.21 | $x_{0}x_{1}\tanh(x_{1}x_{2}/x_{3})$ | $x_{0}x_{1}\frac{\exp(2x_{1}x_{2}/x_{3})-1}{\exp(2x_{1}x_{2}/x_{3})+1}$ | Figure [21](https://arxiv.org/html/2511.05849v1#A6.F21) |
| (b) selected complex symbolic regressions from Feynman Dataset. |  |  |  |

E-graph for $\log$ operator. Figure [9](https://arxiv.org/html/2511.05849v1#A6.F9) illustrates the e-graph construction for the expression $\log(x_{1}^{3}x_{2}^{2})$ using rewrite rules for $\log$ operator: $\log(a\times b)\leadsto\log(a)+\exp(b)$ and also $\log(a^{b})\leadsto b\log a$. This visualization is based on the Graphviz API. We also label each e-class with a unique index for clarity.
As shown in Figure [9](https://arxiv.org/html/2511.05849v1#A6.F9), the saturated e-graph grows significantly larger as more rewrite rules are applied.
In our full implementation, we incorporate many additional rewrite rules beyond these basic logarithmic identities, resulting in substantially larger and more complex e-graphs.

Figure: Figure 9: (Top left) Initialized e-graphs for expression $\log(x_{1}^{3}x_{2}^{2})$. (Top Right) The saturated e-graphs after applying one rewrite rule $\log(ab)\leadsto\log a+\log b$. (Bottom) The saturated e-graphs after applying two rewrite rules: $\log(ab)\leadsto\log a+\log b$ and $\log(a^{b})\leadsto b\log a$.
Refer to caption: x11.png

E-graph for $\exp$ operator.
Figure [10](https://arxiv.org/html/2511.05849v1#A6.F10) illustrates the e-graph construction for the expression $\exp(c_{1}x_{1}+x_{2})$ using the exponential rewrite rule $\exp(a+b)\leadsto\exp(a)\times\exp(b)$.
The input expression $\exp(c_{1}\times x_{1}+x_{2})$ is represented as a sequence of production rules: $(A\to\exp(A),\;A\to A+A,\;A\to A\times A,\;A\to c_{1},\;A\to x_{1},\;A\to x_{2})$.

Figure: Figure 10: (Left) Initialized e-graph for expression $\exp(c_{1}x_{1}+x_{2})$. (Right) The saturated e-graphs after applying one rewrite rule $\exp(a+b)\,\leadsto\,\exp(a)\exp(b)$.
Refer to caption: x14.png

E-graph for $\sin,\cos$ operators. Figure [11](https://arxiv.org/html/2511.05849v1#A6.F11) demonstrates the application of the trigonometric identity $\sin(a+b)\leadsto\sin a\cos b+\sin b\cos a$
to the input expression $\sin(x_{1}+x_{2})$. The input expression is represented by the sequence of production rules $(A\to\sin(A),\;A\to A+A,\;A\to x_{1},\;A\to x_{2})$.

Figure: Figure 11: Applying the rewrite rule $\sin(a+b)\leadsto\sin a\cos b+\sin b\cos a$ in an e-graph representing expression $\sin(x_{1}+x_{2})$. Left: Initialized e-graph. Right: e-graph after applying the rewrite rule.
Refer to caption: x16.png

E-graph for $\partial/\partial x_{i}$ operator.
Figure [12](https://arxiv.org/html/2511.05849v1#A6.F12) shows the application of the partial derivative commutativity rule $\frac{\partial^{2}f}{\partial x_{i}\partial x_{j}}\leadsto\frac{\partial^{2}f}{\partial x_{j}\partial x_{i}}$
to the input expression $\frac{\partial^{2}(x_{1}+x_{2})}{\partial x_{1}\partial x_{2}}$. The derivation is represented by the following production rules: $(A\to\partial(A)/\partial x_{1},\;A\to\partial(A)/\partial x_{2},\;A\to x_{1}+x_{2})$.

Figure: Figure 12: Applying the rewrite rule $\frac{\partial}{\partial x_{i}}\left(\frac{\partial f}{\partial x_{j}}\right)\leadsto\frac{\partial}{\partial x_{j}}\left(\frac{\partial f}{\partial x_{i}}\right)$ in an e-graph representing expression $\frac{\partial^{2}(x_{1}+x_{2})}{\partial x_{i}\partial x_{j}}$. Left: Initialized e-graph. Right: e-graph after applying the rewrite rule.
Refer to caption: x18.png

E-graph visualization for case analysis in section [5.3](https://arxiv.org/html/2511.05849v1#S5.SS3).

Figure: Figure 13: Visualization of e-graphs for expression $\log(x_{1}\times\ldots\times x_{n})$, using the rewrite rule $\log(ab)\leadsto\log a+\log b$. The three figures correspond to $n=2,3,4$ accordingly.
Refer to caption: x20.png

Figure: Figure 14: Visualization of e-graphs for expression $\sin(x_{1}+\ldots+x_{n})$, using the trigonometric rewrite rule $\sin(a+b)\leadsto\sin(a)\cos(b)+\sin(b)\cos(a)$. The three figures correspond to $n=2,3,4$.
Refer to caption: x23.png

### F.2 Additional Visualization for Selected Expressions in Feynman Dataset

E-graph for equation ID I.15.3x in the Feynman dataset.
Figure [15](https://arxiv.org/html/2511.05849v1#A6.F15) illustrates the application of the rewrite rules $\sqrt{ab}\leadsto\sqrt{a}\sqrt{b}$ and $a^{2}-b^{2}=(a+b)(a-b)$
to the input expression $\frac{x_{0}-x_{1}x_{2}}{\sqrt{c_{1}^{2}-x_{1}^{2}}}$.

Figure: Figure 15: (Left) Initialized e-graph for the expression $({x_{0}-x_{1}x_{2}})/{\sqrt{c_{1}^{2}-x_{1}^{2}}}$, where the equation ID is I.15.3x in the Feynman dataset. (Right) Saturated e-graph after applying the rewrite rule $\sqrt{ab}\leadsto\sqrt{a}\sqrt{b}$ and $a^{2}-b^{2}=(a+b)(a-b)$.
Refer to caption: x26.png

E-graph for equation ID I.30.3 in the Feynman dataset. Figure [16](https://arxiv.org/html/2511.05849v1#A6.F16) illustrates the application of the rewrite rule $a^{2}/b^{2}\leadsto(a/b)^{2}$
to the input expression $x_{0}\frac{\sin^{2}(x_{1}x_{2}/2)}{\sin^{2}(x_{2}/2)}$.

Figure: Figure 16: (Left) Initialized e-graph for the expression $x_{0}\frac{\sin^{2}(x_{1}x_{2}/2)}{\sin^{2}(x_{2}/2)}$, where the equation ID is I.30.3 in the Feynman dataset. (Right) Saturated e-graph after applying the rewrite rule $\log(a/b)\leadsto\log a-\log b$.
Refer to caption: x28.png

E-graph for equation ID I.44.4 in the Feynman dataset.
Figure [17](https://arxiv.org/html/2511.05849v1#A6.F17) illustrates the application of the rewrite rule $\log(a/b)\;\leadsto\;\log a-\log b$
to the input expression $c_{1}x_{0}x_{1}\log(x_{2}/x_{3})$.

Figure: Figure 17: (Left) Initialized e-graph for the expression $c_{1}x_{0}x_{1}\log(x_{2}/x_{3})$, where the equation ID is I.44.4 in the Feynman dataset. (Right) Saturated e-graph after applying the rewrite rule $\log(a/b)\leadsto\log a-\log b$.
Refer to caption: x30.png

E-graph for equation ID I.50.26 in the Feynman dataset.
Figure [18](https://arxiv.org/html/2511.05849v1#A6.F18) illustrates the application of the rewrite rule $ab+ac\leadsto a(b+c)$
to the input expression $x_{0}(\cos(x_{1}x_{2})+x_{3}\cos^{2}(x_{1}x_{2}))$.

Figure: Figure 18: (Left) Initialized e-graph for the expression $x_{0}(\cos(x_{1}x_{2})+x_{3}\cos^{2}(x_{1}x_{2}))$, where the equation ID is I.50.26 in the Feynman dataset. (Right) Saturated e-graph after applying the rewrite rule $a+ba^{2}\leadsto a(ba+1)$.
Refer to caption: x32.png

E-graph for equation ID II.6.15b in the Feynman dataset. Figure [19](https://arxiv.org/html/2511.05849v1#A6.F19) illustrates the application of the rewrite rule $\cos(a)\sin(a)\leadsto\frac{\sin(2a)}{2}$
to the input expression $\frac{x_{0}}{\exp(x_{1}x_{2}/x_{3})+\exp(-x_{1}x_{2}/x_{3})}$.

Figure: Figure 19: (Left) Initialized e-graph for the expression $\frac{3x_{0}}{4\pi}\frac{\cos x_{1}\sin x_{1}}{x_{2}^{3}}$, where the equation ID is II.6.15b in the Feynman dataset. (Right) Saturated e-graph after applying the rewrite rule $\cos(a)\sin(a)\leadsto\frac{\sin(2a)}{2}$.
Refer to caption: x34.png

E-graph for equation ID II.35.18 in the Feynman dataset. Figure [20](https://arxiv.org/html/2511.05849v1#A6.F20) illustrates the application of the rewrite rule $(\exp(a)+\exp(-a))/2\leadsto\cosh{a}$
to the input expression $\frac{x_{0}}{\exp(x_{1}x_{2}/x_{3})+\exp(-x_{1}x_{2}/x_{3})}$.

Figure: Figure 20: (Left) Initialized e-graph for the expression $\frac{x_{0}}{\exp(x_{1}x_{2}/x_{3})+\exp(-x_{1}x_{2}/x_{3})}$, where the equation ID is II.35.18 in the Feynman dataset. (Right) Saturated e-graph after applying the rewrite rule $(\exp(a)+\exp(-a))\leadsto 2\cosh{a}$.
Refer to caption: x36.png

E-graph for equation ID II.35.21 in the Feynman dataset. Figure [21](https://arxiv.org/html/2511.05849v1#A6.F21) illustrates the application of the rewrite rule $\tanh a\leadsto\frac{\exp({2a})-1}{\exp({2a})+1}$
to the input expression $x_{0}x_{1}\tanh(x_{1}x_{2}/x_{3})$.

Figure: Figure 21: (Left) Initialized e-graph for the expression $x_{0}x_{1}\tanh(x_{1}x_{2}/x_{3})$, where the equation ID is II.35.21 in the Feynman dataset. (Right) Saturated e-graph after applying the rewrite rule $\tanh a\leadsto\frac{\exp({2a})-1}{\exp({2a})+1}$.
Refer to caption: x38.png

## Peer Reviews

confidence: 5
contribution: 2
initial_rating: 2
presentation: 1
questions: 1. **Clarity** 
- In line 42, "A promising yet underexplored direction for reducing the *effective* search space", do you mean reducing the ineffective or redundant search space?
- *Inconsistences*: In line 83, coefficients are denoted as $\boldsymbol{c}$, then in line 93 they are denoted as $const$, and in line 213 $c$ is referred to constant to balance exploration and exploitation.
- *Confusions*: In Fig.1 and lines 133, 134, 252, and 253, notations explaining the substitution rule for recursively constructing a closed-form expression all use a single notation $A$ for a place-holder subexpression, making it hard to distinguish their hierarchy structure and correspondence in the figure. Using a subscription to distinguish placeholders might be better for clarity.
- *Missing Critical Definitions*: There are no formal definitions of states and actions in the Markov Decision Process (MDP) for both MCTS and DRL in the main context. There is also no clear definition of what a node $s$ represents in line 211 (I assume it should be the candidate expression $\phi$ inferred from the example in line 252) and what a sequence $\tau$ represents in line 272 (Is it the same as $\phi$ for node $s$? How EGG is represented as a state here?).
2. **EGG-based Backpropagation**: I have two major concerns about the EGG-based backpropagation based on my understanding, both of which arise from the backpropagation to all the equivalent sub-expressions in MCTS:

- The EGG-based backpropagation seems to backpropagate the increasing visit counts to all the equivalent sub-expression generation paths (even if they are not explored at this stage). Does it mean that the visit counts are dependent on the number of equivalents a sub-expression has, so that visit counts of an expression with more equivalents will grow faster, leading to potentially under-explored UCT search?
- Even if the above case is fine for the terminal nodes that are equivalent, the non-terminal nodes on the intermediate paths might not be equivalent. For example, two equivalent subexpression, their paths $sin^2(A_1)+cos^2(A_2) \rightarrow sin^2(x)+cos^2(x)=1$ and $\frac{B_1}{B_2} \rightarrow \frac{y}{y} = 1$  can have distinct intermediate expressions $sin^2(A_1)+cos^2(A_2)$ and $\frac{B_1}{B_2}$ if the placeholders $A_i$ and $B_i$ are not further sampled to be the same variables respectively. In such a case, would the synchronization of the equivalent terminals' backpropagation regarding the visit counts also affect these non-equivalent intermediate nodes (i.e., more number of visits if they have equivalent terminals), so that they might have biased UCT selections?

I'm happy to change my score if the above concerns and questions are properly addressed.
soundness: 1
strengths: 1. **Significance**: The paper focuses on an important and fundamental problem in symbolic regression (SR), and the introduced e-graph is reasonable for equivalence-aware SR frameworks.

2. **Multiple Backends:** The paper conducts e-graphs on several learning/search methods (MCTS, DRL, and LLM) to show a universal advantage of capturing expression equivalences in SR methods.
summary: This paper introduces the Equality Graph (e-graph) into the symbolic regression (SR) framework to enable uniform rewards and loss assigned to the mathematical equivalent expressions, enabling a more efficient and robust SR search. The paper provides both theoretical analyses and experiments on several backend learning/search methods to support the claim.
weaknesses: 1. **Novelty:** Though the e-graph is new in SR, similar ideas of using graph-based representations to capture expression equality have already been studied for SR. For example, Expression DAGs [1] include the same idea of sharing sub-expressions in DAGs for expression equality. The paper lacks a sufficient literature review on this topic to differentiate its novelty and contribution.

2. **Potentially Biased UCT Search**: The proposed EGG back-propagation in MCTS might lead to biased UCT selections, see Question 2.

3. **Experimental Soundness:** The whole experimental section can be regarded as an ablation study, which only focuses on implementing typical baselines with or without EGG on datasets with abundant equivalencies. However, benchmarkings on widely adopted general datasets (e.g., SRBench [2]) with relevant prevailing baselines (e.g., SPL [3] for MCTS and uDSR [4] for DRL) are missing, which cannot support the claim "EGG-SR ... discovering equations with lower normalized mean squared error than *state-of-the-art* methods" in the abstract. Especially, the *state-of-the-art* methods could include many transformer-based methods, such as TPSR[5], RAG-SR[6], and also DGSR [7], an E2E transformer model to encode expression equivalences.

4. **Clarity:** There are some confusing definitions and notations, see Question 1.

[1] Kahlmeyer, Paul, et al. "Scaling up unbiased search-based symbolic regression." Proceedings of the Thirty-Third International Joint Conference on Artificial Intelligence. 2024.

[2] La Cava, William, et al. "Contemporary symbolic regression methods and their relative performance." Advances in neural information processing systems 2021.DB1 (2021): 1.

[3] Sun, Fangzheng, et al. "Symbolic Physics Learner: Discovering governing equations via Monte Carlo tree search." The Eleventh International Conference on Learning Representations.

[4] Landajuela, Mikel, et al. "A unified framework for deep symbolic regression." Advances in Neural Information Processing Systems 35 (2022): 33985-33998.

[5] Shojaee, Parshin, et al. "Transformer-based planning for symbolic regression." Advances in Neural Information Processing Systems 36 (2023): 45907-45919.

[6] Zhang, Hengzhe, et al. "RAG-SR: Retrieval-augmented generation for neural symbolic regression." The Thirteenth International Conference on Learning Representations. 2025.

[7] Holt, Samuel, Zhaozhi Qian, and Mihaela van der Schaar. "Deep Generative Symbolic Regression." The Eleventh International Conference on Learning Representations.

---

confidence: 4
contribution: 4
initial_rating: 6
presentation: 3
questions: Concerns and questions are described in "Weaknesses".
soundness: 3
strengths: **Novel and Important Problem Formulation**:​​ The paper successfully identifies and tackles the fundamental issue of symbolic equivalence, a significant source of inefficiency in SR that has been largely overlooked. This focus is timely and valuable.

​**High Methodological Innovation**:​​ The primary strength is the proposal of a unified, plug-and-play framework (EGG-SR) rather than a single algorithm. Its applicability across diverse paradigms (MCTS, DRL, LLM) demonstrates remarkable generality and conceptual elegance.

**​Strong Theoretical and Empirical Validation**:​​ The work is supported by non-trivial theoretical guarantees, which substantiate the method's benefits. The experiments are comprehensive, convincingly showing performance improvements across multiple baselines and datasets. The inclusion of efficiency analyses (time/space) and rich e-graph visualizations strengthens the empirical contribution.
summary: This paper presents EGG-SR, a unified framework that addresses the underexplored problem of symbolic equivalence in symbolic regression (SR). The core idea is to integrate equality graphs (e-graphs) to compactly represent equivalent expressions, thereby reducing redundant search. The authors demonstrate the versatility of EGG-SR by embedding it into three distinct SR paradigms: Monte Carlo Tree Search (MCTS), Deep Reinforcement Learning (DRL), and Large Language Models (LLMs). Theoretical analysis shows tighter regret bounds for MCTS and lower gradient variance for DRL. Empirically, the EGG module consistently enhances baseline performance across various benchmarks, leading to the discovery of expressions with lower normalized mean squared error.
weaknesses: **Dependence on Manually Defined Rewrite Rules**:​​ The effectiveness of EGG-SR currently relies on a pre-defined set of rewrite rules. The framework's power and generality could be further amplified by exploring methods to learn or automatically discover these rules from data, as noted by the authors in the conclusion.

**Writings**: There is a significant distance between Figure 1 and the corresponding explanatory text (Section 3.1). To improve the reader's flow, I suggest moving the figure closer to its initial description or adding a cross-reference (e.g., "as illustrated in Figure 1") when it is first mentioned in the text. Plus, there appears to be an error in the reported minimum value for the second column under the "noisy setting" in Table 1.

---

confidence: 5
contribution: 3
initial_rating: 6
presentation: 3
questions: 1. The framework's success depends on the manually curated set of rewrite rules. (a) How was the rule set for the trigonometric benchmarks in Table 1  selected? Was it designed specifically for those problems? (b) How does EGG-SR's performance degrade if key rewrite rules are omitted from the set?

2. Regarding the time-efficiency in Figure 5, how does the "EGG construction" time scale with (a) the complexity (e.g., length or depth) of the initial expression and (b) the total number of rewrite rules in the system?

3. For the EGG-LLM method, how are the equivalent expressions for the feedback prompt selected from the e-graph? Do you use cost-based extraction, random sampling, or some other heuristic? How many equivalent expressions are added, and how are they formatted in the prompt to effectively guide the LLM?

4. Could you please clarify the result in Figure 3 (Left)? Why does EGG-MCTS, which is designed to avoid redundant exploration, result in a larger total search tree than standard MCTS? Does merging equivalent nodes (and sharing their visit counts/rewards) encourage a deeper, more focused search down promising paths, thus leading to a larger total node count even as redundant branches are eliminated?

I am willing to raise my score if the authors can satisfactorily address all the concerns outlined in the weaknesses and questions above.
soundness: 3
strengths: - **Originality**: While e-graphs and their application to SR are not entirely new (as noted in the related works ), this paper's contribution is a novel and highly general framework. Applying the equivalence concept systematically to MCTS (search pruning), DRL (variance reduction), and LLMs (prompt enrichment) is a creative and powerful combination of ideas. The DRL variance reduction and LLM feedback mechanisms are particularly original.

- **Quality**: The paper is technically strong. The theoretical claims are well-supported by proofs in the appendix that build on established literature (e.g., Rao-Blackwellization for DRL variance ). The empirical evaluation is thorough and convincing. The authors test their claims across all three proposed algorithm variants and find consistent improvements. Crucially, they include practical analyses of memory and time overhead (Figures 4 and 5), which demonstrate the method's feasibility.

- **Clarity**: The paper is exceptionally well-written. The problem is motivated with a clear, simple example ($log(x_{1}^{2}x_{2}^{3})$) 16 that is carried through the text. The methodology is explained clearly, with helpful diagrams for the e-graph construction (Figure 1) 17, the MCTS process (Figure 2) 18, and the LLM pipeline (Figure 8)19. The distinction between the baseline algorithms and their EGG-enhanced counterparts is sharp and easy to grasp.

- **Significance**: This work addresses a fundamental and widely recognized source of inefficiency in symbolic regression. Because the EGG-SR framework is shown to be effective across diverse SR methods (search, DRL, LLM) and practical (low overhead), it has the potential for broad impact. It provides a "drop-in" enhancement that could benefit a wide range of existing and future SR systems.
summary: The paper introduces EGG-SR, a framework designed to improve the efficiency and effectiveness of Symbolic Regression (SR). The core problem addressed is that existing SR algorithms inefficiently explore the search space by treating syntactically different but semantically equivalent expressions as distinct candidates. EGG-SR integrates equality graphs (e-graphs) to compactly represent and manage these symbolic equivalences within a grammar-based SR setting.
weaknesses: - The process of building the e-graph, "equality saturation", involves iteratively applying all rules. While the storage is efficient (Figure 4), the construction time could become a bottleneck for very complex expressions or a very large set of rewrite rules. Figure 5  shows the overhead is negligible for one dataset, but it does not analyze how this construction time scales with expression complexity or the number of rules.
- The claim for EGG-MCTS is that it "prunes redundant subtree exploration". However, Figure 3 (Left)  shows that EGG-MCTS explores a larger search tree (more nodes) than standard MCTS. The paper states this indicates exploration of a "larger and more diverse search space", but this seems to contradict the "pruning" claim and is confusing. A clearer explanation is needed.

- The related work section (Section 4) is incomplete and overlooks several significant, recent advancements in symbolic regression. While the paper covers the main paradigms, it omits highly relevant work on generative and transformer-based SR models [2, 3, 4].
A more critical omission is the lack of any discussion or comparison with DySymNet [1]. This method is highly relevant to the present work, as DySymNet also employs a policy gradient approach (similar to EGG-DRL) to dynamically construct symbolic networks and has demonstrated strong performance, particularly on high-dimensional problems. The paper would be significantly strengthened by:

    - Including this and other recent works [2, 3, 4] to provide a more comprehensive and up-to-date overview of the field.

    - Providing at least a detailed conceptual comparison, and ideally an empirical one, between EGG-DRL and DySymNet. This is necessary to properly contextualize the DRL-based contribution of EGG-SR.

[1] Li W, Li W, Yu L, et al. A Neural-Guided Dynamic Symbolic Network for Exploring Mathematical Expressions from Data, ICML 2024

[2] Holt S, Qian Z, van der Schaar M. Deep generative symbolic regression, ICLR 2023

[3] Li W, Li W, Sun L, et al. Transformer-based model for symbolic regression via joint supervised learning, ICLR 2023

[4] Shojaee P, Meidani K, Barati Farimani A, et al. Transformer-based planning for symbolic regression, NeurIPS 2023


Decision: Accept (Poster)