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, 28 Nov 2014 20:34:23 -0600All Ideals of Ringhttp://ask.sagemath.org/question/24892/all-ideals-of-ring/ For given group G, by G.subgroups(), we can list all subgroups.
now my question is :
Is there something for subgroups() for finding all left ideals of a given ring.
For instance,
k = GF(5);
M = MatrixSpace(k,2,2)
How can I have all left ideals?Mon, 17 Nov 2014 01:54:16 -0600http://ask.sagemath.org/question/24892/all-ideals-of-ring/Answer by mmarco for <p>For given group G, by G.subgroups(), we can list all subgroups.
now my question is :</p>
<p>Is there something for subgroups() for finding all left ideals of a given ring.
For instance,
k = GF(5);
M = MatrixSpace(k,2,2)
How can I have all left ideals?</p>
http://ask.sagemath.org/question/24892/all-ideals-of-ring/?answer=25042#post-id-25042There is not a single command to achieve that, but in this particular case you can do the following:
sage: k = GF(5)
sage: M = MatrixSpace(k,2,2)
sage: units = [m for m in M if m.is_invertible()]
sage: nonunits = [m for m in M if not m.is_invertible()]
sage: len(units)
480
sage: len(nonunits)
145
Since every ideal must be generated by some nonunits, but also changing a generator by a unit times it does not change the ideal, let's check how many essentially distinct generators can we have:
sage: associated = []
sage: for m in nonunits:
....: if not True in [a*m in associated for a in units]:
....: associated.append(m)
....:
sage: associated
[
[0 0] [1 0] [0 1] [1 1] [2 1] [1 2] [4 1]
[0 0], [0 0], [0 0], [0 0], [0 0], [0 0], [0 0]
]
That is, you only want to check for subsets of that set as possible generators of your ideals. But it is clear that two of those elements actually generate the other four, so you just need to check for ideals generated by up to two generators.
You have the trivial ideal, the other 6 principal ideals generated by the other elements in associated, and the only thing you need to check is if the ideal generated by two of them is the total one. It is easy to see that it is, but in case you don't notice at first sight you can just check it directly:
sage: for (a,b) in Tuples(units,2):
....: if (a*associated[1] + b*associated[2]).is_invertible():
....: print a
....: print b
....: break
....:
[0 1]
[1 0]
[1 0]
[0 1]
There you are: only six nontrivial ideals, that happen to be principal.
Fri, 28 Nov 2014 13:37:57 -0600http://ask.sagemath.org/question/24892/all-ideals-of-ring/?answer=25042#post-id-25042Comment by tmonteil for <p>There is not a single command to achieve that, but in this particular case you can do the following:</p>
<pre><code>sage: k = GF(5)
sage: M = MatrixSpace(k,2,2)
sage: units = [m for m in M if m.is_invertible()]
sage: nonunits = [m for m in M if not m.is_invertible()]
sage: len(units)
480
sage: len(nonunits)
145
</code></pre>
<p>Since every ideal must be generated by some nonunits, but also changing a generator by a unit times it does not change the ideal, let's check how many essentially distinct generators can we have:</p>
<pre><code>sage: associated = []
sage: for m in nonunits:
....: if not True in [a*m in associated for a in units]:
....: associated.append(m)
....:
sage: associated
[
[0 0] [1 0] [0 1] [1 1] [2 1] [1 2] [4 1]
[0 0], [0 0], [0 0], [0 0], [0 0], [0 0], [0 0]
]
</code></pre>
<p>That is, you only want to check for subsets of that set as possible generators of your ideals. But it is clear that two of those elements actually generate the other four, so you just need to check for ideals generated by up to two generators.</p>
<p>You have the trivial ideal, the other 6 principal ideals generated by the other elements in associated, and the only thing you need to check is if the ideal generated by two of them is the total one. It is easy to see that it is, but in case you don't notice at first sight you can just check it directly:</p>
<pre><code>sage: for (a,b) in Tuples(units,2):
....: if (a*associated[1] + b*associated[2]).is_invertible():
....: print a
....: print b
....: break
....:
[0 1]
[1 0]
[1 0]
[0 1]
</code></pre>
<p>There you are: only six nontrivial ideals, that happen to be principal.</p>
http://ask.sagemath.org/question/24892/all-ideals-of-ring/?comment=25048#post-id-25048Nice. Note that instead of ``True in [a*m in associated for a in units]``, you can use the more pythonic ``any([a*m in associated for a in units])``.Fri, 28 Nov 2014 20:34:23 -0600http://ask.sagemath.org/question/24892/all-ideals-of-ring/?comment=25048#post-id-25048