| 1 | """ |
|---|
| 2 | Algebra left, right, and two-sided ideals |
|---|
| 3 | |
|---|
| 4 | AUTHOR: David Kohel, 2005-09 |
|---|
| 5 | """ |
|---|
| 6 | |
|---|
| 7 | #***************************************************************************** |
|---|
| 8 | # Copyright (C) 2005 David Kohel <kohel@maths.usyd.edu> |
|---|
| 9 | # |
|---|
| 10 | # Distributed under the terms of the GNU General Public License (GPL) |
|---|
| 11 | # |
|---|
| 12 | # This code is distributed in the hope that it will be useful, |
|---|
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty |
|---|
| 14 | # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|---|
| 15 | # |
|---|
| 16 | # See the GNU General Public License for more details; the full text |
|---|
| 17 | # is available at: |
|---|
| 18 | # |
|---|
| 19 | # http://www.gnu.org/licenses/ |
|---|
| 20 | #***************************************************************************** |
|---|
| 21 | |
|---|
| 22 | from sage.algebras.algebra import Algebra |
|---|
| 23 | |
|---|
| 24 | class AlgebraIdeal(object): |
|---|
| 25 | """ |
|---|
| 26 | Generic left, right, and two-sided algebra ideals. |
|---|
| 27 | """ |
|---|
| 28 | def __init__(self, A, gens = []): |
|---|
| 29 | if not isinstance(A, Algebra): raise TypeError, "Argument A must be an algebra." |
|---|
| 30 | self.__algebra = A |
|---|
| 31 | self.__gens = gens |
|---|
| 32 | |
|---|
| 33 | def __repr__(self): |
|---|
| 34 | NotImplementedError |
|---|
| 35 | |
|---|
| 36 | def __call__(self, x): |
|---|
| 37 | raise NotImplementedError |
|---|
| 38 | |
|---|
| 39 | def __contains__(self, x): |
|---|
| 40 | raise NotImplementedError |
|---|
| 41 | |
|---|
| 42 | def base_ring(self): |
|---|
| 43 | return self.__algebra.base_ring() |
|---|
| 44 | |
|---|
| 45 | def gen(self,i): |
|---|
| 46 | if i < 0 or not i < ngens(self): |
|---|
| 47 | raise IndexError, \ |
|---|
| 48 | "Argument i (= %s) must be between 0 and %s."%(i, ngens(self)-1) |
|---|
| 49 | return self.__gens[i] |
|---|
| 50 | |
|---|
| 51 | def ngens(self): |
|---|
| 52 | return len(self.__gens) |
|---|
| 53 | |
|---|
| 54 | class AlgebraLeftIdeal(AlgebraIdeal): |
|---|
| 55 | """ |
|---|
| 56 | A left ideal in an algebra. |
|---|
| 57 | """ |
|---|
| 58 | def __init__(self, A, gens = []): |
|---|
| 59 | AlgebraIdeal.__init__(self, A, gens) |
|---|
| 60 | |
|---|
| 61 | def __repr__(self): |
|---|
| 62 | return "Left ideal on generators %s over %s"%( |
|---|
| 63 | self.gens(), self.algebra()) |
|---|
| 64 | |
|---|
| 65 | def left_algebra(self): |
|---|
| 66 | return self.algebra() |
|---|
| 67 | |
|---|
| 68 | class AlgebraRightIdeal(AlgebraIdeal): |
|---|
| 69 | """ |
|---|
| 70 | A right ideal in an algebra. |
|---|
| 71 | """ |
|---|
| 72 | def __init__(self, A, gens = []): |
|---|
| 73 | AlgebraIdeal.__init__(self, A, gens) |
|---|
| 74 | |
|---|
| 75 | def __repr__(self): |
|---|
| 76 | return "Right ideal on generators %s over %s"%( |
|---|
| 77 | self.gens(), self.algebra()) |
|---|
| 78 | |
|---|
| 79 | def right_algebra(self): |
|---|
| 80 | return self.algebra() |
|---|
| 81 | |
|---|
| 82 | class AlgebraTwoSidedIdeal(AlgebraIdeal): |
|---|
| 83 | """ |
|---|
| 84 | A two-sided ideal in an algebra, such that the left and right orders coincide. |
|---|
| 85 | """ |
|---|
| 86 | def __init__(self, A, gens = []): |
|---|
| 87 | AlgebraIdeal.__init__(self, A, gens) |
|---|
| 88 | |
|---|
| 89 | def __repr__(self): |
|---|
| 90 | return "Two-sided ideal on generators %s over %s"%( |
|---|
| 91 | self.gens(), self.algebra()) |
|---|
| 92 | |
|---|
| 93 | def __call__(self, x): |
|---|
| 94 | raise NotImplementedError |
|---|
| 95 | |
|---|
| 96 | def __contains__(self, x): |
|---|
| 97 | raise NotImplementedError |
|---|
| 98 | |
|---|
| 99 | def right_algebra(self): |
|---|
| 100 | return self.algebra() |
|---|
| 101 | |
|---|
| 102 | def left_algebra(self): |
|---|
| 103 | return self.algebra() |
|---|