In this notebook there are presented examples of usage of shiroin, a python library for proving inequalities of multivariate polynomials.

At the beginning we need to load the packages.

In [1]:
from sympy import *
from shiroindev import *
from IPython.display import Latex
shiro.seed=1
shiro.display=lambda x:display(Latex(x))

shiro.seed=1 sets a seed for proving functions. If you don't write it, you can get a slightly different proof each time you run a function. This line is here only for the sake of reproducibility.

The next line provides a nicer display of proofs, i.e. formulas will be shown instead of LaTeX code of these formulas. Note that this works on Jupyter, but not on the git page.

Now let's make some proofs. We will use problems from https://www.imomath.com/index.php?options=593&lmm=0.

Problem 1

Prove the inequality a2+b2+c2ab+bc+ca, if a,b,c are real numbers.

Function prove tries to prove that given formula is nonnegative, assuming all variables are nonnegative. In this case the nonnegativity assumption is not a problem, since all powers on the left side are even, so if |a|2+|b|2+|c|2|ab|+|ac|+|bc|, then a2+b2+c2=|a|2+|b|2+|c|2|ab|+|ac|+|bc|ab+ac+bc.

In [2]:
prove('(a^2+b^2+c^2-a*b-a*c-b*c)')
numerator: a2abac+b2bc+c2
denominator: 1
status: 0
From weighted AM-GM inequality:
Program couldn't find a solution with integer coefficients. Try to multiple the formula by some integer and run this function again.
ab+ac+bca2+b2+c2
Out[2]:
0

Function prove prints several things. The first two gives us a formula after expanding it. The next one is status, which is the return status of the first use of scipy.optimize.linprog. Possible outputs and explanations are

  • 0 - found a proof with real coefficients,
  • 1 - need more time,
  • 2 - function didn't find a proof,
  • 3,4 - loss of precision (which may happen if it has to work with big numbers).

Then we've got a hint. So let's use it!

In [3]:
prove('(a^2+b^2+c^2-a*b-a*c-b*c)*2')
numerator: 2a22ab2ac+2b22bc+2c2
denominator: 1
status: 0
From weighted AM-GM inequality:
2aba2+b2
2aca2+c2
2bcb2+c2
00
The sum of all inequalities gives us a proof of the inequality.
Out[3]:
0

Problem 2

Find all real numbers such that a2+b2+c2+d2=a(b+c+d).

At first glance it doesn't look like an inequality problem, but actually it is one. If you try to calculate both sides for different values, you can see that the left side of the equation is never less than the right one. So let's try

In [4]:
prove('a^2+b^2+c^2+d^2-a*(b+c+d)')
numerator: a2abacad+b2+c2+d2
denominator: 1
status: 2
Program couldn't find any proof.
ab+ac+ada2+b2+c2+d2
Out[4]:
2

