Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduction map modulo a number field prime ideal still not 100% done #1951

Closed
williamstein opened this issue Jan 27, 2008 · 7 comments
Closed

Comments

@williamstein
Copy link
Contributor

This should work:

sage: K.<i> = NumberField(x^2 + 1)
sage: P = [g[0] for g in K.factor_integer(5)]; P
[Fractional ideal (-i - 2), Fractional ideal (2*i + 1)]
sage: a = 1/(1+2*i)
sage: K = [g.residue_field() for g in P]; K
[Residue field of Fractional ideal (-i - 2), Residue field of Fractional ideal (2*i + 1)]
sage: F = K[0]
sage: a.valuation(P[0])
0
sage: F(i/7)
4
sage: F(a)
Traceback (most recent call last):
...
ZeroDivisionError: Inverse does not exist.

The problem is that a in terms of a basis for the maximal order still has
some 5's in the denominator, even though a is P[0]-integral. To fix this
in general, one could:

  1. Find an element b of the ring of integers that is 1 modulo P[0] and is 0 modulo all the other P[i] (using the not-implemented-right now CRT),

  2. Multiply a through by some power of b.

  3. Reduce.

  4. Divide back through by the reduction of b.

Component: number theory

Keywords: number field residue field reduction

Issue created by migration from https://trac.sagemath.org/ticket/1951

@williamstein williamstein added this to the sage-3.1.3 milestone Jan 27, 2008
@williamstein williamstein self-assigned this Jan 27, 2008
@JohnCremona
Copy link
Member

Attachment: 1951-residues.patch.gz

@JohnCremona
Copy link
Member

comment:1

The patch fixes this, so that any element which is P-integral can be reduced modulo P (non-P-integral elements will raise a ZeroDivisionError with an explanation).

It took a long time to find out where to put the new code, since the structure of the residue fields and reduction maps code is so byzantine! In the end the solution was not hard, though I used a different method from what was suggested (see comments in the patch).

The new code is in sage.rings.residue_field.pyx; I also put a doctest into number_field.number_field_ideal.py.

By the way, it is not really necessary to use recursion since when the function calls itself it always bottoms out right away. So it would be easy to rewrite it without any; I just found it easier to write self(nx) than self.__F(self.__to_vs(nx) * self.__PBinv) and similar.

@JohnCremona
Copy link
Member

Changed keywords from none to number field residue field reduction

@JohnCremona
Copy link
Member

Attachment: 1951-residues-1.patch.gz

@JohnCremona
Copy link
Member

comment:2

It's a small thing but I just noticed that the number field function residue_field() has this definition:

    def residue_field(self, prime, names = None, check = False):

where the "check" parameter claims to control whether "prime" really is prime, but this is ignored. It should be passed down through the call to sage.rings.residue_field.ResidueField(prime, names = names)
which does honour the check parameter.

Example:

sage: K.<i> = NumberField(x^2 + 1)
sage: Q = K.ideal(5)
sage: Q.is_prime()
False
sage: K.residue_field(Q, check=False)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)

/home/john/sage-3.1.2.rc1/devel/<ipython console> in <module>()

/home/john/sage-3.1.2.rc1/local/lib/python2.5/site-packages/sage/rings/number_field/number_field.py in residue_field(self, prime, names, check)
   3000             raise ValueError, "prime must be a prime ideal of self"
   3001         import sage.rings.residue_field
-> 3002         return sage.rings.residue_field.ResidueField(prime, names = names)
   3003 
   3004     def signature(self):

/home/john/sage-3.1.2.rc1/devel/residue_field.pyx in sage.rings.residue_field.ResidueField (sage/rings/residue_field.c:2778)()

ValueError: p must be prime

The second patch fixes this. Note that the default was "check=False", while the called function ResidueField() has its default as "check=True". I thought it safer to change the deafult to "check=True" since this makes the new default behaviour like the old behaviour. (If you use check=False and the ideal is not prime, the first error which arises is a bit obscure:

    AttributeError: 'NumberFieldFractionalIdeal' object has no attribute '_NumberFieldIdeal__smallest_integer'

since smallest_integer() is defined only for prime ideals. But something has to go wrong at some point in this situation, and at least now it will only happen when the user has deliberately turned off checking.

@aghitza
Copy link

aghitza commented Sep 20, 2008

comment:3

Looks good, applies cleanly against 3.1.2, and passes relevant doctests (checked sage/rings, sage/schemes, and sage/modular).

@aghitza aghitza changed the title reducation map modulo a number field prime ideal still not 100% done reduction map modulo a number field prime ideal still not 100% done Sep 20, 2008
@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Sep 20, 2008

comment:4

Merged in Sage 3.1.3.alpha1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants