def __init__(self, base_ring, names, sparse=True, category=None): """ Initialize the ring. TESTS:: sage: L = LazyDirichletSeriesRing(ZZ, 't') sage: TestSuite(L).run(skip=['_test_elements', '_test_associativity', '_test_distributivity', '_test_zero']) """ if base_ring.characteristic() > 0: raise ValueError("positive characteristic not allowed for Dirichlet series") self._sparse = sparse self._coeff_ring = base_ring # TODO: it would be good to have something better than the symbolic ring self._laurent_poly_ring = SR self._internal_poly_ring = PolynomialRing(base_ring, names, sparse=True) category = Algebras(base_ring.category()) if base_ring in IntegralDomains(): category &= IntegralDomains() elif base_ring in Rings().Commutative(): category = category.Commutative() category = category.Infinite() Parent.__init__(self, base=base_ring, names=names, category=category)
def __init__(self, L, q=None): """ Initialize ``self``. TESTS:: sage: L = posets.BooleanLattice(4) sage: M = L.quantum_moebius_algebra() sage: TestSuite(M).run() # long time sage: from sage.combinat.posets.moebius_algebra import QuantumMoebiusAlgebra sage: L = posets.Crown(2) sage: QuantumMoebiusAlgebra(L) Traceback (most recent call last): ... ValueError: L must be a lattice """ if not L.is_lattice(): raise ValueError("L must be a lattice") if q is None: q = LaurentPolynomialRing(ZZ, 'q').gen() self._q = q R = q.parent() cat = Algebras(R).WithBasis() if L in FiniteEnumeratedSets(): cat = cat.Commutative().FiniteDimensional() self._lattice = L self._category = cat Parent.__init__(self, base=R, category=self._category.WithRealizations())
def __init__(self, power_series): """ Initialization EXAMPLES:: sage: K.<q> = LaurentSeriesRing(QQ, default_prec=4); K Laurent Series Ring in q over Rational Field sage: 1 / (q-q^2) q^-1 + 1 + q + q^2 + O(q^3) sage: RZZ = LaurentSeriesRing(ZZ, 't') sage: RZZ.category() Category of infinite commutative no zero divisors algebras over (euclidean domains and infinite enumerated sets and metric spaces) sage: TestSuite(RZZ).run() sage: R1 = LaurentSeriesRing(Zmod(1), 't') sage: R1.category() Category of finite commutative algebras over (finite commutative rings and subquotients of monoids and quotients of semigroups and finite enumerated sets) sage: TestSuite(R1).run() sage: R2 = LaurentSeriesRing(Zmod(2), 't') sage: R2.category() Join of Category of complete discrete valuation fields and Category of commutative algebras over (finite enumerated fields and subquotients of monoids and quotients of semigroups) and Category of infinite sets sage: TestSuite(R2).run() sage: R4 = LaurentSeriesRing(Zmod(4), 't') sage: R4.category() Category of infinite commutative algebras over (finite commutative rings and subquotients of monoids and quotients of semigroups and finite enumerated sets) sage: TestSuite(R4).run() sage: RQQ = LaurentSeriesRing(QQ, 't') sage: RQQ.category() Join of Category of complete discrete valuation fields and Category of commutative algebras over (number fields and quotient fields and metric spaces) and Category of infinite sets sage: TestSuite(RQQ).run() """ base_ring = power_series.base_ring() category = Algebras(base_ring.category()) if base_ring in Fields(): category &= CompleteDiscreteValuationFields() elif base_ring in IntegralDomains(): category &= IntegralDomains() elif base_ring in Rings().Commutative(): category = category.Commutative() if base_ring.is_zero(): category = category.Finite() else: category = category.Infinite() self._power_series_ring = power_series self._one_element = self.element_class(self, power_series.one()) CommutativeRing.__init__(self, base_ring, names=power_series.variable_names(), category=category)
def polynomial_default_category(base_ring_category, n_variables): """ Choose an appropriate category for a polynomial ring. It is assumed that the corresponding base ring is nonzero. INPUT: - ``base_ring_category`` -- The category of ring over which the polynomial ring shall be defined - ``n_variables`` -- number of variables EXAMPLES:: sage: from sage.rings.polynomial.polynomial_ring_constructor import polynomial_default_category sage: polynomial_default_category(Rings(),1) is Algebras(Rings()).Infinite() True sage: polynomial_default_category(Rings().Commutative(),1) is Algebras(Rings().Commutative()).Commutative().Infinite() True sage: polynomial_default_category(Fields(),1) is EuclideanDomains() & Algebras(Fields()).Infinite() True sage: polynomial_default_category(Fields(),2) is UniqueFactorizationDomains() & CommutativeAlgebras(Fields()).Infinite() True sage: QQ['t'].category() is EuclideanDomains() & CommutativeAlgebras(QQ.category()).Infinite() True sage: QQ['s','t'].category() is UniqueFactorizationDomains() & CommutativeAlgebras(QQ.category()).Infinite() True sage: QQ['s']['t'].category() is UniqueFactorizationDomains() & CommutativeAlgebras(QQ['s'].category()).Infinite() True """ category = Algebras(base_ring_category) if n_variables: # here we assume the base ring to be nonzero category = category.Infinite() else: if base_ring_category.is_subcategory(_Fields): category = category & _Fields if base_ring_category.is_subcategory(_FiniteSets): category = category.Finite() elif base_ring_category.is_subcategory(_InfiniteSets): category = category.Infinite() if base_ring_category.is_subcategory(_Fields) and n_variables == 1: return category & _EuclideanDomains elif base_ring_category.is_subcategory(_UniqueFactorizationDomains): return category & _UniqueFactorizationDomains elif base_ring_category.is_subcategory(_IntegralDomains): return category & _IntegralDomains elif base_ring_category.is_subcategory(_CommutativeRings): return category & _CommutativeRings return category
def center(self): r""" Return the center of ``self``. .. SEEALSO:: :meth:`center_basis` EXAMPLES:: sage: A = Algebras(QQ).FiniteDimensional().WithBasis().example(); A An example of a finite dimensional algebra with basis: the path algebra of the Kronecker quiver (containing the arrows a:x->y and b:x->y) over Rational Field sage: center = A.center(); center Center of An example of a finite dimensional algebra with basis: the path algebra of the Kronecker quiver (containing the arrows a:x->y and b:x->y) over Rational Field sage: center in Algebras(QQ).WithBasis().FiniteDimensional().Commutative() True sage: center.dimension() 1 sage: center.basis() Finite family {0: B[0]} sage: center.ambient() is A True sage: [c.lift() for c in center.basis()] [x + y] The center of a semisimple algebra is semisimple:: sage: DihedralGroup(6).algebra(QQ).center() in Algebras(QQ).Semisimple() True .. TODO:: - Pickling by construction, as ``A.center()``? - Lazy evaluation of ``_repr_`` TESTS:: sage: TestSuite(center).run() """ category = Algebras(self.base_ring()).FiniteDimensional( ).Subobjects().Commutative().WithBasis() if self in Algebras.Semisimple: category = category.Semisimple() center = self.submodule(self.center_basis(), category=category, already_echelonized=True) center.rename("Center of {}".format(self)) return center
def __init__(self, base_ring, names, sparse=True, category=None): """ Initialize ``self``. TESTS:: sage: L = LazyLaurentSeriesRing(ZZ, 't') sage: elts = L.some_elements()[:-2] # skip the non-exact elements sage: TestSuite(L).run(elements=elts, skip=['_test_elements', '_test_associativity', '_test_distributivity', '_test_zero']) sage: L.category() Category of infinite commutative no zero divisors algebras over (euclidean domains and infinite enumerated sets and metric spaces) sage: L = LazyLaurentSeriesRing(QQ, 't') sage: L.category() Join of Category of complete discrete valuation fields and Category of commutative algebras over (number fields and quotient fields and metric spaces) and Category of infinite sets sage: L = LazyLaurentSeriesRing(ZZ['x,y'], 't') sage: L.category() Category of infinite commutative no zero divisors algebras over (unique factorization domains and commutative algebras over (euclidean domains and infinite enumerated sets and metric spaces) and infinite sets) sage: E.<x,y> = ExteriorAlgebra(QQ) sage: L = LazyLaurentSeriesRing(E, 't') # not tested """ self._sparse = sparse self._coeff_ring = base_ring # We always use the dense because our CS_exact is implemented densely self._laurent_poly_ring = LaurentPolynomialRing(base_ring, names) self._internal_poly_ring = self._laurent_poly_ring category = Algebras(base_ring.category()) if base_ring in Fields(): category &= CompleteDiscreteValuationFields() else: if "Commutative" in base_ring.category().axioms(): category = category.Commutative() if base_ring in IntegralDomains(): category &= IntegralDomains() if base_ring.is_zero(): category = category.Finite() else: category = category.Infinite() Parent.__init__(self, base=base_ring, names=names, category=category)
def __init__(self, m, n, q, bar, R): """ Initialize ``self``. TESTS:: sage: O = algebras.QuantumMatrixCoordinate(4) sage: TestSuite(O).run() sage: O = algebras.QuantumMatrixCoordinate(10) sage: O.variable_names() ('x0101', ..., 'x1010') sage: O = algebras.QuantumMatrixCoordinate(11,3) sage: O.variable_names() ('x011', ..., 'x113') sage: O = algebras.QuantumMatrixCoordinate(3,11) sage: O.variable_names() ('x101', ..., 'x311') """ gp_indices = [(i, j) for i in range(1, m + 1) for j in range(1, n + 1)] if m == n: cat = Bialgebras(R.category()).WithBasis() else: cat = Algebras(R.category()).WithBasis() self._m = m QuantumMatrixCoordinateAlgebra_abstract.__init__( self, gp_indices, n, q, bar, R, cat) # Set the names mb = len(str(m)) nb = len(str(n)) base = 'x{{:0>{}}}{{:0>{}}}'.format(mb, nb) names = [base.format(*k) for k in gp_indices] self._assign_names(names)
def __init__(self, R, q): r""" Initialize ``self``. TESTS:: sage: A = algebras.AlternatingCentralExtensionQuantumOnsager(QQ) sage: TestSuite(A).run() # long time """ I = DisjointUnionEnumeratedSets( [PositiveIntegers(), ZZ, PositiveIntegers()], keepkey=True, facade=True) monomials = IndexedFreeAbelianMonoid(I, prefix='A', bracket=False) self._q = q CombinatorialFreeModule.__init__( self, R, monomials, prefix='', bracket=False, latex_bracket=False, sorting_key=self._monomial_key, category=Algebras(R).WithBasis().Filtered())
def __init__(self, R, M, ordering=None): """ Initialize ``self``. EXAMPLES:: sage: M = matroids.Wheel(3) sage: OS = M.orlik_solomon_algebra(QQ) sage: TestSuite(OS).run() We check on the matroid associated to the graph with 3 vertices and 2 edges between each vertex:: sage: G = Graph([[1,2],[1,2],[2,3],[2,3],[1,3],[1,3]], multiedges=True) sage: M = Matroid(G) sage: OS = M.orlik_solomon_algebra(QQ) sage: elts = OS.some_elements() + list(OS.algebra_generators()) sage: TestSuite(OS).run(elements=elts) """ self._M = M self._sorting = {x:i for i,x in enumerate(ordering)} # set up the dictionary of broken circuits self._broken_circuits = dict() for c in self._M.circuits(): L = sorted(c, key=lambda x: self._sorting[x]) self._broken_circuits[frozenset(L[1:])] = L[0] cat = Algebras(R).FiniteDimensional().WithBasis().Graded() CombinatorialFreeModule.__init__(self, R, M.no_broken_circuits_sets(ordering), prefix='OS', bracket='{', sorting_key=self._sort_key, category=cat)
def __init__(self, ring, category=None): r""" Initialize this Ore function field. TESTS:: sage: k.<a> = GF(11^3) sage: Frob = k.frobenius_endomorphism() sage: der = k.derivation(a, twist=Frob) sage: S.<x> = k['x', der] sage: K = S.fraction_field() sage: TestSuite(K).run() """ if self.Element is None: import sage.rings.polynomial.ore_function_element self.Element = sage.rings.polynomial.ore_function_element.OreFunction if not isinstance(ring, OrePolynomialRing): raise TypeError("not a Ore Polynomial Ring") if ring.base_ring() not in Fields(): raise TypeError("the base ring must be a field") try: _ = ring.twisting_morphism(-1) self._simplification = True except (TypeError, ZeroDivisionError, NotImplementedError): self._simplification = False self._ring = ring base = ring.base_ring() category = Algebras(base).or_subcategory(category) Algebra.__init__(self, base, names=ring.variable_name(), normalize=True, category=category)
def __init__(self, R, P, prefix='I'): """ Initialize ``self``. TESTS:: sage: P = posets.BooleanLattice(4) sage: I = P.incidence_algebra(QQ) sage: TestSuite(I).run() # long time """ cat = Algebras(R).WithBasis() if P in FiniteEnumeratedSets(): cat = cat.FiniteDimensional() self._poset = P CombinatorialFreeModule.__init__(self, R, map(tuple, P.relations()), prefix=prefix, category=cat)
def __init__(self, n, k, q, F): r""" Initialize ``self``. EXAMPLES:: sage: Cl = algebras.QuantumClifford(1,2) sage: TestSuite(Cl).run(elements=Cl.basis()) sage: Cl = algebras.QuantumClifford(1,3) sage: TestSuite(Cl).run(elements=Cl.basis()) # long time sage: Cl = algebras.QuantumClifford(3) # long time sage: elts = Cl.some_elements() + list(Cl.algebra_generators()) # long time sage: TestSuite(Cl).run(elements=elts) # long time sage: Cl = algebras.QuantumClifford(2,4) # long time sage: elts = Cl.some_elements() + list(Cl.algebra_generators()) # long time sage: TestSuite(Cl).run(elements=elts) # long time """ self._n = n self._k = k self._q = q self._psi = cartesian_product([(-1,0,1)]*n) self._w_poly = PolynomialRing(F, n, 'w') indices = [(tuple(psi), tuple(w)) for psi in self._psi for w in product(*[list(range((4-2*abs(psi[i]))*k)) for i in range(n)])] indices = FiniteEnumeratedSet(indices) cat = Algebras(F).FiniteDimensional().WithBasis() CombinatorialFreeModule.__init__(self, F, indices, category=cat) self._assign_names(self.algebra_generators().keys())
def __init__(self, base_ring, cartan_type, level, twisted): """ Initialize ``self``. EXAMPLES:: sage: Q = QSystem(QQ, ['A',2]) sage: TestSuite(Q).run() sage: Q = QSystem(QQ, ['E',6,2], twisted=True) sage: TestSuite(Q).run() """ self._cartan_type = cartan_type self._level = level self._twisted = twisted indices = tuple(itertools.product(cartan_type.index_set(), [1])) basis = IndexedFreeAbelianMonoid(indices, prefix='Q', bracket=False) # This is used to do the reductions if self._twisted: self._cm = cartan_type.classical().cartan_matrix() else: self._cm = cartan_type.cartan_matrix() self._Irev = {ind: pos for pos, ind in enumerate(self._cm.index_set())} self._poly = PolynomialRing( ZZ, ['q' + str(i) for i in self._cm.index_set()]) category = Algebras(base_ring).Commutative().WithBasis() CombinatorialFreeModule.__init__(self, base_ring, basis, prefix='Q', category=category)
def __init__(self, base_ring=QQ['t'], prefix='S'): r""" Initialize ``self``. EXAMPLES:: sage: S = ShiftingOperatorAlgebra(QQ['t']) sage: TestSuite(S).run() """ indices = ShiftingSequenceSpace() cat = Algebras(base_ring).WithBasis() CombinatorialFreeModule.__init__(self, base_ring, indices, prefix=prefix, bracket=False, category=cat) # Setup default conversions sym = SymmetricFunctions(base_ring) self._sym_h = sym.h() self._sym_s = sym.s() self._sym_h.register_conversion( self.module_morphism(self._supp_to_h, codomain=self._sym_h)) self._sym_s.register_conversion( self.module_morphism(self._supp_to_s, codomain=self._sym_s))
def __init__(self, k, q1, q2, q3, base_ring, prefix): r""" Initialize ``self``. TESTS:: sage: R.<q,r,s> = ZZ[] sage: B4 = algebras.Blob(4, q, r, s) sage: TestSuite(B4).run() sage: B3 = algebras.Blob(3, q, r, s) sage: B = list(B3.basis()) sage: TestSuite(B3).run(elements=B) # long time """ self._q1 = q1 self._q2 = q2 self._q3 = q3 diagrams = BlobDiagrams(k) cat = Algebras(base_ring.category()).FiniteDimensional().WithBasis() CombinatorialFreeModule.__init__(self, base_ring, diagrams, category=cat, prefix=prefix, bracket=False)
def __init__(self, A): r""" Initialize ``self``. EXAMPLES:: sage: S = SymmetricGroupAlgebra(QQ, 3) sage: C = S.cellular_basis() sage: TestSuite(C).run() """ self._algebra = A I = [(la, s, t) for la in A.cell_poset() for s in A.cell_module_indices(la) for t in A.cell_module_indices(la)] # TODO: Use instead A.category().Realizations() so # operations are defined by coercion? cat = Algebras(A.category().base_ring()).FiniteDimensional().WithBasis().Cellular() CombinatorialFreeModule.__init__(self, A.base_ring(), I, prefix='C', bracket=False, category=cat) # Register coercions if A._to_cellular_element is not NotImplemented: to_cellular = A.module_morphism(A._to_cellular_element, codomain=self, category=cat) if A._from_cellular_index is NotImplemented: from_cellular = ~to_cellular else: from_cellular = self.module_morphism(A._from_cellular_index, codomain=A, category=cat) if A._to_cellular_element is NotImplemented: to_cellular = ~from_cellular to_cellular.register_as_coercion() from_cellular.register_as_coercion()
def __init__(self, alg, prefix="D"): r""" Initialize ``self``. EXAMPLES:: sage: TestSuite(DescentAlgebra(QQ, 4).D()).run() """ self._prefix = prefix self._basis_name = "standard" p_set = subsets(range(1, alg._n)) CombinatorialFreeModule.__init__(self, alg.base_ring(), map(tuple, p_set), category=DescentAlgebraBases(alg), bracket="", prefix=prefix) # Change of basis: B = alg.B() self.module_morphism( self.to_B_basis, codomain=B, category=self.category()).register_as_coercion() B.module_morphism(B.to_D_basis, codomain=self, category=self.category()).register_as_coercion() # Coercion to symmetric group algebra SGA = SymmetricGroupAlgebra(alg.base_ring(), alg._n) self.module_morphism(self.to_symmetric_group_algebra, codomain=SGA, category=Algebras( alg.base_ring())).register_as_coercion()
def extra_super_categories(self): r""" Implement Maschke's theorem. In characteristic 0 all finite group algebras are semisimple. EXAMPLES:: sage: FiniteGroups().Algebras(QQ).is_subcategory(Algebras(QQ).Semisimple()) True sage: FiniteGroups().Algebras(FiniteField(7)).is_subcategory(Algebras(FiniteField(7)).Semisimple()) False sage: FiniteGroups().Algebras(ZZ).is_subcategory(Algebras(ZZ).Semisimple()) False sage: FiniteGroups().Algebras(Fields()).is_subcategory(Algebras(Fields()).Semisimple()) False sage: Cat = CommutativeAdditiveGroups().Finite() sage: Cat.Algebras(QQ).is_subcategory(Algebras(QQ).Semisimple()) True sage: Cat.Algebras(GF(7)).is_subcategory(Algebras(GF(7)).Semisimple()) False sage: Cat.Algebras(ZZ).is_subcategory(Algebras(ZZ).Semisimple()) False sage: Cat.Algebras(Fields()).is_subcategory(Algebras(Fields()).Semisimple()) False """ from sage.categories.fields import Fields K = self.base_ring() if (K in Fields) and K.characteristic() == 0: from sage.categories.algebras import Algebras return [Algebras(self.base_ring()).Semisimple()] else: return []
def polynomial_default_category(base_ring, multivariate): """ Choose an appropriate category for a polynomial ring. INPUT: - ``base_ring``: The ring over which the polynomial ring shall be defined. - ``multivariate``: Will the polynomial ring be multivariate? EXAMPLES:: sage: QQ['t'].category() is Category.join([EuclideanDomains(), CommutativeAlgebras(QQ)]) True sage: QQ['s','t'].category() is Category.join([UniqueFactorizationDomains(), CommutativeAlgebras(QQ)]) True sage: QQ['s']['t'].category() is Category.join([UniqueFactorizationDomains(), CommutativeAlgebras(QQ['s'])]) True """ if base_ring in _Fields: if multivariate: return JoinCategory( (_UniqueFactorizationDomains, CommutativeAlgebras(base_ring))) return JoinCategory( (_EuclideanDomains, CommutativeAlgebras(base_ring))) if base_ring in _UFD: #base_ring.is_unique_factorization_domain(): return JoinCategory( (_UniqueFactorizationDomains, CommutativeAlgebras(base_ring))) if base_ring in _ID: #base_ring.is_integral_domain(): return JoinCategory((_IntegralDomains, CommutativeAlgebras(base_ring))) if base_ring in _CommutativeRings: #base_ring.is_commutative(): return CommutativeAlgebras(base_ring) return Algebras(base_ring)
def __init__(self, ct, c, t, base_ring, prefix): r""" Initialize ``self``. EXAMPLES:: sage: k = QQ['c,t'] sage: R = algebras.RationalCherednik(['A',2], k.gen(0), k.gen(1)) sage: TestSuite(R).run() # long time """ self._c = c self._t = t self._cartan_type = ct self._weyl = RootSystem(ct).root_lattice().weyl_group(prefix=prefix[1]) self._hd = IndexedFreeAbelianMonoid(ct.index_set(), prefix=prefix[0], bracket=False) self._h = IndexedFreeAbelianMonoid(ct.index_set(), prefix=prefix[2], bracket=False) indices = DisjointUnionEnumeratedSets([self._hd, self._weyl, self._h]) CombinatorialFreeModule.__init__( self, base_ring, indices, category=Algebras(base_ring).WithBasis().Graded(), sorting_key=self._genkey)
def __init__(self, domain, on_generators, position=0, codomain=None, category=None): """ Given a map on the multiplicative basis of a free algebra, this method returns the algebra morphism that is the linear extension of its image on generators. INPUT: - ``domain`` -- an Askey-Wilson algebra - ``on_generators`` -- a list of length 6 corresponding to the images of the generators - ``codomain`` -- (optional) the codomain - ``position`` -- (default: 0) integer - ``category`` -- (optional) category OUTPUT: - module morphism EXAMPLES:: sage: AW = algebras.AskeyWilson(QQ) sage: sigma = AW.sigma() sage: TestSuite(sigma).run() """ if category is None: category = Algebras(Rings().Commutative()).WithBasis() self._on_generators = tuple(on_generators) ModuleMorphismByLinearity.__init__(self, domain=domain, codomain=codomain, position=position, category=category)
def __init__(self, g, q, c): """ Initialize ``self``. TESTS:: sage: O = lie_algebras.OnsagerAlgebra(QQ) sage: Q = O.quantum_group() sage: TestSuite(Q).run() # long time """ self._g = g self._q = q self._c = c self._q_two = q + ~q R = self._q_two.parent() from sage.monoids.indexed_free_monoid import IndexedFreeAbelianMonoid monomials = IndexedFreeAbelianMonoid(g.basis().keys(), prefix='B', bracket=False, sorting_key=self._monoid_key) CombinatorialFreeModule.__init__( self, R, monomials, prefix='', bracket=False, latex_bracket=False, sorting_key=self._monomial_key, category=Algebras(R).WithBasis().Filtered())
def __init__(self, R, L): """ Initialize ``self``. TESTS:: sage: L = posets.BooleanLattice(4) sage: M = L.moebius_algebra(QQ) sage: TestSuite(M).run() """ cat = Algebras(R).Commutative().WithBasis() if L in FiniteEnumeratedSets(): cat = cat.FiniteDimensional() self._lattice = L self._category = cat Parent.__init__(self, base=R, category=self._category.WithRealizations())
def __init__(self, g, basis_key, prefix, **kwds): """ Initialize ``self``. TESTS:: sage: L = lie_algebras.sl(QQ, 2) sage: PBW = L.pbw_basis() sage: E,F,H = PBW.algebra_generators() sage: TestSuite(PBW).run(elements=[E, F, H]) sage: TestSuite(PBW).run(elements=[E, F, H, E*F + H]) # long time """ if basis_key is not None: self._basis_key = basis_key else: self._basis_key_inverse = None R = g.base_ring() self._g = g monomials = IndexedFreeAbelianMonoid(g.basis().keys(), prefix, sorting_key=self._monoid_key, **kwds) CombinatorialFreeModule.__init__( self, R, monomials, prefix='', bracket=False, latex_bracket=False, sorting_key=self._monomial_key, category=Algebras(R).WithBasis().Filtered())
def __init__(self, R, names=None): """ Initialize ``self``. TESTS:: sage: A = algebras.FreeDendriform(QQ, '@'); A Free Dendriform algebra on one generator ['@'] over Rational Field sage: TestSuite(A).run() sage: F = algebras.FreeDendriform(QQ, 'xy') sage: TestSuite(F).run() # long time """ if names.cardinality() == 1: Trees = BinaryTrees() key = BinaryTree._sort_key else: Trees = LabelledBinaryTrees() key = LabelledBinaryTree._sort_key # Here one would need LabelledBinaryTrees(names) # so that one can restrict the labels to some fixed set self._alphabet = names cat = Algebras(R).WithBasis().Graded() CombinatorialFreeModule.__init__(self, R, Trees, latex_prefix="", sorting_key=key, category=cat)
def __init__(self, I, prefix='R'): """ Initialize ``self``. TESTS:: sage: P = posets.BooleanLattice(3) sage: R = P.incidence_algebra(QQ).reduced_subalgebra() sage: TestSuite(R).run() # long time """ self._ambient = I EC = {} P = self._ambient._poset if not P.is_finite(): raise NotImplementedError("only implemented for finite posets") for i in self._ambient.basis().keys(): S = P.subposet(P.interval(*i)) added = False for k in EC: if S._hasse_diagram.is_isomorphic(k._hasse_diagram): EC[k].append(i) added = True break if not added: EC[S] = [i] self._equiv_classes = map(sorted, EC.values()) self._equiv_classes = {cls[0]: cls for cls in self._equiv_classes} cat = Algebras(I.base_ring()).FiniteDimensional().WithBasis() CombinatorialFreeModule.__init__(self, I.base_ring(), sorted(self._equiv_classes.keys()), prefix=prefix, category=cat)
def __init__(self, base, names, degrees, max_degree, category=None, **kwargs): r""" Construct a commutative graded algebra with finite degree. TESTS:: sage: A.<x,y,z,t> = GradedCommutativeAlgebra(QQ, max_degree=6) sage: TestSuite(A).run() sage: A = GradedCommutativeAlgebra(QQ, ('x','y','z'), [2,3,4], max_degree=8) sage: TestSuite(A).run() sage: A = GradedCommutativeAlgebra(QQ, ('x','y','z','t'), [1,2,3,4], max_degree=10) sage: TestSuite(A).run() """ from sage.arith.misc import gcd if max_degree not in ZZ: raise TypeError('max_degree must be an integer') if max_degree < max(degrees): raise ValueError(f'max_degree must not deceed {max(degrees)}') self._names = names self.__ngens = len(self._names) self._degrees = degrees self._max_deg = max_degree self._weighted_vectors = WeightedIntegerVectors(degrees) self._mul_symbol = kwargs.pop('mul_symbol', '*') self._mul_latex_symbol = kwargs.pop('mul_latex_symbol', '') step = gcd(degrees) universe = DisjointUnionEnumeratedSets( self._weighted_vectors.subset(k) for k in range(0, max_degree, step)) base_cat = Algebras( base).WithBasis().Super().Supercommutative().FiniteDimensional() category = base_cat.or_subcategory(category, join=True) indices = ConditionSet(universe, self._valid_index) sorting_key = self._weighted_vectors.grading CombinatorialFreeModule.__init__(self, base, indices, sorting_key=sorting_key, category=category)
def __init__(self, base): """ Initialize ``self``. EXAMPLES:: sage: from sage.algebras.tensor_algebra import TensorAlgebraFunctor sage: F = TensorAlgebraFunctor(Rings()) sage: TestSuite(F).run() """ ConstructionFunctor.__init__(self, Modules(base), Algebras(base))
def __init__(self, base_ring, morphism, derivation, name, sparse, category=None): r""" Initialize ``self``. INPUT: - ``base_ring`` -- a commutative ring - ``morphism`` -- an automorphism of the base ring - ``derivation`` -- a derivation or a twisted derivation of the base ring - ``name`` -- string or list of strings representing the name of the variables of ring - ``sparse`` -- boolean (default: ``False``) - ``category`` -- a category EXAMPLES:: sage: R.<t> = ZZ[] sage: sigma = R.hom([t+1]) sage: S.<x> = SkewPolynomialRing(R, sigma) sage: S.category() Category of algebras over Univariate Polynomial Ring in t over Integer Ring sage: S([1]) + S([-1]) 0 sage: TestSuite(S).run() """ if self.Element is None: import sage.rings.polynomial.ore_polynomial_element self.Element = sage.rings.polynomial.ore_polynomial_element.OrePolynomial_generic_dense if self._fraction_field_class is None: from sage.rings.polynomial.ore_function_field import OreFunctionField self._fraction_field_class = OreFunctionField self.__is_sparse = sparse self._morphism = morphism self._derivation = derivation self._fraction_field = None category = Algebras(base_ring).or_subcategory(category) Algebra.__init__(self, base_ring, names=name, normalize=True, category=category)
def semisimple_quotient(self): """ Return the semisimple quotient of ``self``. This is the quotient of ``self`` by its radical. .. SEEALSO:: :meth:`radical` EXAMPLES:: sage: A = Algebras(QQ).FiniteDimensional().WithBasis().example(); A An example of a finite dimensional algebra with basis: the path algebra of the Kronecker quiver (containing the arrows a:x->y and b:x->y) over Rational Field sage: a,b,x,y = sorted(A.basis()) sage: S = A.semisimple_quotient(); S Semisimple quotient of An example of a finite dimensional algebra with basis: the path algebra of the Kronecker quiver (containing the arrows a:x->y and b:x->y) over Rational Field sage: S in Algebras(QQ).Semisimple() True sage: S.basis() Finite family {'y': B['y'], 'x': B['x']} sage: xs,ys = sorted(S.basis()) sage: (xs + ys) * xs B['x'] Sanity check: the semisimple quotient of the `n`-th descent algebra of the symmetric group is of dimension the number of partitions of `n`:: sage: [ DescentAlgebra(QQ,n).B().semisimple_quotient().dimension() ....: for n in range(6) ] [1, 1, 2, 3, 5, 7] sage: [Partitions(n).cardinality() for n in range(10)] [1, 1, 2, 3, 5, 7, 11, 15, 22, 30] .. TODO:: - Pickling by construction, as ``A.semisimple_quotient()``? - Lazy evaluation of ``_repr_`` TESTS:: sage: TestSuite(S).run() """ ring = self.base_ring() category = Algebras( ring).WithBasis().FiniteDimensional().Quotients().Semisimple() result = self.quotient_module(self.radical(), category=category) result.rename("Semisimple quotient of {}".format(self)) return result