Elamur Research

Tree-Based Deep Learning for Ranking Symbolic Integration Algorithms

Paper · 2025 · Rashid Barket, Matthew England and Jürgen Gerhard

Summary

When Maple finds an indefinite integral, the way it did the calculation can matter long after the calculation is over. Different methods can return mathematically equivalent antiderivatives in forms that vary considerably in size and readability. Maple ordinarily tries its methods in a fixed order, skipping some when simple checks rule them out, and returns the first answer it finds. The authors ask whether Maple can choose a better order for each integrand. Their target is the size of the returned expression in Maple’s internal representation, which can store a repeated subexpression once and refer to it wherever it occurs.

The proposed selector learns from expressions on which the available integration methods have already been tested. It makes separate judgments about which methods are likely to return an answer and which are likely to return the smallest one. A ranker learns by comparing methods that succeeded on the same input, giving the highest positions particular attention. At evaluation time, the predicted order determines which Maple routines to try. The authors also compare ways of giving the selector the integrand. In a prefix sequence, operators and operands appear in an order from which the grouping can be recovered. In a tree, each operator is connected explicitly to its operands. The tree variants beat their sequential counterparts throughout the main comparisons.

On the generated holdout set of 70,000 examples, the Tree Transformer used the two-stage approach to find an optimal method in almost 90% of cases. On the independent Maple Test Suite, which draws on unit tests, user queries and bug reports, it achieved 73% exact matches and surpassed Maple’s existing selector. The paper’s conclusion reports 80.4% on that suite when accepting any result within 10% of the smallest measured size. The authors also isolate the effect of the applicability stage on the elementary portion of the hold-out set. It reduced the number of calls needed to find an answer, at some cost in exact selection accuracy. The central result concerns how to choose among existing symbolic routines. The routines themselves still do the integration, and the definition of a better answer comes from the chosen size measure.

Deep dive: Tree-Based Deep Learning for Ranking Symbolic Integration Algorithms

Learn how Maple can use expression trees to rank symbolic integration methods and choose the one likely to return the most compact answer. · about 38 minutes to read

The problem and its context

Choosing how an exact answer is written

In symbolic indefinite integration, the input is an expression and the desired output is an antiderivative. Differentiating that output gives back the input. A computer algebra system such as Maple may have several ways to produce an antiderivative for the same expression. The paper opens with the example of integrating the product of the variable and its sine. The methods agree mathematically, yet their answers differ in form. A choice that appears incidental when issuing the integration command can determine whether the returned expression is easy to inspect or cumbersome to work with.

The authors study the choice among 13 integration methods available to Maple’s user-facing integrator. Those methods differ in where they are useful. Some are general-purpose, while others target narrower kinds of input. A routine can finish successfully, or it can take time and still fail to return an antiderivative. Once several routines are capable of answering, there is a further question about which answer is preferable. A selector therefore needs to make judgments about both applicability and quality. The properties that suggest a method will succeed need only tell part of the story about the form of its answer.

Maple’s existing strategy reflects expert choices accumulated over a long period. Its integration command works through a fixed order until a routine succeeds. Some methods have guards, which are heuristic checks that can decide from the input whether to skip a routine. A guard might check whether an expression belongs to a suitable type. These checks already give Maple some sensitivity to the individual problem. The order among methods that remain available is fixed. A learned selector would make that order depend on the integrand, potentially bringing a more suitable routine forward.

There are several ways to define suitability. The order could prioritize speed, or it could prefer a compact antiderivative. In consultation with Maplesoft, the authors chose compactness. The distinction matters because a procedure can be quick and return a complicated answer, or return an economical expression after a longer calculation. Attempts to find a successful routine are relevant to the eventual cost of using the selector, but the main training objective concerns the output. The paper measures that objective through Maple’s storage format, giving the experiments a consistent way to compare results produced by different methods.

This use of machine learning assigns the learned component a decision about software that already performs a mathematical operation. An integration routine still constructs the antiderivative. A poor prediction can lead the command towards a larger answer or an unsuccessful attempt, while the symbolic routine retains responsibility for the calculation. That division matters to the authors because users of computer algebra depend on exact results. Their design uses statistical prediction where a mistake can affect the choice of routine without making a statistical prediction the antiderivative itself.

Earlier work on direct integration and method selection

The paper traces much of the interest in learning from symbolic integration data to Lample and Charton’s work. They generated large collections of integrands paired with their antiderivatives, presented expressions as sequences of tokens, and trained a transformer to produce integral expressions. Their evaluation compared the resulting system with Maple and Mathematica under time constraints. Barket and colleagues point out that the comparison brought together cases of different kinds, including a computer algebra system reaching its time limit and a learned system returning a wrong expression. For a user who needs a correct antiderivative, those outcomes have different consequences. Deep Learning for Symbolic Mathematics

An issue that carried over to the present study was the source of the examples. Lample and Charton found that changing the generator between training and evaluation could sharply reduce performance. A collection can contain many distinct expressions while still repeatedly exhibiting features of the procedure that created them. The present paper also cites analyses of generator biases and possible leakage across splits. These concerns motivate an evaluation that distinguishes performance on newly generated examples from performance on problems gathered for a different purpose. The Use of Deep Learning for Symbolic Integration

The paper also discusses work by Welleck and colleagues on the fragility of direct symbolic integration. Their evaluation searched for small changes to expressions that turned a successful prediction into a failure. It also checked whether success on constituent expressions carried over to their sum, and found that the combined problem could defeat a learned integrator even when the parts were individually manageable. The example makes a distinction that matters for the selection problem too. Good performance within the distribution of an evaluation set gives limited information about behavior when familiar pieces occur in unfamiliar arrangements.

