class_docstr: A class implementing rewriting systems for `FpGroup`s.
  
  References
  ==========
  .. [1] Epstein, D., Holt, D. and Rees, S. (1991).
         The use of Knuth-Bendix methods to solve the word problem in automatic groups.
         Journal of Symbolic Computation, 12(4-5), pp.397-414.
  
  .. [2] GAP's Manual on its KBMAG package
         https://www.gap-system.org/Manuals/pkg/kbmag-1.5.3/doc/manual.pdf
class_docstr_tok: ["A","class","implementing","rewriting","systems","for","`","FpGroup","`","s",".","References","==========","..","[","1","]","Epstein",",","D.",",","Holt",",","D.","and","Rees",",","S.","(","1991",")",".","The","use","of","Knuth-Bendix","methods","to","solve","the","word","problem","in","automatic","groups",".","Journal","of","Symbolic","Computation",",","12","(","4-5",")",",","pp.397-414",".","..","[","2","]","GAP","'s","Manual","on","its","KBMAG","package","https",":","\/\/www.gap-system.org\/Manuals\/pkg\/kbmag-1.5.3\/doc\/manual.pdf"]
docstr: 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
docstr_tok: ["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"]
code: def _remove_redundancies(self, changes=False):
      """
      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
  
      """
      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
  
file_path: sympy/sympy/combinatorics/rewritingsystem.py
imports: from collections import deque
  from sympy.combinatorics.rewritingsystem_fsm import StateMachine
label_desc: Use image node_id 7 for calling the RewritingSystem obj's underlying member method code with example usage: obj._remove_redundancies(changes) and returns: removed,  added