If the arg of abs is real you don't want to wrap it in sqrt(arg**2) or it will become abs(arg) again -- that was the issue that this solves (and the test confirms that this is correct). The objective is to remove the abs from the expression. The `else` part handles the case when the `is_real` state is not known as in vanilla x in abs(x) - 3; that gets converted (and stays) as sqrt(x**2) - 3 and returns [-3, 3] for x. If is_real is False then the checksol will eliminate the spurious solutions ([] is returned in the previous example if x = Symbol('x', real=False)). When `is_real` is known we can't wrap the argument in sqrt(); your suggestion which I implemented here is to wrap it in Piecewise -- and that has worked well.