Other previous work used learning to guide intermediate decisions inside an integrator. The SymPy study discussed in the paper predicts which integration rule to use at a step, narrowing the search conducted by the symbolic procedure. It reported that the search space shrank to one-sixth of its original size, and a 2.28× speed-up against SymPy’s default heuristic search. Its scope was tied to the rules included in the procedure, with some function types outside its coverage. Selecting among Maple’s complete integration methods is a decision at a different level. An individual method can undertake a whole calculation after being chosen, and the success of the selection is assessed through the antiderivative returned by that method.

The authors’ own preliminary Maple study posed method selection as a classification problem. It asked, separately for each routine, whether the routine would produce an answer of minimum size. They compared a sequential LSTM with a TreeLSTM trained under matching conditions, changing the way a layer processed the expression. The tree variant did better on data from the same generators, while the deterioration on independent examples limited what the authors could conclude about its advantage over Maple overall. The present study revisits both the expression representation and the question being learned. A more informative target could help even when the integrand stays exactly the same.

The paper situates the tree comparison among earlier efforts to learn from structured mathematics. Work on formula reconstruction and retrieval had used tree embeddings with a gated recurrent network. Another study used recursive networks, including a TreeLSTM, to predict relations and properties involving polynomials. The authors also describe the use of tree-recursive networks to help select premises in theorem proving, and work that represents dependently typed programs as trees. These studies give a reason to examine hierarchy directly. An expression’s operators, operands and subexpressions already form the relationships that an architecture can use to decide how to combine information.

Why the learning target matters

The original classification question discards much of what Maple reveals when all the methods are tested. A method that returns a slightly larger expression and a method that gives an extremely large answer can both receive the same negative label. A failure can also be negative under that question. The training target gives no reason to favor the near miss over the other alternatives. This matters once the system is asked to choose a routine for an unfamiliar expression and the evidence for its best choice is uncertain.

There is also an imbalance among methods. The paper’s label survey covers 1.5M generated examples and shows that some methods are optimal considerably more frequently than others. Several methods can tie for the smallest result on one example, so the survey is counting occurrences of optimality across methods. A generally useful integrator can appear repeatedly, while a specialized method may be best only for a narrow family of expressions. Separate classifiers can learn different habits from these different distributions, even though their predictions ultimately inform a single decision.

The authors consider estimating the actual size of every potential answer. That would retain information discarded by an optimality label, but a failed method has no answer size. In addition, an accurate estimate in absolute terms can put the methods in the wrong order. The final formulation asks the questions that arise when calling the integrator. First, which methods are viable? Then, among the ones under consideration, which should be tried before which? Much of the paper is an empirical comparison of what those different questions teach the selector.

The method, step by step

From an integrand to a call order

Consider an input involving a sine applied to a power. Its expression tree places the function above the power and places the base and exponent below that power. The selector encounters this structure before any integration routine has been called. During training, it has examples of such inputs with records of which routines succeeded and how large their answers were. It learns from those records to predict whether particular routines are applicable and to compare the expected quality of their output.

At evaluation time, the applicability predictions and ranking scores come from the integrand alone. A method predicted to succeed receives priority over methods predicted to fail, and the ranking scores supply an order within the priorities established by classification. Maple can then try methods in that order and stop at the first answer. The smallest answer produced by testing the methods is available when building labels and evaluating predictions. The selector has to infer a suitable call order without that information when handling the example.

How the selector orders Maple integration methods

The steps in order.

How the selector orders Maple integration methodsStep 1: Read the integrand1. Read the integrandStep 2: Encode its operators, functions and operands2. Encode its operators, functions and operandsStep 3: Predict which integration methods will succeed3. Predict which integration methods will succeedStep 4: Score methods by predicted relative compactness4. Score methods by predicted relative compactnessStep 5: Prioritize methods predicted to succeed5. Prioritize methods predicted to succeedStep 6: Try Maple routines in the resulting order6. Try Maple routines in the resulting orderStep 7: Return the first successful antiderivative7. Return the first successful antiderivative

The following subsections describe the information available at each step. The data generators supply the expressions, Maple supplies the outcomes, and the encoders convert each integrand into a representation that the applicability classifiers and ranker can use.

Generating expressions with known integrals

The authors combine generators with different starting points. The spread matters because recurring properties of a generator can become shortcuts during training. The paper identifies several such problems in earlier data. A procedure can tend to produce long integrands paired with short antiderivatives or the reverse, while rarely producing pairs of comparable length. Many expressions can share a form and differ only in coefficients. Certain shapes may be hard to generate at all. A collection assembled from different procedures broadens the range of structures that enter the selection task. Deep Learning for Symbolic Mathematics

FWD starts with a random expression and asks a computer algebra system to integrate it. The expression and a successful antiderivative become a pair. This gives the generator a direct route from an input to a labelable problem, at the cost of depending on a successful call during sample creation. BWD starts at the other end. It chooses an expression to serve as an antiderivative and differentiates it to obtain the integrand. Differentiation supplies a known answer even if Maple’s integration methods cannot rediscover it. For this study, the latter case still presents a problem, because a known antiderivative by itself supplies no measurements of the answers Maple’s individual routines will return.

IBP constructs a new pair using integration by parts and an integral already known. In the paper’s notation the identity is written with the integration variable implicit.

∫ f g′ = f g − ∫ f′ g

Here f and g are expressions in the same variable, a prime indicates differentiation with respect to that variable, and ∫ denotes indefinite integration. Adjacent expressions are multiplied. If the integral on the right is already available, the product term and the known integral yield an antiderivative for the integrand on the left. The new input is constructed from the same expressions as the known input, but the derivative now falls on the other factor.

