3
$\begingroup$

It seems that Simplify is unable to handle (at least some) expressions involving 22 or more variables. Consider the code snippet below:

X = {x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12};
Y = {y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12};
$Assumptions = 
  Element[X, PositiveIntegers] && Element[Y, PositiveIntegers] && 
   And @@ Table[X[[i]] > Y[[i]], {i, 1, 12}];

Several simplifications all return True as expected:

In[4]:= Simplify[x1 > y1]
Out[4]= True

In[5]:= Simplify[x1 + x2 > y1 + y2]
Out[5]= True

In[6]:= Simplify[Total[X[[1 ;; 10]]] > Total[Y[[1 ;; 10]]]]
Out[6]= True

In[7]:= Simplify[Total[X] > Total[Y[[1 ;; 9]]]] (*21 variables*)
Out[7]= True

However, if I try to simplify an expression involving 22 or more variables, Simplify is unable to handle it:

In[8]:= Simplify[Total[X[[1 ;; 11]]] > Total[Y[[1 ;; 11]]]]
Out[8]= x1 + x10 + x11 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 > 
 y1 + y10 + y11 + y2 + y3 + y4 + y5 + y6 + y7 + y8 + y9
(*True expected*)

In[9]:= Simplify[Total[X] > Total[Y]]
Out[9]= x1 + x10 + x11 + x12 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 > 
 y1 + y10 + y11 + y12 + y2 + y3 + y4 + y5 + y6 + y7 + y8 + y9
(*True expected*)

I couldn't find any global option in the documentation that limits how many variables Simplify will handle. Is there such a parameter that can be increased to deal with more variables? Or is there some other way to handle this many variables? (I also tried using Refine and FullSimplify with the same result).

$\endgroup$
4
$\begingroup$

"Is there a global parameter that limits the number of variables handled by Simplify?"

Yes... System option "SimplificationOptions" gives a list of suboptions and their default settings.:

SystemOptions["Simplif*"]
{"SimplificationOptions" -> {"AssumptionsMaxExponent" -> 25, 
   "AssumptionsMaxNonlinearVariables" -> 4, 
   "AssumptionsMaxVariables" -> 21, "AutosimplifyTrigs" -> True, 
   "AutosimplifyTwoArgumentLog" -> True, 
   "ConvertTrigsToRadicals" -> False, "FiniteSumMaxTerms" -> 30, 
   "FunctionExpandMaxSteps" -> 15, "ListableFirst" -> True, 
   "RestartELProver" -> False, "SimplifyMaxExponents" -> 100, 
   "SimplifyToPiecewise" -> True}}

Your examples hit the limit given by "AssumptionsMaxVariables" -> 21.

You can increase the limits using, for example,

SetSystemOptions["SimplificationOptions" -> "AssumptionsMaxVariables" -> 50]

Note: In version 11.3, using FullSimplify (instead of Simplify) gives True for the last two examples without having to change the system options. Simplify does not return True even if we set a large value for the system option "AssumptionsMaxVariables".

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.