# Solving inequalities for positive Integers

Consider the following;

all = {a, b, c, d, e};
mean = Mean[all];
a1=Accumulate@Prepend[all, 0];
a2=Accumulate@Append[Table[mean, {i, Length[all]}], 0];
a3=a2-a1;
a4=Map[Reduce[# >= 0, all] &, a3]


Now I would like Mathematica to solve this with the restriction that all elements of all are positive Integers.

• Thanks for the answers. I have to admit that I was hoping for a result that says that a4 is always true, for all positive Integers, but as it appears this is not the case. However, I think we can leave my question with the edited heading as it is, in any case, somebody has a similar problem.
– John
Apr 12, 2012 at 22:19

Reduce allows you to specify the domain of Reals, Complexes, or Integers as the third parameter. But, positivity is not directly specifiable at that point. Instead, it must be added to the expr being reduced as an added condition. A simple form of this condition would be

 And @@ Thread[all > 0]


which is equivalent to

a > 0 && b > 0 && c > 0 && d > 0 && e > 0


Combining this with the Integers domain gives this form for Reduce:

Reduce[# >= 0 && And @@ Thread[all > 0], all, Integers] &


As a word of caution, this will result in a very, very large output as Reduce uses GeneratedParameters for its unknown integer coefficients. For the second inequality, this results in 34 unknown coefficients.

This may give you some ideas.

In[230]:= all = {a, b, c, d, e};
mean = Mean[all];
a1 = Accumulate@Prepend[all, 0];
a2 = Accumulate@Append[Table[mean, {i, Length[all]}], 0];
a3 = a2 - a1;


Your solution sets will be unbounded, and require many parameters to describe them. For purposes of illustration I opted instead to combine your inequalities and add another to make the set not too large.

solnb =
Thread[all >= 1], {Element[all, Integers]}], all,
Backsubstitution -> True]

Out[237]= (a == 1 && b == 1 && c == 1 && d == 1 &&
e == 1) || (a == 1 && b == 1 && c == 1 && d == 1 &&
e == 2) || (a == 1 && b == 1 && c == 1 && d == 2 &&
e == 1) || (a == 1 && b == 1 && c == 2 && d == 1 &&
e == 1) || (a == 1 && b == 2 && c == 1 && d == 1 &&
e == 1) || (a == 1 && b == 2 && c == 1 && d == 1 &&
e == 2) || (a == 1 && b == 2 && c == 1 && d == 2 &&
e == 1) || (a == 1 && b == 2 && c == 2 && d == 1 &&
e == 1) || (a == 1 && b == 3 && c == 1 && d == 1 &&
e == 1) || (a == 2 && b == 1 && c == 1 && d == 1 &&
e == 1) || (a == 2 && b == 1 && c == 1 && d == 1 &&
e == 2) || (a == 2 && b == 1 && c == 1 && d == 2 &&
e == 1) || (a == 2 && b == 1 && c == 2 && d == 1 &&
e == 1) || (a == 2 && b == 1 && c == 2 && d == 1 &&
e == 2) || (a == 2 && b == 1 && c == 2 && d == 2 &&
e == 1) || (a == 2 && b == 1 && c == 3 && d == 1 &&
e == 1) || (a == 2 && b == 2 && c == 1 && d == 1 &&
e == 1) || (a == 2 && b == 2 && c == 1 && d == 1 &&
e == 2) || (a == 2 && b == 2 && c == 1 && d == 2 &&
e == 1) || (a == 2 && b == 2 && c == 2 && d == 1 &&
e == 1) || (a == 2 && b == 2 && c == 2 && d == 1 &&
e == 2) || (a == 2 && b == 2 && c == 2 && d == 2 &&
e == 1) || (a == 2 && b == 2 && c == 2 && d == 2 &&
e == 2) || (a == 2 && b == 2 && c == 2 && d == 3 &&
e == 1) || (a == 2 && b == 2 && c == 3 && d == 1 &&
e == 1) || (a == 2 && b == 2 && c == 3 && d == 1 &&
e == 2) || (a == 2 && b == 2 && c == 3 && d == 2 &&
e == 1) || (a == 2 && b == 2 && c == 4 && d == 1 &&
e == 1) || (a == 2 && b == 3 && c == 1 && d == 1 &&
e == 2) || (a == 2 && b == 3 && c == 1 && d == 2 &&
e == 1) || (a == 2 && b == 3 && c == 1 && d == 2 &&
e == 2) || (a == 2 && b == 3 && c == 1 && d == 3 &&
e == 1) || (a == 2 && b == 3 && c == 2 && d == 1 &&
e == 1) || (a == 2 && b == 3 && c == 2 && d == 1 &&
e == 2) || (a == 2 && b == 3 && c == 2 && d == 2 &&
e == 1) || (a == 2 && b == 3 && c == 3 && d == 1 &&
e == 1) || (a == 2 && b == 4 && c == 1 && d == 1 &&
e == 2) || (a == 2 && b == 4 && c == 1 && d == 2 &&
e == 1) || (a == 2 && b == 4 && c == 2 && d == 1 &&
e == 1) || (a == 3 && b == 1 && c == 1 && d == 1 &&
e == 2) || (a == 3 && b == 1 && c == 1 && d == 2 &&
e == 1) || (a == 3 && b == 1 && c == 2 && d == 1 &&
e == 1) || (a == 3 && b == 1 && c == 2 && d == 1 &&
e == 2) || (a == 3 && b == 1 && c == 2 && d == 2 &&
e == 1) || (a == 3 && b == 1 && c == 2 && d == 2 &&
e == 2) || (a == 3 && b == 1 && c == 2 && d == 3 &&
e == 1) || (a == 3 && b == 1 && c == 3 && d == 1 &&
e == 1) || (a == 3 && b == 1 && c == 3 && d == 1 &&
e == 2) || (a == 3 && b == 1 && c == 3 && d == 2 &&
e == 1) || (a == 3 && b == 1 && c == 4 && d == 1 &&
e == 1) || (a == 3 && b == 2 && c == 1 && d == 1 &&
e == 2) || (a == 3 && b == 2 && c == 1 && d == 2 &&
e == 1) || (a == 3 && b == 2 && c == 1 && d == 2 &&
e == 2) || (a == 3 && b == 2 && c == 1 && d == 3 &&
e == 1) || (a == 3 && b == 2 && c == 2 && d == 1 &&
e == 1) || (a == 3 && b == 2 && c == 2 && d == 1 &&
e == 2) || (a == 3 && b == 2 && c == 2 && d == 2 &&
e == 1) || (a == 3 && b == 2 && c == 3 && d == 1 &&
e == 1) || (a == 3 && b == 3 && c == 1 && d == 1 &&
e == 2) || (a == 3 && b == 3 && c == 1 && d == 2 &&
e == 1) || (a == 3 && b == 3 && c == 2 && d == 1 &&
e == 1) || (a == 4 && b == 1 && c == 1 && d == 2 &&
e == 2) || (a == 4 && b == 1 && c == 1 && d == 3 &&
e == 1) || (a == 4 && b == 1 && c == 2 && d == 1 &&
e == 2) || (a == 4 && b == 1 && c == 2 && d == 2 &&
e == 1) || (a == 4 && b == 1 && c == 3 && d == 1 &&
e == 1) || (a == 4 && b == 2 && c == 1 && d == 1 &&
e == 2) || (a == 4 && b == 2 && c == 1 && d == 2 &&
e == 1) || (a == 4 && b == 2 && c == 2 && d == 1 && e == 1)


The way to specify your requirements can be taken from the Reduce invocation above.