SUB uses a known integral through a change of variable. It creates a composed integrand whose derivative factor enables the substitution.

∫ f(g(x)) g′(x) dx = ∫ f(u) du

The expression f is the function with a known antiderivative, g supplies the inner expression, and x is the original variable. The substituted variable u stands for g(x). The term g′(x) is the derivative of g, dx and du specify the integration variables, and ∫ indicates an indefinite integral on either side. The expression obtained by integrating with respect to u can be put back in terms of x using the substitution. Like IBP, this generator begins with an available integration result and uses a calculus identity to create a related problem.

The RISCH and LIOUVILLE generators make use of the structure of elementary antiderivatives. Liouville’s theorem, as presented in the paper, starts with a differential field and an integrand in that field. A differential field supplies algebraic operations and differentiation. A constant of the field has derivative zero, and the theorem permits coefficients from the algebraic closure of the constant field. If an elementary antiderivative exists over the differential field, the integrand admits the following form.

f = v₀′ + ∑ᵐᵢ₌₁ cᵢ vᵢ′ / vᵢ

Here f is the integrand, v₀ and the indexed vᵢ belong to the differential field, and cᵢ is a constant coefficient from the algebraic closure just described. The index i runs from 1 through m, where m is the number of terms in the sum. The primes indicate derivatives. The division by vᵢ makes each ratio a logarithmic derivative. ∑ adds these terms, including their respective coefficients.

The corresponding elementary antiderivative has the following representative form.

g = v₀ + ∑ᵐᵢ₌₁ cᵢ log(vᵢ)

In this expression g denotes an antiderivative, v₀ is its nonlogarithmic part, and log is the logarithm. The vᵢ, cᵢ, index i and count m refer to the same terms as in the integrand formula. Differentiating the logarithms produces the ratios in that formula. The theorem concerns the form an elementary integral can take when one exists, giving the generators a way to design integrable expressions with structure.

RISCH begins with an expression containing symbolic coefficients and follows steps of the Risch algorithm to find constraints on those coefficients. The generator then assigns values that satisfy the constraints. The symbols used while constructing the problem can thus provide control over the eventual expression while the finished training example has instantiated coefficients. LIOUVILLE uses the parallel Risch algorithm as inspiration. It constructs a space of possible coefficients for a structured expression and uses the form with logarithms to build an integrand and an antiderivative. The paper distinguishes the theoretical basis of the Risch algorithm from the heuristic approach behind parallel Risch.

Extending the generators to special functions

The generated collection includes both elementary expressions and expressions with non-elementary, or special, functions. The elementary vocabulary includes familiar families such as polynomials, rational functions and trigonometric functions. Maple also deals with functions outside that collection. A selector intended to handle such inputs needs examples involving them, yet unrestricted random generation creates a practical problem. Maple often failed to integrate the results when the authors populated random trees with special functions. Compositions of special functions and combinations of unrelated ones were particularly difficult to label.

The authors address this by building smaller expressions and grouping related functions with guidance from Maplesoft. A generated expression draws its special functions from a single group. The groups include families such as Bessel functions, error functions and orthogonal polynomials. Membership can overlap. Within a generation run, restricting the choice makes it possible to produce combinations of related functions without declaring that all special functions belong to mutually exclusive mathematical categories.

For the special-function versions of FWD and BWD, construction begins with a special function applied to valid arguments. A term added to the expression can use a special function from the chosen group or be a randomly generated elementary term. The generator combines the current expression and the added term with a binary arithmetic operator and keeps the resulting expression small. FWD then attempts to integrate it and BWD differentiates it to create a problem. The restrictions make labeling more feasible in both cases. Even when the input to BWD provides an antiderivative by construction, the routine outcomes needed for training still have to come from Maple.

LIOUVILLE requires a different extension. Its construction uses field extensions, which introduce additional expressions over a starting field. In the elementary generator these may involve exponentials, logarithms or tangents. Choosing special functions in the same way can lead to a derivative that introduces other special functions missing from the starting extensions. A differentiated expression would still be integrable by construction, but the generator would lose the intended structure and operate more like BWD. The authors therefore start by differentiating a sampled special function to see which expressions they need to include.

T = [θ₀, …, θₙ], with θ₀ = x

Here T is the ordered list of field extensions used by the generator, θ denotes an entry and its subscript gives its position. The entry θ₀ is the integration variable x. In the adaptation to special functions, θₙ is the sampled function and the entries between the first and last come from differentiating it. The index n identifies the last entry. This arrangement supplies the expressions needed to construct the numerator, denominator and logarithmic terms in the generator.

The appendix describes how LIOUVILLE generates denominator polynomials in the last extension, with coefficients drawn from earlier ones. It factors the denominator to obtain the building blocks for a logarithmic contribution. The numerator is another polynomial in the last extension, with degree bounded by that of the denominator. The generator also creates a collection of logarithmic terms independent of the denominator factors. In the partial fraction branch, the assembled antiderivative has this form.

G = PartialFraction(N / D) + A + B

Here G is the constructed antiderivative, N is the numerator and D is the denominator. PartialFraction expresses the rational part in partial fraction form. A is the logarithmic contribution built using factors of D, and B is the additional group of logarithmic terms. The branch returns the derivative of G as the integrand and G as its known integral. In the other branch the generator normalizes the rational part together with the denominator-related contribution, retaining the additional logarithmic group separately. The choice gives the generator control over how it presents the constructed expressions.

Turning Maple outcomes into labels

