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
Zero does not belong to zero ideal of a number field #14366
Comments
comment:1
It seems to me that there is generic code in sage/rings/ideal.py for (I do wonder why the code for |
Attachment: trac_14366.patch.gz |
comment:4
Now with a commit message. |
comment:6
I just bumped into this bug myself. Wouldn't it make more sense to make coordinates() return an empty tuple instead? I believe this makes sense since 0 is in the zero-dimensional vector space. |
Changed keywords from none to sd51 |
comment:8
@saraedum, what should the output of K.ideal(0).coordinates(1) be where K is a number field? What kind of error should it produce? |
comment:9
Replying to @sagetrac-mkosters:
This should raise a ValueError, I believe. |
comment:10
Replying to @saraedum:
Yep, in vector spaces:
|
comment:11
The coordinate function of a relative number field returns 'absolute' coordinates to QQ. Shouldn't this actually also be in terms of the relative field (same for I.basis() where I is an ideal)? |
comment:12
Replying to @sagetrac-mkosters:
I agree. If you want to you could put this into a new ticket. |
comment:13
Attachment: 14366_method2.patch.gz 14366_method2.patch changes the coordinate function for the 0 ideal (but does not do relative coordinates), and fixes the containment bug. |
comment:14
Replying to @saraedum:
Actually, I think it is not a good idea to do. Basically, modules (and ideals, integral closures) are not free any more (because the class number is not 1 in general), so a basis might not exist. |
comment:15
I can't help thinking that an easier solution would be to use the We could just reimplement def coordinates(self, x):
K = self.number_field()
V, from_V, to_V = K.absolute_vector_space()
return self.free_module().coordinates(to_V(K(x))) and then there is no longer any need to worry about the special case of the zero ideal, it will be dealt with automatically. |
Replace previous patches. |
comment:16
Attachment: 14366_metrod3.patch.gz Looks fine to me. |
Reviewer: David Loeffler |
Author: Michiel Kosters |
This comment has been minimized.
This comment has been minimized.
comment:19
Apply 14366_metrod3.patch (for patchbot) |
comment:20
Apply 14366_metrod3.patch |
comment:21
Apply 14366_metrod3.patch (for patchbot) |
Merged: sage-5.12.beta3 |
The following is mathematically wrong:
It comes from the function contains(self, x) in the class NumberFieldIdeal (file sage/rings/number_field/number_field_ideal.py), which tries to compute the coordinates of the element in a basis (over ZZ) of the ideal. The function coordinates(self, x) fails for the zero ideal, raising a TypeError (in fact when
_contains_
is called directly, a TypeError is raised).A workaround is to replace
with
but I am not sure if it is the "right" way to do it.
Is it desirable to have the
_contains_
function in sage/rings/ideal.py catch the TypeError (silently)?Apply attachment: 14366_metrod3.patch
Component: number fields
Keywords: sd51
Author: Michiel Kosters
Reviewer: David Loeffler
Merged: sage-5.12.beta3
Issue created by migration from https://trac.sagemath.org/ticket/14366
The text was updated successfully, but these errors were encountered: