code: def critical_pair(f, g, ring):
      """
      Compute the critical pair corresponding to two labeled polynomials.
  
      A critical pair is a tuple (um, f, vm, g), where um and vm are
      terms such that um * f - vm * g is the S-polynomial of f and g (so,
      wlog assume um * f > vm * g).
      For performance sake, a critical pair is represented as a tuple
      (Sign(um * f), um, f, Sign(vm * g), vm, g), since um * f creates
      a new, relatively expensive object in memory, whereas Sign(um *
      f) and um are lightweight and f (in the tuple) is a reference to
      an already existing object in memory.
      """
      domain = ring.domain
  
      ltf = Polyn(f).LT
      ltg = Polyn(g).LT
      lt = (monomial_lcm(ltf[0], ltg[0]), domain.one)
  
      um = term_div(lt, ltf, domain)
      vm = term_div(lt, ltg, domain)
  
      # The full information is not needed (now), so only the product
      # with the leading term is considered:
      fr = lbp_mul_term(
          lbp(Sign(f), Polyn(f).leading_term(), Num(f)), um
      )
      gr = lbp_mul_term(
          lbp(Sign(g), Polyn(g).leading_term(), Num(g)), vm
      )
  
      # return in proper order, such that the S-polynomial is just
      # u_first * f_first - u_second * f_second:
      if lbp_cmp(fr, gr) == -1:
          return (Sign(gr), vm, g, Sign(fr), um, f)
      else:
          return (Sign(fr), um, f, Sign(gr), vm, g)
  
imports: from sympy.core.symbol import Dummy
  from sympy.polys.monomials import monomial_mul, monomial_lcm, monomial_divides, term_div
  from sympy.polys.orderings import lex
  from sympy.polys.polyerrors import DomainError
  from sympy.polys.polyconfig import query
label_desc: Use image node_id 16 for calling a global function with example usage: critical_pair(f, g, ring) and returns: Sign,  vm,  g,  Sign,  um,  f, Sign,  um,  f,  Sign,  vm,  g