#NEWLINE# def _basis( G , ring ) : #NEWLINE# #INDENT# '\n    Computes a list of monomials which are not divisible by the leading\n    monomials wrt to ``O`` of ``G``. These monomials are a basis of\n    `K[X_1, \\ldots, X_n]/(G)`.\n    ' #NEWLINE# order = ring . order #NEWLINE# leading_monomials = [ g . LM for g in G ] #NEWLINE# candidates = [ ring . zero_monom ] #NEWLINE# basis = [ ] #NEWLINE# while candidates : #NEWLINE# #INDENT# t = candidates . pop ( ) #NEWLINE# basis . append ( t ) #NEWLINE# new_candidates = [ _incr_k ( t , k ) for k in range ( ring . ngens ) if all ( ( ( monomial_div ( _incr_k ( t , k ) , lmg ) is None ) for lmg in leading_monomials ) ) ] #NEWLINE# candidates . extend ( new_candidates ) #NEWLINE# candidates . sort ( key = ( lambda m : order ( m ) ) , reverse = True ) #NEWLINE# #UNINDENT# basis = list ( set ( basis ) ) #NEWLINE# return sorted ( basis , key = ( lambda m : order ( m ) ) )