Added rewrite rules to equivalence implementation