Implement rewrite as Piecewise for Abs, sign and Heaviside (issue 3478)