def is_rewritable_or_comparable(sign, num, B):
 for h in B:
  if (sign[1] < Sign(h)[1]):
   if monomial_divides(Polyn(h).LM, sign[0]):
    return True
  if (sign[1] == Sign(h)[1]):
   if (num < Num(h)):
    if monomial_divides(Sign(h)[0], sign[0]):
     return True
 return False

def is_rewritable_or_comparable ( sign , num , B ) : for h in B : if ( sign [ 1 ] < Sign ( h ) [ 1 ] ) : if monomial_divides ( Polyn ( h ) . LM , sign [ 0 ] ) : return True if ( sign [ 1 ] == Sign ( h ) [ 1 ] ) : if ( num < Num ( h ) ) : if monomial_divides ( Sign ( h ) [ 0 ] , sign [ 0 ] ) : return True return False
check if a labeled polynomial is redundant by checking if its signature and number imply rewritability or comparability .