The Computational Complexity of Finding Arithmetic Expressions With and Without Parentheses
š” Research Summary
The paper investigates the computational complexity of constructing arithmetic expression trees under two new constraints: (1) Enforced Parentheses (AECāEP), where the exact tree structure (i.e., a full parenthesization) is given in advance, and (2) No Parentheses (AECāNP), where expressions must be written without any parentheses and are evaluated according to the standard precedence rules (multiplication and division before addition and subtraction).
The classic problem, called Arithmetic Expression Construction (AECāStd), asks whether a multiset of input numbersāÆA and a target valueāÆt can be combined using any subset of the four basic operators {+, ā, Ć, Ć·} (each input used exactly once) to obtain t. Prior work by Lynch & Wong (2020) gave NPācompleteness results for many operator subsets. This paper extends that line of work by analyzing how the additional structural constraints affect complexity.
A comprehensive table (TableāÆ1) lists the complexity classification for all 16 nonāempty subsets of {+, ā, Ć, Ć·} under both AECāEP and AECāNP. The main findings are:
- Singleāoperator sets {+} and {Ć} are solvable in polynomial time for both variants.
- The singleāoperator set {ā} is polynomial for AECāNP (no parentheses) but only weakly NPācomplete for AECāEP (parentheses forced).
- The singleāoperator set {Ć·} is strongly NPācomplete for both variants, reflecting the fact that division can generate arbitrarily large intermediate values independent of the input size.
- All twoāoperator combinations except {Ć, Ć·} are weakly NPācomplete for both variants; {Ć, Ć·} remains strongly NPācomplete.
- Any threeāoperator or the full fourāoperator set is weakly NPācomplete for both variants.
The authors prove these results using the Rational Function Framework introduced by Leo et al. (2020). This framework translates integer instances into rational functions (polynomials with variables x, y, etc.) so that the effect of each allowed operator can be captured by algebraic manipulation of degrees and coefficients. By constructing appropriate polynomial representations of classic NPācomplete problemsāmost notably Product Partition (productāpartitionān/2), 3āPartition, and a variant involving divisionāthe paper shows polynomialātime reductions to the AECāEP and AECāNP problems.
For example, to prove that AECāNP with the operator set {+, Ć·, ā} is weakly NPāhard, the authors start from a productāpartitionān/2 instance A = {aā,ā¦,aā}. Each aįµ¢ is turned into a term aᵢ·x, and two auxiliary monomials y^{n/2} and y^{n/2ā1} are added. The target value is set to t = 2Ā·x^{n/2}Ā·āaįµ¢. Because multiplication and division are evaluated before addition, any feasible expression must consist of exactly one addition of two large products; this forces a partition of the original numbers into two equalāsize subsets whose products are equal, i.e., a solution to the original productāpartition problem. The same construction works when the tree shape D is prescribed (AECāEP), showing that the forcedāparentheses variant does not lower the difficulty.
Reductions for other operator subsets follow a similar pattern: the authors encode the required arithmetic structure into the degrees of x and y, ensuring that the only way to achieve the target polynomial is to mimic the solution of the source NPācomplete problem. When subtraction is allowed, the reductions are adapted to guarantee that the subtraction terms cancel only in the intended configuration, leading to weak NPāhardness.
The distinction between strong and weak NPācompleteness is highlighted throughout. Strong NPācompleteness appears only when division is present (single {Ć·} or the pair {Ć, Ć·}). In these cases, the size of intermediate numbers can grow exponentially relative to the input encoding, so the hardness persists even if the numeric values are bounded by a polynomial in the input length. All other operator sets are only weakly NPācomplete; their hardness stems from a reduction to a subsetāsumālike problem, which becomes tractable if the numeric values are small (pseudoāpolynomial algorithms exist).
The paperās contributions are threefold:
- Problem Extension ā It formally defines two realistic variants of arithmetic expression construction that correspond to practical scenarios (fixed parenthesization in code generation, or flat expressions as used in many programming languages).
- Comprehensive Complexity Map ā By completing the classification for every nonāempty operator subset, it provides a clear guide for researchers and practitioners about which combinations admit polynomialātime algorithms and which are intractable.
- Methodological Innovation ā It demonstrates the power of the rationalāfunction reduction technique, showing that many seemingly different arithmetic constraints can be captured within a unified algebraic framework.
The results have immediate relevance to fields such as automated math problem solving, neuralānetworkābased expression generation, and educational puzzle design (e.g., the ā24 gameā). They indicate that, except for trivial singleāoperator cases, any algorithm that must guarantee exact solutions will inevitably face NPāhardness, motivating the use of heuristics, approximation, or restriction to special numeric domains.
In conclusion, the paper establishes that both enforcedāparentheses and noāparentheses variants of arithmetic expression construction are generally NPācomplete, with division being the key operator that elevates the difficulty to strong NPācompleteness. The work deepens our theoretical understanding of arithmetic expression synthesis and sets the stage for future investigations into parameterized algorithms, approximation schemes, and integration with machineālearning models.
Comments & Academic Discussion
Loading comments...
Leave a Comment