This time prove didn't found the proof. But it doesn't mean that the inequality is not true! prove uses a list of n positive values, where n is a number of variables in the formula. List of values should correspond to the list of variables in alphabetical order. Here are a few tips how to choose the right values.

  1. Consider a function pos(values) which is the sum of the positive addends in the formula after substitution of values to variables. Analogically, let neg(values) be the sum of the negative addends. We should choose such values for which quotient=pos(values)/|neg(values)| is small.
  2. The symmetry group of the formula splits set of variables into orbits. Using the same values for variables in one orbit is recommended. In particular, if the symmetry group of the formula is transitive (for example, when the formula is cyclic), then all values (probably) should be the same.
  3. If the formula is homogeneous, then values=(a1,a2,...,an) provide a proof iff values=(ka1,ka2,...,kan) provides a proof for any kQ+ (as long as you don't run into overflow error).

In the formula above b,c,d are in one orbit and the formula is homogenous, so let's try a=2 and b=c=d=1.

In [5]:
prove('a^2+b^2+c^2+d^2-a*(b+c+d)','2,1,1,1')
Substitute a2e
numerator: b22be+c22ce+d22de+4e2
denominator: 1
status: 0
From weighted AM-GM inequality:
2beb2+e2
2cec2+e2
2ded2+e2
0e2
The sum of all inequalities gives us a proof of the inequality.
Out[5]:
0

Function makes a substitution a2e and try to prove new inequality. This time it succeeded. Moreover, if starting formula is equal to 0, then all these inequalities have to be equalities, so e2=0 and eventually a=0. We can also try a little bit lower value for a.

In [6]:
prove('a^2+b^2+c^2+d^2-a*(b+c+d)','7/4,1,1,1')
Substitute a7f4
numerator: 16b228bf+16c228cf+16d228df+49f2
denominator: 16
status: 0
From weighted AM-GM inequality:
28bf14b2+14f2
28cf14c2+14f2
28df14d2+14f2
02b2+2c2+2d2+7f2
The sum of all inequalities gives us a proof of the inequality.
Out[6]:
0

Now we can see that if a2+b2+c2+d2a(b+c+d)=0, then 7f2+2b2+2c2+2d2=0 and eventually a=b=c=d=0. Note that inequality is proved only for positive numbers (which, by continuity, can be expanded to nonnegative numbers). But using similar argumentation to the one in previous problem, if (a,b,c,d)=(x,y,z,t) is the solution of a2+b2+c2+d2a(b+c+d)=0, then (a,b,c,d)=(|x|,|y|,|z|,|t|) is a solution, too. Since the only nonnegative solution is (0,0,0,0), it means that it is the only solution.

It is worth noting that this time function prove used f as a new variable instead of e. If you want to start a new proof and you don't care about the collision of variables from previous proofs, you can use newproof function, which clears the set of used variables.

We can also use the findvalues function to find values for the proof more automatically. It looks for (local) minimum of the quotient value defined above.

In [7]:
formula=S('a^2+b^2+c^2+d^2-a*(b+c+d)')
numvalues=findvalues(formula)
numvalues
Optimization terminated successfully.
         Current function value: 1.154701
         Iterations: 68
         Function evaluations: 127
Out[7]:
(1.4339109663193974,
 0.8278441585048405,
 0.8279027492686561,
 0.8278930696996669)

If the quotient value were less than 1, that would mean that the formula is negative for given values. If quotient were equal to 1, then we have to choose exactly these values (or other values for which the quotient is equal to 1. But here quotient is greater than 1, so we can take a point near it and (probably) still have a proof. The values given to the prove function must not be floating point numbers, so we can rationalize them.

In [8]:
values=nsimplify(numvalues,tolerance=0.1,rational=True)
values
Out[8]:
(107, 56, 56, 56)
In [9]:
newproof()
prove(formula,values)
Substitute a10e7
Substitute b5f6
Substitute c5g6
Substitute d5h6
numerator: 3600e22100ef2100eg2100eh+1225f2+1225g2+1225h2
denominator: 1764
status: 0
From weighted AM-GM inequality:
2100ef1050e2+1050f2
2100eg1050e2+1050g2
2100eh1050e2+1050h2
0450e2+175f2+175g2+175h2
The sum of all inequalities gives us a proof of the inequality.
Out[9]:
0

If you set the tolerance bigger, then the values will have smaller numerators and denominators, so coefficients in the proof will be smaller, too. But if the tolerance is too big, then proof will not be found.

Let's skip the problem 3 and look solve the problem 4 instead.

Problem 4

If x and y are two positive numbers less than 1, prove that

11x2+11y221xy.

In [10]:
prove('1/(1-x^2)+1/(1-y^2)-2/(1-x*y)')
numerator: x3y+2x2y2x2xy3+2xyy2
denominator: x3y3x3yx2y2+x2xy3+xy+y21
status: 2
Program couldn't find any proof.
x3y+x2+xy3+y22x2y2+2xy
It looks like the formula is symmetric. You can assume without loss of generality that x >= y. Try
prove(makesubs(S("-x**3*y + 2*x**2*y**2 - x**2 - x*y**3 + 2*x*y - y**2"),[('y', 'oo')])
Out[10]:
2

prove assumes that formula is well-defined if all variables are positive, so it doesn't have to analyze the denominator (except of choosing the right sign). In this case it is not true, since if x=1, then 1x2=0. Also denominator is equal to (x21)(y21)(xy1) which is negative for x,y(0,1). So we need to make some substitution after which new variables can have all positive values, not just these inside (0,1) interval.

We will use a function makesubs to generate these substitutions. It has three basic parameters: formula, intervals and values. intervals are current limitations of variables, values are values of variables for which quotient of formula is small. values should be inside corresponding intervals. This argument is optional but it's better to use it. Let's go back to our problem. If x=y, then 11x2+11y221xy, so it's the minimum value of the formula. So let values=(1/2,1/2) (warning: do not use decimal point, for example '0.5,0.5').

In [11]:
newproof()
newformula,newvalues=makesubs('1/(1-x^2)+1/(1-y^2)-2/(1-x*y)','[0,1],[0,1]','1/2,1/2')
prove(newformula*3,newvalues)
Substitute x11a+1
Substitute y11b+1
numerator: 6a3b+3a312a2b23a2b+3a2+6ab33ab26ab+3b3+3b2
denominator: 4a2b+2a2+4ab2+8ab+3a+2b2+3b+1
status: 0
From weighted AM-GM inequality:
12a2b26a3b+6ab3
3a2b2a3+b3
3ab2a3+2b3
6ab3a2+3b2
00
The sum of all inequalities gives us a proof of the inequality.
Out[11]:
0

Now let's get back to problem 3.

Problem 3

If a,b,c are positive real numbers that satisfy a2+b2+c2=1, find the minimal value of

a2b2c2+b2c2a2+c2a2b2

The problem is equivalent to finding minimum of xy/z+yz/x+zx/y assuming x+y+z=1 and x,y,z>0. The first idea is to suppose that the minimum is reached when x=y=z. In that case, x=y=z=1/3 and formula is equal to 1. Now we can substitute z1xy. Constraints for variables are x>0, y>0, x+y<1. We can rewrite it as x(0,1y), y(0,1). These two conditions have two important properties:

  • constraints for variables are written as intervals,
  • there are no "backwards dependencies", i.e. there is no x in the interval of y.

If these two conditions hold, then you can use makesubs function.

In [12]:
newproof()
formula=Sm('xy/z+yz/x+zx/y-1').subs('z',S('1-x-y'))
newformula,values=makesubs(formula,'[0,1-y],[0,1]','1/3,1/3')
prove(newformula,values)
Substitute xy+1+y1a+1
Substitute y11b+1
Substitute bc2
numerator: a4c2+a3c22a3c4a2c+4a2+ac22ac+c2
denominator: a3c2+2a3c+2a2c2+4a2c+ac2+2ac
status: 0
From weighted AM-GM inequality:
2a3ca4c2+a2
4a2ca3c2+2a2+ac2
2aca2+c2
00
The sum of all inequalities gives us a proof of the inequality.
Out[12]:
0

The proof is found, so the assumption that 1 is the minimum of xy/z+yz/x+zx/y was good.

Functions S and Sm creates a SymPy object from a string. The only difference is that Sm assumes that there are no multi-letter variables and adds a multiplication sign between every two terms which has no operator sign, so object Sm(xy/z+yz/x+zx/y) has 3 variables x,y,z and S('xy/z+yz/x+zx/y') has 6 variables x,y,z,xy,yz,zx.

As you may have noticed, formulas are often cyclic or symmetric. Therefore you can use cyclize or symmetrize function to reduce the length of the written formula. Here are a few commands which will do the same as each other.

In [13]:
prove('(a^2+b^2+c^2-a*b-a*c-b*c)*2')
#prove(S('(a^2+b^2+c^2-a*b-a*c-b*c)*2'))
#prove(Sm('2(a^2+b^2+c^2-ab-ac-bc)'))
#prove(cyclize('2*a^2-2*a*b'))
#prove(symmetrize('a^2-a*b'))
numerator: 2a22ab2ac+2b22bc+2c2
denominator: 1
status: 0
From weighted AM-GM inequality:
2aba2+b2
2aca2+c2
2bcb2+c2
00
The sum of all inequalities gives us a proof of the inequality.
Out[13]:
0

Now look at formula (x1)4. It's quite obvious that it's nonnegative, but prove fails to show this!

In [14]:
prove('(x-1)^4')
numerator: x44x3+6x24x+1
denominator: 1
status: 2
Program couldn't find any proof.
4x3+4xx4+6x2+1
Out[14]:
2

But there is a relatively simple method to generate a proof using this library. We will make to proofs: one for x(1,) and the second one for (,1).

In [15]:
newproof()
prove(makesubs('(x-1)^4','(1,oo)'))
Substitute xa+1
numerator: a4
denominator: 1
status: 0
0a4
The sum of all inequalities gives us a proof of the inequality.
Out[15]:
0
In [16]:
newproof()
prove(makesubs('(x-1)^4','(-oo,1)'))
Substitute x1a
numerator: a4
denominator: 1
status: 0
0a4
The sum of all inequalities gives us a proof of the inequality.
Out[16]:
0

Now let's go to the problem 10

Problem 10

If a,b,c,d>0, prove that

ab+c+bc+d+cd+a+da+b2.

Let's try a simple approach.

In [17]:
formula=cyclize('a/(b+c)',variables='a,b,c,d')-2
formula
Out[17]:
ab+c+bc+d+ca+d+da+b2
In [18]:
prove(formula)
numerator: a3c+a3d+a2b2a2bd2a2c2a2cd+a2d2+ab3ab2cab2dabc2+ac3acd2+b3d+b2c22b2d2+bc3bc2dbcd2+bd3+c2d2+cd3
denominator: a2bc+a2bd+a2c2+a2cd+ab2c+ab2d+abc2+2abcd+abd2+ac2d+acd2+b2cd+b2d2+bc2d+bcd2
status: 2
Program couldn't find any proof.
a2bd+2a2c2+a2cd+ab2c+ab2d+abc2+acd2+2b2d2+bc2d+bcd2a3c+a3d+a2b2+a2d2+ab3+ac3+b3d+b2c2+bc3+bd3+c2d2+cd3
Out[18]:
2

This problem, like the previous one, can be solved by splitting the domain of variables to several subdomains. But we can also use the symmetry of this inequality. For example, without loss of generality we can assume that ac and bd, so a[c,), b[d,).

In [19]:
newproof()
prove(makesubs(formula,'[c,oo],[d,oo]'))
Substitute ac+e
Substitute bd+f
numerator: c2e2c2ef+c2f2+2cde2+2cdf2+ce3+cef2+cf3+d2e2+d2ef+d2f2+de3+de2f+2def2+df3+e2f2+ef3
denominator: c4+4c3d+2c3e+2c3f+6c2d2+6c2de+6c2df+c2e2+3c2ef+c2f2+4cd3+6cd2e+6cd2f+2cde2+6cdef+2cdf2+ce2f+cef2+d4+2d3e+2d3f+d2e2+3d2ef+d2f2+de2f+def2
status: 0
From weighted AM-GM inequality:
Program couldn't find a solution with integer coefficients. Try to multiple the formula by some integer and run this function again.
c2efc2e2+c2f2+2cde2+2cdf2+ce3+cef2+cf3+d2e2+d2ef+d2f2+de3+de2f+2def2+df3+e2f2+ef3
Out[19]:
0
In [20]:
newproof()
prove(makesubs(formula,'[c,oo],[d,oo]')*2)
Substitute ac+e
Substitute bd+f
numerator: 2c2e22c2ef+2c2f2+4cde2+4cdf2+2ce3+2cef2+2cf3+2d2e2+2d2ef+2d2f2+2de3+2de2f+4def2+2df3+2e2f2+2ef3
denominator: c4+4c3d+2c3e+2c3f+6c2d2+6c2de+6c2df+c2e2+3c2ef+c2f2+4cd3+6cd2e+6cd2f+2cde2+6cdef+2cdf2+ce2f+cef2+d4+2d3e+2d3f+d2e2+3d2ef+d2f2+de2f+def2
status: 0
From weighted AM-GM inequality:
2c2efc2e2+c2f2
0c2e2+c2f2+4cde2+4cdf2+2ce3+2cef2+2cf3+2d2e2+2d2ef+2d2f2+2de3+2de2f+4def2+2df3+2e2f2+2ef3
The sum of all inequalities gives us a proof of the inequality.
Out[20]:
0

It's a good idea to use intervals that are unbounded from one side (i.e. those which contain ±). In this problem we could assume that a(0,c], b(0,d] as well. But as you can see, in this case the proof is several times longer.

In [21]:
newproof()
prove(makesubs(formula,'[0,c],[0,d]')*2)
Substitute acce+1
Substitute bddf+1
numerator: 2c4ef3+6c4ef2+6c4ef+2c4e2c3de2f24c3de2f2c3de2+4c3def3+8c3def2+4c3def+2c3df3+4c3df2+2c3df+2c2d2e3f+2c2d2e3+4c2d2e2f+4c2d2e2+2c2d2ef3+4c2d2ef2+6c2d2ef+4c2d2e+2c2d2f3+4c2d2f2+4c2d2f+2c2d2+4cd3e3f+2cd3e3+2cd3e2f2+12cd3e2f+6cd3e2+4cd3ef2+12cd3ef+6cd3e+2cd3f2+4cd3f+2cd3+2d4e3f+6d4e2f+6d4ef+2d4f
denominator: c4e3f3+3c4e3f2+3c4e3f+c4e3+c4e2f3+3c4e2f2+3c4e2f+c4e2+4c3de3f3+10c3de3f2+8c3de3f+2c3de3+6c3de2f3+15c3de2f2+12c3de2f+3c3de2+2c3def3+5c3def2+4c3def+c3de+6c2d2e3f3+12c2d2e3f2+7c2d2e3f+c2d2e3+12c2d2e2f3+24c2d2e2f2+14c2d2e2f+2c2d2e2+7c2d2ef3+14c2d2ef2+8c2d2ef+c2d2e+c2d2f3+2c2d2f2+c2d2f+4cd3e3f3+6cd3e3f2+2cd3e3f+10cd3e2f3+15cd3e2f2+5cd3e2f+8cd3ef3+12cd3ef2+4cd3ef+2cd3f3+3cd3f2+cd3f+d4e3f3+d4e3f2+3d4e2f3+3d4e2f2+3d4ef3+3d4ef2+d4f3+d4f2
status: 0
From weighted AM-GM inequality:
2c3de2f2c4ef3+c2d2e3f
2c3de2c4e+c2d2e3
4c3de2fc4ef3+c4e+c2d2e3f+c2d2e3
06c4ef2+6c4ef+4c3def3+8c3def2+4c3def+2c3df3+4c3df2+2c3df+4c2d2e2f+4c2d2e2+2c2d2ef3+4c2d2ef2+6c2d2ef+4c2d2e+2c2d2f3+4c2d2f2+4c2d2f+2c2d2+4cd3e3f+2cd3e3+2cd3e2f2+12cd3e2f+6cd3e2+4cd3ef2+12cd3ef+6cd3e+2cd3f2+4cd3f+2cd3+2d4e3f+6d4e2f+6d4ef+2d4f
The sum of all inequalities gives us a proof of the inequality.
Out[21]:
0

Function powerprove is a shortcut for splitting domain R+n on several subdomains and proving the inequality for each of them. This function uses 2n of n-dimensional intervals with a common point (by default it's (1,1,...,1)), where n is a number of variables. Here there are two examples of using it. As you can see, proofs are very long.

In [22]:
newproof()
#this is equivalent to
#prove(makesubs('(x-1)^4','[1,oo]'))
#prove(makesubs('(x-1)^4','[1,0]')) 
#you can write ends of interval in any order, so [1,0] is the same as [0,1]
#but the substitution is slightly simpler when 0 is on the right side
powerprove('(x-1)^4')
numerator: x44x3+6x24x+1
denominator: 1
_______________________
Substitute x1+a
Numerator after substitutions: a4
status: 0
0a4
The sum of all inequalities gives us a proof of the inequality.
_______________________
Substitute x1/(1+b)
Numerator after substitutions: b4
status: 0
0b4
The sum of all inequalities gives us a proof of the inequality.
Out[22]:
Counter({0: 2})
In [23]:
newproof()
formula=Sm('-(3a+2b+c)(2a^3+3b^2+6c+1)+(4a+4b+4c)(a^4+b^3+c^2+3)')
#this is equivalent to
#prove(makesubs(formula,'[1,oo],[1,oo],[1,oo]'))
#prove(makesubs(formula,'[1,0],[1,oo],[1,oo]'))
#prove(makesubs(formula,'[1,oo],[1,0],[1,oo]'))
#prove(makesubs(formula,'[1,0],[1,0],[1,oo]'))
#prove(makesubs(formula,'[1,oo],[1,oo],[1,0]'))
#prove(makesubs(formula,'[1,0],[1,oo],[1,0]'))
#prove(makesubs(formula,'[1,oo],[1,0],[1,0]'))
#prove(makesubs(formula,'[1,0],[1,0],[1,0]'))
powerprove(formula)
numerator: 4a5+4a4b+4a4c6a44a3b2a3c+4ab39ab2+4ac218ac+9a+4b4+4b3c6b33b2c+4bc212bc+10b+4c36c2+11c
denominator: 1
_______________________
Substitute a1+d,b1+e,c1+f
Numerator after substitutions: 4d5+4d4e+4d4f+22d4+12d3e+14d3f+42d3+12d2e+18d2f+34d2+4de3+3de22de+4df2+4e4+4e3f+18e3+9e2f+18e2+4ef2+2ef+4f3+14f2
status: 0
From weighted AM-GM inequality:
2ded2+e2
04d5+4d4e+4d4f+22d4+12d3e+14d3f+42d3+12d2e+18d2f+33d2+4de3+3de2+4df2+4e4+4e3f+18e3+9e2f+17e2+4ef2+2ef+4f3+14f2
The sum of all inequalities gives us a proof of the inequality.
_______________________
Substitute a1/(1+g),b1+h,c1+i
Numerator after substitutions: 4g5h4+4g5h3i+14g5h3+9g5h2i+15g5h2+4g5hi2+2g5hi+6g5h+4g5i3+10g5i2+8g5i+10g5+20g4h4+20g4h3i+74g4h3+45g4h2i+78g4h2+20g4hi2+10g4hi+24g4h+20g4i3+54g4i2+30g4i+40g4+40g3h4+40g3h3i+156g3h3+90g3h2i+162g3h2+40g3hi2+20g3hi+36g3h+40g3i3+116g3i2+40g3i+60g3+40g2h4+40g2h3i+164g2h3+90g2h2i+168g2h2+40g2hi2+20g2hi+20g2h+40g2i3+124g2i2+18g2i+34g2+20gh4+20gh3i+86gh3+45gh2i+87gh2+20ghi2+10ghi+2gh+20gi3+66gi2+4h4+4h3i+18h3+9h2i+18h2+4hi2+2hi+4i3+14i2
status: 0
04g5h4+4g5h3i+14g5h3+9g5h2i+15g5h2+4g5hi2+2g5hi+6g5h+4g5i3+10g5i2+8g5i+10g5+20g4h4+20g4h3i+74g4h3+45g4h2i+78g4h2+20g4hi2+10g4hi+24g4h+20g4i3+54g4i2+30g4i+40g4+40g3h4+40g3h3i+156g3h3+90g3h2i+162g3h2+40g3hi2+20g3hi+36g3h+40g3i3+116g3i2+40g3i+60g3+40g2h4+40g2h3i+164g2h3+90g2h2i+168g2h2+40g2hi2+20g2hi+20g2h+40g2i3+124g2i2+18g2i+34g2+20gh4+20gh3i+86gh3+45gh2i+87gh2+20ghi2+10ghi+2gh+20gi3+66gi2+4h4+4h3i+18h3+9h2i+18h2+4hi2+2hi+4i3+14i2
The sum of all inequalities gives us a proof of the inequality.
_______________________
Substitute a1+j,b1/(1+k),c1+l
Numerator after substitutions: 4j5k4+16j5k3+24j5k2+16j5k+4j5+4j4k4l+18j4k4+16j4k3l+76j4k3+24j4k2l+120j4k2+16j4kl+84j4k+4j4l+22j4+14j3k4l+30j3k4+56j3k3l+132j3k3+84j3k2l+216j3k2+56j3kl+156j3k+14j3l+42j3+18j2k4l+22j2k4+72j2k3l+100j2k3+108j2k2l+168j2k2+72j2kl+124j2k+18j2l+34j2+4jk4l2+jk4+16jk3l2+8jk3+24jk2l2+9jk2+16jkl2+2jk+4jl2+4k4l3+10k4l2+3k4l+4k4+16k3l3+44k3l2+8k3l+18k3+24k2l3+72k2l2+3k2l+18k2+16kl3+52kl22kl+4l3+14l2
status: 0
From weighted AM-GM inequality:
2klk2+l2
04j5k4+16j5k3+24j5k2+16j5k+4j5+4j4k4l+18j4k4+16j4k3l+76j4k3+24j4k2l+120j4k2+16j4kl+84j4k+4j4l+22j4+14j3k4l+30j3k4+56j3k3l+132j3k3+84j3k2l+216j3k2+56j3kl+156j3k+14j3l+42j3+18j2k4l+22j2k4+72j2k3l+100j2k3+108j2k2l+168j2k2+72j2kl+124j2k+18j2l+34j2+4jk4l2+jk4+16jk3l2+8jk3+24jk2l2+9jk2+16jkl2+2jk+4jl2+4k4l3+10k4l2+3k4l+4k4+16k3l3+44k3l2+8k3l+18k3+24k2l3+72k2l2+3k2l+17k2+16kl3+52kl2+4l3+13l2
The sum of all inequalities gives us a proof of the inequality.
_______________________
Substitute a1/(1+m),b1/(1+n),c1+o
Numerator after substitutions: 4m5n4o3+6m5n4o2+11m5n4o+9m5n4+16m5n3o3+28m5n3o2+40m5n3o+38m5n3+24m5n2o3+48m5n2o2+51m5n2o+57m5n2+16m5no3+36m5no2+30m5no+34m5n+4m5o3+10m5o2+8m5o+10m5+20m4n4o3+34m4n4o2+45m4n4o+40m4n4+80m4n3o3+156m4n3o2+160m4n3o+170m4n3+120m4n2o3+264m4n2o2+195m4n2o+246m4n2+80m4no3+196m4no2+110m4no+136m4n+20m4o3+54m4o2+30m4o+40m4+40m3n4o3+76m3n4o2+70m3n4o+70m3n4+160m3n3o3+344m3n3o2+240m3n3o+300m3n3+240m3n2o3+576m3n2o2+270m3n2o+414m3n2+160m3no3+424m3no2+140m3no+204m3n+40m3o3+116m3o2+40m3o+60m3+40m2n4o3+84m2n4o2+48m2n4o+58m2n4+160m2n3o3+376m2n3o2+152m2n3o+248m2n3+240m2n2o3+624m2n2o2+138m2n2o+312m2n2+160m2no3+456m2no2+52m2no+116m2n+40m2o3+124m2o2+18m2o+34m2+20mn4o3+46mn4o2+15mn4o+19mn4+80mn3o3+204mn3o2+40mn3o+82mn3+120mn2o3+336mn2o2+15mn2o+81mn2+80mno3+244mno210mno2mn+20mo3+66mo2+4n4o3+10n4o2+3n4o+4n4+16n3o3+44n3o2+8n3o+18n3+24n2o3+72n2o2+3n2o+18n2+16no3+52no22no+4o3+14o2
status: 0
From weighted AM-GM inequality:
2mnm2+n2
2non2+o2
10mno2m2+2mn2o+4mo2+2n3
04m5n4o3+6m5n4o2+11m5n4o+9m5n4+16m5n3o3+28m5n3o2+40m5n3o+38m5n3+24m5n2o3+48m5n2o2+51m5n2o+57m5n2+16m5no3+36m5no2+30m5no+34m5n+4m5o3+10m5o2+8m5o+10m5+20m4n4o3+34m4n4o2+45m4n4o+40m4n4+80m4n3o3+156m4n3o2+160m4n3o+170m4n3+120m4n2o3+264m4n2o2+195m4n2o+246m4n2+80m4no3+196m4no2+110m4no+136m4n+20m4o3+54m4o2+30m4o+40m4+40m3n4o3+76m3n4o2+70m3n4o+70m3n4+160m3n3o3+344m3n3o2+240m3n3o+300m3n3+240m3n2o3+576m3n2o2+270m3n2o+414m3n2+160m3no3+424m3no2+140m3no+204m3n+40m3o3+116m3o2+40m3o+60m3+40m2n4o3+84m2n4o2+48m2n4o+58m2n4+160m2n3o3+376m2n3o2+152m2n3o+248m2n3+240m2n2o3+624m2n2o2+138m2n2o+312m2n2+160m2no3+456m2no2+52m2no+116m2n+40m2o3+124m2o2+18m2o+31m2+20mn4o3+46mn4o2+15mn4o+19mn4+80mn3o3+204mn3o2+40mn3o+82mn3+120mn2o3+336mn2o2+13mn2o+81mn2+80mno3+244mno2+20mo3+62mo2+4n4o3+10n4o2+3n4o+4n4+16n3o3+44n3o2+8n3o+16n3+24n2o3+72n2o2+3n2o+16n2+16no3+52no2+4o3+13o2
The sum of all inequalities gives us a proof of the inequality.
_______________________
Substitute a1+p,b1+q,c1/(1+r)
Numerator after substitutions: 4p5r3+12p5r2+12p5r+4p5+4p4qr3+12p4qr2+12p4qr+4p4q+18p4r3+58p4r2+62p4r+22p4+12p3qr3+36p3qr2+36p3qr+12p3q+28p3r3+98p3r2+112p3r+42p3+12p2qr3+36p2qr2+36p2qr+12p2q+16p2r3+66p2r2+84p2r+34p2+4pq3r3+12pq3r2+12pq3r+4pq3+3pq2r3+9pq2r2+9pq2r+3pq22pqr36pqr26pqr2pq+4pr3+4pr2+4q4r3+12q4r2+12q4r+4q4+14q3r3+46q3r2+50q3r+18q3+9q2r3+36q2r2+45q2r+18q2+2qr32qr+10r3+14r2
status: 0
From weighted AM-GM inequality:
2pqr3p2qr3+qr3
2pqp2+q2
2qrq2+r2
6pqr2p3q+2q2r+2r2
6pqr22pq2r3+pq2+3pr2
04p5r3+12p5r2+12p5r+4p5+4p4qr3+12p4qr2+12p4qr+4p4q+18p4r3+58p4r2+62p4r+22p4+12p3qr3+36p3qr2+36p3qr+10p3q+28p3r3+98p3r2+112p3r+42p3+11p2qr3+36p2qr2+36p2qr+12p2q+16p2r3+66p2r2+84p2r+33p2+4pq3r3+12pq3r2+12pq3r+4pq3+pq2r3+9pq2r2+9pq2r+2pq2+4pr3+pr2+4q4r3+12q4r2+12q4r+4q4+14q3r3+46q3r2+50q3r+18q3+9q2r3+36q2r2+43q2r+16q2+qr3+10r3+11r2
The sum of all inequalities gives us a proof of the inequality.
_______________________
Substitute a1/(1+s),b1+t,c1/(1+u)
Numerator after substitutions: 4s5t4u3+12s5t4u2+12s5t4u+4s5t4+10s5t3u3+34s5t3u2+38s5t3u+14s5t3+6s5t2u3+27s5t2u2+36s5t2u+15s5t2+8s5tu3+18s5tu2+16s5tu+6s5t+8s5u3+24s5u2+22s5u+10s5+20s4t4u3+60s4t4u2+60s4t4u+20s4t4+54s4t3u3+182s4t3u2+202s4t3u+74s4t3+33s4t2u3+144s4t2u2+189s4t2u+78s4t2+34s4tu3+72s4tu2+62s4tu+24s4t+44s4u3+114s4u2+90s4u+40s4+40s3t4u3+120s3t4u2+120s3t4u+40s3t4+116s3t3u3+388s3t3u2+428s3t3u+156s3t3+72s3t2u3+306s3t2u2+396s3t2u+162s3t2+56s3tu3+108s3tu2+88s3tu+36s3t+96s3u3+216s3u2+140s3u+60s3+40s2t4u3+120s2t4u2+120s2t4u+40s2t4+124s2t3u3+412s2t3u2+452s2t3u+164s2t3+78s2t2u3+324s2t2u2+414s2t2u+168s2t2+40s2tu3+60s2tu2+40s2tu+20s2t+100s2u3+190s2u2+84s2u+34s2+20st4u3+60st4u2+60st4u+20st4+66st3u3+218st3u2+238st3u+86st3+42st2u3+171st2u2+216st2u+87st2+12stu3+6stu24stu+2st+46su3+66su2+4t4u3+12t4u2+12t4u+4t4+14t3u3+46t3u2+50t3u+18t3+9t2u3+36t2u2+45t2u+18t2+2tu32tu+10u3+14u2
status: 0
From weighted AM-GM inequality:
4stus2u2+2st2+u2
2tut2+u2
04s5t4u3+12s5t4u2+12s5t4u+4s5t4+10s5t3u3+34s5t3u2+38s5t3u+14s5t3+6s5t2u3+27s5t2u2+36s5t2u+15s5t2+8s5tu3+18s5tu2+16s5tu+6s5t+8s5u3+24s5u2+22s5u+10s5+20s4t4u3+60s4t4u2+60s4t4u+20s4t4+54s4t3u3+182s4t3u2+202s4t3u+74s4t3+33s4t2u3+144s4t2u2+189s4t2u+78s4t2+34s4tu3+72s4tu2+62s4tu+24s4t+44s4u3+114s4u2+90s4u+40s4+40s3t4u3+120s3t4u2+120s3t4u+40s3t4+116s3t3u3+388s3t3u2+428s3t3u+156s3t3+72s3t2u3+306s3t2u2+396s3t2u+162s3t2+56s3tu3+108s3tu2+88s3tu+36s3t+96s3u3+216s3u2+140s3u+60s3+40s2t4u3+120s2t4u2+120s2t4u+40s2t4+124s2t3u3+412s2t3u2+452s2t3u+164s2t3+78s2t2u3+324s2t2u2+414s2t2u+168s2t2+40s2tu3+60s2tu2+40s2tu+20s2t+100s2u3+189s2u2+84s2u+34s2+20st4u3+60st4u2+60st4u+20st4+66st3u3+218st3u2+238st3u+86st3+42st2u3+171st2u2+216st2u+85st2+12stu3+6stu2+2st+46su3+66su2+4t4u3+12t4u2+12t4u+4t4+14t3u3+46t3u2+50t3u+18t3+9t2u3+36t2u2+45t2u+17t2+2tu3+10u3+12u2
The sum of all inequalities gives us a proof of the inequality.
_______________________
Substitute a1+v,b1/(1+w),c1/(1+x)
Numerator after substitutions: 4v5w4x3+12v5w4x2+12v5w4x+4v5w4+16v5w3x3+48v5w3x2+48v5w3x+16v5w3+24v5w2x3+72v5w2x2+72v5w2x+24v5w2+16v5wx3+48v5wx2+48v5wx+16v5w+4v5x3+12v5x2+12v5x+4v5+14v4w4x3+46v4w4x2+50v4w4x+18v4w4+60v4w3x3+196v4w3x2+212v4w3x+76v4w3+96v4w2x3+312v4w2x2+336v4w2x+120v4w2+68v4wx3+220v4wx2+236v4wx+84v4w+18v4x3+58v4x2+62v4x+22v4+16v3w4x3+62v3w4x2+76v3w4x+30v3w4+76v3w3x3+284v3w3x2+340v3w3x+132v3w3+132v3w2x3+480v3w2x2+564v3w2x+216v3w2+100v3wx3+356v3wx2+412v3wx+156v3w+28v3x3+98v3x2+112v3x+42v3+4v2w4x3+30v2w4x2+48v2w4x+22v2w4+28v2w3x3+156v2w3x2+228v2w3x+100v2w3+60v2w2x3+288v2w2x2+396v2w2x+168v2w2+52v2wx3+228v2wx2+300v2wx+124v2w+16v2x3+66v2x2+84v2x+34v2+5vw4x3+7vw4x2+3vw4x+vw4+24vw3x3+40vw3x2+24vw3x+8vw3+33vw2x3+51vw2x2+27vw2x+9vw2+18vwx3+22vwx2+6vwx+2vw+4vx3+4vx2+7w4x3+16w4x2+9w4x+4w4+38w3x3+82w3x2+46w3x+18w3+63w2x3+120w2x2+51w2x+18w2+38wx3+56wx2+2wx+10x3+14x2
status: 0
04v5w4x3+16v5w3x3+24v5w2x3+16v5wx3+4v5x3+14v4w4x3+60v4w3x3+96v4w2x3+68v4wx3+18v4x3+16v3w4x3+76v3w3x3+132v3w2x3+100v3wx3+28v3x3+4v2w4x3+28v2w3x3+60v2w2x3+52v2wx3+16v2x3+5vw4x3+24vw3x3+33vw2x3+18vwx3+4vx3+7w4x3+38w3x3+63w2x3+38wx3+10x3+12v5w4x2+48v5w3x2+72v5w2x2+48v5wx2+12v5x2+46v4w4x2+196v4w3x2+312v4w2x2+220v4wx2+58v4x2+62v3w4x2+284v3w3x2+480v3w2x2+356v3wx2+98v3x2+30v2w4x2+156v2w3x2+288v2w2x2+228v2wx2+66v2x2+7vw4x2+40vw3x2+51vw2x2+22vwx2+4vx2+16w4x2+82w3x2+120w2x2+56wx2+14x2+12v5w4x+48v5w3x+72v5w2x+48v5wx+12v5x+50v4w4x+212v4w3x+336v4w2x+236v4wx+62v4x+76v3w4x+340v3w3x+564v3w2x+412v3wx+112v3x+48v2w4x+228v2w3x+396v2w2x+300v2wx+84v2x+3vw4x+24vw3x+27vw2x+6vwx+9w4x+46w3x+51w2x+2wx+4v5w4+16v5w3+24v5w2+16v5w+4v5+18v4w4+76v4w3+120v4w2+84v4w+22v4+30v3w4+132v3w3+216v3w2+156v3w+42v3+22v2w4+100v2w3+168v2w2+124v2w+34v2+vw4+8vw3+9vw2+2vw+4w4+18w3+18w2
The sum of all inequalities gives us a proof of the inequality.
_______________________
Substitute a1/(1+y),b1/(1+z),c1/(1+a1)
Numerator after substitutions: 10a13y5z3+30a13y5z2+24a13y5z+8a13y5+9a13y4z4+86a13y4z3+195a13y4z2+142a13y4z+44a13y4+36a13y3z4+244a13y3z3+480a13y3z2+328a13y3z+96a13y3+54a13y2z4+312a13y2z3+558a13y2z2+360a13y2z+100a13y2+30a13yz4+166a13yz3+282a13yz2+172a13yz+46a13y+7a13z4+38a13z3+63a13z2+38a13z+10a13+11a12y5z4+62a12y5z3+117a12y5z2+78a12y5z+24a12y5+64a12y4z4+346a12y4z3+612a12y4z2+384a12y4z+114a12y4+146a12y3z4+764a12y3z3+1278a12y3z2+756a12y3z+216a12y3+162a12y2z4+816a12y2z3+1284a12y2z2+700a12y2z+190a12y2+73a12yz4+370a12yz3+549a12yz2+258a12yz+66a12y+16a12z4+82a12z3+120a12z2+56a12z+14a12+16a1y5z4+74a1y5z3+120a1y5z2+72a1y5z+22a1y5+75a1y4z4+350a1y4z3+543a1y4z2+298a1y4z+90a1y4+140a1y3z4+660a1y3z3+972a1y3z2+472a1y3z+140a1y3+126a1y2z4+592a1y2z3+798a1y2z2+296a1y2z+84a1y2+42a1yz4+206a1yz3+228a1yz2+4a1yz+9a1z4+46a1z3+51a1z2+2a1z+9y5z4+38y5z3+57y5z2+34y5z+10y5+40y4z4+170y4z3+246y4z2+136y4z+40y4+70y3z4+300y3z3+414y3z2+204y3z+60y3+58y2z4+248y2z3+312y2z2+116y2z+34y2+19yz4+82yz3+81yz22yz+4z4+18z3+18z2
status: 0
From weighted AM-GM inequality:
2yzy2+z2
011a12y5z4+16a1y5z4+9y5z4+10a13y5z3+62a12y5z3+74a1y5z3+38y5z3+30a13y5z2+117a12y5z2+120a1y5z2+57y5z2+24a13y5z+78a12y5z+72a1y5z+34y5z+8a13y5+24a12y5+22a1y5+10y5+9a13y4z4+64a12y4z4+75a1y4z4+40y4z4+86a13y4z3+346a12y4z3+350a1y4z3+170y4z3+195a13y4z2+612a12y4z2+543a1y4z2+246y4z2+142a13y4z+384a12y4z+298a1y4z+136y4z+44a13y4+114a12y4+90a1y4+40y4+36a13y3z4+146a12y3z4+140a1y3z4+70y3z4+244a13y3z3+764a12y3z3+660a1y3z3+300y3z3+480a13y3z2+1278a12y3z2+972a1y3z2+414y3z2+328a13y3z+756a12y3z+472a1y3z+204y3z+96a13y3+216a12y3+140a1y3+60y3+54a13y2z4+162a12y2z4+126a1y2z4+58y2z4+312a13y2z3+816a12y2z3+592a1y2z3+248y2z3+558a13y2z2+1284a12y2z2+798a1y2z2+312y2z2+360a13y2z+700a12y2z+296a1y2z+116y2z+100a13y2+190a12y2+84a1y2+33y2+30a13yz4+73a12yz4+42a1yz4+19yz4+166a13yz3+370a12yz3+206a1yz3+82yz3+282a13yz2+549a12yz2+228a1yz2+81yz2+172a13yz+258a12yz+4a1yz+46a13y+66a12y+7a13z4+16a12z4+9a1z4+4z4+38a13z3+82a12z3+46a1z3+18z3+63a13z2+120a12z2+51a1z2+17z2+38a13z+56a12z+2a1z+10a13+14a12
The sum of all inequalities gives us a proof of the inequality.
Out[23]:
Counter({0: 8})

Now let's take a look at slightly another kind of the problem.

Problem

Let f:R3R be a convex function. Prove that

f(1,2,3)+f(2,3,1)+f(3,1,2)f(4,3,1)+f(3,1,4)+f(1,4,3).

To create a proof, we will use provef function. It assumes that f is convex and nonnegative, then it tries to find a proof. However, if the last inequality is 00, then the proof works for any convex function.

In [24]:
provef('(-f(1,2,3)-f(2,3,1)-f(3,1,2)+f(4,3,-1)+f(3,-1,4)+f(-1,4,3))*21')
numerator: 21f(1,4,3)21f(1,2,3)21f(2,3,1)+21f(3,1,4)21f(3,1,2)+21f(4,3,1)
denominator: 1
status: 0
From Jensen inequality:
21f(1,2,3)11f(1,4,3)+8f(3,1,4)+2f(4,3,1)
21f(2,3,1)8f(1,4,3)+2f(3,1,4)+11f(4,3,1)
21f(3,1,2)2f(1,4,3)+11f(3,1,4)+8f(4,3,1)
00
The sum of all inequalities gives us a proof of the inequality.
Out[24]:
0

Let's try to solve problem 6 from the finals of LXIII Polish Mathematical Olympiad. It was one of the hardest inequality in the history of this contest, solved only by 3 finalists.

Problem

Prove the inequality

(abc)2+(bca)2+(cab)222(abc+bca+cab)
for any positive numbers a,b,c.

The first observation is that the formula is cyclic, so without loss of generality we may assume that ab,c. We can go a step further and divide it into two cases: abc and acb.

In [25]:
shiro.display=lambda x:None #turn off printing of proofs
newproof()
formula=cyclize('((a-b)/c)^2-2*sqrt(2)*(a-b)/c')
In [26]:
formula1=makesubs(formula,'[b,oo],[c,oo]',variables='a,b') #a>=b>=c
prove(formula1) 
Out[26]:
2
In [27]:
formula2=makesubs(formula,'[c,oo],[b,oo]',variables='a,c') #a>=c>=b
prove(formula2) 
Out[27]:
0

So the case acb is done, but abc is not. But maybe we can adjust values.

In [28]:
values=findvalues(formula1)
values
Optimization terminated successfully.
         Current function value: 1.000000
         Iterations: 137
         Function evaluations: 249
Out[28]:
(1.7908873553542452e-10, 2.5326984818340415e-10, 7.129450063690368)

First and second value is approximately equal to 0, so we can try to replace 0 with 1.

In [29]:
prove(formula1,values='1,1,7')
Out[29]:
2

The key observation is that the formula1 is homogenous, so we can scale values.

In [30]:
newvalues=(1,values[1]/values[0],values[2]/values[0])
newvalues
Out[30]:
(1, 1.4142142855953455, 39809595184.05965)
In [31]:
newvalues[1]**2
Out[31]:
2.000002045581953

Now the third value is very big. Technically we could use it, but it would run into overflow error, so we will use 1 instead of it. Second value is very close to 2, so this value will be our next try.

In [32]:
prove(formula1,values='1,sqrt(2),1')
Out[32]:
0

So after getting the code all together we have got the following proof.

In [33]:
newproof()
shiro.display=lambda x:display(Latex(x)) #turn on printing proofs 
formula=cyclize('((a-b)/c)^2-2*sqrt(2)*(a-b)/c')
display(Latex('Case $a\ge c\ge b$'))
formula1=makesubs(formula,'[c,oo],[b,oo]',variables='a,c,b')
prove(formula1)
display(Latex('Case $a\ge b\ge c$'))
formula2=makesubs(formula,'[b,oo],[c,oo]')
prove(formula2,values='1,2**(1/2),1')
Case acb
Substitute ac+d
Substitute cb+e
numerator: 2b4d2+2b4de+2b4e2+4b3d3+22b3d2e+10b3d2e+22b3de2+6b3de2+4b3e3+2b2d4+22b2d3e+10b2d3e+62b2d2e2+12b2d2e2+4b2de3+42b2de3+2b2e4+2bd4e+22bd3e2+6bd3e2+4bd2e3+42bd2e3+22bde4+d4e2+2d3e3+d2e4
denominator: b6+2b5d+4b5e+b4d2+6b4de+6b4e2+2b3d2e+6b3de2+4b3e3+b2d2e2+2b2de3+b2e4
status: 0
02b4d2+2b4de+2b4e2+4b3d3+22b3d2e+10b3d2e+22b3de2+6b3de2+4b3e3+2b2d4+22b2d3e+10b2d3e+62b2d2e2+12b2d2e2+42b2de3+4b2de3+2b2e4+2bd4e+22bd3e2+6bd3e2+42bd2e3+4bd2e3+22bde4+d4e2+2d3e3+d2e4
The sum of all inequalities gives us a proof of the inequality.
Case abc
Substitute ab+f
Substitute bc+g
Substitute f2h
numerator: 2c4g2+22c4gh+4c4h2+4c3g34c3g2h+62c3g2h42c3gh2+20c3gh2+82c3h3+2c2g48c2g3h+42c2g3h122c2g2h2+24c2g2h28c2gh3+202c2gh3+8c2h44cg4h82cg3h2+8cg3h28cg2h3+122cg2h3+8cgh4+2g4h2+42g3h3+4g2h4
denominator: c6+4c5g+22c5h+6c4g2+62c4gh+2c4h2+4c3g3+62c3g2h+4c3gh2+c2g4+22c2g3h+2c2g2h2
status: 0
From weighted AM-GM inequality:
4c3g2h2c4g2+2c2g2h2
42c3gh222c4gh+2c3h3+2cg2h3
8c2g3h4c3g3+4cg3h2
122c2g2h262c3g2h+62cg2h3
8c2gh34c3gh2+2c2h4+2g2h4
4cg4h2c2g4+2g4h2
82cg3h242c2g3h+42g3h3
8cg2h34cg3h2+4cgh4
04c4h2+16c3gh2+72c3h3+22c2g2h2+202c2gh3+6c2h4+52cg2h3+4cgh4+2g2h4
The sum of all inequalities gives us a proof of the inequality.
Out[33]:
0