def critical_pair(f, g, ring):
 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)
 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)
 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)

def critical_pair ( f , g , ring ) : 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 ) 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 ) 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 )
compute the critical pair corresponding to two labeled polynomials .