Skip to content

Commit

Permalink
Trac #34261: Allow multiplication of a left and right noncommutative …
Browse files Browse the repository at this point in the history
…ideal

Their product has a simple generating set, but right now Sage does not
allow this:
{{{
sage: MS = MatrixSpace(QQ,2,2)
sage: IL = MS * [2*MS.0,3*MS.1]
sage: IR = MS.3 * MS
sage: IL * IR
...
NotImplementedError: Cannot multiply non-commutative ideals.
}}}
We fix this.

URL: https://trac.sagemath.org/34261
Reported by: tscrim
Ticket author(s): Travis Scrimshaw
Reviewer(s): Dave Morris
  • Loading branch information
Release Manager committed Aug 29, 2022
2 parents 86ae68f + c41575e commit 456c8fb
Showing 1 changed file with 35 additions and 7 deletions.
42 changes: 35 additions & 7 deletions src/sage/rings/noncommutative_ideals.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,26 @@ class Ideal_nc(Ideal_generic):
return self.__side

def __mul__(self, other):
"""
r"""
Multiply ``self`` with ``other``.
Multiplication of a one-sided ideal with its ring from the other side
yields a two-sided ideal.
Let `L` (resp. `R`) be a left (resp. right) ideal, then the product
`LR` is a twosided ideal generated by `x y`, where `x` (resp. `y`)
is a generator of `L` (resp. `R`).
.. TODO::
The product of left (resp. right) ideals is a left
(resp. right) ideal. However, these do not necessarily have
simple generating sets.
TESTS::
sage: MS = MatrixSpace(QQ,2,2)
sage: IL = MS*[2*MS.0,3*MS.1]; IL
sage: IL = MS * [2*MS.0,3*MS.1]; IL
Left Ideal
(
[2 0]
Expand All @@ -361,7 +373,7 @@ class Ideal_nc(Ideal_generic):
[0 1]
)
of Full MatrixSpace of 2 by 2 dense matrices over Rational Field
sage: IL*MS # indirect doctest
sage: IL * MS
Twosided Ideal
(
[2 0]
Expand All @@ -371,12 +383,26 @@ class Ideal_nc(Ideal_generic):
[0 0]
)
of Full MatrixSpace of 2 by 2 dense matrices over Rational Field
sage: IR*IR
sage: IL * IR
Twosided Ideal
(
[0 3]
[0 0]
)
of Full MatrixSpace of 2 by 2 dense matrices over Rational Field
sage: IR * IR
Traceback (most recent call last):
...
NotImplementedError: Cannot multiply non-commutative ideals.
NotImplementedError: cannot multiply non-commutative ideals
"""
if isinstance(other, Ideal_nc) and self.ring() == other.ring():
if self.side() == "left" and other.side() == "right":
gens = [z for z in (x * y for x in self.gens() for y in other.gens()) if z]
return self.ring().ideal(gens, side='twosided')
raise NotImplementedError("cannot multiply non-commutative ideals")

if not isinstance(other, Ideal_nc):
# Perhaps other is a ring and thus has its own
# multiplication.
Expand All @@ -390,4 +416,6 @@ class Ideal_nc(Ideal_generic):
if other.side() == 'left':
return other
return other.ring().ideal(other.gens(), side='twosided')
raise NotImplementedError("Cannot multiply non-commutative ideals.")

raise NotImplementedError("cannot multiply non-commutative ideals")

0 comments on commit 456c8fb

Please sign in to comment.