Skip to content

weird bug creating fractional ideal in relative number field #1367

@williamstein

Description

@williamstein

I noticed this bug when thinking about implementing factorization of integers
in a general relative number field (via the absolute field corresponding
to it). If this bug were fixed, then general factorization would be
trivial to implement, as suggested by the example below.

sage: K.<a,b> = NumberField([x^2 + 1, x^2 + 2])
sage: A = K.absolute_field('z')
sage: I = A.factor_integer(3)[0][0]
sage: from_A, to_A = A.structure()
sage: G = [from_A(z) for z in I.gens()]; G
[3, (-2*b - 1)*a + b - 1]
sage: K.fractional_ideal(G)
---------------------------------------------------------------------------
<type 'exceptions.TypeError'>             Traceback (most recent call last)

/Users/was/s/devel/sage-main/sage/rings/number_field/<ipython console> in <module>()

/Users/was/s/local/lib/python2.5/site-packages/IPython/Prompts.py in __call__(self, arg)
    521 
    522             # and now call a possibly user-defined print mechanism
--> 523             manipulated_val = self.display(arg)
    524             
    525             # user display hooks can change the variable to be stored in

/Users/was/s/local/lib/python2.5/site-packages/IPython/Prompts.py in _display(self, arg)
    545         """
    546 
--> 547         return self.shell.hooks.result_display(arg)
    548 
    549     # Assign the default display method:

/Users/was/s/local/lib/python2.5/site-packages/IPython/hooks.py in __call__(self, *args, **kw)
    132             #print "prio",prio,"cmd",cmd #dbg
    133             try:
--> 134                 ret = cmd(*args, **kw)
    135                 return ret
    136             except ipapi.TryNext, exc:

/Users/was/s/local/lib/python2.5/site-packages/IPython/hooks.py in result_display(self, arg)
    160     
    161     if self.rc.pprint:
--> 162         out = pformat(arg)
    163         if '\n' in out:
    164             # So that multi-line strings line up with the left column of

/Users/was/s/local/lib/python2.5/pprint.py in pformat(self, object)
    109     def pformat(self, object):
    110         sio = _StringIO()
--> 111         self._format(object, sio, 0, 0, {}, 0)
    112         return sio.getvalue()
    113 

/Users/was/s/local/lib/python2.5/pprint.py in _format(self, object, stream, indent, allowance, context, level)
    127             self._readable = False
    128             return
--> 129         rep = self._repr(object, context, level - 1)
    130         typ = _type(object)
    131         sepLines = _len(rep) > (self._width - 1 - indent - allowance)

/Users/was/s/local/lib/python2.5/pprint.py in _repr(self, object, context, level)
    193     def _repr(self, object, context, level):
    194         repr, readable, recursive = self.format(object, context.copy(),
--> 195                                                 self._depth, level)
    196         if not readable:
    197             self._readable = False

/Users/was/s/local/lib/python2.5/pprint.py in format(self, object, context, maxlevels, level)
    205         and whether the object represents a recursive construct.
    206         """
--> 207         return _safe_repr(object, context, maxlevels, level)
    208 
    209 

/Users/was/s/local/lib/python2.5/pprint.py in _safe_repr(object, context, maxlevels, level)
    290         return format % _commajoin(components), readable, recursive
    291 
--> 292     rep = repr(object)
    293     return rep, (rep and not rep.startswith('<')), False
    294 

/Users/was/s/local/lib/python2.5/site-packages/sage/rings/number_field/number_field_ideal.py in __repr__(self)
    215 
    216     def __repr__(self):
--> 217         return "Fractional ideal %s"%self._repr_short()
    218 
    219     def _repr_short(self):

/Users/was/s/local/lib/python2.5/site-packages/sage/rings/number_field/number_field_ideal.py in _repr_short(self)
    232         # makes things insanely slow in general.
    233         # When I fix this, I *have* to also change the _latex_ method.
--> 234         return '(%s)'%(', '.join([str(x) for x in self.gens_reduced()]))
    235 
    236     def __div__(self, other):









/Users/was/s/local/lib/python2.5/site-packages/sage/rings/number_field/number_field_ideal_rel.py in gens_reduced(self)
     84             S = L['x']
     85             gens = L.pari_rnf().rnfidealtwoelt(self.pari_rhnf())
---> 86             gens = [ L(R(x.lift().lift())) for x in gens ]
     87             ## Make sure that gens[1] is in L, not K
     88             Lcoeff = [ L(x) for x in list(gens[1].polynomial()) ]

/Users/was/s/local/lib/python2.5/site-packages/sage/rings/number_field/number_field.py in __call__(self, x)
   3321             return self.base_field()(x)
   3322         
-> 3323         return self._element_class(self, x)
   3324 
   3325     def _coerce_impl(self, x):

/Users/was/s/devel/sage-main/sage/rings/number_field/number_field_element.pyx in sage.rings.number_field.number_field_element.NumberFieldElement.__init__()
    231         num = f * den
    232         for i from 0 <= i <= num.degree():
--> 233             (<Integer>ZZ(num[i]))._to_ZZ(&coeff)
    234             ZZX_SetCoeff( self.__numerator, i, coeff )
    235 

/Users/was/s/devel/sage-main/sage/rings/number_field/integer_ring.pyx in sage.rings.integer_ring.IntegerRing_class.__call__()

<type 'exceptions.TypeError'>: Unable to coerce -b - 2 to an integer

Component: number theory

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions