arXiv:2608.30162cs.LGAug 2026

Manuscript Offprint

arXiv:2608.30162

Reinforcement Learning for Symbolic Equation Solving

Kevin P O Keeffe

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

We present a reinforcement-learning agent that solves symbolic equations step by step — both nonlinear closed equations (radicals, exponentials, trigonometric) and, for the first time, a controlled class of restricted-open families requiring a change of variables (CoV) such as completing the square. We cast algebra as an MDP with a dynamic action space and a tree-structured policy (TreeMLP). The main policy learns the full solution procedure from reward alone, with no supervised solution traces; the CoV substitution itself comes from a supervised generator interchangeable with a CAS call (≤0.02\leq 0.02 end-task effect). Success means one root verified by substitution and mapped back by exact inverse composition. On closed equations the agent matches the prior best on CommonCore (0.93 greedy vs. ConPoLe's 0.925) and handles nonlinear families (radical, log, trig) under a single policy. On four hand-designed restricted-open families — quadratic, cubic, quartic, and exponential, each with a known closed-form substitution — it reaches 0.79 beam / 0.67 greedy (5-seed means on the 3M-step headline cohort of Section 4.2.2); the greedy mean alone exceeds the strongest non-learned search (A∗A^*, 0.64), with beam adding a further margin. We test the CoV trigger directly against hand-coded rules: on the three single-CoV families (quadratic, cubic, quartic) a one-line detector matches or beats the policy — nothing is learned there — and learned timing has content only on the exponential family, the one family requiring a nested CoV, where the natural rule solves none of the held-out equations while the policy solves 75% from reward alone. The honest claim is recovery of a hand-engineered trigger without access to the detector, not superiority over it. At 10×10\times scale a sharp seed-level bimodality emerges; a UCB learning-progress curriculum shows a non-significant positive trend toward mitigating it. We do not claim general open-equation solving: every open-equation result here is confined to these four controlled families.

1 Introduction

Most machine-learning approaches to symbolic mathematics map a problem directly to its answer Lample & Charton (2020): a model emits a solution in one shot. Many downstream goals, however, need the procedure: a sequence of explicit, replayable transformations that reaches the solution and exposes the trace and the policy that produced it. Differential-equation reductions, theorem-prover tactics, and didactic step-by-step solvers all consume such traces. We show that reinforcement learning can acquire this procedural capability for algebraic equation solving: building on RL for nonlinear closed equations (our earlier work; O'Keeffe, 2025) (radical, exponential, trigonometric), our agent additionally solves, to our knowledge for the first time, the harder restricted-open setting, where the solution requires a change of variables (CoV) drawn from hand-designed families with known closed forms. The main policy learns from reward alone, with no supervised solution traces; the one supervised component is the CoV substitution generator, which is interchangeable with a CAS call. Throughout, solving means producing one root verified by substitution in the active equation and mapped back by exact inverse composition.

Scope of the claims. Every open-equation claim in this paper is scoped to a controlled restricted-open benchmark: four hand-designed families (quadratic, cubic, quartic, exponential), each restricted to forms admitting a known closed-form depression substitution, with generic instances that admit no such substitution excluded by construction (Section 4.2). We do not claim general open-equation solving, and we do not claim that the entire pipeline is reward-driven: the claim of reward-only learning attaches to the main RL policy, not to πcov\pi_{\mathrm{cov}}, which is supervised (and replaceable by a CAS at ≤0.02\leq 0.02 end-task cost). Success is one substitution-verified root, not the complete solution set.

We formulate symbolic algebra as an MDP whose actions pair an algebraic operation with a sub-expression of the current equation, the legal-action set re-derived from the state each step. The policy/value network is TreeMLP: node IDs are embedded, KK rounds of strictly-local sum-aggregation message passing update node states, and a masked pool yields a fixed-size graph feature for the PPO heads. Three light inductive biases (curriculum, success-replay buffer, constant-relabel macroaction) are layered on top; on CommonCore this matches the prior best (ConPoLe; Poesia et al. 2021).

We expose CoV as a single macroaction in the same dynamic action space; the main policy learns the surrounding procedure and selects the CoV trigger from reward. We test that trigger directly against hand-coded rules rather than asserting it (Section 4.2.4): on the three single-CoV families a one-line detector matches or beats the policy — nothing is learned there. The trigger has content only on the exponential family, which requires a nested CoV, where the natural rule solves 0/75 and the policy solves 56/75 from reward alone. The honest claim is recovery of a hand-engineered trigger without access to the detector, not superiority over it. At 10×10\times scale a sharp seed-level bimodality emerges; a UCB learning-progress curriculum shows a non-significant positive trend toward mitigating it.

Contributions. (a) The first RL agent whose main policy is reward-driven for restricted-open (CoV) symbolic equation solving on a controlled four-family benchmark, with the trigger recovered from reward alone and composable with closed-equation steps under a single policy. The claim is scoped to recovery, and the trigger ablation of Section 4.2.4 localizes where it has content: on the three single-CoV families (quadratic, cubic, quartic) a one-line hand-coded rule matches or beats the policy, so nothing is learned there; learned timing matters only on the exponential family, the sole family requiring a nested CoV, where the policy recovers the trigger without being given the detector. (b) TreeMLP and supporting machinery: a tree-structured policy/value backbone together with relabel-constants and success replay — the configuration PPO-TREE-RC-BUF, which matches the prior best on closed CommonCore equations (0.93 greedy vs. ConPoLe's 0.925; Table 1). (c) A seed-level failure mode and a candidate mitigation: a sharp bimodality at 10×10\times scale in which a run either learns the task or collapses into a policy trap, with a UCB learning-progress curriculum as a non-significant positive mitigation trend.

References (25)