Yes, sympy 0.7.6 is wrong in this case, and in some other cases. In general, I do not know of any symbolic mathematical package that I would trust to make a calculus with piecewise defined functions.
Please note that although
inner = Piecewise((0, (x>=y)|(x<0)), (a,True))
throws TypeError during integration, logically equivalent definition
inner = Piecewise((a, (x<y)&(x>=0)), (0,True))
leads to the correct result
Piecewise((a*z, And(z < y, z >= 0)), (0, And(z <= 0, z >= -oo)), (a*y, True))
By the way, the previous version, sympy 0.7.5, handles
inner = Piecewise( (0, (x>=y)|(x<0)), (a,True) )
without TypeError, creating the correct result (in another form):
Piecewise((0, z <= 0), (a*y, z >= y), (a*z, True))
Here is another simpler example of erroneous behavior:
>>> Integral(Piecewise((1,(x<1)|(z<x)), (0,True)) ,(x,0,2)).doit() -Max(0, Min(2, Max(0, z))) + 3 >>> Integral(Piecewise((1,(x<1)|(x>z)), (0,True)) ,(x,0,2)).doit() -Max(0, Min(2, Max(1, z))) + 3
The first result is incorrect (for example, it fails at z = 0). The second is correct. The only difference between the two formulas is: z<x vs x>z .