(sign, num, B)
return False
Check if a labeled polynomial is redundant by checking if its
    signature and number imply rewritability or comparability.

    (sign, num) is comparable if there exists a labeled polynomial
    h in B, such that sign[1] (the index) is less than Sign(h)[1]
    and sign[0] is divisible by the leading monomial of h.

    (sign, num) is rewritable if there exists a labeled polynomial
    h in B, such thatsign[1] is equal to Sign(h)[1], num < Num(h)
    and sign[0] is divisible by Sign(h)[0].
Check if a labeled polynomial is redundant by checking if its
    signature and number imply rewritability or comparability.
Check if a labeled polynomial is redundant by checking if its signature and number imply rewritability or comparability .
def is_rewritable_or_comparable(sign, num, B):
    """
    Check if a labeled polynomial is redundant by checking if its
    signature and number imply rewritability or comparability.

    (sign, num) is comparable if there exists a labeled polynomial
    h in B, such that sign[1] (the index) is less than Sign(h)[1]
    and sign[0] is divisible by the leading monomial of h.

    (sign, num) is rewritable if there exists a labeled polynomial
    h in B, such thatsign[1] is equal to Sign(h)[1], num < Num(h)
    and sign[0] is divisible by Sign(h)[0].
    """
    for h in B:
        # comparable
        if sign[1] < Sign(h)[1]:
            if monomial_divides(Polyn(h).LM, sign[0]):
                return True

        # rewritable
        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 : # comparable if sign [ 1 ] < Sign ( h ) [ 1 ] : if monomial_divides ( Polyn ( h ) . LM , sign [ 0 ] ) : return True # rewritable if sign [ 1 ] == Sign ( h ) [ 1 ] : if num < Num ( h ) : if monomial_divides ( Sign ( h ) [ 0 ] , sign [ 0 ] ) : return True return False