Each integrand needs labels that describe the available routines. For a successful method, the authors measure the size of its returned antiderivative. They use Maple’s directed acyclic graph, or DAG, representation as the basis of the measurement. A tree depicts each occurrence of a subexpression as its own branch. A DAG can share the same stored subexpression across multiple uses. In Maple, that sharing makes a result’s stored representation relevant to its compactness even when the printed expression repeats some material.

expr -> length(sprintf("%lm",expr))

In this Maple expression, expr is the returned antiderivative and -> defines a function of that argument. sprintf produces a representation of expr using the format designated by "%lm", which serializes Maple’s DAG. The outer length measures the length of that serialization. Throughout the paper, DAG size refers to this measurement. It favors results that occupy a more compact serialized representation, which often corresponds to a shorter expression and can also reflect the benefits of sharing repeated pieces.

An unsuccessful routine supplies an applicability outcome and no size. Every successful routine supplies both. The smallest size among the successful outputs determines the exact optimum for that input. If several routines achieve the smallest size, they are all optimal under the measurement. The resulting records can support different learning targets. They tell a classifier which routines succeeded, tell another classifier which reached the minimum, and tell a ranker how the successful routines compare. Working through the methods to collect these labels was time-consuming. The trained selector is intended to use the resulting knowledge without repeating the full labeling procedure for a new case.

Preserving symbolic structure in the input

The authors consider several ways of representing an expression. Hand-designed features could describe such things as the number of variables or terms. That kind of summary can be useful in computer algebra tasks for which labeling is expensive and smaller training sets are practical. It also lets a researcher identify the inputs to a decision more readily. Its information is limited to what the feature designer chooses to capture. The experiments here instead compare two representations that retain the operators and operands themselves.

The sequential representation uses prefix notation, placing each operator before its operands. For the sum of a constant and the cosine of the variable, addition comes first, followed by the constant and then the cosine applied to the variable. The arity of an operator or function, meaning how many arguments it takes, determines how the sequence can be read back into an expression. This permits the representation to omit the brackets that would separate terms in ordinary infix notation. The tree represents the same grouping through the links from a parent to its children. Its inner nodes hold operations and functions, while leaves hold variables and constants.

The authors’ tokenization assigns tokens to functions, operators and variables. Integer encoding starts with a sign flag, INT+ or INT-. The magnitude receives a distinct token for 0, 1 or 2. Other single-digit magnitudes are represented by CONST; magnitudes with two digits use CONST2; the remaining magnitudes use CONST3. As a consequence, the range [−2, 2] retains exact values, while many larger coefficients are recorded by category. The authors explain the choice through an exponent example. Raising an expression to the first power and raising it to the negative first power make different integration problems, so retaining those small values can preserve a decisive distinction.

The coarser tokens let training concentrate on recurring structures without splitting them into separate patterns for every literal value. They also make previously distinct integrands identical as inputs to the selector. The authors remove duplicate integrands after the transformation so that identical encodings do not repeatedly enter the dataset. Each input is given a [CLS] token whose final representation can serve as an expression-level summary for classification. The paper draws on the use of that token in BERT. BERT

The tree given to the neural architecture keeps repeated subexpressions as repeated branches. The DAG used to measure the answer is Maple’s representation of an output. They serve different purposes. An input tree exposes how terms are nested so the selector can make a decision. The output DAG supplies the objective by which those decisions are judged. Tree-based selection can therefore be useful even when the smallest answer owes its measured advantage to a sharing pattern in the DAG.

Processing a sequence or a tree

A Long Short-Term Memory network, or LSTM, processes a sequence by passing a state from each position to the next. The state carries forward information about earlier tokens. A forget gate controls how much previous information to retain, an input gate controls what new information to store, and an output gate determines what to pass onward. The design helps a recurrent network preserve information over a long sequence. Each position still depends on the preceding state, so distant parts of a prefix expression interact through a chain of updates, and processing within a sequence follows that dependency.

The TreeLSTM changes where the incoming state comes from. At an operator, it combines the states of that operator’s children. In the sine-of-a-power example, the base and exponent feed the power node. The power node then supplies information to the sine node about the whole argument. A parent can thus build a representation of its subexpression from the representations of the immediate parts. The earlier TreeLSTM work cited by the paper provides the tree-structured architecture that the authors apply to this mathematical input. Tree-Structured Long Short-Term Memory Networks

A Transformer uses attention to let tokens draw on each other’s representations directly. In the sequential variant, a position encoding adds information about where each token appears in the prefix string. The paper describes the standard encoding using sine and cosine values to produce position vectors. Attention can compare pairs of tokens in parallel, and a token near the end of the sequence can attend to one near the beginning. The selection task uses the encoder, which builds representations of the input, because it needs scores for method choices rather than a decoder that constructs an antiderivative token by token. Attention Is All You Need

The Tree Transformer changes the positional information supplied to the encoder. At each depth, a short one-hot vector distinguishes descent to the left child from descent to the right child. A one-hot vector identifies a choice by activating its corresponding entry. The resulting position code records the node’s path, which the paper illustrates as readable from the current node up towards the root. As a consequence, the position of a power inside a sine identifies something about their relationship even if they are far from other relevant tokens in the prefix string. The code allocates a fixed depth. Nodes can occur deeper than that allocation, so the structural position information has a limit.

These are distinct ways of building knowledge of the tree into the computation. The TreeLSTM routes the subexpression states through parent and child links. The Tree Transformer gives each position a description of its place in the tree, which attention can use alongside the token’s identity. The sequential versions provide valuable comparisons because they work from essentially the same symbolic ingredients. A prefix string contains the information needed to reconstruct the tree, while a tree architecture gives the grouping a direct role in how the inputs are processed.

