def __init__(self, R, names=None): """ Initialize ``self``. TESTS:: sage: A = algebras.FreePreLie(QQ, '@'); A Free PreLie algebra on one generator ['@'] over Rational Field sage: TestSuite(A).run() sage: A = algebras.FreePreLie(QQ, None); A Free PreLie algebra on one generator ['o'] over Rational Field sage: F = algebras.FreePreLie(QQ, 'xy') sage: TestSuite(F).run() # long time """ if names is None: Trees = RootedTrees() key = RootedTree.sort_key self._alphabet = Alphabet(['o']) else: Trees = LabelledRootedTrees() key = LabelledRootedTree.sort_key self._alphabet = names # Here one would need LabelledRootedTrees(names) # so that one can restrict the labels to some fixed set cat = MagmaticAlgebras(R).WithBasis().Graded() & LieAlgebras( R).WithBasis().Graded() CombinatorialFreeModule.__init__(self, R, Trees, latex_prefix="", sorting_key=key, category=cat)
def __init__(self, R, n, names): """ Initialize ``self``. EXAMPLES:: sage: Z.<x,y,z> = algebras.FreeZinbiel(QQ) sage: TestSuite(Z).run() TESTS:: sage: Z.<x,y,z> = algebras.FreeZinbiel(5) Traceback (most recent call last): ... TypeError: argument R must be a ring """ if R not in Rings: raise TypeError("argument R must be a ring") indices = Words(Alphabet(n, names=names)) cat = MagmaticAlgebras(R).WithBasis().Graded() self._n = n CombinatorialFreeModule.__init__(self, R, indices, prefix='Z', category=cat) self._assign_names(names)
def __init__(self, A, names=None): """ Initialize ``self``. TESTS:: sage: F.<x,y,z> = FreeAlgebra(QQ) sage: J = JordanAlgebra(F) sage: TestSuite(J).run() sage: J.category() Category of commutative unital algebras with basis over Rational Field """ R = A.base_ring() C = MagmaticAlgebras(R) if A not in C.Associative(): raise ValueError("A is not an associative algebra") self._A = A cat = C.Commutative() if A in C.Unital(): cat = cat.Unital() self._no_generic_basering_coercion = True # Remove the preceding line once trac #16492 is fixed # Removing this line will also break some of the input formats, # see trac #16054 if A in C.WithBasis(): cat = cat.WithBasis() if A in C.FiniteDimensional(): cat = cat.FiniteDimensional() Parent.__init__(self, base=R, names=names, category=cat)
def __init__(self, A, names=None): """ Initialize ``self``. TESTS:: sage: F.<x,y,z> = FreeAlgebra(QQ) sage: J = JordanAlgebra(F) sage: TestSuite(J).run() sage: J.category() Category of commutative unital algebras with basis over Rational Field """ R = A.base_ring() C = MagmaticAlgebras(R) if A not in C.Associative(): raise ValueError("A is not an associative algebra") self._A = A cat = C.Commutative() if A in C.Unital(): cat = cat.Unital() if A in C.WithBasis(): cat = cat.WithBasis() if A in C.FiniteDimensional(): cat = cat.FiniteDimensional() Parent.__init__(self, base=R, names=names, category=cat)
def __init__(self, R, names=None): """ Initialize ``self``. TESTS:: sage: A = algebras.FreePreLie(QQ, '@'); A Free PreLie algebra on one generator ['@'] over Rational Field sage: TestSuite(A).run() sage: F = algebras.FreePreLie(QQ, 'xy') sage: TestSuite(F).run() # long time sage: F = algebras.FreePreLie(QQ, ZZ) sage: elts = F.some_elements()[:-1] # Skip the last element sage: TestSuite(F).run(some_elements=elts) # long time """ if names.cardinality() == 1: Trees = RootedTrees() else: Trees = LabelledRootedTrees() # Here one would need LabelledRootedTrees(names) # so that one can restrict the labels to some fixed set self._alphabet = names cat = MagmaticAlgebras(R).WithBasis().Graded() CombinatorialFreeModule.__init__(self, R, Trees, latex_prefix="", category=cat)
def super_categories(self): """ EXAMPLES:: sage: from categories.lie_algebras import LieAlgebras sage: LieAlgebras(Rings()).super_categories() [Category of magmatic algebras over rings] """ return [MagmaticAlgebras(self.base_ring())]
def extra_super_categories(self): """ EXAMPLES:: sage: AdditiveMagmas().Algebras(QQ).extra_super_categories() [Category of magmatic algebras with basis over Rational Field] sage: AdditiveMagmas().Algebras(QQ).super_categories() [Category of magmatic algebras with basis over Rational Field, Category of set algebras over Rational Field] """ from sage.categories.magmatic_algebras import MagmaticAlgebras return [MagmaticAlgebras(self.base_ring()).WithBasis()]
def __init__(self, R, form, names=None): """ Initialize ``self``. TESTS:: sage: m = matrix([[-2,3],[3,4]]) sage: J = JordanAlgebra(m) sage: TestSuite(J).run() """ self._form = form self._M = FreeModule(R, form.ncols()) cat = MagmaticAlgebras(R).Commutative().Unital().FiniteDimensional().WithBasis() Parent.__init__(self, base=R, names=names, category=cat)
def _Hom_(self, B, category): """ Construct a homset of ``self`` and ``B``. EXAMPLES:: sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([1])]) sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) sage: A._Hom_(B, A.category()) Set of Homomorphisms from Finite-dimensional algebra of degree 1 over Rational Field to Finite-dimensional algebra of degree 2 over Rational Field """ cat = MagmaticAlgebras(self.base_ring()).FiniteDimensional().WithBasis() if category.is_subcategory(cat): from sage.algebras.finite_dimensional_algebras.finite_dimensional_algebra_morphism import FiniteDimensionalAlgebraHomset return FiniteDimensionalAlgebraHomset(self, B, category=category) return super(FiniteDimensionalAlgebra, self)._Hom_(B, category)
def extra_super_categories(self): """ EXAMPLES:: sage: Magmas().Commutative().Algebras(QQ).extra_super_categories() [Category of commutative magmas] This implements the fact that the algebra of a commutative magma is commutative:: sage: Magmas().Commutative().Algebras(QQ).super_categories() [Category of magma algebras over Rational Field, Category of commutative magmas] In particular, commutative monoid algebras are commutative algebras:: sage: Monoids().Commutative().Algebras(QQ).is_subcategory(Algebras(QQ).Commutative()) True """ from sage.categories.magmatic_algebras import MagmaticAlgebras return [MagmaticAlgebras(self.base_ring())]
def __init__(self, R, n, names, prefix): """ Initialize ``self``. EXAMPLES:: sage: Z.<x,y,z> = algebras.FreeZinbiel(QQ) sage: TestSuite(Z).run() sage: Z = algebras.FreeZinbiel(QQ, ZZ) sage: G = Z.algebra_generators() sage: TestSuite(Z).run(elements=[Z.an_element(), G[1], G[1]*G[2]*G[0]]) TESTS:: sage: Z.<x,y,z> = algebras.FreeZinbiel(5) Traceback (most recent call last): ... TypeError: argument R must be a ring sage: algebras.FreeZinbiel(QQ, ['x', 'y'], prefix='f') Free Zinbiel algebra on generators (f[x], f[y]) over Rational Field """ if R not in Rings(): raise TypeError("argument R must be a ring") if names is None: indices = Words(Alphabet(n), infinite=False) self._n = None else: indices = Words(Alphabet(n, names=names), infinite=False) self._n = n cat = MagmaticAlgebras(R).WithBasis().Graded() CombinatorialFreeModule.__init__(self, R, indices, prefix=prefix, category=cat) if self._n is not None: self._assign_names(names)
def __classcall_private__(cls, k, table, names='e', assume_associative=False, category=None): """ Normalize input. TESTS:: sage: table = [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])] sage: A1 = FiniteDimensionalAlgebra(GF(3), table) sage: A2 = FiniteDimensionalAlgebra(GF(3), table, names='e') sage: A3 = FiniteDimensionalAlgebra(GF(3), table, names=['e0', 'e1']) sage: A1 is A2 and A2 is A3 True The ``assume_associative`` keyword is built into the category:: sage: from sage.categories.magmatic_algebras import MagmaticAlgebras sage: cat = MagmaticAlgebras(GF(3)).FiniteDimensional().WithBasis() sage: A1 = FiniteDimensionalAlgebra(GF(3), table, category=cat.Associative()) sage: A2 = FiniteDimensionalAlgebra(GF(3), table, assume_associative=True) sage: A1 is A2 True Uniqueness depends on the category:: sage: cat = Algebras(GF(3)).FiniteDimensional().WithBasis() sage: A1 = FiniteDimensionalAlgebra(GF(3), table) sage: A2 = FiniteDimensionalAlgebra(GF(3), table, category=cat) sage: A1 == A2 False sage: A1 is A2 False Checking that equality is still as expected:: sage: A = FiniteDimensionalAlgebra(GF(3), table) sage: B = FiniteDimensionalAlgebra(GF(5), [Matrix([0])]) sage: A == A True sage: B == B True sage: A == B False sage: A != A False sage: B != B False sage: A != B True """ n = len(table) table = [b.base_extend(k) for b in table] for b in table: b.set_immutable() if not (is_Matrix(b) and b.dimensions() == (n, n)): raise ValueError("input is not a multiplication table") table = tuple(table) cat = MagmaticAlgebras(k).FiniteDimensional().WithBasis() cat = cat.or_subcategory(category) if assume_associative: cat = cat.Associative() names = normalize_names(n, names) return super(FiniteDimensionalAlgebra, cls).__classcall__(cls, k, table, names, category=cat)