def dmp_exclude(f, u, K):
 if ((not u) or dmp_ground_p(f, None, u)):
  return ([], f, u)
 (J, F) = ([], dmp_to_dict(f, u))
 for j in range(0, (u + 1)):
  for monom in F.keys():
   if monom[j]:
    break
  else:
   J.append(j)
 if (not J):
  return ([], f, u)
 f = {}
 for (monom, coeff) in F.items():
  monom = list(monom)
  for j in reversed(J):
   del monom[j]
  f[tuple(monom)] = coeff
 u -= len(J)
 return (J, dmp_from_dict(f, u, K), u)

def dmp_exclude ( f , u , K ) : if ( ( not u ) or dmp_ground_p ( f , None , u ) ) : return ( [ ] , f , u ) ( J , F ) = ( [ ] , dmp_to_dict ( f , u ) ) for j in range ( 0 , ( u + 1 ) ) : for monom in F . keys ( ) : if monom [ j ] : break else : J . append ( j ) if ( not J ) : return ( [ ] , f , u ) f = { } for ( monom , coeff ) in F . items ( ) : monom = list ( monom ) for j in reversed ( J ) : del monom [ j ] f [ tuple ( monom ) ] = coeff u -= len ( J ) return ( J , dmp_from_dict ( f , u , K ) , u )
exclude useless levels from f .