Learning applicability and learning order

The first stage uses binary relevance, training a separate yes-or-no classifier for each method. A positive example for a classifier is an integrand that the corresponding routine successfully integrated during labeling. That meaning is central to the design. A routine can be a reliable way to obtain an antiderivative and routinely miss the smallest answer. It can still be useful to put it ahead of routines that are likely to fail. In the earlier optimality-only formulation, the positive label meant the routine attained the minimum size. The same general classification technique thus answers different questions in the two designs.

The second stage assigns scores to the available methods together. It learns a relative preference using an adaptation of RankNet, a pairwise ranking approach. Take two successful methods for the same input. If the first produces the smaller answer, the ranker is trained to favor it over the second. Repeating such comparisons teaches preferences among methods below the very best as well. The training calculation uses masks to exclude comparisons that cannot establish a strict size preference and weights to give high-ranked methods greater influence. Learning to Rank using Gradient Descent

ℒrank = ∑ᵢ₌₁^|L| ∑ⱼ₌ᵢ₊₁^|L| δᵢⱼ wᵢⱼ ln(1 + e^(pᵢ − pⱼ))

Here ℒrank is the ranking loss. L is the set of integration methods and |L| is the number of methods in that set. The summation indices i and j identify methods in a pair, with the inner sum starting at i + 1. The pair’s mask is δᵢⱼ and its weight is wᵢⱼ. The predictions for the two methods are pᵢ and pⱼ. The function ln is the natural logarithm and e is its base. For a retained pair in the orientation shown in the paper, the loss penalizes a positive difference between the prediction for the better method and the prediction for the worse one. Lower predicted scores therefore express the preferred direction in this formula.

δᵢⱼ = 1 if mᵢ = mⱼ = 1 and yᵢ < yⱼ, otherwise 0

Here δᵢⱼ is the pair mask, mᵢ and mⱼ indicate whether the respective methods produced an answer during labeling, and yᵢ and yⱼ are the recorded ranks. A lower recorded rank is better. A value of 1 includes the comparison when both answers exist and the first rank is strictly better. A value of 0 removes the comparison otherwise. In particular, an unsuccessful method has no observed size to compare, and a tie supplies no strict preference for this term.

wᵢⱼ = 1 / log₂((yᵢ + yⱼ) / 2 + 2)

Here wᵢⱼ is the weight for the methods indexed by i and j, and yᵢ and yⱼ are the same observed ranks. log₂ is the logarithm to base 2. The ranks enter through their average, with the offset shown inside the logarithm. Better ranks make the denominator smaller and the comparison more influential. The authors adapt the weighting idea from the discount used in normalized discounted cumulative gain. The priority is useful for an integrator that acts first on the top of the ranking, where an error can change the answer immediately.

The true success masks in the loss come from running the integration routines during labeling. The predicted success flags used when ordering methods are outputs of the applicability classifiers. Keeping these roles distinct explains why the first stage can make a mistake even when the ranker learned the relevant preference. A routine that has a favorable score may be given low priority because the separate classifier doubts it will apply. Conversely, a method can have a favorable score even when the training loss offers little direct evidence about how to score it on inputs where it fails. The applicability stage supplies that part of the call decision.

The authors make the code and data underpinning the experiments available through a Zenodo record. They also identify their GitHub repository, Ranking_Symbolic_Int_Methods, as the place for updates associated with preparing the work for Maple.

Experiments and results

How the test sets differ

The training collection has 1,000,000 examples, drawn evenly from the six generators. The generated hold-out collection contains 70,000 examples. Its elementary portion has 50,000 expressions from the full set of generators, and its non-elementary portion has 20,000 expressions produced by FWD, BWD and LIOUVILLE. Evaluating on the hold-out set asks whether the learned selection rules work on separate examples from broadly the same sources as training. The elementary and non-elementary groups allow a further comparison within that test.

The Maple Test Suite supplies an independent evaluation. Maplesoft built it for checking the integration procedure, drawing on unit tests, user queries and bug reports. The authors used it for testing, with separate preparation to bring the inputs into the training vocabulary and notation. After filtering, the suite contains 13,040 examples, of which 2,980 contain non-elementary functions. Its origin makes it a different test of generalization from drawing another set of inputs from the data generators.

The authors retain expressions whose functions are in the training vocabulary, substitute x for a differently named integration variable, and handle symbolic coefficients through constant categories. The generated training expressions have no symbolic coefficients. On the Maple suite, the authors generally use CONST3 for such coefficients, following Maplesoft’s expectation that a large integer parameter value can yield an answer of similar shape. Where this treatment creates a division by 0, they vary the substitution between CONST2 and CONST3. This preparation lets the learned system receive the independent cases in a familiar input format. The underlying reliance on symbolic coefficients in the collected problems remains relevant to interpreting the results.

What counts as a correct choice

The comparisons include the sequential LSTM, TreeLSTM, sequential Transformer and Tree Transformer. Each is tested under optimality-only binary classification and under applicability classification followed by ranking. Maple’s own selector is the software baseline. The paper also evaluates the intermediate approach of classifying applicability and then predicting sizes, and separately checks what happens when a ranker is used without the applicability stage.

An exact match means that the selection yields an antiderivative with the minimum measured DAG size available for that integrand. The comparison concerns the size of the result, so routines that tie at the minimum can all supply an exact match. The paper also reports counts of inputs on which the result is within 5% or 10% of the optimum. In these measures the percentage threshold is about the size of an individual result. The reported accuracy is about the share of inputs meeting that threshold. A selector can therefore gain substantially under the relaxed measure if many of its errors return only slightly larger answers.

