A permutation group is a subgroup of some symmetric group
. Sage has a Python class
PermutationGroup
, so you can work
with such groups directly:
sage: G = PermutationGroup(['(1,2,3)(4,5)']) sage: G Permutation Group with generators [(1,2,3)(4,5)] sage: g = G.gens()[0]; g (1,2,3)(4,5) sage: g*g (1,3,2) sage: G = PermutationGroup(['(1,2,3)']) sage: g = G.gens()[0]; g (1,2,3) sage: g.order() 3
For the example of the Rubik's cube group
(a permutation subgroup of
, where the non-center facets
of the Rubik's cube are labeled
in some fixed way),
you can use the GAP-Sage interface as follows.
sage: cube = "cubegp := Group( ( 1, 3, 8, 6)( 2, 5, 7, 4)( 9,33,25,17)(10,34,26,18)(11,35,27,19), ( 9,11,16,14)(10,13,15,12)( 1,17,41,40)( 4,20,44,37)( 6,22,46,35), (17,19,24,22)(18,21,23,20)( 6,25,43,16)( 7,28,42,13)( 8,30,41,11), (25,27,32,30)(26,29,31,28)( 3,38,43,19)( 5,36,45,21)( 8,33,48,24), (33,35,40,38)(34,37,39,36)( 3, 9,46,32)( 2,12,47,29)( 1,14,48,27), (41,43,48,46)(42,45,47,44)(14,22,30,38)(15,23,31,39)(16,24,32,40) )" sage: gap(cube) 'permutation group with 6 generators' sage: gap("Size(cubegp)") 43252003274489856000'
Another way you can choose to do this:
cubegroup.py
containing the lines
cube = "cubegp := Group( ( 1, 3, 8, 6)( 2, 5, 7, 4)( 9,33,25,17)(10,34,26,18)(11,35,27,19), ( 9,11,16,14)(10,13,15,12)( 1,17,41,40)( 4,20,44,37)( 6,22,46,35), (17,19,24,22)(18,21,23,20)( 6,25,43,16)( 7,28,42,13)( 8,30,41,11), (25,27,32,30)(26,29,31,28)( 3,38,43,19)( 5,36,45,21)( 8,33,48,24), (33,35,40,38)(34,37,39,36)( 3, 9,46,32)( 2,12,47,29)( 1,14,48,27), (41,43,48,46)(42,45,47,44)(14,22,30,38)(15,23,31,39)(16,24,32,40) )"
local/lib/python2.4/site-packages/sage
of your Sage home directory.
import
) it into Sage:
sage: import sage.cubegroup sage: sage.cubegroup.cube 'cubegp := Group(( 1, 3, 8, 6)( 2, 5, 7, 4)( 9,33,25,17)(10,34,26,18) (11,35,27,19),( 9,11,16,14)(10,13,15,12)( 1,17,41,40)( 4,20,44,37) ( 6,22,46,35),(17,19,24,22)(18,21,23,20)( 6,25,43,16)( 7,28,42,13) ( 8,30,41,11),(25,27,32,30)(26,29,31,28)( 3,38,43,19)( 5,36,45,21) ( 8,33,48,24),(33,35,40,38)(34,37,39,36)( 3, 9,46,32)( 2,12,47,29) ( 1,14,48,27),(41,43,48,46)(42,45,47,44)(14,22,30,38)(15,23,31,39) (16,24,32,40) )' sage: gap(sage.cubegroup.cube) 'permutation group with 6 generators' sage: gap("Size(cubegp)") '43252003274489856000'
(You will have line wrap instead of the above carriage returns in your Sage output.)
CubeGroup
class
sage: rubik = CubeGroup() sage: rubik The PermutationGroup of all legal moves of the Rubik's cube. sage: print rubik The Rubik's cube group with genrators R,L,F,B,U,D in SymmetricGroup(48). sage: G = rubik.group() sage: G.order() 43252003274489856000
(2) Sage also has implemented finite and infinite (but finitely generated) abelian groups.
See About this document... for information on suggesting changes.