'Reduce left- and right-hand sides of reduction rules
and remove redundant equations (i.e. those for which
lhs == rhs). If `changes` is `True`, return a set
containing the removed keys and a set containing the
added keys'

def _remove_redundancies(self, changes=False):

    removed = set()
    added = set()
    rules = self.rules.copy()
    for r in rules:
        v = self.reduce(r, exclude=r)
        w = self.reduce(rules[r])
        if (v != r):
            del self.rules[r]
            removed.add(r)
            if (v > w):
                added.add(v)
                self.rules[v] = w
            elif (v < w):
                added.add(w)
                self.rules[w] = v
        else:
            self.rules[v] = w
    if changes:
        return (removed, added)
    return