A further measure is the number of routine calls before the integrator obtains an answer. That counts attempts irrespective of the size of the antiderivative eventually produced. It captures a different consequence of ordering methods. A selector can make several unsuccessful calls and finally return the smallest answer. It can also find an acceptable answer immediately, with the possibility that another method would have produced a more compact one. The main results focus on size, while the comparison that removes the applicability stage examines both selection accuracy and attempts.

From generated tests to the independent suite

In the binary classification comparison, the learned approaches performed well on the generated hold-out set and deteriorated on the independent suite. On that suite, only the tree versions exceeded the existing Maple selector, and the margin amounted to a small number of problems. Allowing near-optimal answers added relatively little to the binary classifiers’ results. These classifiers received an optimality target, which gives them a reason to identify minima but provides no direct training incentive to put a method producing a small near miss ahead of a method producing a much larger result.

The two-stage approach produced stronger results on the hold-out collection. The Tree Transformer selected a minimum-size answer almost 90% of the time across the generated hold-out set. Its exact-match accuracy on the independent Maple Test Suite was 73%. The gap between the tests is evidence that the independent cases remain harder for the selector. At the same time, the paper reports a substantially larger advantage over the existing Maple selector on that independent set than it found with binary classification.

The independent test also shows how the ranking framework changes the frequency of near misses. The results discussion describes the Tree Transformer as reaching 80% on the Maple Test Suite when allowing answers within 10% of the optimum, and reports an advantage of 17.3 points over the existing selector under that measure. The conclusion gives the within-10% accuracy as 80.4%. This result indicates how often the chosen answer falls inside the stated tolerance. It gives no account of the size of errors beyond that tolerance, which can still cover a wide range of results.

Elementary and non-elementary cases

The generated hold-out results show that mathematical difficulty and selection difficulty can move in different directions. For the Tree Transformer, exact selection was more accurate on the non-elementary portion than on the elementary portion. In the paper’s explanation, the methods available for a given non-elementary expression tend to be fewer. Maple still has to integrate the expression, but the selector may face fewer plausible successful candidates whose answers it must distinguish.

Two-stage Tree Transformer exact-match accuracy on the generated hold-out set

The selector reaches the minimum output size more often on the non-elementary portion.

Two-stage Tree Transformer exact-match accuracy on the generated hold-out setElementary expressions: 88.1Elementary expressions88.1Non-elementary expressions (this paper): 92.7Non-elementary expressions (this paper)92.7
The numbers
System or settingExact-match accuracy %
Elementary expressions88.1
Non-elementary expressions (this paper)92.7

The average number of applicable methods on an elementary example is 2.9, compared with 1.7 on a non-elementary example. The authors offer this contrast as an explanation for the accuracy pattern. With fewer competing successful methods, a prediction can more often put a minimum-size answer first. The comparison does not isolate the number of applicable methods from every other difference between the groups. In particular, the non-elementary portion has a narrower set of source generators, and the construction of its inputs was adapted so Maple could label enough of them.

What smaller answers look like

The paper includes selected Maple Test Suite examples to show what the size measure captures. For a logarithm of the sum of a fourth power and a constant, divided by the integration variable, the answer chosen by the tree-based selector uses a compact polylogarithm expression. Maple’s existing choice uses dilogarithms in a much longer expression that also introduces irrational and complex numbers. The answers represent equivalent antiderivatives. The example shows how the choice of integration route can affect the functions and constants that appear, in addition to the length of the resulting expression.

Another example starts from the square of an Airy function. The selected result can be written using Airy functions, while the existing selector returns a larger expression involving other special functions. These examples illustrate outcomes a reader might notice directly. The authors also chose a case in which visible length and measured DAG size disagree. The expression chosen by the Tree Transformer looks slightly longer, yet the same subexpression appears repeatedly and can be shared in Maple’s storage. That is enough to give it the smaller serialized representation.

One of the paper’s examples does admit a straightforward simplification from Maple’s answer to the compact result. The authors observe that the same approach would not recover the other selected answers in their table. Applying a simplifier to the eventual output addresses a related problem, but the expressions a simplifier receives depend on the integration path that led to them. Here, some favorable representations are obtained by choosing a different routine at the start. The examples show how that mechanism can work. Their selection by the authors makes them illustrations of possible outcomes, with the full test results supplying the evidence about frequency.

What the ablations show

What changes when the input structure changes

The comparisons between sequential and tree architectures hold the selection task fixed within each framework. In the figures for optimality classification and for the two-stage approach, the tree version consistently outperforms its sequential counterpart. This holds across the generated and independent evaluations reported in those figures. The advantage is described as modest for the Transformer pair and larger for the LSTM pair. In this task, explicitly supplying hierarchy makes a difference even when the alternative encoding is a prefix sequence from which the hierarchy can be recovered.

The pattern has a plausible architectural interpretation. A sequential LSTM moves information through tokens in order, while its tree counterpart delivers the parts of a subexpression directly to their parent. A sequential Transformer already has attention between distant positions. Giving it tree positions adds explicit structural information, while access to distant tokens is already present in the sequence version. The paper establishes the performance pattern with the comparisons. It leaves the reason for the different size of the gains open, since it does not trace individual predictions through the recurrent states or attention weights.

The comparison also helps locate what the structure contributes relative to the training target. The tree advantage appears with optimality classification alone. Moving to ranking then improves what the tree architectures can achieve, particularly on the independent set. A tree gives the predictor a more direct representation of the integrand. Ranking changes the information in the supervision. The strongest reported result uses both changes, and their effects can be understood separately through the comparisons within and across the frameworks.

What changes when the training target changes

