def red_groebner(G, ring):
 def reduction(P):
  '\n        The actual reduction algorithm.\n        '
  Q = []
  for (i, p) in enumerate(P):
   h = p.rem((P[:i] + P[(i + 1):]))
   if h:
    Q.append(h)
  return [p.monic() for p in Q]
 F = G
 H = []
 while F:
  f0 = F.pop()
  if (not any((monomial_divides(f.LM, f0.LM) for f in (F + H)))):
   H.append(f0)
 return reduction(H)

def red_groebner ( G , ring ) : def reduction ( P ) : Q = [ ] for ( i , p ) in enumerate ( P ) : h = p . rem ( ( P [ : i ] + P [ ( i + 1 ) : ] ) ) if h : Q . append ( h ) return [ p . monic ( ) for p in Q ] F = G H = [ ] while F : f0 = F . pop ( ) if ( not any ( ( monomial_divides ( f . LM , f0 . LM ) for f in ( F + H ) ) ) ) : H . append ( f0 ) return reduction ( H )
compute reduced groebner basis .