ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 20 Jul 2012 18:18:43 -0500How to check if a number field is a PIDhttp://ask.sagemath.org/question/9037/how-to-check-if-a-number-field-is-a-pid/Given a NumberField, is there a way to check if its ring of integers is a PID? This could be with a built in method, analogous to is_noetherian(), but if there's a more complicated way to do it that's good too.Wed, 06 Jun 2012 12:28:05 -0500http://ask.sagemath.org/question/9037/how-to-check-if-a-number-field-is-a-pid/Answer by DSM for <p>Given a NumberField, is there a way to check if its ring of integers is a PID? This could be with a built in method, analogous to is_noetherian(), but if there's a more complicated way to do it that's good too.</p>
http://ask.sagemath.org/question/9037/how-to-check-if-a-number-field-is-a-pid/?answer=13661#post-id-13661You could try something like
sage: QQ in PrincipalIdealDomains
True
sage: RR in PrincipalIdealDomains
True
sage: Zmod(3) in PrincipalIdealDomains
False
but AFAIK this only tests whether *Sage* thinks of that capital-F Field as a PID in its Category framework. I don't think it does independent testing if you're constructing your own.Wed, 06 Jun 2012 12:36:51 -0500http://ask.sagemath.org/question/9037/how-to-check-if-a-number-field-is-a-pid/?answer=13661#post-id-13661Comment by Alex C for <p>You could try something like</p>
<pre><code>sage: QQ in PrincipalIdealDomains
True
sage: RR in PrincipalIdealDomains
True
sage: Zmod(3) in PrincipalIdealDomains
False
</code></pre>
<p>but AFAIK this only tests whether <em>Sage</em> thinks of that capital-F Field as a PID in its Category framework. I don't think it does independent testing if you're constructing your own.</p>
http://ask.sagemath.org/question/9037/how-to-check-if-a-number-field-is-a-pid/?comment=19676#post-id-19676This seems to not work unfortunately, as you suspected. Note that I misstated my question. I asked about checking if the number field was a PID, when I meant to ask about checking if its ring of integers is. Nevertheless thanks for the suggestion.Wed, 06 Jun 2012 14:17:13 -0500http://ask.sagemath.org/question/9037/how-to-check-if-a-number-field-is-a-pid/?comment=19676#post-id-19676Comment by Alex C for <p>You could try something like</p>
<pre><code>sage: QQ in PrincipalIdealDomains
True
sage: RR in PrincipalIdealDomains
True
sage: Zmod(3) in PrincipalIdealDomains
False
</code></pre>
<p>but AFAIK this only tests whether <em>Sage</em> thinks of that capital-F Field as a PID in its Category framework. I don't think it does independent testing if you're constructing your own.</p>
http://ask.sagemath.org/question/9037/how-to-check-if-a-number-field-is-a-pid/?comment=19677#post-id-19677This seems to not work unfortunately, as you suspected. Note that I misstated my question. I asked about checking if the number field was a PID, when I meant to ask about checking if its ring of integers is. Nevertheless thanks for the suggestion.
Example:
sage: C = NumberField(x^2 + 1, 'i')
sage: OC = C.ring_of_integers()
sage: OC in PrincipalIdealDomains
FalseWed, 06 Jun 2012 14:17:13 -0500http://ask.sagemath.org/question/9037/how-to-check-if-a-number-field-is-a-pid/?comment=19677#post-id-19677Answer by vdelecroix for <p>Given a NumberField, is there a way to check if its ring of integers is a PID? This could be with a built in method, analogous to is_noetherian(), but if there's a more complicated way to do it that's good too.</p>
http://ask.sagemath.org/question/9037/how-to-check-if-a-number-field-is-a-pid/?answer=13838#post-id-13838The method class_number gives you the answer, there is no need for further methods
sage: QuadraticField(2).class_number()
1
sage: QuadraticField(-5).class_number()
2
For a number field K, the fractional ideals form a group under multiplication. The class number of K is the number of elements in the quotient of this ring by the principal ideals. In particular, the class number is 1 if and only if the ring of integers of K is a PID.
see also: http://en.wikipedia.org/wiki/Ideal_class_groupFri, 20 Jul 2012 18:18:43 -0500http://ask.sagemath.org/question/9037/how-to-check-if-a-number-field-is-a-pid/?answer=13838#post-id-13838