The regression experiment is an intermediate comparison between classifying a winner and learning an order. The authors first considered predicting an absolute DAG size per method. A failed integration has no size to use as a target. Assigning it a small imputed size encouraged selection of the failed routine, while assigning a large one pushed in the opposite direction. Using the average as a compromise still left poor predictions on examples with imputed values. This result motivated putting the success decision in its own stage.

The two-stage regression variant uses applicability classification followed by a separate size predictor for each method. It compares predicted sizes among methods that pass the first stage. If none of those methods works, the authors describe a fallback that tries all methods through the second stage. The TreeLSTM and both Transformer variants surpass the Maple selector on the hold-out set in this comparison, and the paper reports improvements on the independent suite as well. The result shows that it helps to make distinctions that optimality-only labels discard, even when the second stage learns sizes instead of pairwise preferences.

The appendix gives a hypothetical example of why that improvement can still leave room for ranking. Two predictors assign the same size to the second method and make equal-sized errors in opposite directions on the first. One error changes the predicted order and the other preserves it. The paper’s two mean squared error calculations make the symmetry explicit.

((10 − 14)² + (13 − 13)²) / 2 = 8

In this illustration 10 and 13 are the true sizes for the first and second methods. The predictor assigns them 14 and 13, respectively. The superscript ² squares each error and division by 2 averages the pair. The mean squared error is 8, and the predicted sizes place the second method ahead of the first.

((10 − 6)² + (13 − 13)²) / 2 = 8

The true sizes are again 10 and 13. This predictor assigns 6 to the first method and 13 to the second. The squared differences, averaged by dividing by 2, again yield 8. The predicted order now agrees with the true order. The example is about the decision implied by the errors. A loss that depends on their squared magnitudes assigns the same value to these cases, while a loss trained on the pairwise preference distinguishes the useful ordering from the reversed one.

These experiments clarify why going from classification to size prediction helps, and why going from size prediction to ranking can help further. A predicted size gives a basis for sorting all the successful candidates. A ranking loss can supervise that order directly and concentrate on errors near the top. The paper’s target remains ordinal even when the consequence of getting a pair wrong is a substantial change in absolute size.

What the applicability stage buys

To isolate the applicability stage, the authors apply ranking alone and classification followed by ranking to the 50,000 elementary hold-out examples. The question in this comparison is how many routines have to be attempted before an answer appears. They restrict it to elementary cases, explaining that non-elementary examples tend to have fewer applicable methods. This makes the result specific to the elementary split even though the main evaluation includes both kinds of expression.

The combined selector used 57, 411 calls over the elementary split, compared with 93, 845 calls for ranking alone. The paper describes the ranking-only count as 63.5% more calls than the two-stage count. It also reports that the two-stage approach found an applicable method on its first attempt 43.8% more often. The applicability classifiers help because a ranking loss over observed sizes lacks size comparisons for methods that fail. By putting likely successes first, the classifiers keep some of those unsuccessful calls from occurring before the returned answer.

Exact-match accuracy with and without applicability classification on the elementary hold-out split

Ranking alone selects a minimum-size answer more often in the applicability-stage comparison.

Exact-match accuracy with and without applicability classification on the elementary hold-out splitRanking alone (this paper): 89.6Ranking alone (this paper)89.6Applicability classification and ranking: 87.8Applicability classification and ranking87.8
The numbers
System or settingExact-match accuracy %
Ranking alone (this paper)89.6
Applicability classification and ranking87.8

The exact-match result in this comparison favors ranking alone. With a ranker by itself, the integrator may try a method that fails, then reach the routine with the smallest answer. With applicability classification, that optimal routine can be assigned low priority along with the failures. A different method may then produce an answer before the optimal one is attempted. The paper illustrates this mechanism with a hypothetical ordering and reports it among its actual examples. The 87.8% for the combined approach is the figure cited in this specific comparison. The 88.1% reported in the main results is the figure given for the elementary portion in the comparison with non-elementary expressions.

The finding gives the authors a basis for retaining the first stage in the proposed framework. It is a choice between the number of attempts and the probability of obtaining the smallest measured result. The evidence is about how frequently routines are tried, with the accuracy figures describing the associated change in outputs. A routine’s cost can vary from one input to another, so the call counts have a direct meaning even where the effect on elapsed time has yet to be measured.

Where the Tree Transformer makes mistakes

The paper examines incorrect selections on the Maple Test Suite through a confusion matrix. A prominent pattern is overprediction of default among the errors. This is a general-purpose method that appears frequently among successful routines. The authors suggest that its broad applicability makes the cases in which it is genuinely optimal harder to characterize. A selector can learn to expect a useful result from default, while the smaller class of inputs on which it gives the best result requires a more discriminating prediction.

The distribution of mistakes differs by the true optimal method. The paper identifies risch and parallelrisch as often misclassified true labels, in keeping with their frequent optimality in the data. Many mistakes for risch go to default. Mistakes for parallelrisch are spread more widely across methods. There is also an asymmetry between the two related routines. The analysis reports that the selector often substitutes parallelrisch for risch, with the reverse confusion much less characteristic. The authors suggest a greater penalty for an incorrect prediction of default, leaving its effect to be assessed experimentally.

Among misclassified Maple Test Suite examples, 57% had symbolic coefficients. This is a share of errors, rather than an error rate measured over all examples with such coefficients. It identifies a substantial part of the errors as cases involving a type of input missing from training. Testing whether symbolic coefficients cause a disproportionate share of failures would also require the rate at which those cases occur in the evaluation set and how frequently the selector succeeds on them. The authors use the observation to motivate generation of training examples that retain symbolic coefficients.

