Algebraic simplification of expressions