Re: [sage-combinat-devel] Should we be more careful with integral domains?

42 views
Skip to first unread message

Nicolas M. Thiery

unread,
Feb 8, 2013, 3:54:33 PM2/8/13
to sage-comb...@googlegroups.com, sage-a...@googlegroups.com
On Fri, Feb 08, 2013 at 08:44:18PM +0000, Simon King wrote:
> I would like to change the FractionField construction functor, see
> #14084, so that its domain is what it should be: The category of
> integral domains, and not just the category of rings.

Sounds good.

> Problem: If we would do so, then some tests would fail, because Zp(p)
> and ZZ[['x']] do not know that they are integral domains. Similarly,
> Qp(p) is not initialised as a field:
>
> sage: Zp(7) in IntegralDomains()
> False
> sage: ZZ[['x']] in IntegralDomains()
> False
> sage: Qp(7).category()
> Category of commutative rings
> sage: Qp(7).is_field()
> True
> sage: Qp(7) in IntegralDomains()
> False

Hmm, fun indeed:

sage: Qp(7).category()
Category of commutative rings
sage: Qp(7) in IntegralDomains()
False
sage: Qp(7) in Fields()
True
sage: Qp(7).category()
Category of fields
sage: Qp(7) in IntegralDomains()
True

I agree that Qp(p) should be declared from the beginning in the Fields
category. And similarly ZZ[['x']] should be in IntegralDomains. This
costs nothing. Zp is a bit more complicated, since that depends on p,
and one may not want to test the primality of p right away (that was
discussed around 2009 on sage-devel).

> On a related note, isn't the power series ring over a field itself a
> field? Currently, it is not, in Sage:
>
> sage: (QQ[['x']]).is_field()
> False

Laurent power series form a field; however x is not invertible in
ZZ[['x']], right?

Cheers,
Nicolas
--
Nicolas M. Thi�ry "Isil" <nth...@users.sf.net>
http://Nicolas.Thiery.name/

John Cremona

unread,
Feb 8, 2013, 3:59:48 PM2/8/13
to sage-a...@googlegroups.com
Zp constructs the p-adic ring, which are always integral domains, and
raises an error if p is not prime. Not to be confused with
Integers(n) which constructs Z/nZ.

John
> Nicolas M. Thiéry "Isil" <nth...@users.sf.net>
> http://Nicolas.Thiery.name/
>
> --
> You received this message because you are subscribed to the Google Groups "sage-algebra" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-algebra...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Nicolas M. Thiery

unread,
Feb 8, 2013, 4:03:33 PM2/8/13
to sage-a...@googlegroups.com
On Fri, Feb 08, 2013 at 08:59:48PM +0000, John Cremona wrote:
> Zp constructs the p-adic ring, which are always integral domains, and
> raises an error if p is not prime. Not to be confused with
> Integers(n) which constructs Z/nZ.

Oh, right, I read too fast. Worst: I did that while attending a
semester which is specifically about p-adic integrals :-)

That being said, Simon will probably face the problem with Integers(n)
as well.

Cheers,
Nicolas
--

David Roe

unread,
Feb 8, 2013, 4:07:50 PM2/8/13
to sage-a...@googlegroups.com
Zp constructs the p-adic ring, which are always integral domains, and
raises an error if p is not prime.   Not to be confused with
Integers(n) which constructs Z/nZ.

Indeed.  You can turn the check off and get an object that you can work with in some ways, but it's definitely not supported.  Many things will break if p is not prime.
 
John

On 8 February 2013 20:54, Nicolas M. Thiery <Nicolas...@u-psud.fr> wrote:
> On Fri, Feb 08, 2013 at 08:44:18PM +0000, Simon King wrote:
>> I would like to change the FractionField construction functor, see
>> #14084, so that its domain is what it should be: The category of
>> integral domains, and not just the category of rings.
>
> Sounds good.

+1
 
>> Problem: If we would do so, then some tests would fail, because Zp(p)
>> and ZZ[['x']] do not know that they are integral domains. Similarly,
>> Qp(p) is not initialised as a field:
>>
>>    sage: Zp(7) in IntegralDomains()
>>    False
>>    sage: ZZ[['x']] in IntegralDomains()
>>    False
>>    sage: Qp(7).category()
>>    Category of commutative rings
>>    sage: Qp(7).is_field()
>>    True
>>    sage: Qp(7) in IntegralDomains()
>>    False

