You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

273 lines
8.2 KiB

  1. class Unique(object):
  2. def __init__(self,name):
  3. self.name = name
  4. def __str__(self):
  5. return self.name
  6. def __repr__(self):
  7. return "Unique(\"%s\")" % self.name
  8. class Idealized(object):
  9. UNION = ["UNION"]
  10. def __init__(self, R, idealMap = 0, vars = {}):
  11. self.varnames = vars
  12. if not isinstance(idealMap,dict):
  13. idealMap = {()*R:idealMap}
  14. self.idealMap = idealMap
  15. self.R = R
  16. self._sqrt = None
  17. self._isqrt = None
  18. @staticmethod
  19. def uvar(x):
  20. return Idealized.var(Unique(x))
  21. @staticmethod
  22. def var(x):
  23. name = str(x)
  24. R = PolynomialRing(QQ,[name])
  25. rx = R.gens()[0]
  26. return Idealized(R,rx,{x:(name,rx)})
  27. @staticmethod
  28. def vars(xs):
  29. return tuple((Idealized.var(x) for x in xs))
  30. @staticmethod
  31. def uvars(xs):
  32. return tuple((Idealized.uvar(x) for x in xs))
  33. def __str__(self):
  34. def rep(I,x):
  35. x = str(x)
  36. gs = I.gens()
  37. gs = [g for g in gs if g != 0]
  38. if len(gs) == 0: return x
  39. else: