Goal -- Make the command "K.completion(p, absprec=30)" work when K is a number field and p is a prime of K
Type -- basic features, structural improvements
Priority -- Medium-High
Difficulty -- Medium-Easy
Prerequisites -- the later stages need general extension rings
Background -- completions of number fields, residue fields, sage.structure.factory
Contributors -- David Roe
Progress - I have a patch implementing coerce_keys, and have changed most of residue fields for number fields to use it.
Related Tickets --
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:
- 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.
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
Implement coerce-keys.
Change the implementation of residue fields for number fields to use coerce_keys
Change the implementation of residue fields for local fields to use coerce_keys
Write completions using coerce_keys.