# Evaluation of triangle inequality

I wrote the following code:

x = var('x')
assume(x,'real')
y = var('y')
assume(y,'real')
z = var('z')
assume(z,'real')

expr = abs(x-y)+abs(y-z) >= abs(x-z)


The I run it:

sage: bool(expr)
False


The expression is obviously mathematically correct. How come Sage returns "False"?

edit retag close merge delete

Sort by » oldest newest most voted

Sage implements booleans,and answers to a"logical" query either by True, which means that Sage can compute an equality, or False, meaning that Sage cannot compute this equality. This does not mean that the result is false, only that Sage cannot prove it.

Mathematica does the same:

sage: %%mathematica
....: P = Abs[x - y] + Abs[y - z] >= Abs[x - z]
....: Assuming[x \[Element] Reals && y \[Element] Reals && z \[Element] Reals, Re
....: duce[P]]
....:
Abs[x - y] + Abs[y - z] >= Abs[x - z]
Out= Abs[y - z] >= -Abs[x - y] + Abs[x - z]


Contrast this with Maxima:

sage: %%maxima
....: declare(x,real,y,real,z,real);
....: is(abs(x-y)+abs(y-z)>=abs(x-z));
....:
done
unknown


Maxima implements "trinary logicals", i. e. a logical value can be true (i. e. the result can be computed true), false(the result can be cimputed false) or unknown (the result cannot be computed).

HTH,

more