The analysis also asks how bad an incorrect selection tends to be. Among misclassified examples on the Maple Test Suite, 26.5% were assigned the method with the largest DAG size. Among those worst-choice errors, 67.5% occurred where only two methods were available to choose between. In such cases the successful outcomes supply no intermediate option, so missing the best also means selecting the worst. With more successful choices, a ranker can miss the optimum and still return one of the alternatives between the extremes. Hand-picked errors illustrate that possibility, while the reported percentages place it in the context of the full set of incorrect choices.

Limitations

Limits identified by the authors

The authors emphasize that generalization remains incomplete. Performance falls when the evaluation moves from a generated hold-out set to Maple’s independent suite, even with the strongest architecture and training formulation tested. Their comparison with the existing selector supports an improvement on that independent suite. There are still cases from a source as closely related as Maple’s own integration tests on which the learned call order misses the best answer. Understanding those cases is a remaining problem in the authors’ account.

The authors also acknowledge that their compactness objective and printed expression length can disagree. A repeated expression can be stored once while appearing multiple times when displayed. The Airy and logarithm examples show that a smaller DAG can coincide with a more approachable answer, while another example shows that a result can look longer and still meet the metric better. The preference learned by the system is for the particular measure used to label its training examples. A reader who values keeping the answer elementary, avoiding complex constants or preserving a recognizable mathematical form may rank some of the outputs differently.

The choice of an applicability stage has a cost the authors explicitly accept for this application. Giving likely successes priority reduces calls before the first answer, but an inaccurate applicability prediction can delay the true best routine until the search has already found a result. The authors present the choice as dependent on the application. A setting in which calls are cheap could value the additional exact matches from ranking alone. A setting in which a failed call can run a long time could give greater weight to the applicability predictions.

Finally, the authors distinguish their results from proposed applications. Ranking integration methods by expected runtime is a possible change of target. Applying the approach to the choice of resultant algorithms is another possibility they raise. Their future work also discusses examining attention and embeddings in direct symbolic integration and trying alternative ways to represent position or local relationships in trees. These proposals follow from the design and comparisons. The reported experiments concern Maple’s choice of method under the DAG-size criterion.

Limits of the comparisons

Optimality is relative to the answers produced by the available methods in the labeling exercise. The exact-match rate measures whether the selected routine attains the smallest observed serialized size. Certifying that an expression is the smallest among every mathematically equivalent antiderivative would be a different task. A more compact expression might be obtainable using an algorithm outside the portfolio or a transformation that none of the tested routines applied. Conversely, ties between answers with different mathematical forms can be indistinguishable under the chosen objective.

The independent suite offers a stronger change of distribution than the generated hold-out set, within a defined input boundary. The vocabulary filter removes cases that the trained selector cannot encode as designed. Converting variable names brings the syntax into alignment with training. Encoding symbolic coefficients as constant categories gives the predictor a usable representation but discards distinctions between parameters and certain relationships among them. The resulting results characterize generalization on the prepared test suite. A full evaluation of unfamiliar functions and parameter-sensitive cases would require evidence on inputs beyond those admitted by that preparation.

The special-function experiments also depend on labelability. The generators use related function groups and small constructions because unrestricted expressions frequently cannot be integrated by Maple. BWD can give the researchers a known answer even when the tested routines cannot reproduce it, and such a case still does not provide the per-routine sizes needed by the ranker. Accordingly, higher exact selection accuracy on the generated non-elementary group describes the sampled Maple-labelable cases. It cannot establish that special-function integrals in general pose an easier selection problem.

Calls before the first answer are a partial measure of computational cost. Different calls can take different amounts of time, and the classifications and ranking also require computation. The paper contrasts the number of attempts on the elementary split and discusses the time a failed method can consume. Computing an end-to-end speed gain would require timing those calls and the selector as parts of the same procedure. Such a measurement would also help distinguish savings from avoiding costly failures from savings on cases where the skipped calls would have ended quickly.

The paper’s architecture comparisons show an advantage for the tested tree variants. They leave room for further analysis of where that advantage comes from. The TreeLSTM changes the routes by which states are composed, and the Tree Transformer changes position information. Within each family those choices make hierarchy explicit in different ways. The results do not isolate the effect of tree depth or tell which operators benefit most from the change. The fixed depth of the tree position encoding gives a concrete reason to ask how the gains vary with the shape of the expression. The paper proposes inspection of tree embeddings and attention as future work.

The examples involving symbolic coefficients point to a candidate explanation of errors, and the confusion matrix points to ways that particular methods are over- or underselected. Neither analysis is an intervention on the training data or the loss. A comparison with a training collection that includes symbolic coefficients could test one proposed explanation. An experiment changing the penalty for an erroneous default prediction could test another. The paper establishes the error patterns and leaves the effects of those changes open.

What came after

There are no identified follow-up studies to describe. The paper closes with prospective work on tree representations, direct symbolic integration and other choices among computer algebra algorithms.

Cite

Cite as Rashid Barket, Matthew England and Jürgen Gerhard. 2025. Tree-Based Deep Learning for Ranking Symbolic Integration Algorithms. arXiv:2508.06383.

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.48550/arxiv.2508.06383 · arXiv 2508.06383

@misc{barket2025tree,
  title = {{Tree-Based Deep Learning for Ranking Symbolic Integration Algorithms}},
  author = {Rashid Barket, Matthew England and Jürgen Gerhard},
  year = {2025},
  doi = {10.48550/arxiv.2508.06383},
  eprint = {2508.06383},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.48550/arxiv.2508.06383}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/barket-2025-tree-based-deep-learning-ranking/