It seems to work fine for me:
sage: var('x')
x
sage: f=function('f',nargs=1)
sage: f
f
sage: f == f
True
sage: f(x) == f(x)
f(x) == f(x)
sage: bool(f(x) == f(x))
True
sage: if f(x) == f(x):
....: print 'equal!'
....:
equal!
Do you mean that you want f(x) == f(x)
to be automatically simplified to True
, instead of returning an equation? That can't work in general, because in Sage, an equation is False
if Sage can't prove that it's true. So if you had an equation like
sage: x^2 - 4 == 0
x^2 - 4 == 0
it would instead give you False
rather than the equation, because it's possible that x
is something other than 2
or -2
..
Long story short, if you want the truth value, call bool
. You might be able to construct a subclass which gives you the behaviour you want but ISTM it'll only lead to headaches.