Arithmetic Expression Construction
Leo Alcock, Sualeh Asif, Jeffrey Bosboom, Josh Brunner, Charlotte Chen, Erik D. Demaine, Rogers Epstein, Adam Hesterberg, Lior Hirschfeld, William Hu, Jayson Lynch, Sarah Scheffler, Lillian Zhang
aa r X i v : . [ c s . CC ] N ov Arithmetic Expression Construction
Leo Alcock ∗ Sualeh Asif † Jeffrey Bosboom ‡ Josh Brunner ‡ Charlotte Chen † Erik D. Demaine ‡ Rogers Epstein ‡ Adam Hesterberg ∗ Lior Hirschfeld † William Hu † Jayson Lynch ‡ Sarah Scheffler § Lillian Zhang † Abstract
When can n given numbers be combined using arithmetic operators from a given subset of { + , − , × , ÷} to obtain a given target number? We study three variations of this problem of Arithmetic Expression Construction : when the expression (1) is unconstrained; (2) has a speci-fied pattern of parentheses and operators (and only the numbers need to be assigned to blanks);or (3) must match a specified ordering of the numbers (but the operators and parenthesizationare free). For each of these variants, and many of the subsets of { + , − , × , ÷} , we prove theproblem NP-complete, sometimes in the weak sense and sometimes in the strong sense. Mostof these proofs make use of a rational function framework which proves equivalence of theseproblems for values in rational functions with values in positive integers. Algebraic complexity theory [AB09, vzG88] is broadly interested in the smallest or fastest arithmeticcircuit to compute a desired (multivariate) polynomial. An arithmetic circuit is a directed acyclicgraph where each source node represents an input and every other node is an arithmetic operation,typically among { + , − , × , ÷} , applied to the values of its incoming edges, and one sink vertexrepresents the output. One of the earliest papers on this topic is Scholz’s 1937 study of minimaladdition chains [Sch37], which is equivalent to finding the smallest circuit with operation + thatoutputs a target value t . Scholz was motivated by efficient algorithms for computing x n mod N .Minimal addition chains have been well-studied since; in particular, the problem is NP-complete[DLS81].Algebraic computation models serve as a more restrictive model of computation, making it easierto prove lower bounds. In cryptography, a common model is to limit computations to a group orring [Mau05]. For example, Shoup [Sho97] proves an exponential lower bound for discrete logarithmin the generic group model, and Aggarwal and Maurer [AM09] prove that RSA is equivalent tofactoring in the generic ring model. Minimal addition chains is the same problem as minimal groupexponentiation in generic groups, and thus the problem has received a lot of attention in algorithmdesign [Gor98].In our paper, we study a new, seemingly simpler type of problem, where the goal is to designan expression instead of a circuit , i.e., a tree instead of a directed acyclic graph . Specifically, themain Arithmetic Expression Construction (AEC) problem is as follows: ∗ Harvard University, Cambridge, MA, USA † MIT, Cambridge, MA, USA ‡ MIT CSAIL, Cambridge, MA, USA § Boston University, Boston, MA, USA roblem 1 (( L , ops ) -AEC-Std / Standard) .Instance: A multiset of values A = { a , a , . . . , a n } ⊆ L and a target value t ∈ L . Question:
Does there exist a parenthesized expression using any of the operations in ops that contains each element of A exactly once and evaluates to t ?The problem ( N , { + , − , × , ÷} ) -AEC-Std naturally generalizes two games played by humans.The 24 Game [Wik] is a card game dating back to the 1960s, where players race to construct anarithmetic expression using four cards with values 1–9 (a standard deck without face cards) thatevaluates to 24. In the tabletop role-playing game Pathfinder, the Sacred Geometry feat requiresconstructing an arithmetic expression using dice rolls that evaluate to one of a specified set of primeconstants.In this paper, we prove that this problem is NP-hard when the input values are in N or thealgebraic extension N [ x , . . . , x k ]. Expressions can be represented as trees with all operands at leaf nodes and operators at internalnodes using Dijkstra’s shunting yard algorithm [Dij61]. Similarly, an expression tree can be con-verted into a parenthesized expression by concatenating the operands and operators as they areencountered with an inorder traversal, adding an opening parenthesis when descending the treeand a closing parenthesis when ascending. + × ÷ −
23 1Figure 1: An example expression tree for 7 ×
11 + (4 ÷ (3 − D ) on the expression trees: Problem 2 (( L , ops ) -AEC-EL / Enforced Leaves) .Instance: A target value t ∈ L and a multiset of values A = { a , . . . , a n } ⊆ L with theleaf order encoded by D : A → [ n ]. Question:
Can an expression tree be formed such that each internal node has anoperation from ops , and the leaves of the tree are the list A in order D , where the treeevaluates to t ? Problem 3 (( L , ops ) -AEC-EO / Enforced Operations) . To clarify the notation: all values are in the field extension Q ( x , . . . , x k ), but the input values are restricted to N [ x , . . . , x k ], i.e., have nonnegative integer coefficients. nstance: A multiset of values A = { a , a , . . . , a n } ⊆ L , a target t ∈ L , and anexpression tree D with internal nodes each containing an operation from ops and emptyleaf nodes. Question:
Can the expression tree be completed by assigning each value in A to exactlyone leaf node such that the tree evaluates to t ?The first variant fixes the ordering of leaf nodes of the tree, and asks whether an expression canbe formed which reaches the target. The second variant constrains the shape of the tree and internalnode operations, and asks whether an ordering of the leaves can be found which evaluates to thetarget. We represent all instances of these variants by triples ( A, t, D ) where A = { a , a , . . . a n } isa multiset of values, t is the target value, and D is additional data for the instance: a leaf orderingfor EL, and an expression tree for EO.In this paper, we prove hardness results in all of these variants by reduction from Partition andrelated problems listed in Appendix A, and develop polynomial or pseudopolynomial algorithmswhere appropriate. Table 1 summarizes our results. In particular, we prove NP-hardness with L = N for the Standard and EO variants for all subsets of operations { + , − , × , ÷} . Note that allof these problems are in NP: simply evaluate the expression given as a certificate. Operations Standard Enforced Operations Enforced Leaves { + } ∈ P ( § ∈ P ( § ∈ P ( § {−} weakly NP-complete ( § weakly NP-complete ( § weakly NP-complete ( § {×} ∈ P ( § ∈ P ( § ∈ P ( § {÷} strongly NP-complete ( § strongly NP-complete ( § strongly NP-complete ( § { + , −} weakly NP-complete ( § weakly NP-complete ( § weakly NP-complete ( § { + , ×} weakly NP-complete ( §
3) weakly NP-complete a ( § weakly NP-complete ( § { + , ÷} weakly NP-complete ( § strongly NP-complete ( § {− , ×} weakly NP-complete ( § strongly NP-complete ( § § {− , ÷} weakly NP-complete ( § strongly NP-complete ( § {× , ÷} strongly NP-complete ( § strongly NP-complete ( § strongly NP-complete ( § { + , − , ×} weakly NP-complete ( § strongly NP-complete ( § § { + , − , ÷} weakly NP-complete ( § strongly NP-complete ( § { + , × , ÷} weakly NP-complete ( § strongly NP-complete ( § § {− , × , ÷} weakly NP-complete ( § strongly NP-complete ( § { + , − , × , ÷} weakly NP-complete ( § strongly NP-complete ( § Table 1: Our results for Arithmetic Expression Construction. Bold font indicates NP-completenessresults that are tight; for weakly NP-complete results, this means that we have a correspondingpseudopolynomial-time algorithm. The proof is given in the section in parentheses. a Strong in all variables except the target t Our first step is to show that, for any k and k ′ , there is a polynomial-time reduction from the k -variable variant to the k ′ -variable variant. Such a reduction is trivial for k ≤ k ′ by leaving theinstance unchanged. For the converse, we present the Rational Function Framework in Section 2,which provides a polynomial-time construction of a positive integer B on an instance I (i.e., set ofvalues { a i } , t ∈ N [ x , . . . , x k ]) such that replacing x k = B yields a solvable instance if and only if I is solvable. That is, for all variants var ∈ { Std , EO , EL } , we obtain a simple reduction( N [ x , . . . , x k ] , ops ) -AEC- var → ( N [ x , . . . , x k − ] , ops ) -AEC- var Because this reduction preserves algebraic properties, it yields interesting positive results in additionto hardness results. For example, this result demonstrates that ( N [ x , . . . , x k ] , { + , −} ) -AEC-Std N , { + , −} ) -AEC-Std whichis equivalent to the classic Partition problem.
Beyond the I = ( A, t, D ) instance notation introduced above, we often use the variable E to denotean expression; the Standard variant is to decide whether ∃ E : E ( A ) = t . We also use “ev( · )” todenote the value of an expression at a node of an expression tree (i.e., the evaluation of the subtreewhose root is that node). In Section 2, we describe the Rational Function Framework which demonstrates equivalence betweenAEC variants over different numbers of free variables. In Section 3, we present the structuretheorem which will be used to prove hardness of the nontrivial cases of Standard and we presenta proof of the full case with it. In Section 4, we use two similar reductions to cover all remainingnontrivial cases of Standard. In Section 5, we present the nontrivial proofs for the Enforced Leavesvariant. In Section 6.4, we prove an interesting reduction for Enforced Operations. In Section 6,we present the remainder of our hardness proofs, which more straightforward and do not use therational framework, along with pseudopolynomial algorithms for some weakly NP-hard problems.Appendix A lists the problems we reduce from for our hardness proofs.
In this section, we present the rational function framework. This framework proves the polynomial-time equivalence of all Arithmetic Expression Construction variants with values as ratios of poly-nomials with integer coefficients, that is, Q ( x , . . . , x k ), for differing k . This equivalence also allowsus to restrict to N [ x , . . . , x k ] and critically will make proving hardness for variants over N easierby allowing us to reduce to N [ x , . . . , x k ] versions. Theorem 2.1.
For all ops ⊆ { + , − , × , ÷} , for all variants var , for all integers k > , there existsan efficient algorithm A mapping instances I to positive integers A ( I ) such that a polynomial-timereduction ( Q ( x , . . . , x k ) , ops ) -AEC- var → ( Q ( x , . . . , x k − ) , ops ) -AEC- var is given by substituting x k = B in an instance I for any B ∈ N satisfying B ≥ A ( I ) . To formalize the idea of a “big enough” B , we introduce the concept of sufficiency of integers forinstances of AEC. Let B be a positive integer and let I be a ( Q ( x , . . . , x k ) , ops ) -AEC- var instance.Loosely, we consider B to be ( I, ops , var ) -sufficient if substituting x k = B in instance I creates avalid reduction on I , as in Theorem 2.1.We will shorten the terminology and call this I -sufficient or sufficient for I when ops and var are clear from context. Theorem 2.1 says there is an efficient algorithm that produces sufficientintegers. Note that this definition is not yet rigorous. To remedy this we introduce the pairedmodel of computation on rational functions.In the paired model of computation, objects are given by pairs ( f, g ) of integer-coefficientpolynomials f, g ∈ Z [ x , . . . , x k ]. Intuitively, the paired model simulates rational functions by( f, g ) ↔ f /g . We define operations (+ , − , × , ÷ ) and equivalence relation ( ∼ ) on pairs ( a, b ) and4 f, g ) as follows: ( f, g ) + ( a, b ) = ( f b + ga, gb )( f, g ) − ( a, b ) = ( f b − ga, gb )( f, g ) × ( a, b ) = ( f a, gb )( f, g ) ÷ ( a, b ) = ( f b, ga )( f, g ) ∼ ( a, b ) ⇔ f b = ga As mentioned, the intuition is that f is the numerator and g is the denominator of a ratio ofpolynomials with integer coefficients. The utility of the model is that it keeps track of rationalfunctions as specific quotients of integer coefficient polynomials. This will remove the ambiguityof representation of elements in Q ( x , . . . , x n ). Such a model allows us to make arguments aboutwhich polynomials can occur in the numerator and denominator of a rational function, such as bydefining the range of these polynomials, as in the proof in Section 5.4.We can define Arithmetic Expression Construction in the paired model for all variants bychanging target and values into pairs and using all the operations as defined above. An instance inthe paired model is solvable if there exists a valid expression E in values from A and such that given( f, g ) = E ( A ), we have ( f, g ) ∼ ( f t , g t ) = t . We add restrictions on the solution in an additionalvariable, D . For example, in enforced leaves, the entries of leaves of E must be in the order specifiedby D , and in enforced order, the expression E is already specified and one must reorder A . Theonly difference is that we now compute in the paired model rather than with rational functions.Similarly, note that one can convert instances in the paired model to the nonpaired model viamapping entries ( f i , g i ) f i /g i and for a nonpaired model, one can always write r ∈ Q ( x , . . . , x k )as f i /g i where f i , g i have integer coefficients. A paired instance of AEC is solvable if and only if it’snonpaired variant is solvable. We now rigorously define sufficiency in Definition 1 and characterizeits use in Lemma 2.1.
Definition 1.
Let B be a positive integer, and I = ( A, t = f t /g t , D ) be an instance of ( Q ( x , . . . , x k ) , ops ) -AEC- var . Represent I in the paired model. Suppose that, for every evaluation ( f, g ) = E ( A ) of avalid AEC expression E (as restricted by D ) in the paired model, the norms of the coefficients of f g t and f t g are all less than B/ . Then B is ( I, ops , var ) -sufficient. Lemma 2.1.
Given an instance I = ( A, t = f t /g t , D ) of ( Q ( x , . . . , x k ) , ops ) -AEC- var and B ∈ N which is I -sufficient as defined above. Let E ( · ) be some expression from a valid ops expression treeaccording to D . Then, for every evaluation of E over the polynomials in A , one has: E ( { ( a i ( x , . . . , x k ) } a i ∈ A ) = t ( x , . . . , x k ) ⇔ E ( { a i ( x , . . . , x k − , B ) } a i ∈ A ) = t ( x , . . . , x k − , B ) . Proof.
Let E ( A ) denote E (cid:0)S a i ∈ A a i ( x , . . . , x k ) (cid:1) . For any evaluation E ( A ), we can write E ( A ) = f /g such that the norms of the coefficients of f g t and f t g are less than B/
2. Note that E ( A ) = t if and only if f g t = f t g .Define C as the set { ( ℓ , . . . , ℓ k ) : x ℓ · · · x ℓ k k has nonzero coefficient in one of f t g, f g t } . Thendefine the polynomial s ( x , . . . , x k ) = X ( ℓ ,...,ℓ k ) ∈ C ( B/ x ℓ · · · x ℓ k k Note that this representation is not unique! f g t + s ) and ( f t g + s ) have positive coefficients of size between 0 and B −
1. The Basis Representation Theorem shows that if we have a polynomial f ( x ) = P i c i x i withall c i ∈ [0 , B − f ( B ) in base B , and recover all c i . A multivariate polynomialversion of the same shows us that we can replace the last variable with B , and recover all the othercoefficients in terms of the remaining variables. Thus, we have( f g t + s )( x , . . . , x k ) = ( f t g + s )( x , . . . , x k ) ⇔ ( f g t + s )( x , . . . , x k − , B ) = ( f t g + s )( x , . . . , x k − , B Combining these we get the desired result: f /g = f t /g t ⇔ f g t = f t g ⇔ f g t + s = f t g + s ⇔ ( f g t + s )( x , . . . , x k − , B ) = ( f t g + s )( x , . . . , x k − , B ) ⇔ ( f g t )( x , . . . , x k − , B ) = ( f t g )( x , . . . , x k − , B )This shows that f g t = f t g , which shows that E ( A ) = t .Essentially, this lemma shows that constructing I -sufficient integers efficiently is sufficient toprove our main theorem. The rest of this section is dedicated to the polynomial-time constructionof I sufficient integers B by an algorithm A .Let m ( f ) := (cid:18) deg( f ) + k deg( f ) (cid:19) where m ( f ) is the maximum number of terms a k -variable polynomial f of degree deg( f ) can have.Let maxcoeff( f ) denote the max of all of the norms of coefficients of f . That is,maxcoeff( f ) = max c {| c | : c coefficient of f } . Now we are ready to present an integer sufficient for an instance.
Lemma 2.2.
Let I = ( A, t, D ) be an instance of ( Q ( x , . . . , x k ) , ops ) -AEC- var . Then B = 2 m ( t ) maxcoeff ( t )(2 M q ) n is sufficient for I , where n = | A | , q := max f i /g i ∈ A (maxcoeff ( f i ) , maxcoeff ( g i )) is the largest coeffi-cient appearing in a paired polynomial within A , and M = P a i ∈ A m ( a i ) . We prove this by first proving the following lemma bounding the coefficient blow up of theproduct of two polynomials and then inducting on this result to form our final I -sufficient B . Remark:
The algorithm presented in this proof gives a large B that will give blowup sizeswhich are unnecessary for most AEC instances. One key use of sufficiency is to facilitate proofswith lower blowup. Often times we will have the following situation: We will give a reduction froma partition-type problem P to ( Q ( x i ) , ops )-AEC- var and construct ( I, ops , var )-sufficient B suchthat the composition P → ( Q ( x , . . . , x k ) , ops ) -AEC- var → ( N , ops ) -AEC- var is a valid reduction. 6 emma 2.3. Given two polynomials a, b ∈ Z [ x , . . . , x k ] , let h ∈ Z [ x , . . . , x k ] be their product, h = a ∗ b . The norm of each coefficient of h is bounded by min { m ( a ) , m ( b ) } · maxcoeff( a ) · maxcoeff( b ) Proof.
Let a ( x , . . . , x k ) = X ( ℓ l ,...,ℓ k ) c ( a )( ℓ ,...,ℓ k ) x ℓ · · · x ℓ k k , b ( x , . . . , x k ) = X ( j ,...,j k ) c ( b )( j ,...,j k ) x j · · · x j k k and let h ( x , . . . , x k ) = P ( i ,...,i k ) c ( h )( i ,...,i k ) x i · · · x i k k be the product of a and b .Then the coefficient for the x i · · · x i k k term of h can be written as c ( h )( i ,...,i k ) = X ( j ,...,j k ) c ( a )( i − j ,...,i k − j k ) c ( b )( j ,...,j k ) ≤ X ( j ,...,j k ) maxcoeff( a ) maxcoeff ( b ) ≤ m ( b ) maxcoeff ( a ) maxcoeff ( b )Symmetrically, we could have chosen to sum over the indices of a rather than b , and so we alsoknow that c ( h )( i ,...,i k ) ≤ m ( a ) maxcoeff ( a ) maxcoeff ( b )Thus, we know that the norm of each coefficient of h is bounded by min { m ( a ) , m ( b ) } · maxcoeff ( a ) · maxcoeff( b ) as desired.And now, the proof of lemma 2.2. Proof.
Define q to be the largest coefficient within all our paired functions: q := max f i /g i ∈ A (maxcoeff( f i ) , maxcoeff ( g i )) . Recall that m ( a i ) := (cid:0) deg( a i )+ k deg( a i ) (cid:1) . Let M = X a i ∈ A m ( a i ) . Let B = 2 m ( t ) maxcoeff ( t )(2 M q ) n where n = | A | .First, observe that computing B is efficient; using repeated squaring and schoolbook multipli-cation, M = O ( n ) can be put to the n th power in O (( n log n ) ) time.We proceed to show that B = 2 m ( t ) maxcoeff ( t )(2 M q ) n is sufficient for I . using strong induc-tion on the number of operations in a subtree. Let T r be a valid evaluation on instance I . For anysubtree T , let A T be the set of leaves in T , and let p = | A T | − f T and g T are bounded in magnitude by (2 M q ) p , where( f T , g T ) = E ( T ).If p = 0, then T has one element a i ( x , . . . , x k ), and our result is trivially true since B is largerthan the max coefficient in any function in A by construction.7ext, for any n > T , L and R . Let ( f L , g L ) and ( f R , g R )be the corresponding polynomial pairs in Q ( x , . . . x k ) that L and R evaluate to. There are fourpossible operations that can combine L and R . We show the + case ( f T , g T ) = ( f L , g L ) + ( f R , g R ) =( f L g R + g L f R , g L g R ), but the other cases ( − , × , and ÷ ) follow a very similar method.Let j be the number of operations in L . The bound on the coefficients of f T is:maxcoeff( f T ) = maxcoeff( f L g R + g L f R )= max( m ( f L ) , m ( g R )) maxcoeff ( f L ) maxcoeff( g R )+ max( m ( g L ) , m ( f R )) maxcoeff ( g L ) maxcoeff ( f R ) ≤ max( m ( f L ) , m ( g R ) , m ( g L ) , m ( f R ))(2 M q ) j (2 M q ) p − j − ≤ M (2 M q ) p − ≤ (2 M q ) p We can similarly show that maxcoeff( g T ) = maxcoeff( g L g R ) is bounded by (2 M q ) p . Themultiplication result relies on Lemma 2.3. In this section, we informally explore the possibility of extending the rational framework to theproblems more general than expression construction, such as circuits. The generalization to circuitsnaturally becomes an arithmetic version of the Minimum Circuit Size Problem.The original Minimum Circuit Size Problem (MCSP) [KyC00] asks if given a truth table and aninteger k , can you construct a boolean circuit of size at most k that computes the truth table; thisproblem has many connections throughout complexity theory. A new variant, “Arithmetic MCSP”would ask if given n values in { a , . . . , a n } ⊆ L , within 0 < k < n operations from { + , − , × , ÷} canyou construct a target t ∈ L ? For L = Q ( x , . . . , x k ), this problem asks whether a given rationalfunction is constructable by an arithmetic circuit of size at most k starting from a set of rationalfunctions. It would be very useful if the rational framework could be adapted for ArithmeticMCSP; this would demonstrate an equivalence between the problem of circuit construction ofrational functions and of reaching a rational number given input rational numbers.Unfortunately, the reduction methods provided above do not work naively for circuits: Givena polynomial-sized “sufficient” B as presented, and a polynomial of the form cx , the term ( c k x k )is formable by repeated squaring. That is, we can form superpolynomial coefficents that will bebigger than B . This removes the concept of “sufficiency” which is a key requirement for the rationalframework as it is.On the bright side, the rational framework should work for Arithmetic Minimum Formula Con-structions. Arithmetic formulae are expression trees with internal nodes operations { + , − , × , ÷} except that one may use the input values in A a flexible number of times. This is analogous toBoolean formulae; indeed, Minimum Boolean Formula problems [BU08, HS11] have also receivedsignificant attention. We can define Arithmetic Minimum Formula Construction as follows: Givenmultiset A ⊆ L , target t , 0 < k < n , can you give a formula of size at most k with values in A which reaches a target t ∈ L ?The intuitive reason that the rational framework should hold in this case is because formulaestill have a tree structure and the number of leaves is polynomial. Thus, the same proofs in the Note that since we can reuse values here, picking k to be less than n is the same as picking k to be bounded by afixed polynomial p ( n ) by a padding argument. That is, you can reduce from this problem where you specify k < p ( n )to k < n by padding any given instance A with ≈ p ( n ) copies of a . This is similar to the proof that linear spacesimulation is PSPACE complete. In this section, we provide NP-hardness proofs for operations { + , ×} ⊆ S ⊆ { + , − , × , ÷} of theStandard variant of Arithmetic Expression Construction. In Section 4 we give similar reductionsthat cover all other subsets of operations.All of these results use the rational function framework described in Section 2.First, we outline some proof techniques that are used in this section to both combine proofsof results from differing sets of operations as well as simplify them. The first comes from theobservation that if an instance of ( L , S ) -AEC-Std is solvable, then for any operation set S ′ ⊃ S ,the same instance will be solvable in ( L , S ′ ) -AEC-Std . This allows us to bundle reductions toseveral AEC- Std cases simultaneously by giving a reduction ( R ) from some partition problem P to ( L , S ) -AEC-Std and proving that if any constructed instance is solvable in ( L , S ′ ) -AEC-Std ,the partition instance is also solvable. That is, we have the following implications: P -instance x Solvable R ( x ) is S -Solvable R ( x ) is S ′ -Solvable Theorem 3.1.
Standard { + , ×} ⊆ S ⊆ { + , − , × , ÷} is weakly NP-hard by reduction from SquareProductPartition - n/ . We spend the remainder of this section proving this theorem.We will reduce from
SquareProductPartition - n/ Z [ x, y, z ] , S ) -AEC-Std . On an instance { a , . . . , a n } with all a i ≥ of SquareProductPartition - n/ B y = y − x n/ sY i a i ; B z = z − x n/ sY i a i . We then construct the instance of Arithmetic Expression Construction with input set A = { B y , B z } ∪ { a i x } i and target t = yz . Here the square root of the product of all a i is the value wewant each partition to achieve, the polynomial x n/ will help us argue that we must multiply allof our a i values, and B y , B z are gadgets which will force a partitioned tree structure as given byTheorem 3.2. Methods from Section 2 allow us to construct a reduction by replacing x, y , and z with sufficient integers B , B and B .If the SquareProductPartition - n/ { + , ×} ⊆ S . On the partition with equalized products, partition the a i x terms intocorresponding sets and take their products to get two polynomials of value x n/ pQ i a i . Then form( B y + x n/ pQ i a i )( B z + x n/ pQ i a i ) = yz .Next we prove the converse via contradiction by proving the following theorem that will beuseful for the other AEC- Std cases. This theorem shows that any expression tree which evaluates We can assume this property with loss of generality by replacing all a i with 2 a i .
9o target t ≈ yz on an instance of similar structure to the constructed instance above must havea very particular partitioned structure described in Theorem 3.2. This will be the key to showingthe soundness of our reduction. We use ev( T ) to refer to the evaluation of the subtree rooted atnode T .Before stating Theorem 3.2, we first introduce the concept of Q ( x )-equivalence and give a coupleof characterizations of it: Definition 2.
Given a field K with a subfield F , for L , L ∈ K − F , we say L and L are F -equivalent (written L ∼ F L ) if by a sequence of operations between L and elements of F wecan form L . The following lemma gives an alternate characterization of ∼ F : Lemma 3.1. ∼ F is an equivalence relation and L ∼ F L if and only if for some c i , d i ∈ F with c d − c d = 0 , L = c L + d c L + d Proof.
Maps of the form z az + bcz + d , ad − bc = 0 are called linear fractional transformations. For ageneral reference on linear fractional transformations see [You84]. One can first note that for anyoperation with c ∈ F − { } with operations { + , − , × , ÷} is a linear fractional transformation. E.g. c ÷ z = 0 z + c z + 0 , z + c = 1 z + c z + 1Another thing worth noting is that the composition of two linear fractional transformation is alsoa linear fractional transformation. In fact, composition of two fractional linear transformationsdescribed by matrices. (cid:18) a bc d (cid:19) , (cid:18) a ′ b ′ c ′ d ′ (cid:19) is given by matrix composition. Thus, we can conclude that any F -equivalent element is of theform of linear fractional in L . However, to show that any linear fractional in L is F -equivalentto L we simply write an arbitrary linear fractional as a sequence of operations in { + , − , × , ÷} : aL + bcL + d = ( a/d ) L + b/d if c = 0 , aL + bcL + d = bc − adc ( L + d/c ) + a/c if c = 0We will refer to Q ( x ) equivalence with respect to Q ( x ) as a subfield of Q ( x, y, z ).We will also define the notion of degree of elements in the field K ( x ), of rational functions withcoefficients in K , and prove a lemma which will be useful in the proof of the structure theorembelow. Definition 3.
Let K be a field, consider the field K ( x ) and the function deg x : K ( x ) − → N defined as deg x ( p/q ) = max(deg x p, deg x q ) where r = p/q is written in lowest terms. Lemma 3.2.
The function deg x is subadditive in all the operations + , − , × , ÷ . In fact, the group of linear fractional transformation is PSL ( F ) roof.
1. deg x (cid:18) p q ∗ p q (cid:19) = deg x (cid:18) p p q q (cid:19) = max (deg x ( p p ) , deg x ( q q ))= max (deg x ( p ) + deg x ( p ) , deg x ( q ) + deg x ( q )) ≤ max (deg x ( p ) , deg x ( q )) + max (deg x ( p ) , deg x ( q ))= deg x (cid:18) p q (cid:19) + deg x (cid:18) p q (cid:19) .
2. deg x (cid:18) p q (cid:30) p q (cid:19) = deg x (cid:18) p q ∗ q p (cid:19) ≤ deg x (cid:18) p q (cid:19) + deg x (cid:18) q p (cid:19) = deg x (cid:18) p q (cid:19) + deg x (cid:18) p q (cid:19) .
3. deg x (cid:18) p q ± p q (cid:19) = deg x (cid:18) p q ± p q q q (cid:19) ≤ max (deg x ( p q ± p q ) , deg x ( q q )) ≤ max (deg x ( p q ) , deg x ( p q ) , deg x ( q q )) ≤ max (deg x ( p ) , deg x ( q )) + max (deg x ( p ) , deg x ( q ))= deg x (cid:18) p q (cid:19) + deg x (cid:18) p q (cid:19) . Also, if deg x ( p ± q ) ≤
0, deg x ( p ∗ q ) ≤
0, or deg x ( p/q ) ≤
0, then deg x ( p ) = deg x ( q ).We now state our structure theorem: Theorem 3.2.
For any S ⊆ { + , − , × , ÷} , let I be a solvable ( Q ( x, y, z ) , S ) -AEC-Std instancewith entries of the form { B y , B z } ∪ { r i ( x ) } i where B y ∼ Q ( x ) y, B z ∼ Q ( x ) z , and r i ∈ Q [ x ] andtarget t with t ∼ Q ( x ) yz . Then any solution expression tree for I has the form depicted in Figure 2:The operation at the least common ancestor of leaves B y and B z , denoted N , is × or ÷ , and ev( N ) = ( lyz ) ± , l ∈ Q ( x ) . For T y , T z the children of N containing B y , B z respectively, ev( T y ) =( ay ) ± , ev( T z ) = ( a ′ z ) ± , where a, a ′ ∈ Q ( x ) . ( lyz ) ± ( ay ) ± xa xa B y ( a ′ z ) ± B z xa xa xa xa xa T y T z Figure 2: Example expression tree for standard { + , − , × , ÷} . Proof.
In our expression tree T , N is the least common ancestor between B y and B z . One has thatev( N ) = eyz + fgyz + h , eh − gf = 0 , e, f, g, h ∈ Q ( x )since ev( N ) is combined with a sequence of operations with elements in Q ( x ) to form t . That is, itis Q ( x ) equivalent to yz .Let T y be the child of N containing B y as a leaf and T z the child of N containing B z . A prioriwe know ev( T y ) = ay + bcy + d , ev( T z ) = a ′ z + b ′ c ′ z + d ′ , ev( N ) = eyz + fgyz + h ,ad − bc = 0 , a ′ d ′ − b ′ c ′ = 0 , eh − f g = 0 , a, b, c, d, a ′ , b ′ , c ′ , d ′ , e, f, g, h ∈ Q ( x )by similar Q ( x )-equivalence arguments. The rest of the proof is casework done via trying outdifferent operations at N . We will see that if the operation is × , ÷ then the evaluations must be ofthe form described in the statement of the theorem and that if the operation is ± then we reach acontradiction.First we check the case that the operation at N is × . For this argument we’ll reduce to a setof equations in Q ( x )[ y, z ] and make some divisibility arguments using the fact that this is a uniquefactorization domain. ay + bcy + d · a ′ z + b ′ c ′ z + d ′ = eyz + fgyz + h ⇒ ( ay + b )( a ′ z + b ′ )( gyz + h ) = ( cy + d )( c ′ z + d ′ )( eyz + f )If both e, f = 0, then eyz + f is irreducible and since eyz + f | ( ay + b )( a ′ z + b ′ )( gyz + h ) we findthat eyz + f | gyz + h and eyz + fgyz + h = l ∈ Q ( x ). However, this would contradict ev( N ) ∼ Q ( x ) yz .We conclude that exactly one of e, f is nonzero. A similar argument with gyz + h allows us toconclude that at most one of g, h is nonzero. We cannot have g = 0 and e = 0, or we would haveev( N ) ∈ Q ( x ). This reduces us to the case that ev( N ) = ( lyz ) ± . We now have one of the twocases: ( ay + b )( a ′ z + b ′ ) = lyz ( cy + d )( c ′ z + d ′ ) (1) lyz ( ay + b )( a ′ z + b ′ ) = ( cy + d )( c ′ z + d ′ ) (2)12or the first case to hold one must have c = c ′ = 0 for the degrees in y and z to match up. Given c = c ′ = 0, one must also have b = b ′ = 0 so that the right hand side of the equation is divisibleby yz . A similar argument for the second case yields a = a ′ = d = d ′ = 0. For multiplication, thiscase is covered. If the operation is division, one gets the relation: ay + bcy + d ÷ a ′ y + b ′ c ′ y + d ′ = ay + bcy + d · c ′ y + d ′ a ′ y + b ′ = eyz + fgyz + h and the same argument follows through.Next we show that the operation at N can not be +: ay + bcy + d + a ′ z + b ′ c ′ z + d ′ = eyz + fgyz + h (( ac ′ + a ′ c ) yz + ( ad ′ + b ′ c ) y + ( bc ′ + a ′ d ) z + ( bd ′ + b ′ d ))( gyz + h )= ( cy + d )( c ′ z + d ′ )( eyz + f ) (3)Starting with a similar divisibility argument, if g, h = 0, we find that gyz + h is irreducible andthat gyz + h | eyz + f, eyz + hgyz + f ∈ Q ( x ). Thus either g = 0 or h = 0.Suppose g = 0. Then we must have e = 0 to maintain ev( N ) ∼ Q ( x ) yz . With nonzero e , onemust have that c = c ′ = 0 so that the RHS of equation (9) has degree no bigger than the left handside. The coefficient of yz on the LHS of the equation is ( ac ′ + a ′ c ) h = 0 and the coefficient of yz on the RHS is edd ′ which must be nonzero and thus we get a contradiction.Suppose h = 0. We must have g, f = 0 to maintain ev( N ) ∼ Q ( x ) yz . The LHS of the equationis divisible by yz . Thus yz | ( cy + d )( c ′ z + d ′ )( eyz + f ) and this can only occur if d = d ′ = 0 and c, c ′ = 0. Expanding the equations now and looking at the coefficient of yz in the LHS and RHSwe find: 0 = cc ′ f = g ( bd ′ + b ′ d ) = 0. This concludes the proof of our helper theorem.Now we will return to our proof of the soundness of the reduction to AEC- Std . Suppose thatthe constructed instance I is solvable and the product partition instance is not solvable. Then forsome S ∈ { leaves( T y ) ∩ { a i x } , leaves( T z ) ∩ { a i x }} , either1. S contains < n/ a i x .2. S contains n/ a i x with product αx n/ with α < pQ i a i .WLOG let this set be leaves( T y ) ∩ { a i x } . In the next two claims, we prove that in neither of thesetwo cases can a subtree evaluate to an expression of the form ( ay ) ± as Theorem 3.2 requires. Claim 3.1. If T y contains < n/ leaves { a i x } and y ′ = y − x n/ pQ a i , then ev( T y ) is not of theform ( ay ) ± for any a ∈ Q [ x ] .Proof. The value of any subtree can be written in the form p ( x,y ′ ) q ( x,y ′ ) for polynomials p and q . Letdeg x ( p ( x,y ′ ) q ( x,y ′ ) ) = max(deg x ( p ( x, y ′ )) , deg x ( q ( x, y ′ ))). This degree is subadditive for the four arithmeticoperations (+ , − , × , ÷ ), given by Lemma 3.2. Also, if deg x ( p ± q ) ≤
0, deg x ( p ∗ q ) ≤
0, ordeg x ( p/q ) ≤
0, then deg x ( p ) = deg x ( q ).By induction, the degree in x (respectively to y ′ ) at a node A is at most the number of leavesof A ’s subtree of the form a i x . This is true for the leaves (deg x ( a i x ) = 1), and subadditivity provesit for the inductive step.Hence ev( T y ) has degree at most 1 in y ′ and less than n/ x . If ev( T y ) = ( ay ) ± = ( a ( y ′ + x n/ ) ± ) for nonzero a ∈ Q ( x ), then it has degree at least n/ x , a contradiction.13 laim 3.2. If T y contains n/ leaves a i x with Q i a i = α < pQ i a i and y ′ = y − x n/ pQ a i , then ev( T y ) is not of the form ( ay ) ± for any a ∈ Q ( x ) .Proof. First, we rewrite our target ev( T y ) in terms of y ′ , yielding ev( T y ) = ( a ( y ′ + x n/ pQ a i )) ± .We will first show that regardless of the value of a , the maximum coefficient of the rational functionev( T y ) is at least pQ a i . Note that since y ′ is not in Q ( x ), ( y ′ + x n/ pQ a i ) is an irreduciblepolynomial in x , so the denominator of a will never cancel out with anything. Thus, we onlyconsider the numerator of a . Consider the leading coefficient of the numerator of the product. Thisleading coefficient must be exactly the product of the leading coefficient of the numerator of a and x n/ pQ a i . Since the leading coefficient of the numerator of a is an integer, it must be at least 1,so the leading coefficient of the numerator of a ( y ′ + x n/ pQ a i ) must be at least x n/ pQ a i .From our reduction we have that all the a i are at least 2, and the largest possible integer thatcan be generated from the a i and arithmetic operations is their product α . Every coefficient ofev( T y ) is some combinations of arithmetic operations of the a i since it is comprised of the a i x and y ′ and arithmetic operations. Thus, it is not possible for ev( T y ) to ever have a coefficient of at least x n/ pQ a i . Thus, from the above argument it cannot be of the form ( a ( y ′ + x n/ pQ a i )) ± .Note that the proof of this claim yields a reduction from SquareProductPartition - n/ Z [ x, y, z ] , S ) -AEC-Std for all { + , ×} ⊆ S ⊆ { + , − , × , ÷} . Using our rational function framework,we get a reduction from ( Z [ x, y, z ] , S ) -AEC-Std to ( Z , S ) -AEC-Std by replacements based oninstance I with x = B = A ( I ) , y = B = A ( I ( B )) , z = A ( I ( B , B )) . However, since the reduction is of the form { y − αx n/ , z − αx n/ } ∪ { a i x } , if we replace B with B ′ = max( B , αB n/ ), and B with B ′ = max( A ( I ( B , B ′ )) , α ( A (( B , B ′ ))) n/ ) this will yield still sufficient B , B such that the composition of these maps isa reduction from ProductPartition - n/ N , S ) -AEC-Std . To cover the rest of the cases for standard Arithmetic Expression Construction, we will give twomore reductions of essentially the same structure and then use the Structure Theorem 3.2 forreductions of this type and prove two analogues of the final claim in the proof from Claim 3.1above. {− , ×} ⊆ S ⊆ { + , − , × , ÷} AEC Standard
This case’s reduction and hardness proof are identical to that of the proof above with only a coupleof sign flips. On instances { a i } of SquareProductPartition - n/
2, produce instances I : I = y + x n/ sY i a i , z + x n/ sY i a i , ∪ { a i x } , t = yz Note that this denotes replacing with B i which are I -sufficient but since this is done via three reductions theinstance I changes. Therefore, when replacing with B , you need B to be I ( B ) sufficient (i.e., the instance I with x = B replaced). Similar requirements hold for B .
14f ( N [ x, y, z ] , S ) -AEC-Std . If the product partition instance is solvable the constructed instanceis solvable. Suppose the constructed instance is solvable in { + , − , × , ÷} and the product partitioninstance is not solvable.First, we apply Theorem 3.2 again, to obtain that the solution tree has the form of Figure 2.The analogs of the Claims 3.1 and 3.2 with y ′ = y + x n/ pQ i a i (instead of y ′ = y − pQ i a i ) andthe proofs of the analogs are virtually identical. For an analog of Claim 3.1, the proof is identicalsince the proof only requires a degree in x argument which is blind to the sign of Q i a i . The proofof the analog of Claim 3.2 refers to the maximal sizes of coefficients and thus goes through as well.This will reduce us down to the implication that if the constructed instance is solvable there mustbe a product partition and finishes the proof. {− , ÷} , { + , ÷} , { + , − , ÷} AEC Standard
The form of the reduction in this section is similar to the previous reductions however we will reducefrom
SquareProductPartition (in a way that simulates
SquareProductPartition - n/
2) to( Q ( x, y, z ) , S ) -AEC-Std for { + , ÷} ⊆ S ⊆ { + , − , × , ÷} . This will not affect the application of theStructure Theorem 3.2 but our analogs of Claims 3.1 and 3.2 will be different.On an instance of ProductPartition , { a i } ni =1 , construct the following instance: I = y − x n +1 sY i a i , z − x n +1 sY i a i , ∪ { a i x } ∪ { x } ∗ [ n + 2] , t = yzx n Q i a i . We add n + 2 x monomials into the instance. If the product partition instance is solvable, youcan partition S = { a i x } ∪ { x } ∗ [ n + 2] into two sets of n + 1 monomials with product x n +1 pQ i a i .Call these sets S , S . Divide B y by all but one of the elements of the form x in S and then addthat element to it: B y a x · a x · · · + x = yx n pQ i a i do the same with B z and then take the product of the output to reach the target.For the converse, assume the SquareProductPartition instance is unsolvable but I has asolution tree T :By the Theorem 3.2, we have a have two subtrees T y , T z containing B y , B z respectively whichmust evaluate to ( ay ) ± , ( a ′ z ) ± respectively a, a ′ ∈ Q ( x ) with leaves disjoint subsets of S = { a i x } ∪ { x } ∗ [ n + 2]. Suppose one of the two subtrees’ leave’s (WLOG T y ’s) has less than n + 1of the elements of S . Then this subtree cannot evaluate to ( ay ) ± since has deg x ( ay ) ± is higherthan than the sum of deg x of the subtree’s leaves (where deg x is defined relative to writing allrational functions with respect to B y , x ). Thus, this leaves the case where both T y and T z have n + 1 monomials. Claim 4.1.
Let y ′ = y ± αx n +1 , α ∈ N , and let S be a (multi)set of n + 1 elements of the form a i x, a i ∈ N satisfying the product of the elements of S is βx n +1 where | β | < | α | .Then all expressions in S ∪ y with operations { + , − , ÷} which yield deg x = n + 1 are of theform:1. y ′ (cid:16)Q ai ∈ S a i (cid:17) x n +1 y ′ ± βx n +1 ( Q i = k a i ) x n amely, it will not be of the form ( ay ) ± for a ∈ Q ( x ) since deg x ( ay ) ± ≥ n + 1 (w.r.t. ( x, y ′ ) ).Proof. We first note that any evaluation tree that evaluates to an element v with deg x v = n + 1cannot have a nontrivial subtree with leaves consisting only of elements of the form ax, a ∈ Z . Thiscan be seen by noting that any operation between two elements ax, bx is loses at least 1 in deg x : ax ± bx = ( a ± b ) xax ÷ bx = a/b This means that any evaluation tree evaluating to something of deg x = n + 1 must be a sequenceof operations between y ′ and the elements { a i x } . Thus, our evaluation tree can be modeled as: y ′ = y ′ , y ′ k = y ′ k − ± a k x, or y ′ k = y ′ k − / ( a k x ) , or y ′ k = ( a k x ) /y ′ k − ; ev( T y ) = y ′ n +1 . Suppose y ′ k = p ( y ′ , x ) / ( q ( y ′ , x )) , k < n + 1, with deg x p > deg x q , then the next operation losesat least one in deg x and cannot yield an evaluation with deg x v = n + 1: pq ± ax = p ± axqq ; pq ÷ ax = paxq ; ax ÷ pq = axqp . Thus we have the invariant that deg x q ≥ deg x p for y ′ i , i < n + 1. However, from the aboveequations, we can also note that if deg x q ≥ deg x p , only the operation p/q ÷ ax maintains thisproperty. Thus we conclude that y ′ n = y ′ ( Q i = k a i ) x n given a sequence of n a i x divisions with a i x ∈ S . The last operation can be an addition, subtractionor division by a i x and any of these operations will give the two cases from the statement of theclaim.Note that if the product partition instance is not solvable, then one of the subtrees has mono-mials a i x whose product is less than pQ i a i x n +1 and thus by this claim and the structure theoremwe finish the proof of the converse.We note at this point that the exact same argument will apply for S = {− , ÷} where you flipthe signs in B y , B z and proceed similarly.The last piece of housekeeping is translating this reduction to AEC with entries in N . As itstands, we can use the algorithm A to produce B i which will create a valid reduction to AEC withentries in Q . In the {− , ÷} construction these replacements will yield positive coefficients already.For { + , ÷} , on an instance I we can do replacements: x = B = A ( I ) , y = B ′ = max B , B n +11 sY i a i , z = B ′ = max B , sY i a i B n +11 to achieve positivity. After these replacements, the only element that may still not be an integer is t = yz ( Q i a i ) x n and one can do a final replacement z = B ′′ = ( Q i a i ) B n B ′ . This finishes the hardness proofs forall of the standard AEC cases. 16 m , deg( m ) ≥ xc , deg( c ) ≥ × d , deg( d ) ≥ a i x g xg Figure 3: Proof of Lemma 5.1: a × nodecannot have a descendant × node. × m , deg( m ) ≥ c , deg( c ) ≥ a i − x x + c , deg( c ) ≥ a i x x Figure 4: Proof of Lemma 5.2: a × node cannothave two children + nodes. Recall that an instance of the Enforced Leaves (EL) AEC variant has a fixed ordering of leaves(operands), and the goal is to arrange the internal nodes of the expression tree such that the target t is the result of the tree’s evaluation. In this section, we present hardness proofs for operation sets { + , ×} , { + , − , ×} , {− , ×} , { + , × , ÷} of the Enforced Leaves variant. { + , ×} Claim 5.1. ( N [ x ] , { + , ×} ) -AEC-EL is weakly NP-hard. Before we prove this claim, we state and prove some useful lemmas that utilize the following( N [ x ] , { + , ×} ) -AEC-EL instance structure:Given an instance of Partition - n/ A = { a , a , . . . , a n } , let I A bean instance of ( N [ x ] , { + , ×} ) -AEC-EL with polynomials of the form a i x interspersed with n − x in the leaf order a x x a x x a x · · · x a n x and with target t ( x ) = ( x + x ) P i a i + ( n − x . Lemma 5.1.
All solutions of I A that meet the target have the property that no × operator nodehas a × operator descendant node.Proof of Lemma 5.1. Refer to Figure 3. With the operations { + , ×} and leaves that are positivepowers of x with positive coefficients, the value at a node cannot be a polynomial of higher degreethan any of its ancestors. For the sake of contradiction, consider some node m with the × operatorand a descendant d also with the × operator. Let g , g be the children of d , and let c be the childof m that is not d or an ancestor of d . Then c must evaluate to at least x ; similarly, one of g and g evaluates to at least x and the other to at least x . However this implies that the parent × nodeevaluates to at least x , which is greater than the target. Therefore, any node with the × operatorcan only have leaves or + operators as descendants. Lemma 5.2.
All solutions to I A that meet the target have the property that there is at least oneleaf child of all internal × nodes.Proof of Lemma 5.2. Refer to Figure 4. Assume for the sake of contradiction that m is a × operatornode and neither of its children c , c are leaf nodes. Then, by Lemma 5.1, both children must be+ operator nodes and thus have at least two descendants; Because of the alternating ordering of x and a i x leaves, both of these subtrees must have an a i x term. The product of these sums mustthen have a term of order x , which is a contradiction.17 a i x x a i x (a) Case 1: Both children areleaf nodes. × c x + c x x + c x + c xa i x x (b) Case 2: One child is a leafnode with value x . × c x + c x a i x + c x + c xx a i +1 x (c) Case 3: One child is a leafnode with value a i x . Figure 5: Proof of Lemma 5.3.
Lemma 5.3.
In all solutions to I A that meet the target, any internal × operator node has exactlytwo children, both of which are leaves.Proof of Lemma 5.3. Refer to Figure 5. By Lemma 5.2, there are three possible child pairs undera × operator: (i) two leaves x × ax or ax × x , (ii) one ax leaf and a + operator, and (iii) one x leaf and a + operator. We will show that the first case is the only one that does not provide acontradiction.In the second case, there is at least one ax leaf under the + operator, so the degree of thepolynomial evaluated at the × operator would be at least 6, a contradiction.Consider the third case. Let m be the × operator and let e, d be its children where e is the x leaf and d is the + operator. Since, by Lemma 5.1, × operator nodes cannot have × operatordescendants, all descendants of d must be leaves or + operators. Due to the alternating leaf order, d must have an x descendant and an a i x descendant, so the evaluation of d is of the form c x + c x where c and c are positive integers. Thus the evaluation of m is of the form c x + c x . Weshow that it is impossible to reach the target t ( x ) if an internal node in the evaluation containsthis expression.By Lemma 5.1, no ancestor node p of m can be a × operator as m is a × operator. Thusall ancestors of m are + operators. Thus the evaluation at p must have an x term since we aresumming multiple polynomials with x terms with non-negative coefficients. This remains truewhen p is the root, so the evaluation of the entire expression tree must contain an x term, whichis a contradiction. Proof of Claim 5.1.
This proof proceeds by reduction from
Partition - n/ A be the set of positive integers for Partition - n/
2, and let I A consist of the ordering andtarget defined above.If the instance of Partition - n/ A , A of A exist such that P A = P A = P A and A contains a . Then in the AEC instance, for a i in A (other than a ) we assign operations so that · · · + ( x + a i x ) + · · · , and for a i in A we assignoperations so that · · · + ( x × a i x ) + · · · .Let the symbol + × represent the choice of either + or × depending on the set a i belongs to.18valuating our expression, we get a x + ( x + × a x ) + · · · + ( x + × a n x ) = a x + X a i ∈ A ; i =1 ( x + a i x ) + X a i ∈ A a i x = ( x + x ) P i a i (cid:16) n − (cid:17) x = t ( x ) . Therefore, our constructed instance of AEC has a solution if the original instance of
Partition - n/ I A that meets t ( x ). Recall that there are( n − x leaves of the instance. The only way to achieve the ( n/ − x terms in the target is forexactly ( n/ −
1) of those leaves to have + operator parents instead of × , since otherwise the x termis multiplied by an ax node and (since we have only + and × with non-negative coefficients) thiscannot be an x term in the evaluation. Thus, the remaining ( n/ x terms must have × operatorparents. By Lemma 5.3, the only × operators in the expression tree are parents of two leaves, andso are of the form ( x × ax ) or ( ax × x ).If we let A be the set of a i such that a i x was as child of a × operator, and A be the setof all other a i , then we have divided A into two complementary subsets A and A such that | A | = | A | = n/
2. Further, since the target was achieved, x P A + x P A + ( | A | − x =( x + x ) P i a i + ( n − x so P A = P i a i = P A . Thus A and A provide a valid partitioningfor Partition- n/
2, so the original instance of
Partition - n/ { + , ×} - EL has a solution.As our instance of { + , ×} - EL has a solution if and only if the instance of Partition has asolution, we have found a valid reduction from
Partition to { + , ×} - EL . As our reduction takespolynomial time and Partition - n/ { + , ×} - EL must also be weakly NP-hard. Claim 5.2. ( N , { + , ×} ) -AEC-EL is weakly NP-complete.Proof. We know by Claim 5.1 combined with Theorem 2.1 that ( N , { + , ×} ) -AEC-EL is weaklyNP-hard. To show that this hardness is tight, we provide a pseudopolynomial algorithm for it.Suppose that the enforced leaf ordering is a , a , . . . , a n (all in N ), and the target is t ∈ N . Let F i,j be the set of all possible values in [ t ] that can be attained via operations for the values ordered a i , . . . , a j , for 1 ≤ i ≤ j ≤ t . The instance has a solution if and only if F ,n includes t .We can use dynamic programming on the F i,j sets to compute F ,n . Initialize F i,i = { a i } forall i ∈ [ n ]. Then each set F i,j with j > i can be computed as the union F i,j = j [ k = i { ℓ + r, ℓr | ℓ ∈ F i,k , r ∈ F k +1 ,j } ∩ [ t ] . Note that each of these sets is at most size t ; we do not need to keep track of values larger than t since they cannot be combined using + and × operations to reach the target t . Therefore,computing each set of new values from F i,k and F k +1 ,j takes time O ( t ). To get each F i,j we takethe union over O ( n ) such computed sets. To “reach” F ,n in this way we must compute O ( n )values of F i,j , so the total runtime of this protocol is O ( n t ).The existence of this pseudopolynomial algorithm shows that ( N , { + , ×} ) -AEC-EL is notstrongly NP-hard, and so combined with our hardness result, we have shown that the problemis weakly NP-complete, as desired. 19 .2 Weak NP-hardness of AEC Enforced Leaves { + , − , ×} We present a proof for the weak NP-hardness of ( N [ x, y ] , { + , − , ×} ) -AEC-EL . Using the techniquedescribed in Section 2, this also proves NP-hardness of ( N , { + , − , ×} ) -AEC-EL .Our proof is a reduction from SetProductPartitionBound- K . This strongly NP-hard prob-lem asks if given a set (without repetition) of positive integers A = { a , a , . . . , a n } where all a i > K and all prime factors of all a i are also greater than K , we can partition A into two subsets withequal products. The problem is also defined formally in Appendix A. Claim 5.3. ( N [ x, y ] , { + , − , ×} ) -AEC-EL is weakly NP-hard. This statement is proved via reduction from
SetProductPartitionBound-
3. Let the in-stance be A = { a , . . . , a n } , where all prime factors of all a i ∈ A (and all a i themselves) are greaterthan 3.Let L = 2 Q i ∈ [ n ] a i . Let p , . . . , p n be unique primes greater than 3 that are coprime to Q i ∈ [ n ] a i ( a i + 1)( a i − a i , construct integer-coefficient y terms b i = L ( a i + a i ) p i y and c i = L ( a i − a i ) p i y . Observe that b i + c i = ( La i ) p i y and b i − c i = ( L/a i ) p i y . Also note thatthey both have integer coefficients because a i | L for all i .Now, construct instance I A of ( N [ x, y ] , { + , − , ×} ) -AEC-EL which has target polynomial t ( x, y ) = L n y n x n − Q i ∈ [ n ] p i , and the following order of leaves: b c x b c x · · · x b n c n . If an instance of this product partition variant is solvable, then the constructed instance evalu-ates to t ( x, y ) = L n x n − y n Q i ∈ [ n ] p i when we have ( b i + c i ) for a i in one partition and ( b i − c i ) for a i in the other, and the × operator at every other node. The partition corresponds to whether the a i was written as a difference or a sum.We must also show that any expression achieving the target must take the form above. Werestrict the set of possible forms by (1) inducting to show that each subtree of a solution musthave degree in x equal to its number of leaves of value x , (2) counting primes factors of the highestdegree term to show that subtrees with no x values must be of form {± b i , ± c i , ± b i ± c i } , (3) adivisibility argument to show that sums of elements of form {± b i , ± c i , ± b i ± c i } as appearing in anyevaluation of a subtree is nonzero, and (4) an argument on the degree of y for terms with degree 0in x to show that these sums can never be canceled.The bulk of the proof will occur in Lemma 5.7, which states that all subtrees of a solution tothis instance evaluate to monomials. To prove Lemma 5.7, we use 3 helper lemmas, which we nowproceed to state and prove: Lemma 5.4.
Let T full be the tree representation of a solution to instance I A . All subtrees T of T full have an evaluation with degree in x equal to the number of x terms in its leaves. If two subtreesboth have a nonzero number of x terms in its leaves, their lowest common ancestor must be a × operator.Proof of Lemma 5.4. We prove by strong induction on subtrees of increasing height that subtrees T of T full have an evaluation with degree in x at most k T , the number of x terms in its leaves. Wethen use the equality condition of the induction to show that the evaluation has degree in x exactly k T . It is clear that all leaves, that is, subtrees of height 0, have degree in x equal to 1 if it is an x term and 0 if it is an a i y term. 20ssume that the degree in x of the evaluation of all subtrees of height at most h is at most thenumber of leaves of value x . We show this is also true for all subtrees of height h + 1.Let T be a subtree of height h + 1 with left subtree L with k L leaves of value x and rightsubtree R with k R leaves of value x . Since L and R have height at most h , the degree in x oftheir evaluations are k L and k R . If T is rooted at an + or − operator, then the degree in x of theevaluation of T is at most max( k L , k R ). If T is rooted at a × operator, then the degree in x of theevaluation of T is at most k L + k R . Thus the evaluation of T has degree in x at most k T = k L + k R ,the number of leaves of value x .Note that the evaluation of T has x -degree exactly k T = k L + k R when the evaluations of L and R have x -degree exactly k L and k R (since they have degree in x at most k L and k R ). If k L and k R nonzero, then in order for T to have x -degree k T , it must be the case that L and R are multipliedtogether. Since any T full evaluates to t ( x, y ) = L n y n x n − Q i ∈ [ n ] p i , which has x -degree equal to thenumber of x leaves, propagating this property from the root of the tree to the leaves we find thatany subtree T has degree in x equal to the number of leaves of value x . Lemma 5.5.
Let b i and c i be as defined above. Let T full be the tree representation of a solution to I A . All subtrees of T full whose evaluation has degree 0 in x must evaluate to ± b i , ± c i , or ± b i ± c i .In other words, the subtree ± b i × c i cannot exist.Proof of Lemma 5.5. First, we show that the coefficient of the term with highest degree in x in theevaluation of T full must be of the form: n Y i =1 F i where F i ∈ {± , ± b i , ± c i , ± b i ± c i , ± b i c i } for all i ∈ [ n ].Let n j be the j th leaf from the left in leaf ordering. Consider the subtree rooted at highestancestor of n j not containing n j ℓ , n j r with j ℓ < j < j r . The leaves of this subtree are within therange [ j ℓ + 1 , j r − x formed with b i or c i will in the form F i as above, before being operated with a subtree containing an x . This term only contribute thecoefficient of the term with highest degree in x if it is multiplied.Recall that the target t ( x, y ) = L n y n x n − Q i ∈ [ n ] p i contains n unique primes p , . . . , p n . Fur-thermore, recall that by construction b i and c i both contain p i as a factor. Thus, a solution T full must have F i ∈ {± b i , ± c i , ± b i ± c i } for all i because there is exactly one factor of each p i in t ( x, y ).We may never multiply b i and c i , as b i c i has 2 factors of p i , so if it were multiplied into a subtreecontaining x , the resulting evaluation would have too many p i factors to meet the target. Lemma 5.6.
Let b i and c i be as defined above. All sums of the following form, where at least one d j is nonzero, have nonzero evaluations: d b i + d c i + d b i ′ + d c i ′ , d j ∈ { , ± } . (4) Proof of Lemma 5.6.
Suppose, for contradiction, that we do have an expression of the form abovewhich evaluates to 0. d b i + d c i + d b i ′ + d c i ′ = Ly (cid:18) d p i (cid:18) a i + 1 a i (cid:19) + d p i (cid:18) a i − a i (cid:19) + d p i ′ (cid:18) a i ′ + 1 a i ′ (cid:19) + d p i ′ (cid:18) a i ′ − a i ′ (cid:19)(cid:19) = 0 (5)21e can cancel out the Ly a i a i ′ factor in our equation:( d + d ) p i a i a i ′ + ( d + d ) p i ′ a i a i ′ + ( d − d ) p i a i ′ + ( d − d ) p i ′ a i = 0 (6)For Equation 6 to hold, we require ( d − d ) p i a i ′ ≡ a i and ( d − d ) p i ′ a i ≡ a i ′ .Since these p i , a i ′ , and a i are distinct, there is a prime factor, which we call q i of a i that is notin either a i ′ or p i , and by construction q i >
3. Since, by construction, d − d ∈ { , ± , ± } and d − d ≡ q i , we must have d = d . Similarly, d = d .Applying these two substitutions, Equation 6 becomes 2 d p i a i a i ′ + 2 d p i ′ a i a i ′ = 0. Now consid-ering this equation modulo p i and p i ′ in the same way as before, we find we must have d , d = 0.This implies all d j = 0, a contradiction. Lemma 5.7.
For a solution T full to I A as defined above, consider any subtree T containing x . Itsevaluation ev( T ) is a monomial in x and y .Proof of Lemma 5.7. We show by an induction from the root that the evaluation of any subtree T of solution T full , such that T contains at least one x leaf, is a monomial in x and y .At the root of the tree, our target fulfills this condition.Now we will show that if some x -containing subtree T evaluates to a monomial, then its leftsubtree L and right subtree R do as well. There are two cases:Case 1: L and R contain at least one leaf with value x . By Lemma 5.4, we know that theoperator connecting L and R must be × . Suppose by way of contradiction that the evaluation ofeither L or R had more than one term. Then their product would have more than one term. But T is a monomial. Thus, L and R must both be monomials in x and y .Case 2: One of L or R contain at least one leaf with value x and the other does not. We willshow that in this case, for the evaluation of T to be a monomial it must be rooted at a × operator.This will show that the evaluations of both L and R must be monomials. which will complete ourproof.Assume for the sake of contradiction there is some subtree of T full such this subtree T is rootedat a + or − operator, it evaluates to a monomial in x and y , and it has one child with leaves ofvalue x and another without.Case (i): T has no × operator. Then by Lemma 5.4 it only has one x leaf and its evaluation is ± x plus a sum with form as in Equation 4. By Lemma 5.6 the sum is nonzero, so T would be abinomial, a contradiction.Case(ii): If T has a × operator, but not at the root. Let A be the subtree of highest × operatornode in T . By Lemma 5.5, A must contain some x leaf, and by Lemma 5.4 A must contain all x leaves in T . Thus, T must equal A plus or minus multiples of b i and c i (but not b i × c i , byLemma 5.5). Observe that the sum that we add or subtract from A to form T has degree 0 in x ,degree 1 in y , and by Lemma 5.6 it is nonzero. However, the evaluation of A has no term withdegree 0 in x and degree 1 in y . This is because A was defined to have a × node at the root, soany of its terms with degree 0 in x must be a product of two terms with degree 0 in x , one fromeach of its subtrees. This would require A to have degree at least 2 in y , which it does not. Thus T cannot be a monomial if it is rooted at a + or − operator.We are now ready to prove the claim. Proof of Claim 5.3 .
Let A be an instance of SetProductPartitionBound-
3, and let I A be the( N [ x, y ] , { + , − , ×} ) -AEC-EL instance as defined above.As mentioned in the sketch, if an instance of this product partition variant is solvable, then theconstructed instance evaluates to t ( x, y ) = L n y n x n − Q i ∈ [ n ] p i when we have ( b i + c i ) for a i in one22artition and ( b i − c i ) for a i in the other, and the × operator at every other node. The partitioncorresponds to whether the a i was written as a difference or a sum.We now show that any expression achieving the target must take the form above, and thusimplies the existence of a solution to the instance of the product partition variant.By Lemma 5.7, all subtrees of a solution evaluate to monomials. Thus, addition and subtractioncan only occur between b i and c i . Further, because our target has only one factor of each p i , additionand subtraction must occur between b i and c i , else by Lemma 5.7 both would need to be multipliedin, resulting in an evaluation at the root with too many factors of p i . Thus any tree evaluating tothe target must be the product of x leaves and the sums or differences of b i and c i . This completesthe proof. {− , ×} Claim 5.4. ( N [ x, y ] , {− , ×} ) -AEC-EL is weakly NP-hard. The proof for this claim is very similar to the proof for AEC Enforced Leaves { + , − , ×} inSection 5.2, and will use lemmas and modifications of lemma from the previous section. The keydifference is that we use an additional leaf to represent addition using only subtraction and brackets,as a − (0 − b ) = a + b .As in Section 5.2, let A = { a , . . . , a n } be an instance of SetProductPartitionBound- L = 2 Q i ∈ [ n ] a i , and let p j for j ∈ [ n ] be unique primes greater than 3 that are coprime to Q i ∈ [ n ] a i ( a i + 1)( a i − b i and c i be y times what it was before, sothat b i + c i = ( La i ) p i y and b i − c i = ( L/a i ) p i y . We cannot use 0 in the equation, since it isnon-positive. Instead, we will add some terms of b ′ i = b i + p i y .Let instance I A of ( N [ x, y ] , {− , ×} ) -AEC-EL enforce the following order of leaves: b ′ p y c x b ′ p y c x · · · x b ′ n p n y c n , and have target polynomial t ( x, y ) = L n y n x n − Q i ∈ [ n ] p i .The structure of this proof is similar to the previous section. We can directly use the statementand proof of Lemma 5.4 and Lemma 5.6 (with an extra factor of y canceled in the proof of thelatter). We now state the analogue of Lemma 5.5, as well as the analogue of Lemma 5.7 (whichis the same statement but has an altered proof due to the new problem instance structure), showhow the latter lemma can be applied to prove Claim 5.4, and finally prove the lemmas. Lemma 5.8.
In the evaluation of a solution T full to I A , the coefficient of the term with highestdegree in x must be of the form: Y i F i ( b ′ i , p i y, c i ) where F i ( b ′ i , p i y, c i ) ∈ { c i , b i , b i ± c i } . Lemma 5.9.
For a solution T full to I A consider any subtree T containing x . Its evaluation ev( T ) is a monomial in x and y . To complete the proof of this claim, we prove the two modified lemmas.
Proof of Lemma 5.8.
As in the proof of Lemma 5.5, the coefficient of the term with highest degreein x in the evaluation of T full must be a product of functions of b ′ i , p i y , and c i . Since there is exactlyone factor of each p i in the target, multiplication cannot be used in the construction of F i ( b ′ i , p i y, c i ).Thus using 0, 1, or 2 subtraction operations, we may form the set { b ′ i , c i , b i , p i y − c i , b i ± c i } . Sincethe target is a monomial in x and y , then each F i ( b ′ i , p i y, c i ) must also be a monomial in x and y .Thus F i ( b ′ i , p i y, c i ) ∈ { c i , b i , b i ± c i } . 23 roof of Lemma 5.9. As in the proof of Lemma 5.7, we show by an induction from the root thatfor any solution T full , the evaluation of any subtree T containing x is a monomial in x and y .As before, our target fulfills this condition at the root of the tree, and if both the left subtree L and right subtree R contain at least one leaf with value x , then the evaluation of both subtreesare monomials in x and y . To complete the proof of this lemma we show that the evaluation of T to be a monomial in x and y , then its left or right subtree containing x must also be a monomial.If T is rooted at a × operator and it evaluates to a monomial then the evaluations of both L and R must be monomials.Unlike before, Lemma 5.8 is weaker than its analogue Lemma 5.5, so there is a more complexanalysis of the case where T is rooted at a − operator, one of L or R contain at least one leaf withvalue x , and the other does not.Assume for the sake of contradiction there is some subtree of T full such this subtree T is rootedat a − operator, evaluates to a monomial in x and y , and it has one child without leaves of value x and another which evaluates to a monomial in x and y .Let A be the subtree rooted at the highest × operator that is an ancestor to some x leaf in T ,if there is such an operator. If there is no such operator, then by Lemma 5.4, it A contains onlyone x leaf. Let A be the leaf x . If there is such an operator, then by Lemma 5.4 A contains all x leaves in T . There are at most 6 leaves in T not in A , the 3 to the left of the leftmost x in A whichwe assign index i , and the 3 to the right of the rightmost x in A which we assign index j . There isat least one leaf in T not in A , as T is rooted at a − operator and A lies within it and is rooted ata × operator.We use the following properties: Property 1. ev( T ) − ev( A ) has degree 0 in x and degree 2 or 3 in y .By Lemma 5.4, there are no x leaves in T not in A , so ev( T ) − ev( A ) must have degree 0 in x .By Lemma 5.8, at least one of b ′ i and c i must be in F i ( b ′ i , p i y, c i ), so the degree in y of ev( T ) − ev( A )is at most 3, which occurs when it is the product of p i y and b ′ i or c i . Since there is at least one leafin T not in A , then ev( T ) − ev( A ) has degree at least 1 in y . Further, if there is just a single leaf itcannot be p i y , as that would require multiplying both b ′ i and c i into subtrees containing containing x , which would put too many p i terms in the target. Thus ev( T ) − ev( A ) has degree at least 2 in y . Property 2. ev( T ) − ev( A ) is nonzero.If there are no × operators in T not in A , then the evaluation of T , ev( T ), has form d b ′ i + d p i yd c i ± ev( A ) + d b ′ j + d p j y + d c j for d i ∈ { , ± } and not all d i zero. Note that ev( T ) − ev( A )has degree 0 in x and degree 1 or 2 in y . Observing the part with degree 0 in x and degree 2 in y ,they are a sum with form as in Equation 4, which by Lemma 5.6 is nonzero.If there is some × operator in T not in A , then by Lemma 5.8 the only F i ( b ′ i , p i y, c i ) usingjust less than two leaves is c i , so the evaluation at the × operator must be b ′ i p i y (or b ′ j p j y ). Theevaluation of these subtree that is degree 3 in y is b i p i y and b j p j y . Both these values are nonzero,as are their sum and difference. Thus ev( T ) − ev( A ) is again nonzero.Now, we can finally prove that ev( T ) is not a monomial under these conditions, a contradiction.If ev( A ) is a monomial in x and y , then it cannot have any part with degree 0 in x . By the twoproperties, ev( T ) − ev( A ) is nonzero and has degree 0 in x , so their sum ev( T ) = (ev( T ) − ev( A )) +ev( A ) is not a monomial.If ev( A ) is not a monomial, then we let A L and A R be the left and right subtrees of A . If atleast one of ev( A L ) and ev( A R ) has no part with degree 0 in x , then ev( A ) has no terms withdegree 0 in x . As before since ev( T ) − ev( A ) is nonzero and has degree 0 in x , then ev( T ) is not amonomial. If both ev( A L ) and ev( A R ) have some part with degree 0 in x , then these parts mustalso have degree at least 2 in y (by an analogue of the argument in the first property). Thus thedegree in y of the part of ev( A ) with degree 0 in x is at least 4. By the first property ev( T ) − ev( A )24as degree at most 3 in y , so the parts with with degree 0 in x in ev( A ) and ev( T ) − ev( A ) cannotcancel, implying ev( T ) is not a monomial. Proof of Claim 5.4.
The idea of this proof is the same as the proof from Section 5.2. However, thistime, we will construct either (( b ′ i − p i y ) − c i ) = b i − c i or ( b ′ i − ( p i y − c i )) = b i + c i , making theplacement of parentheses indicate the partition membership instead of the sign.Like before, Lemma 5.9 implies that subtraction can only occur between terms with degree 0in x . Further, because our target has only one factor of each p i , subtraction must occur betweenterms with degree 0 in x , else by Lemma 5.7 both would need to be multiplied in, resulting in anevaluation at the root with too many factors of p i . Thus any tree evaluating to the target mustbe the product of x leaves and one of the two subtraction structures (( b ′ i − p i y ) − c i ) = b i − c i or( b ′ i − ( p i y − c i )) = b i + c i , on the terms of degree 0 in x as we desire.This shows that any solution to the instance can be read as a solution to the underlying SetProductPartitionBound- { + , × , ÷} Claim 5.5. ( N [ x ] , { + , × , ÷} ) -AEC-EL is weakly NP-hard.Proof. We will reduce from
ProductPartition to ( N [ x ] , { + , × , ÷} ) -AEC-EL . For an instance of ProductPartition with elements { a , . . . , a n } , we construct an instance of ( N [ x ] , { + , × , ÷} ) -AEC-EL with leaf order a x a x · · · x a n − x a n and target t ( x ) = x n − .If the ProductPartition instance is solvable then this ( N [ x ] , { + , × , ÷} ) -AEC-EL is solvablewith operations × and ÷ by multiplying the x s and the a i s in the same partition as a and dividingthe other a i s.Furthermore, if an AEC-EL solution only uses the × and ÷ operators, observe that it yields avalid solution to ProductPartition , since the numerator and denominator will provide two setsof a i with equal product.We proceed to show that only × and ÷ can be used in our constructed AEC instance. Thisproof proceeds in four steps, which ultimately show that any evaluation subtree containing k x leaves can only be an x k term or an x − k term. This implies that addition can never occur, as thealternating x and a i pattern we constructed for leaf order would under addition create polynomialsof more than one term, a contradiction.Recall from the paired model of rational function computation in Section 2 that we may repre-sent the evaluation of a subtree T as a pair of integer polynomials ( f T , g T ). Our proof proceeds infour steps:1. First we use an inductive argument to bound the degree of f T and g T at k , the number of x leaves within T .2. Then, we note that the equality condition of the induction, the target is achieved only whenone of f T or g T have degree exactly k .3. We then show that the other integer polynomial ( g T or f T respectively) is a constant.4. Finally, we show by induction from the root that both integer polynomials are monomials asdesired. 25ote the first two steps are together the rational equivalent of Lemma 5.4. Step 1.
For any subtree T represented as ( f T , g T ) , the evaluation of T has degree at most thenumber of x leaves within T . We prove the first step by strong induction on subtrees of increasing height.All subtrees of height 0 (leaves), can be represented by the pair ( a i ,
1) or ( x, h are integer polynomials withdegree at most the number of leaves of value x . We will show this is also true for all subtrees ofheight h + 1.Let T be a subtree of height h + 1 with left subtree L with k L leaves of value x and right subtree R with k R leaves of value x . We will show that the evaluation of T has integer polynomials withdegree at most k T = k L + k R , the number of leaves of value x .Because L and R have height at most h , by the inductive hypothesis the degrees of f L and g L are at most k L ; similarly the degrees of f R and g R are at most k R . Recall the definitions of thefollowing operations:1. ( f T , g T ) = ( f L , g L ) + ( f R , g R ) = ( f L g R + g L f R , g L g R )2. ( f T , g T ) = ( f L , g L ) × ( f R , g R ) = ( f L f R , g L g R )3. ( f T , g T ) = ( f L , g L ) ÷ ( f R , g R ) = ( f L g R , g L f R )Thus, the degrees of both f T and g T are at most the max of the degrees of f L f R , f L g R , g L f R , or g L g R . Each of these terms is the product of two polynomials with degrees k L and k R . Thus, thedegree of each of these is at most k L + k R = k T . This completes step 1. Step 2.
Consider an AEC-EL solution tree T full that meets the target. For a subtree T of T full , represented by ( f T , g T ) , one of f T or g T has degree k T . Let T be a subtree with child subtrees L and R , and define f T , g T , f L , g L , andf R , g R appropri-ately. Let h T be either f T or g T , whichever has larger degree. Define h L and h R in the samemanner. In this step, our goal is to show that deg( h T ) = k T for any subtree of a valid AEC-ELsolution.Recall from Step 1 that the maximum of the degrees of f L f R , f L g R , g L f R , g L g R is at most k T = k L + k R . Observe that equality holds only if deg( h L ) = k L and deg( h R ) = k R ; else the degreeof the product is less than k T .Let T full be the full tree. Observe that if T full evaluates to the target polynomial, thendeg( h T full ) = k T full = n −
1. Since this equality holds only if the equality condition also holds forits left and right subtree, induction from the root shows that one of deg( f T ) = k T or deg( g T ) = k T for all subtrees. This proves the second step. Step 3.
Consider an AEC-EL solution tree T full that meets the target. For a subtree T of T full , one of f T or g T is constant. For all subtrees T , let h T be defined as in the previous step, and recall that it has degree k T .Let c T be the other polynomial and let its degree be d T .Table 2 shows casework for determining the degrees of f T and g T given the options for h L and h R , and the operation. Observe that when combining L and R into T , for these three operationsit always holds that deg( c L ) + deg( c R ) ≤ deg( c T ).The evaluation of T full is some constant multiple of ( x n − ,
1) so deg( c T full ) = 0. Since degreesare non-negative, the degrees of the c polynomials are non-decreasing, and deg( c T full ) = 0, we findthat deg( c T ) = 0 for all subtrees T . 26 egrees of f T ; g T under operation h L , h R + × ÷ f L , f R max( k L + d R , d L + k R ); d L + d R k L + k R ; d L + d R k L + d R ; d L + k R f L , g R k L + k R ; d L + k R k L + d R ; d L + k R k L + k R ; d L + d R g L , f R k L + k R ; k L + d R d L + k R ; k L + d R d L + d R ; k L + k R g L , g R max( k L + d R , d L + k R ); k L + k R d L + d R ; k L + k R d L + k R ; k L + d R Table 2: The degrees of f T ; g T under the three operations +, × , and ÷ in the cases i, j for i, j ∈{ f, g } where deg( i L ) = k L , deg( j R ) = k R , and the other two have degrees d L and d R . Cells wheredeg( h T ) = k T and deg( c T ) = 0 when k L + k R = k T and d L + d R = 0 are highlighted. Step 4.
Let T full be an AEC-EL solution tree that meets the target. For a subtree T of T full represented by ( f T , g T ) , both f T and g T are monomials. We show this by induction from the root. At the root of the tree, we have ( f T full , g T full ) =( x n − , T fulfills ( f T , g T ) = ( b n x k T , b d ) or ( f T , g T ) = ( b n , b d x k T )for constant b n , b d , then its left subtree L and right subtree R also fulfill one of these two conditions.Case 1: k L , k R >
0. ( L and R both contain at least one x leaf.)When k L , k R >
0, then k L , k R < k L + k R = k T . We know by the previous steps that one of f T and g T must have degree k T (call this h T ), and the other must have degree 0 (call this c T ). Table 2highlights the four situations where deg( h T ) = k T and c T constant. In particular, these situationsonly occur under the × and ÷ operations. The resulting expression is of the form: ( h L h R , c L c R ) or( c L c R , h L h R ).Since h T and c T are monomials, then this implies h L h R and c L c R are monomials. The latteris certainly true when c L and c R are constant, and the former is only true when both h L and h R are monomials, because if either has more than one term, then their product must have more thanone term. With the conditions from the previous steps, this means in particular that ( f T , g T ) =( b n x k T , b d ) or ( f T , g T ) = ( b n , b d x k T ) where b n and b d are constant.Case 2: k R > k L = 0. ( R contains an x leaf but L does not.)In this case, L is an a i leaf, and both its integer polynomials are constant. We know h T , c T , h L , c L , c R are monomials, and we would like to show that h R is also a monomial.Note that the operation at T cannot be + because f T = f L g R + g L f R is the sum of a degree k R polynomial and a constant, and thus cannot be a monomial. If the operation at T is × or ÷ , then h R is a monomial because if it were not, then h T could not be a monomial of degree k T .Case 3: k L > k R = 0. ( L contains an x leaf but R does not.) This holds for the same reasonas case 2.Case 4: k L = k R = 0 never happens due to the ordering of our leaves.This completes our proof. In this section, we present some basic results in Arithmetic Expression Construction that do notuse the rational framework: a classification of the hardness of { + } , {×} , {−} , {÷} , { + , −} , and {× , ÷} Arithmetic Expression Construction for all variants, and of {− , ×} and { + , − , ×} ArithmeticExpression Construction for the Enforced Operations variant.( N , { + } ) -AEC- var and ( N , {×} ) -AEC- var are trivial for all variants as any expression involvingjust an addition (multiplication) reduces to a sum (product) of the terms. Checking the solvability27educes to testing that P i a i = t or Q i a i = t and is in P.For ( N , { + , −} ) -AEC- var and ( N , {−} ) -AEC- var variants we prove weak NP-hardness by re-ductions from Partition or Partition- n/
2. We then give pseudopolynomial algorithms for allvariants of ( N , { + , −} ) -AEC- var and ( N , {−} ) -AEC- var . { + , −} , {−} is Weakly NP-hard for All Variants { + , −} is Weakly NP-hard for All Variants To prove hardness of the Standard and Enforced Leaves variants, we reduce from
Partition . Anyexpression E using { + , −} over the set A to be partitioned can be written in the form X i ∈| A | c i a i = X c i =1 a i − X c i = − a i where c i ∈ {± } by distributing the sums and differences of E . We construct an instance of( N , { + , −} ) -AEC- var given by A with target t = 0. If there is a partition ( A , A ) of A with P A = P A , then we can form the expression: a i + a i + · · · + a i k − a j − a j − · · · − a j k ′ = 0 , a i ∈ A , a j ∈ A and if there is an AEC solution we can recover a partition from the coefficients c i .For Enforced Leaves, we choose an arbitrary ordering of the partition set A and produce a( N , { + , −} ) -AEC-EL instance: a a · · · a n , t = 0The expressions formable with this ordering are: a ± a ± a ± · · · ± a n These are the same expressions in the Standard case except that a must be positive. In the contextof our reduction from Partition we can have a ∈ A without loss of generality, so this does notaffect the reduction.For Enforced Operations, we reduce from Partition- n/
2. We create an ( N , { + , −} ) -AEC-EO instance using the same set of integers A and an expression which equates the difference of two setsof n/ t = 0:( + + + · · · ) − ( + + + · · · )It is clear this expression is 0 exactly when the subtracted terms are a partition of A . {−} is Weakly NP-hard Given an instance of
Partition , we produce an instance of ( N , {−} ) -AEC-Std with the same setof positive integers A and target t = 0. If the Partition instance has a solution, we can constructan expression of the form( p − n − · · · − n | A | ) − ( n − p − · · · − p | A | ) = X A − X A = 0with p i in A and n i in A . Conversely, any solution to the produced ( N , {−} ) -AEC-Std instancecan be factored into this form. Since P A = P A and a i > a i ∈ A + A , both A and A have nonzero sum and are thus nonempty. 28 .1.3 Enforced Operations {−} is Weakly NP-hard Given an instance of
Partition - n/
2, we construct an instance of ( N , {−} ) -AEC-EO with thesame set of positive integers A , target t = 0, and operation tree formula( − − − . . . ) − ( − − − . . . )If this instance of {−} - aec-eo has a solution, we can divide A into two complementary subsets A , A as above in Section 6.1.2 such that | A | = | A | = n/ P A = P A . {−} is Weakly NP-hard Given an instance of
Partition , we construct an ( N , {−} ) -AEC-EL instance with the same set ofintegers a i ∈ A plus one 1, target t = 1, and leaf order1 a a a . . . a n . If our instance of
Partition has a solution such that P A = P A where A , A are non-empty complementary subsets of A , there is a solution to the corresponding ( N , {−} ) -AEC-EL instance. Without loss of generality, let A be the subset that contains a . We want our expressionto simplify to 1 − X A + X A , or equivalently 1 + X c i a i where c i = − a i ∈ A and c i = 1 for a i ∈ A .In all constructions, c = −
1, but for any choice of c i where i >
1, we can construct a corre-sponding expression for our instance of ( N , {−} ) -AEC-EL . For a given term a i , if we wish for c i to have the opposite sign of c i − , we insert a parentheses before a i − . We close the parentheticalexpression at the end of the expression: . . . − ( a i − − a i − a i +1 . . . a n )The sign of c i − is unchanged from before, as . . . − a i − − . . . is equivalent to . . . − ( a i − − . . . )with respect to the sign of c i − . Thus we can construct an expression with the given leaf orderingsuch that c i = − a i ∈ A and c i = 1 if a i ∈ A . This evaluates to 1, our target.Conversely if there is a solution for our instance of ( N , {−} ) -AEC-EL ,1 + X c i a i = 1Define A = { a i | a i ∈ A, c i = − } and A = { a i | a i ∈ A, c i = 1 } . X A − X A = X c i a i = 0 X A = X A The two complementary subsets A , A of A have nonzero sum and are thus nonempty. {× , ÷} , {÷} is Strongly NP-hard for All Variants The reductions for ( N , {× , ÷} ) -AEC- var closely follow our reductions for ( N , { + , −} ) -AEC- var .We reduce from ProductPartition or ProductPartition - n/
2, which are both NP-hard.29 .2.1 {× , ÷} is Strongly NP-hard for All Variants To prove hardness of the Standard and Enforced Leaves variants, we reduce from
Product-Partition . Given a
ProductPartition instance A , we will produce an instance of ( N , {× , ÷} ) -AEC- var with the same set of positive integers A and target t = 1.If this instance of ( N , {× , ÷} ) -AEC- var has a solution, we can divide A into two complementarysubsets A and A such that Q A / Q A = t . As t = 1, Π A = Π A . This means that A and A are a valid product-partitioning. If the instance of ProductPartition has a solution, we knowtwo complementary subsets A , A of A exist such that Π A = Π A . Our instance of ( N , {× , ÷} ) -AEC- var allows us assign nodes to produce the expression Π A / Π A = 1.We can construct a similar reduction for Enforced Leaves by choosing an arbitrary ordering ofthe elements in A .For Enforced Operations, we reduce from ProductPartition - n/
2. We construct an instanceof ( N , {× , ÷} ) -AEC-EO using the same set of positive integers A , target t = 1, and an expressiontree of the form ( n × n × · · · × n n/ ) ÷ ( d × d × · · · × d n/ )where there are n/ {÷} is Strongly NP-hard Given an instance of
ProductPartition , we will produce an instance of ( N , {÷} ) -AEC-Std withthe same set of positive integers A and target t = 1.Our instance of ( N , {÷} ) -AEC-Std allows us assign nodes to produce an expression equivalentto Π A ÷ Π A = 1:( n ÷ d ÷ · · · ÷ d | A | ) ÷ ( d ÷ n ÷ · · · ÷ n | A | ) = Π A ÷ Π A where A + A = A ; n i in A and d i in A If Π A = Π A = 1, both A and A must be nonempty.Otherwise, Π A = Π A = 1 and all integers a i ∈ A are 1, making both problems trivial. S ⊇ {÷} is Strongly NP-hard Given an instance of
ProductPartition - n/
2, we will construct an instance of ( N , {÷} ) -AEC-EO with the same set of positive integers A , target t = 1, and tree requiring formula( n ÷ d ÷ · · · ÷ d n/ ) ÷ ( d ÷ n ÷ · · · ÷ n n/ )where there are n/ S ⊆ {÷} in reductions to show that all set of operations S ⊇ {÷} are strongly NP-hard. {÷} is Strongly NP-hard Given an instance of
ProductPartition , we will produce an instance of ( N , {÷} ) -AEC-EL withthe same set of positive integers A and n − t = 1, and leaf order as a a a . . . a n If this instance of ( N , {÷} ) -AEC-EL has a solution, we expand our expression such that ÷ (1 ÷ a i )is simplified to × a i . We can then divide A into two complementary subsets A , containing elements30receded by × after expansion, and A , containing elements preceded by ÷ after expansion, so Q A / Q A = t . As t = 1, Π A = Π A .If the instance of ProductPartition has a solution, we know two complementary subsets A , A of A exist such that Π A = Π A . Assume a ∈ A . Our instance of ( N , {÷} ) -AEC-EL allows us assign operations to produce an expression equivalent to Π A / Π A = 1, by assigning ÷ (1 ÷ a i ) equivalent to × a i for a i ∈ A (except a , which is not preceded by anything and isalready equivalent to × a ) and ÷ ÷ a i equivalent to ÷ a i for a i ∈ A . {− , ×} and { + , − , ×} are Strongly NP-hard Given an instance of
ProductPartition - n/
2, we will produce an instance of ( N , {− , ×} ) -AEC-EO with the same set of positive integers A , target t = 0, and tree requiring formula( × × · · · × ) − ( × × · · · × ) , where there are n/ ProductPartition - n/ A , A of A exist such that Π A = Π A . Our instance of ( N , {− , ×} ) -AEC-EO allows us assignnodes to produce the expression Π A − Π A = 0.Similarly if this instance of ( N , {− , ×} ) -AEC-EO has a solution, we can divide A into twocomplementary subsets A and A such that | A | = | A | = n/ Q A − Q A = t . As t = 0,Π A = Π A .We have shown ( N , {− , ×} ) -AEC-EO is strongly NP-hard. Since ( N , {− , ×} ) -AEC-EO is aspecial case of ( N , { + , − , ×} ) -AEC-EO , ( N , { + , − , ×} ) -AEC-EO is strongly NP-hard as well. { + , ×} is weakly NP-hard To prove that ( N , { + , ×} ) -AEC-EO is weakly NP-hard, we proceed by reduction from 3 -Partition -3, which is 3 -Partition with the extra restriction that all the subsets have size 3. Given an instanceof 3 -Partition -3, A = { a , a , · · · , a n } , construct instance I A of ( N , { + , ×} ) -AEC-EO with thesame set of values A , target t = (cid:16) Sn/ (cid:17) n/ , where S = P i a i , and expression-tree:( + + ) × ( + + ) × · · · × ( + + ) , where there are n/ -Partition -3 instance, one can use the same partition to fill in the 3-sums and solve our ( N , { + , ×} ) -AEC-EO instance. If the constructed instance is solvable, we claimthat each expression ( + + ) must have equal value. Denote the value of the i th ( + + )by s i . Since P i s i = S , the arithmetic mean-geometric mean inequality yields Q n/ i =1 s i ≤ (cid:16) Sn/ (cid:17) n/ ,with equality occurring if and only if s i = Sn/ for all i . This completes the proof. { + , −} , {−} has a Pseudopolynomial Algorithm for All Variants The following pseudopolynomial algorithms demonstrate that the the proofs of weak NP-hardnessfor all variants of ( N , { + , −} ) -AEC- var and ( N , {−} ) -AEC- var are tight.In all variants, all the possible values which are formable from an AEC instance with integers { a , . . . , a n } are of the form X i c i a i , c i ∈ {± } . t , the target number.For example, in ( N , { + , −} ) -AEC-Std , we can construct all expressions of the above form whereat least one c i is positive (the first number in the expression), whereas in ( N , {−} ) -AEC-EL wemust have c = 1 and c = − DPSums effectively evaluates all expressions of the above form. Table entry DP [ i, v ] is true exactly when there is a c j ∈ {± } assignment such that the P j ≤ i c j a j = v .The innermost for loop iterates across all integers possibly already formed and adds or subtracts a i from them to set new table entries. We use DPSums or slight modifications of it to givepseudopolynomial algorithms for all variants of AEC with { + , −} and {−} . Algorithm 1
DP Subroutine procedure DPSums ( { a , . . . , a n } ) DP [ i, v ] ← new table DP [1 , ± a ] ← T rue for i ∈ [2 , n ] do for v ∈ [ − P i − j =0 a j , P i − j =0 a j ] do if DP [ i − , v ] then DP [ i, v ± a i ] ← T rue end if end for end for return DP end procedure6.5.1 { + , −} , {−} has a Pseudopolynomial Algorithm for Standard and EnforcedLeaves For ( N , { + , −} ) -AEC-Std , we can construct any expression of the above form except when all c i = −
1, so our algorithm first checks if t = − P i a i and returns false if so, otherwise returning DPSums ( { a i } )[ n, t ].For ( N , { + , −} ) -AEC-EL , the only requirement one has is that c must equal 1, so we modifyline 3 of DPSums to only set DP [1 , a ] to true, then return DPSums ( { a i } )[ n, t ].The ( N , {−} ) -AEC- var case is slightly more involved. Any expression with purely − operationsmust have at least one c i be positive and one c i be negative. We claim that this is the onlyrestriction and that any other expression is formable. That is, given enforced leaves a a a · · · a n one can form the expressions a − a + X i> c i a i with c i arbitrary. To see this, we use the same sign-flipping procedure from Section 6.1.4 andnote that given a chain of positive coefficients c i following a negative coefficient we can rewrite theexpression using only negative signs via converting: − a i + a i +1 + · · · + a i + k
7→ − ( a i − a i +1 − · · · − a i + k )thus, any ± {−} -ops given that there is always a c i whichis negative preceding any positive c i (with the exception of c = 1). For Enforced Leaves,32his translates to the expression written above, so solvability of an AEC instance is given by DPSums ( { a i } i> )[ n − , t + a − a ].For the Standard variant, ( N , {−} ) -AEC-Std , we can simply loop through all choices of a, a ′ ∈ A and return true if any DPSums ( { a i } − { a, a ′ } )[ n − , t + a ′ − a ] is true. This will check for allexpressions with at least one positive c i and one negative c i . { + , −} , {−} has a Pseudopolynomial Algorithm Trivially, note that ( N , {−} ) -AEC-EO reduces to ( N , { + , −} ) -AEC-EO and thus we need onlyprovide a single algorithm. Any expression E in operations { + , −} expands into an expressionwith k additions and n − k subtractions. Thus, given an instance I = { a i , E } , we can compute thenumber k of additions and then use a similar DP algorithm which keeps count of the number ofadditions used to form a given subexpression. The algorithm is given by DPCount . Algorithm 2
DP Algorithm for { + , −} -AEC-EO procedure DPCount ( { a , . . . , a n } , k ) DP [ i, c, v ] ← new table DP [1 , k − , a ] = T rueDP [1 , k, − a ] = T rue for i ∈ [2 , n ] dofor c ∈ [0 , k ] dofor v ∈ [ − P i − j =0 a j , P i − j =0 a j ] doif DP [ i − , c, v ] then DP [ i, c − , v + a i ] ← T rue, DP [ i, c, v − a i ] ← T rue end ifend forend forend forreturn DP [ n, , end procedure Acknowledgments
This work was initiated during open problem solving in the MIT class on Algorithmic Lower Bounds:Fun with Hardness Proofs (6.892) taught by Erik Demaine in Spring 2019. We thank the otherparticipants of that class — in particular, Josh Gruenstein, Mirai Ikebuchi, and Vilhelm AndersenWoltz — for related discussions and providing an inspiring atmosphere.
References [AB09] Sanjeev Arora and Boaz Barak.
Computational Complexity: A Modern Approach . Cam-bridge University Press, USA, 2009.[AM09] Divesh Aggarwal and Ueli Maurer. Breaking RSA generically is equivalent to factoring.In Antoine Joux, editor,
Advances in Cryptology — EUROCRYPT 2009 , pages 36–53,Berlin, Heidelberg, 2009. Springer Berlin Heidelberg.33BU08] David Buchfuhrer and Christopher Umans. The complexity of boolean formula mini-mization. In Luca Aceto, Ivan Damg a rd, Leslie Ann Goldberg, Magn´us M. Halld´orsson,Anna Ing´olfsd´ottir, and Igor Walukiewicz, editors, Automata, Languages and Program-ming , pages 24–35, Berlin, Heidelberg, 2008. Springer Berlin Heidelberg.[Dij61] E. W. Dijkstra. ALGOL-60 translation. Technical Report MR 34/61, Rekenafdeling,Stichting Mathematisch Centrum, 1961.[DLS81] Peter Downey, Benton Leong, and Ravi Sethi. Computing sequences with additionchains.
SIAM Journal on Computing , 10(3):638–646, 1981.[GJ02] Michael R. Garey and David S. Johnson.
Computers and Intractability . W. H. Freemanand Company, New York, 2002.[Gor98] Daniel M. Gordon. A survey of fast exponentiation methods.
Journal of Algorithms ,27:129–146, 1998.[HS11] Edith Hemaspaandra and Henning Schnoor. Minimization for generalized boolean for-mulas. arXiv:1104.2312, 2011.[KyC00] Valentine Kabanets and Jin yi Cai. Circuit minimization problem. In
Proceedings of the32nd Annual ACM Symposium on Theory of Computing , pages 73–79, Portland, OR,2000.[Mau05] Ueli Maurer. Abstract models of computation in cryptography. In Nigel P. Smart,editor,
Cryptography and Coding , pages 1–12, Berlin, Heidelberg, 2005. Springer BerlinHeidelberg.[NBCK10] C. T. Ng, M. S. Barketau, T. C. E. Cheng, and Mikhail Y. Kovalyov. “Product Parti-tion” and related problems of scheduling and systems reliability: Computational com-plexity and approximation.
European Journal of Operational Research , 207(2):601–604,2010.[Sch37] Arnold Scholz. Aufgaben und L¨osungen 253.
Jahresbericht der DeutschenMathematiker-Vereinigung , 47:41–42, 1937.[Sho97] Victor Shoup. Lower bounds for discrete logarithms and related problems. In WalterFumy, editor,
Advances in Cryptology — EUROCRYPT ’97 , pages 256–266, Berlin,Heidelberg, 1997. Springer Berlin Heidelberg.[vzG88] Joachim von zur Gathen. Algebraic complexity theory. In
Annual Review of ComputerScience , volume 3, pages 317–347. Annual Reviews Inc., 1988.[Wik] Wikipedia. 24 game. https://en.wikipedia.org/wiki/24 Game.[You84] N. J. Young. Linear fractional transformations in rings and modules.
Linear Algebraand its Applications , 56:251–290, 1984.
A Related Problems
To show the NP-hardness of the variants of Arithmetic Expression Construction, we reduce fromthe following problems: 34 roblem 4 ( Partition ) .Instance: A multiset of positive integers A = a , a , . . . , a n . Question:
Can A be partitioned into two subsets with equal sum? Reference: [GJ02], problem SP12.
Comment:
Weakly NP-hard.
Problem 5 ( Partition - n/ .Instance: A multiset of positive integers A = a , a , . . . , a n . Question:
Can A be partitioned into two subsets with equal size n and equal sum? Reference: [GJ02], problem SP12.
Comment:
Weakly NP-hard.
Problem 6 ( ProductPartition ) .Instance: A multiset of positive integers A = a , a , . . . , a n . Question:
Can A be partitioned into two subsets with equal product? Reference: [NBCK10].
Comment:
Strongly NP-hard.
Problem 7 ( ProductPartition - n/ .Instance: A multiset of positive integers A = a , a , . . . , a n . Question:
Can A be partitioned into two subsets with equal size n and equal product? Comment:
Strongly NP-hard. See Theorem A.1.
Problem 8 ( SquareProductPartition ) .Instance: A multiset of square numbers A = a , a , . . . , a n . Question:
Can A be partitioned into two subsets with equal product? Comment:
Strongly NP-hard. See Theorem A.2.
Problem 9 ( SquareProductPartition - n/ .Instance: A multiset of square numbers A = a , a , . . . , a n . Question:
Can A be partitioned into two subsets with equal size n and equal product? Comment:
Strongly NP-hard. See Theorem A.2.
Problem 10 ( SetProductPartitionBound- K ) . nstance: A set (without repetition) of positive integers A = a , a , . . . , a n where a i > K and all prime factors of a i are also greater than K . K is fixed and the primefactors are not specified in the instance. Question:
Can A be partitioned into two subsets with equal product? Reference: [NBCK10].
Comment:
Strongly NP-hard by a modification of the proof for
ProductPartition in [NBCK10]. The reduction constructs a set of positive integers A where all elementsare unique, which we modify by choosing primes factors > K when constructing A . Problem 11 ( -3) .Instance: A multiset of positive integers A = a , a , . . . , a n , with n a multiple of 3. Question:
Can A be partitioned into n/ Reference: [GJ02], problem SP15.
Comment:
Strongly NP-hard, even when all subsets are required to have size 3 (
Theorem A.1.
ProductPartition - n/ is strongly NP-complete.Proof. We can reduce from
ProductPartition to ProductPartition - n/
2. Given instance of
ProductPartition { a , · · · , a n } i with n elements, where n is even, we construct an correspondinginstance of ProductPartition - n/ { a , · · · , a n } ∪ { } ∗ n , where { } ∗ n denotes n instancesof the integer 1.Clearly if we have a valid solution to ProductPartition - n/
2, we have a valid solution tothe instance of
ProductPartition . Conversely, given a valid solution to
ProductPartition ,two subsets S , S ⊆ { a i } i with equal product, the difference between the sizes of S and S isat most n −
2. One can then distribute the 1s as needed to even the out the number of elementsof S and S . We can then construct two sets: S ∪ { } ∗ | S | , S ∪ { } ∗ | S | which form asolution to ProductPartition - n/
2. Strong NP-hardness follows from strong NP-hardness of
ProductPartition - n/ Theorem A.2.
SquareProductPartition and
SquareProductPartition - n/ is stronglyNP-complete.Proof. One can reduce from
ProductPartition to SquareProductPartition by simply tak-ing an instance I = { a i } i ∈ α and producing the instance I ′ = { a i } i ∈ α . Given a partition of α = α ⊔ α such that Q i ∈ α a i = Q i ∈ α a i , the same partition of α will produce a valid partition of I ′ asthe squares will remain equal. The converse also holds by taking noting that Q i ∈ α ′ a i = qQ i ∈ α ′ a i .The same construction above, with the added requirement that | α | = | α | , will reduce from ProductPartition - n/ SquareProductPartition - n/n/