Discussion

Coerce Keys

By a "coerce key" I mean the following. It's an object that is accepted as a keyword argument by UniqueFactory.__call__ that serves two purposes:

  1. It overrides uniqueness of parents, allow you to get a new parent object with the same parameters as an existing one. The factory will cache these parents using keys that have the coerce key appended.
  2. It provides facilities to change the class of the returned parent (using dynamic classes) and to insert coercions and conversions mapping to the new parent. These are accomplished by overriding appropriate functions on the coerce_key object.

This will allow one to create a residue field as follows:

   1 class CoerceKey_res_field(CoerceKey):
   2     def __init__(self, OK, p):
   3         self.OK = OK
   4         self.K = OK.fraction_field()
   5         self.p = p
   6     def __hash__(self):
   7         return hash(self.p)
   8     def __cmp__(self, other):
   9         return cmp(self.p, other.p)
  10     def __call__(self, new_object):
  11         new_object.__class__ = dynamic_class(new_object.__class__.__name__, (new_object.__class__, ResidueField), doccls=new_object.__class__)
  12         return new_object
  13 
  14     def coerce_list(self, new_object):
  15         return [self.OK._residue_homomorphism(self.p, new_object)]
  16     def convert_list(self, new_object):
  17         return [self.K._residue_conversion(self.p, new_object)]
  18 
  19 sage: K = NumberField(x^3-2); p = K.prime_above(17)
  20 sage: k.<a> = GF(17, coerce_key=CoerceKey_res_field(K.maximal_order(), p))

Tasks

  1. Implement coerce-keys.

  2. Change the implementation of residue fields for number fields to use coerce_keys

  3. Change the implementation of residue fields for local fields to use coerce_keys

  4. Write completions using coerce_keys.

padics/Completions (last edited 2010-12-02 18:22:43 by DavidRoe)