These should be changed.
 
>
> Hmm, fun indeed:
>
>     sage: Qp(7).category()
>     Category of commutative rings
>     sage: Qp(7) in IntegralDomains()
>     False
>     sage: Qp(7) in Fields()
>     True
>     sage: Qp(7).category()
>     Category of fields
>     sage: Qp(7) in IntegralDomains()
>     True
>
> I agree that Qp(p) should be declared from the beginning in the Fields
> category. And similarly ZZ[['x']] should be in IntegralDomains.
 
+1
 
>
>> On a related note, isn't the power series ring over a field itself a
>> field? Currently, it is not, in Sage:
>>
>>    sage: (QQ[['x']]).is_field()
>>    False
>
> Laurent power series form a field; however x is not invertible in
> ZZ[['x']], right?

Yeah, x is not invertible in ZZ[['x']] or in k[['x']].
David

Simon King

unread,
Feb 8, 2013, 4:21:45 PM2/8/13
to sage-comb...@googlegroups.com, sage-a...@googlegroups.com, Nicolas M. Thiery
Hi!


Am Freitag, 8. Februar 2013 21:54:33 UTC+1 schrieb Nicolas M. Thiery:
I agree that Qp(p) should be declared from the beginning in the Fields
category. And similarly ZZ[['x']] should be in IntegralDomains.  This
costs nothing.

Here is the reason why it does not work yet. From the initialisation of power series rings:
    if isinstance(base_ring, field.Field):
        R = PowerSeriesRing_over_field(base_ring, name, default_prec, sparse=sparse)
    elif isinstance(base_ring, integral_domain.IntegralDomain):
        R = PowerSeriesRing_domain(base_ring, name, default_prec, sparse=sparse)
    elif isinstance(base_ring, commutative_ring.CommutativeRing):
        R = PowerSeriesRing_generic(base_ring, name, default_prec, sparse=sparse)
    else:
        raise TypeError, "base_ring must be a commutative ring"

Hence, instead of testing containment in categories, the inheritance from the old base classes is tested.

So, changing this will indeed be fun.

Cheers,
Simon

Nicolas M. Thiery

unread,
Feb 8, 2013, 5:09:39 PM2/8/13
to sage-comb...@googlegroups.com, sage-a...@googlegroups.com
On Fri, Feb 08, 2013 at 09:10:03PM +0000, Simon King wrote:
> So, as a middle-ground, one could say that it is "IntegralDomain()" if
> bool(check) (because the primality test will happen anyway), and
> "CommutativeRings()" otherwise.

Sounds good to me!

> Nevertheless, P[['x']] should be an integral domain, provided that P is.

Yup.

Jean-Pierre Flori

unread,
May 31, 2013, 11:25:34 AM5/31/13
to sage-a...@googlegroups.com
On Friday, February 8, 2013 11:09:39 PM UTC+1, Nicolas M. Thiéry wrote:
> On Fri, Feb 08, 2013 at 09:10:03PM +0000, Simon King wrote:
>
> > So, as a middle-ground, one could say that it is "IntegralDomain()" if
>
> > bool(check) (because the primality test will happen anyway), and
>
> > "CommutativeRings()" otherwise.
>
>
>
> Sounds good to me!
>
>
>
> > Nevertheless, P[['x']] should be an integral domain, provided that P is.
>
>
>
> Yup.

Has anyone open a ticket for this "in IntegralDomains()" stuff?

I'm currently going through different part of Sage where tests like is_field(), is_prime_field(), is_integral_domain(), or is_Field(), or enven isinstance(Field_generic) etc. are used, trying to replace them by "in Fields()" and so on when this actually makes sense, and many times this just does not work out of the box because some classes which are in a mathematical sense integral domains and so on do not implement methods which are expected to be implemented, or some object answer yes when is_integral_domain() is called, but no when "in IntegralDomains()" is.

The reason why I'm going through this is that I want to be able to feed Sage with integer mod something without letting it call is_prime() on something and to achieve it declare at creation time that this ring is in the category FiniteFields().
In his ecm example William overrides the is_field() method so that it always returns True, but I find this less clean (and it is not sufficient to avoid calling is_prime for my use).

Best,
JP
Reply all
Reply to author
Forward
0 new messages