Basic combinatorial objects

{{{id=5| p = Partition([3,3,2,1]) p /// [3, 3, 2, 1] }}} {{{id=65| p.pp() /// *** *** ** * }}} {{{id=9| p.conjugate().pp() /// **** *** ** }}} {{{id=11| p.conjugate? ///

File: /home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/combinat/partition.py

Type: <type ‘instancemethod’>

Definition: p.conjugate()

Docstring:

Returns the conjugate partition of the partition self. This is also called the associated partition in the literature.

EXAMPLES:

sage: Partition([2,2]).conjugate()
[2, 2]
sage: Partition([6,3,1]).conjugate()
[3, 2, 2, 1, 1, 1]

The conjugate partition is obtained by transposing the Ferrers diagram of the partition (see ferrers_diagram()):

sage: print Partition([6,3,1]).ferrers_diagram()
******
***
*
sage: print Partition([6,3,1]).conjugate().ferrers_diagram()
***
**
**
*
*
*
}}} {{{id=12| s = Permutation([5,3,2,6,4,8,9,7,1]) /// }}} {{{id=62| (p,q) = s.robinson_schensted() /// }}} {{{id=63| p.pp() /// 1 4 7 9 2 6 8 3 5 }}} {{{id=64| q.pp() /// 1 4 6 7 2 5 8 3 9 }}} {{{id=13| p.row_stabilizer() /// Permutation Group with generators [(), (7,9), (6,8), (4,7), (2,6), (1,4)] }}}

Enumerated sets (combinatorial classes)

{{{id=66| P5 = Partitions(5) /// }}} {{{id=14| P5.list() /// [[5], [4, 1], [3, 2], [3, 1, 1], [2, 2, 1], [2, 1, 1, 1], [1, 1, 1, 1, 1]] }}} {{{id=15| P5.cardinality() /// 7 }}} {{{id=16| Partitions(100000).cardinality() /// 27493510569775696512677516320986352688173429315980054758203125984302147328114964173055050741660736621590157844774296248940493063070200461792764493033510116079342457190155718943509725312466108452006369558934464248716828789832182345009262853831404597021307130674510624419227311238999702284408609370935531629697851569569892196108480158600569421098519 }}} {{{id=17| Permutations(20).random_element() /// [14, 15, 18, 10, 5, 11, 1, 9, 8, 4, 17, 19, 16, 20, 2, 7, 3, 13, 12, 6] }}} {{{id=18| Compositions(10).unrank(100) # TODO: non stupid algorithm /// [1, 1, 3, 1, 2, 1, 1] }}} {{{id=53| for p in StandardTableaux([3,2]): print "-----------------------------" p.pp() /// ----------------------------- 1 3 5 2 4 ----------------------------- 1 2 5 3 4 ----------------------------- 1 3 4 2 5 ----------------------------- 1 2 4 3 5 ----------------------------- 1 2 3 4 5 }}}

Todo: trees

Summary

Constructions

{{{id=80| C = DisjointUnionEnumeratedSets( [ Compositions(4), Permutations(3)] ) C /// Disjoint union of Family (Compositions of 4, Standard permutations of 3) }}} {{{id=81| C.cardinality() /// 14 }}} {{{id=79| C.list() /// [[1, 1, 1, 1], [1, 1, 2], [1, 2, 1], [1, 3], [2, 1, 1], [2, 2], [3, 1], [4], [1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]] }}} {{{id=69| C = CartesianProduct(Compositions(8), Permutations(20)) /// }}} {{{id=74| C.cardinality() /// 311411457046609920000 }}} {{{id=122| from sage.categories.examples.infinite_enumerated_sets import NonNegativeIntegers F = Family(NonNegativeIntegers(), Permutations) F /// Lazy family (Permutations(i))_{i in An example of an infinite enumerated set: the non negative integers} }}} {{{id=78| F[5] /// Standard permutations of 5 }}} {{{id=76| U = DisjointUnionEnumeratedSets(F) /// }}} {{{id=67| U.cardinality() /// +Infinity }}} {{{id=77| p = iter(U) for i in range(12): print p.next() /// [] [1] [1, 2] [2, 1] [1, 2, 3] [1, 3, 2] [2, 1, 3] [2, 3, 1] [3, 1, 2] [3, 2, 1] [1, 2, 3, 4] [1, 2, 4, 3] }}}

Summary:

Enumeration kernels

Integer lists

{{{id=86| Compositions(5, max_part = 3, min_length = 2, max_length = 3).list() /// [[3, 2], [3, 1, 1], [2, 3], [2, 2, 1], [2, 1, 2], [1, 3, 1], [1, 2, 2], [1, 1, 3]] }}} {{{id=87| Partitions(5, max_slope = -1).list() /// [[5], [4, 1], [3, 2]] }}} {{{id=88| IntegerListsLex(10, length=3, min_part = 2, max_part = 5, floor = [2, 4, 2]).list() /// [[4, 4, 2], [3, 5, 2], [3, 4, 3], [2, 5, 3], [2, 4, 4]] }}} {{{id=89| IntegerListsLex(5, min_part = 1, max_part = 3, min_length = 2, max_length = 3).list() /// [[3, 2], [3, 1, 1], [2, 3], [2, 2, 1], [2, 1, 2], [1, 3, 1], [1, 2, 2], [1, 1, 3]] }}} {{{id=90| IntegerListsLex(5, min_part = 1, max_slope = -1).list() /// [[5], [4, 1], [3, 2]] }}} {{{id=91| type(Compositions(5)[1]) /// }}} {{{id=123| type(IntegerListsLex(5, min_part = 1)[1]) /// }}}

Species / decomposable classes

{{{id=129| from sage.combinat.species.library import * o = var("o") /// }}}

Fibonacci words

{{{id=131| Eps = EmptySetSpecies() Z0 = SingletonSpecies() Z1 = Eps*SingletonSpecies() FW = CombinatorialSpecies() FW.define(Eps + Z0*FW + Z1*Eps + Z1*Z0*FW) FW /// Combinatorial species }}} {{{id=128| FW.isotype_generating_series().coefficients(15) /// [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987] }}} {{{id=135| FW3 = FW.isotypes([o]*4); FW3 /// Isomorphism types for Combinatorial species with labels [o, o, o, o] }}} {{{id=136| FW3.list() /// [o*(o*(o*(o*{}))), o*(o*(o*(({}*o)*{}))), o*(o*((({}*o)*o)*{})), o*((({}*o)*o)*(o*{})), o*((({}*o)*o)*(({}*o)*{})), (({}*o)*o)*(o*(o*{})), (({}*o)*o)*(o*(({}*o)*{})), (({}*o)*o)*((({}*o)*o)*{})] }}}

Binary trees

{{{id=152| BT = CombinatorialSpecies() Leaf = SingletonSpecies() BT.define(Leaf+(BT*BT)) BT5 = BT.isotypes([o]*5) BT5.list() /// [o*(o*(o*(o*o))), o*(o*((o*o)*o)), o*((o*o)*(o*o)), o*((o*(o*o))*o), o*(((o*o)*o)*o), (o*o)*(o*(o*o)), (o*o)*((o*o)*o), (o*(o*o))*(o*o), ((o*o)*o)*(o*o), (o*(o*(o*o)))*o, (o*((o*o)*o))*o, ((o*o)*(o*o))*o, ((o*(o*o))*o)*o, (((o*o)*o)*o)*o] }}}

Lattice points of polytopes

{{{id=93| A=random_matrix(ZZ,3,6,x=7) L=LatticePolytope(A) L.plot3d() /// }}} {{{id=56| L.npoints() # should be cardinality! /// 21 }}}

This example used PALP and J-mol.

Graphs up to an isomorphism

{{{id=23| show(graphs(5, lambda G: G.size() <= 4)) /// }}}

Predefined algebraic structures

{{{id=94| L = RootSystem(['A',2,1]).weight_space() L.plot(size=[[-1..1],[-1..1]],alcovewalks=[[0,2,0,1,2,1,2,0,2,1]]) /// }}} {{{id=107| CartanType.samples() /// Traceback (most recent call last): File "", line 1, in File "_sage_input_52.py", line 10, in exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("Q2FydGFuVHlwZS5zYW1wbGVzKCk="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))' + '\n', '', 'single') File "", line 1, in File "/tmp/tmpZf4MTy/___code___.py", line 2, in exec compile(u'CartanType.samples()' + '\n', '', 'single') File "", line 1, in File "/home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/combinat/root_system/cartan_type.py", line 544, in samples result = self._samples() File "/home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/misc/cachefunc.py", line 555, in __call__ w = self._cachedmethod._instance_call(self._instance, *args, **kwds) File "/home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/misc/cachefunc.py", line 778, in _instance_call return self._cachedfunc.f(inst, *args, **kwds) File "/home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/combinat/root_system/cartan_type.py", line 568, in _samples [CartanType(t).dual() for t in [["B", 5, 1], ["C", 4, 1], ["F", 4, 1], ["G", 2, 1]]] + \ File "/home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/combinat/root_system/cartan_type.py", line 689, in dual import type_dual File "/home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/combinat/root_system/type_dual.py", line 214, in class CartanType_affine(sage.combinat.root_system.cartan_type.CartanType_affine): AttributeError: 'module' object has no attribute 'cartan_type' }}} {{{id=109| T = CartanType(["E", 8, 1]) T.dynkin_diagram() /// O 2 | | O---O---O---O---O---O---O---O 1 3 4 5 6 7 8 0 E8~ }}} {{{id=108| T.is_simply_laced(), T.is_finite(), T.is_crystalographic() /// (True, False, True) }}} {{{id=105| W = WeylGroup(["B", 3]) W /// Weyl Group of type ['B', 3] (as a matrix group acting on the ambient space) }}} {{{id=104| W.cayley_graph(side = "left", simple = True).plot3d() /// }}} {{{id=126| print W.character_table() # Thanks GAP! /// CT1 2 4 4 3 3 4 3 1 1 3 4 3 1 . . . . . 1 1 . 1 1a 2a 2b 4a 2c 2d 6a 3a 4b 2e X.1 1 1 1 1 1 1 1 1 1 1 X.2 1 1 1 -1 -1 -1 -1 1 1 -1 X.3 1 1 -1 -1 1 -1 1 1 -1 1 X.4 1 1 -1 1 -1 1 -1 1 -1 -1 X.5 2 2 . . -2 . 1 -1 . -2 X.6 2 2 . . 2 . -1 -1 . 2 X.7 3 -1 -1 1 -1 -1 . . 1 3 X.8 3 -1 1 1 1 -1 . . -1 -3 X.9 3 -1 1 -1 -1 1 . . -1 3 X.10 3 -1 -1 -1 1 1 . . 1 -3 }}} {{{id=127| rho = SymmetricGroupRepresentation([3, 2], "orthogonal"); rho /// Orthogonal representation of the symmetric group corresponding to [3, 2] }}} {{{id=52| view(rho([1, 3, 2, 4, 5])) /// \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrrr} 1 & 0 & 0 & 0 & 0 \\ 0 & -\frac{1}{2} & \frac{1}{2} \, \sqrt{3} & 0 & 0 \\ 0 & \frac{1}{2} \, \sqrt{3} & \frac{1}{2} & 0 & 0 \\ 0 & 0 & 0 & -\frac{1}{2} & \frac{1}{2} \, \sqrt{3} \\ 0 & 0 & 0 & \frac{1}{2} \, \sqrt{3} & \frac{1}{2} \end{array}\right) }}} {{{id=102| W = WeylGroup(["C", 3, 1]) W /// Traceback (most recent call last): File "", line 1, in File "_sage_input_60.py", line 10, in exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("VyA9IFdleWxHcm91cChbIkMiLCAzLCAxXSkKVw=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))' + '\n', '', 'single') File "", line 1, in File "/tmp/tmp8vsZoW/___code___.py", line 3, in W = WeylGroup(["C", _sage_const_3 , _sage_const_1 ]) File "/home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/combinat/root_system/weyl_group.py", line 148, in WeylGroup return WeylGroup_gens(ct.root_system().root_space(), prefix=prefix) File "/home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/combinat/root_system/cartan_type.py", line 888, in root_system return RootSystem(self) File "/home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/misc/classcall_metaclass.py", line 276, in __call__ return cls.__classcall__(cls, *args, **options) File "/home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/combinat/root_system/root_system.py", line 226, in __classcall__ return super(RootSystem, cls).__classcall__(cls, CartanType(cartan_type), as_dual_of) File "/home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/misc/cachefunc.py", line 178, in __call__ w = self.f(*args, **kwds) File "/home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/structure/unique_representation.py", line 450, in __classcall__ instance = type.__call__(cls, *args, **options) File "/home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/combinat/root_system/root_system.py", line 243, in __init__ self.dual = RootSystem(self._cartan_type.dual(), as_dual_of=self); File "/home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/combinat/root_system/cartan_type.py", line 689, in dual import type_dual File "/home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/combinat/root_system/type_dual.py", line 214, in class CartanType_affine(sage.combinat.root_system.cartan_type.CartanType_affine): AttributeError: 'module' object has no attribute 'cartan_type' }}} {{{id=124| W.category() /// Category of finite weyl groups }}} {{{id=106| W.an_element() /// [ 0 0 -1] [ 1 0 0] [ 0 1 0] }}} {{{id=101| W.from_reduced_word([1,2,3,0,3,0,3,2,1,3,3,2]).stanley_symmetric_function() /// Traceback (most recent call last): File "", line 1, in File "_sage_input_63.py", line 10, in exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("Vy5mcm9tX3JlZHVjZWRfd29yZChbMSwyLDMsMCwzLDAsMywyLDEsMywzLDJdKS5zdGFubGV5X3N5bW1ldHJpY19mdW5jdGlvbigp"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))' + '\n', '', 'single') File "", line 1, in File "/tmp/tmpUjdzqR/___code___.py", line 3, in exec compile(u'W.from_reduced_word([_sage_const_1 ,_sage_const_2 ,_sage_const_3 ,_sage_const_0 ,_sage_const_3 ,_sage_const_0 ,_sage_const_3 ,_sage_const_2 ,_sage_const_1 ,_sage_const_3 ,_sage_const_3 ,_sage_const_2 ]).stanley_symmetric_function()' + '\n', '', 'single') File "", line 1, in File "/home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/categories/weyl_groups.py", line 331, in stanley_symmetric_function return m.from_polynomial_exp(self.stanley_symmetric_function_as_polynomial()) File "/home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/misc/cachefunc.py", line 555, in __call__ w = self._cachedmethod._instance_call(self._instance, *args, **kwds) File "/home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/misc/cachefunc.py", line 778, in _instance_call return self._cachedfunc.f(inst, *args, **kwds) File "/home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/categories/weyl_groups.py", line 278, in stanley_symmetric_function_as_polynomial pieri_factors = W.pieri_factors() File "/home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/categories/weyl_groups.py", line 116, in pieri_factors raise NotImplementedError("Pieri factors for type %s"%ct) NotImplementedError: Pieri factors for type ['B', 3] }}} {{{id=103| Sym = SymmetricFunctions(QQ) Sym /// Symmetric Functions over Rational Field }}} {{{id=95| s = Sym.schur() h = Sym.complete() e = Sym.elementary() m = Sym.monomial() p = Sym.powersum() /// }}} {{{id=110| m(( ( h[2,1] * ( 1 + 3 * p[2,1]) ) + s[2](s[3]))) /// 3*m[1, 1, 1] + 10*m[1, 1, 1, 1, 1, 1] + 2*m[2, 1] + 43*m[2, 1, 1, 1, 1] + 47*m[2, 2, 1, 1] + 40*m[2, 2, 2] + m[3] + 40*m[3, 1, 1, 1] + 33*m[3, 2, 1] + 20*m[3, 3] + 23*m[4, 1, 1] + 17*m[4, 2] + 10*m[5, 1] + 4*m[6] }}} {{{id=116| Sym = SymmetricFunctions(QQ['t']) Jack = Sym.jack_polynomials() # todo: not implemented P = Jack.P(); J = Jack.J(); Q = Jack.Q() # todo: not implemented J(P[2,1]) # todo: not implemented /// Traceback (most recent call last): File "", line 1, in File "_sage_input_67.py", line 10, in exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("U3ltID0gU3ltbWV0cmljRnVuY3Rpb25zKFFRWyd0J10pCkphY2sgPSBTeW0uamFja19wb2x5bm9taWFscygpCQkgICMgdG9kbzogbm90IGltcGxlbWVudGVkClAgPSBKYWNrLlAoKTsgSiA9IEphY2suSigpOyBRID0gSmFjay5RKCkgICMgdG9kbzogbm90IGltcGxlbWVudGVkCkooUFsyLDFdKSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgdG9kbzogbm90IGltcGxlbWVudGVk"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))' + '\n', '', 'single') File "", line 1, in File "/tmp/tmpuirIS_/___code___.py", line 4, in Jack = Sym.jack_polynomials() # todo: not implemented File "parent.pyx", line 823, in sage.structure.parent.Parent.__getattr__ (sage/structure/parent.c:6324) File "parent.pyx", line 323, in sage.structure.parent.getattr_from_other_class (sage/structure/parent.c:3162) AttributeError: 'SymmetricFunctions_with_category' object has no attribute 'jack_polynomials' }}} {{{id=118| J = MacdonaldPolynomialsJ(QQ) P = MacdonaldPolynomialsP(QQ) Q = MacdonaldPolynomialsQ(QQ) J /// Macdonald polynomials in the J basis over Fraction Field of Multivariate Polynomial Ring in q, t over Rational Field }}} {{{id=125| f = P(J[2,2] + 3 * Q[3,1]) f /// (q^2*t^6-q^2*t^5-q^2*t^4-q*t^5+q^2*t^3+2*q*t^3+t^3-q*t-t^2-t+1)*McdP[2, 2] + ((3*q^3*t^5-6*q^3*t^4+3*q^3*t^3-3*q^2*t^4+6*q^2*t^3-3*q^2*t^2-3*q*t^3+6*q*t^2-3*q*t+3*t^2-6*t+3)/(q^7*t-2*q^6*t+2*q^4*t-q^4-q^3*t+2*q^3-2*q+1))*McdP[3, 1] }}} {{{id=117| view(f) /// \newcommand{\Bold}[1]{\mathbf{#1}}\left(q^{2} t^{6} - q^{2} t^{5} - q^{2} t^{4} - q t^{5} + q^{2} t^{3} + 2 q t^{3} + t^{3} - q t - t^{2} - t + 1\right)McdP_{2,2} + \left(\frac{3 q^{3} t^{5} - 6 q^{3} t^{4} + 3 q^{3} t^{3} - 3 q^{2} t^{4} + 6 q^{2} t^{3} - 3 q^{2} t^{2} - 3 q t^{3} + 6 q t^{2} - 3 q t + 3 t^{2} - 6 t + 3}{q^{7} t - 2 q^{6} t + 2 q^{4} t - q^{4} - q^{3} t + 2 q^{3} - 2 q + 1}\right)McdP_{3,1} }}} {{{id=112| Sym = SymmetricFunctions(J.base_ring()) s = Sym.s() view(s(f)) /// \newcommand{\Bold}[1]{\mathbf{#1}}\left(\frac{- q^{8} t^{6} + q^{7} t^{7} + q^{9} t^{4} + q^{7} t^{6} - 2 q^{6} t^{7} - q^{9} t^{3} - q^{7} t^{5} + 2 q^{6} t^{6} - q^{9} t^{2} + 2 q^{8} t^{3} - 3 q^{7} t^{4} + 2 q^{6} t^{5} - 2 q^{5} t^{6} + 2 q^{4} t^{7} + q^{9} t + q^{8} t^{2} + q^{5} t^{5} - 2 q^{4} t^{6} - q^{3} t^{7} - 2 q^{8} t + 2 q^{7} t^{2} - 3 q^{6} t^{3} + 3 q^{5} t^{4} - 3 q^{4} t^{5} + 3 q^{3} t^{6} - q^{6} t^{2} + q^{5} t^{3} + q^{4} t^{4} - q^{3} t^{5} + 3 q^{6} t - 3 q^{5} t^{2} + 3 q^{4} t^{3} - 3 q^{3} t^{4} + 2 q^{2} t^{5} - 2 q t^{6} - q^{6} - 2 q^{5} t + q^{4} t^{2} + 3 q^{3} t^{3} - 3 q^{2} t^{4} + q t^{5} + t^{6} + 2 q^{5} - 2 q^{4} t - q^{3} t^{2} - q t^{4} + 2 t^{5} - q^{3} t + 2 q^{2} t^{2} + 3 q t^{3} - 4 t^{4} + q^{3} - 2 q^{2} t + 3 q t^{2} - 2 t^{3} + q^{2} - 4 q t + 3 t^{2}}{q^{7} t - 2 q^{6} t + 2 q^{4} t - q^{4} - q^{3} t + 2 q^{3} - 2 q + 1}\right)s_{1,1,1,1} + \left(\frac{- q^{8} t^{6} + q^{7} t^{7} + q^{8} t^{5} + 2 q^{7} t^{6} - 3 q^{6} t^{7} + q^{8} t^{4} - 4 q^{7} t^{5} + 3 q^{5} t^{7} - q^{8} t^{3} - q^{7} t^{4} + 5 q^{6} t^{5} - 2 q^{5} t^{6} - q^{4} t^{7} + 2 q^{7} t^{3} - 2 q^{6} t^{4} - q^{7} t^{2} + q^{6} t^{3} + q^{5} t^{4} - 4 q^{4} t^{5} + 3 q^{3} t^{6} + q^{7} t + 2 q^{6} t^{2} - 6 q^{5} t^{3} + 5 q^{4} t^{4} + q^{3} t^{5} - 3 q^{2} t^{6} - 3 q^{6} t + q^{5} t^{2} + 5 q^{4} t^{3} - 6 q^{3} t^{4} + 2 q^{2} t^{5} + q t^{6} + 3 q^{5} t - 4 q^{4} t^{2} + q^{3} t^{3} - 2 q^{2} t^{4} + 2 q t^{5} + 4 q^{2} t^{3} - 4 q t^{4} - q^{4} - 2 q^{3} t + 2 q^{2} t^{2} + 2 q t^{3} - t^{4} + 3 q^{3} - q t^{2} - 2 t^{3} - 3 q^{2} - 4 q t + 7 t^{2} + 4 q - 4 t}{q^{6} t - 3 q^{5} t + 3 q^{4} t - q^{3} t - q^{3} + 3 q^{2} - 3 q + 1}\right)s_{2,1,1} + \left(\frac{q^{9} t^{7} - q^{9} t^{6} - 2 q^{8} t^{7} - q^{9} t^{5} + q^{8} t^{6} + q^{9} t^{4} + 2 q^{8} t^{5} + 2 q^{7} t^{6} + 2 q^{6} t^{7} - 3 q^{6} t^{6} - q^{5} t^{7} - 3 q^{7} t^{4} - q^{6} t^{5} + q^{5} t^{6} - q^{8} t^{2} - q^{7} t^{3} + q^{6} t^{4} + q^{4} t^{6} + q^{7} t^{2} + q^{6} t^{3} + q^{5} t^{4} - 2 q^{4} t^{5} - 2 q^{3} t^{6} + q^{7} t + 2 q^{6} t^{2} + 2 q^{3} t^{5} + q^{2} t^{6} - 2 q^{6} t - 2 q^{5} t^{2} + q^{4} t^{3} - 2 q^{3} t^{4} + 4 q^{2} t^{5} + q^{5} t + 7 q^{3} t^{3} - 7 q^{2} t^{4} - q t^{5} + q^{4} t - 4 q^{3} t^{2} - q^{4} - 3 q^{3} t + 2 q^{3} + 2 q^{2} t + 5 q t^{2} - 2 t^{3} - 5 q t + 5 t^{2} + q - 4 t + 1}{q^{7} t - 2 q^{6} t + 2 q^{4} t - q^{4} - q^{3} t + 2 q^{3} - 2 q + 1}\right)s_{2,2} + \left(\frac{3 q^{3} t^{5} - 6 q^{3} t^{4} + 3 q^{3} t^{3} - 3 q^{2} t^{4} + 6 q^{2} t^{3} - 3 q^{2} t^{2} - 3 q t^{3} + 6 q t^{2} - 3 q t + 3 t^{2} - 6 t + 3}{q^{7} t - 2 q^{6} t + 2 q^{4} t - q^{4} - q^{3} t + 2 q^{3} - 2 q + 1}\right)s_{3,1} }}} {{{id=119| Cat = FiniteSemigroups(); Cat /// Category of finite semigroups }}} {{{id=146| Cat.category_graph().plot() /// }}} {{{id=144| S = Cat.example(alphabet = ('a','b','c')) S /// An example of a finite semigroup: the left regular band generated by ('a', 'b', 'c') }}} {{{id=149| S.cayley_graph(side = "left", simple = True).plot() /// }}} {{{id=24| S.j_transversal_of_idempotents() /// ['a', 'acb', 'ac', 'ab', 'cb', 'c', 'b'] }}} {{{id=145| S?? ///

File: /home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/categories/examples/finite_semigroups.py

Source Code (starting at line 19):

class LeftRegularBand(UniqueRepresentation, Parent):
    r"""
    An example of a finite semigroup

    This class provides a minimal implementation of a finite semigroup.

    EXAMPLES::

        sage: S = FiniteSemigroups().example(); S
        An example of a finite semigroup: the left regular band generated by ('a', 'b', 'c', 'd')

    This is the semigroup generated by::

        sage: S.semigroup_generators()
        Family ('a', 'b', 'c', 'd')

    such that `x^2 = x` and `x y x = xy` for any `x` and `y` in `S`::

        sage: S('dab')
        'dab'
        sage: S('dab') * S('acb')
        'dabc'

    It follows that the elements of `S` are strings without
    repetitions over the alphabet `a`, `b`, `c`, `d`::

        sage: S.list()
        ['a', 'c', 'b', 'bd', 'bda', 'd', 'bdc', 'bc', 'bcd', 'cb',
         'ca', 'ac', 'cba', 'ba', 'cbd', 'bdca', 'db', 'dc', 'cd',
         'bdac', 'ab', 'abd', 'da', 'ad', 'cbad', 'acb', 'abc',
         'abcd', 'acbd', 'cda', 'cdb', 'dac', 'dba', 'dbc', 'dbca',
         'dcb', 'abdc', 'cdab', 'bcda', 'dab', 'acd', 'dabc', 'cbda',
         'bca', 'dacb', 'bad', 'adb', 'bac', 'cab', 'adc', 'cdba',
         'dca', 'cad', 'adbc', 'adcb', 'dbac', 'dcba', 'acdb', 'bacd',
         'cabd', 'cadb', 'badc', 'bcad', 'dcab']

    It also follows that there are finitely many of them::

        sage: S.cardinality()
        64

    Indeed::

        sage: 4 * ( 1 + 3 * (1 + 2 * (1 + 1)))
        64

    As expected, all the elements of `S` are idempotents::

        sage: all( x.is_idempotent() for x in S )
        True

    Now, let us look at the structure of the semigroup::

        sage: S = FiniteSemigroups().example(alphabet = ('a','b','c'))
        sage: S.cayley_graph(side="left", simple=True).plot()
        sage: S.j_transversal_of_idempotents() # random (arbitrary choice)
        ['acb', 'ac', 'ab', 'bc', 'a', 'c', 'b']

    We conclude by running systematic tests on this semigroup::

        sage: TestSuite(S).run(verbose = True)
        running ._test_an_element() . . . pass
        running ._test_associativity() . . . pass
        running ._test_category() . . . pass
        running ._test_elements() . . .
          Running the test suite of self.an_element()
          running ._test_category() . . . pass
          running ._test_eq() . . . pass
          running ._test_not_implemented_methods() . . . pass
          running ._test_pickling() . . . pass
          pass
        running ._test_elements_eq() . . . pass
        running ._test_enumerated_set_contains() . . . pass
        running ._test_enumerated_set_iter_cardinality() . . . pass
        running ._test_enumerated_set_iter_list() . . . pass
        running ._test_eq() . . . pass
        running ._test_not_implemented_methods() . . . pass
        running ._test_pickling() . . . pass
        running ._test_some_elements() . . . pass
    """

    def __init__(self, alphabet=('a','b','c','d')):
        r"""
        A left regular band.

        EXAMPLES::

            sage: S = FiniteSemigroups().example(); S
            An example of a finite semigroup: the left regular band generated by ('a', 'b', 'c', 'd')
            sage: S = FiniteSemigroups().example(alphabet=('x','y')); S
            An example of a finite semigroup: the left regular band generated by ('x', 'y')
            sage: TestSuite(S).run()
        """
        self.alphabet = alphabet
        Parent.__init__(self, category = FiniteSemigroups())

    def _repr_(self):
        r"""
        TESTS::

            sage: S = FiniteSemigroups().example()
            sage: S._repr_()
            "An example of a finite semigroup: the left regular band generated by ('a', 'b', 'c', 'd')"
        """
        return "An example of a finite semigroup: the left regular band generated by %s"%(self.alphabet,)

    def product(self, x, y):
        r"""
        Returns the product of two elements of the semigroup.

        EXAMPLES::

            sage: S = FiniteSemigroups().example()
            sage: S('a') * S('b')
            'ab'
            sage: S('a') * S('b') * S('a')
            'ab'
            sage: S('a') * S('a')
            'a'

        """
        assert x in self
        assert y in self
        x = x.value
        y = y.value
        return self(x + ''.join(c for c in y if c not in x))

    @cached_method
    def semigroup_generators(self):
        r"""
        Returns the generators of the semigroup.

        EXAMPLES::

            sage: S = FiniteSemigroups().example(alphabet=('x','y'))
            sage: S.semigroup_generators()
            Family ('x', 'y')

        """
        return Family([self(i) for i in self.alphabet])

    def an_element(self):
        r"""
        Returns an element of the semigroup.

        EXAMPLES::

            sage: S = FiniteSemigroups().example()
            sage: S.an_element()
            'cdab'

            sage: S = FiniteSemigroups().example(("b"))
            sage: S.an_element()
            'b'
        """

        return self(''.join(self.alphabet[2:]+self.alphabet[0:2]))

    class Element (ElementWrapper):
        wrapped_class = str
        __lt__ = ElementWrapper._lt_by_value
}}} {{{id=147| Cat = HopfAlgebrasWithBasis(QQ); Cat /// Category of hopf algebras with basis over Rational Field }}} {{{id=113| Cat.category_graph().plot() /// }}} {{{id=143| Cat? ///

File: /home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/categories/hopf_algebras_with_basis.py

Type: <class ‘sage.categories.hopf_algebras_with_basis.HopfAlgebrasWithBasis’>

Definition: Cat(x, *args, **opts)

Docstring:

The category of Hopf algebras with a distinguished basis

EXAMPLES:

sage: C = HopfAlgebrasWithBasis(QQ)
sage: C
Category of hopf algebras with basis over Rational Field
sage: C.super_categories()
[Category of hopf algebras over Rational Field,
 Category of algebras with basis over Rational Field,
 Category of coalgebras with basis over Rational Field]

We now show how to use a simple hopf algebra, namely the group algebra of the dihedral group (see also AlgebrasWithBasis):

sage: A = C.example(); A
An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Rational Field
sage: A.__custom_name = "A"
sage: A.category()
Category of hopf algebras with basis over Rational Field

sage: A.one_basis()
()
sage: A.one()
B[()]

sage: A.base_ring()
Rational Field
sage: A.basis().keys()
Dihedral group of order 6 as a permutation group

sage: [a,b] = A.algebra_generators()
sage: a, b
(B[(1,2,3)], B[(1,3)])
sage: a^3, b^2
(B[()], B[()])
sage: a*b
B[(1,2)]

sage: A.product           # todo: not quite ...
<bound method MyGroupAlgebra_with_category._product_from_product_on_basis_multiply of A>
sage: A.product(b,b)
B[()]

sage: A.zero().coproduct()
0
sage: A.zero().coproduct().parent()
A # A
sage: a.coproduct()
B[(1,2,3)] # B[(1,2,3)]

sage: TestSuite(A).run(verbose=True)
running ._test_additive_associativity() . . . pass
running ._test_an_element() . . . pass
running ._test_associativity() . . . pass
running ._test_category() . . . pass
running ._test_distributivity() . . . pass
running ._test_elements() . . .
  Running the test suite of Cat.an_element()
  running ._test_category() . . . pass
  running ._test_eq() . . . pass
  running ._test_not_implemented_methods() . . . pass
  running ._test_pickling() . . . pass
  pass
running ._test_elements_eq() . . . pass
running ._test_eq() . . . pass
running ._test_not_implemented_methods() . . . pass
running ._test_one() . . . pass
running ._test_pickling() . . . pass
running ._test_prod() . . . pass
running ._test_some_elements() . . . pass
running ._test_zero() . . . pass
sage: A.__class__
<class 'sage.categories.examples.hopf_algebras_with_basis.MyGroupAlgebra_with_category'>
sage: A.element_class
<class 'sage.combinat.free_module.MyGroupAlgebra_with_category.element_class'>

Let us look at the code for implementing A:

sage: A??                       # todo: not implemented

TESTS:

sage: TestSuite(A).run()
sage: TestSuite(C).run()
}}} {{{id=111| H = Cat.example() H /// An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Rational Field }}} {{{id=114| H?? ///

File: /home/stumpc5/progs/sage-4.8/local/lib/python2.6/site-packages/sage/categories/examples/hopf_algebras_with_basis.py

Source Code (starting at line 17):

class MyGroupAlgebra(CombinatorialFreeModule):
    r"""
    An of a Hopf algebra with basis: the group algebra of a group

    This class illustrates a minimal implementation of a Hopf algebra with basis.
    """

    def __init__(self, R, G):
        """
        EXAMPLES::

            sage: from sage.categories.examples.hopf_algebras_with_basis import MyGroupAlgebra
            sage: A = MyGroupAlgebra(QQ, DihedralGroup(6))
            sage: A.category()
            Category of hopf algebras with basis over Rational Field
            sage: TestSuite(A).run()
        """
        self._group = G
        CombinatorialFreeModule.__init__(self, R, G, category = HopfAlgebrasWithBasis(R))

    def _repr_(self):
        """
        EXAMPLES::

            sage: HopfAlgebrasWithBasis(QQ).example() # indirect doctest
            An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Rational Field
        """
        return "An example of Hopf algebra with basis: the group algebra of the %s over %s"%(self._group, self.base_ring())

    @cached_method
    def one_basis(self):
        """
        Returns the one of the group, which index the one of this algebra,
        as per :meth:`AlgebrasWithBasis.ParentMethods.one_basis`.

        EXAMPLES::

            sage: A = HopfAlgebrasWithBasis(QQ).example()
            sage: A.one_basis()
            ()
            sage: A.one()
            B[()]
        """
        return self._group.one()

    def product_on_basis(self, g1, g2):
        r"""
        Product, on basis elements, as per :meth:`AlgebrasWithBasis.ParentMethods.product_on_basis`.

        The product of two basis elements is induced by the product of
        the corresponding elements of the group.

        EXAMPLES::

            sage: A = HopfAlgebrasWithBasis(QQ).example()
            sage: (a, b) = A._group.gens()
            sage: a*b
            (1,2)
            sage: A.product_on_basis(a, b)
            B[(1,2)]
        """
        return self.basis()[g1 * g2]

    @cached_method
    def algebra_generators(self):
        r"""
        The generators of this algebra, as per :meth:`Algebras.ParentMethods.algebra_generators`.

        They correspond to the generators of the group.

        EXAMPLES::

            sage: A = HopfAlgebrasWithBasis(QQ).example(); A
            An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Rational Field
            sage: A.algebra_generators()
            Finite family {(1,2,3): B[(1,2,3)], (1,3): B[(1,3)]}
        """
        return Family(self._group.gens(), self.monomial)

    def coproduct_on_basis(self, g):
        r"""
        Coproduct, on basis elements, as per :meth:`HopfAlgebrasWithBasis.ParentMethods.coproduct_on_basis`.

        The basis elements are group like: `\Delta(g) = g \otimes g`.

        EXAMPLES::

            sage: A = HopfAlgebrasWithBasis(QQ).example()
            sage: (a, b) = A._group.gens()
            sage: A.coproduct_on_basis(a)
            B[(1,2,3)] # B[(1,2,3)]
        """
        g = self.monomial(g)
        return tensor([g, g])

    def counit_on_basis(self, g):
        r"""
        Counit, on basis elements, as per :meth:`HopfAlgebrasWithBasis.ParentMethods.counit_on_basis`.

        The counit on the basis elements is 1.

        EXAMPLES::

            sage: A = HopfAlgebrasWithBasis(QQ).example()
            sage: (a, b) = A._group.gens()
            sage: A.counit_on_basis(a)
            1
        """
        return self.base_ring().one()

    def antipode_on_basis(self, g):
        r"""
        Antipode, on basis elements, as per :meth:`HopfAlgebrasWithBasis.ParentMethods.antipode_on_basis`.

        It is given, on basis elements, by `\nu(g) = g^{-1}`

        EXAMPLES::

            sage: A = HopfAlgebrasWithBasis(QQ).example()
            sage: (a, b) = A._group.gens()
            sage: A.antipode_on_basis(a)
            B[(1,3,2)]
        """
        return self.monomial(~g)
}}}