added an equivariant version of a the matching function. Fixed a bug
where rewriting would return the old term instead of rewritten in the
case of tuples in rewrite function.