Module: sage.groups.perm_gps.permgroup_element
Author Log:
The Rubik's cube group:
sage: f= [(17,19,24,22),(18,21,23,20),(6,25,43,16),(7,28,42,13),(8,30,41,11)] sage: b=[(33,35,40,38),(34,37,39,36),( 3, 9,46,32),( 2,12,47,29),( 1,14,48,27)] sage: l=[( 9,11,16,14),(10,13,15,12),( 1,17,41,40),( 4,20,44,37),( 6,22,46,35)] sage: r=[(25,27,32,30),(26,29,31,28),( 3,38,43,19),( 5,36,45,21),( 8,33,48,24)] sage: u=[( 1, 3, 8, 6),( 2, 5, 7, 4),( 9,33,25,17),(10,34,26,18),(11,35,27,19)] sage: d=[(41,43,48,46),(42,45,47,44),(14,22,30,38),(15,23,31,39),(16,24,32,40)] sage: cube = PermutationGroup([f,b,l,r,u,d]) sage: F=cube.gens()[0] sage: B=cube.gens()[1] sage: L=cube.gens()[2] sage: R=cube.gens()[3] sage: U=cube.gens()[4] sage: D=cube.gens()[5] sage: cube.order() 43252003274489856000 sage: F.order() 4
The interested user may wish to explore the following commands: move = cube.random() and time word_problem([F,B,L,R,U,D], move, False). This typically takes about 5 minutes (on a 2 Ghz machine) and outputs a word ('solving' the cube in the position move) with about 60 terms or so.
Module-level Functions
x) |
Put a permutation in Gap format, as a string.
x) |
Class: PermutationGroupElement
sage: G = PermutationGroup(['(1,2,3)(4,5)']) sage: G Permutation Group with generators [(1,2,3)(4,5)] sage: g = G.random() sage: g in G True sage: g = G.gen(0); g (1,2,3)(4,5) sage: print g (1,2,3)(4,5) sage: g*g (1,3,2) sage: g**(-1) (1,3,2)(4,5) sage: g**2 (1,3,2) sage: G = PermutationGroup([(1,2,3)]) sage: g = G.gen(0); g (1,2,3) sage: g.order() 3
This example illustrates how permutations act on multivariate polynomials.
sage: R = MPolynomialRing(RationalField(), 5, ["x","y","z","u","v"]) sage: x, y, z, u, v = R.gens() sage: f = x**2 - y**2 + 3*z**2 sage: G = PermutationGroup(['(1,2,3)(4,5)', '(1,2,3,4,5)']) sage: sigma = G.gen(0) sage: f * sigma -1*z^2 + y^2 + 3*x^2
self, g, [parent=True], [check=None]) |
Create element of a permutation group.
There are several ways to define a permutation group element:
G.gens()
and multiplication * to construct
elements.
G([(1,2),(3,4,5)])
to construct an element of
the group. You could also use G('(1,2)(3,4,5)')
PermutationGroupElement([(1,2),(3,4,5)])
or PermutationGroupElement('(1,2)(3,4,5)')
to make a permutation group element with parent
INPUT: g -- defines element parent (optional) -- defines parent group (g must be in parent if specified, or a TypeError is raised). check -- bool (default: True), if False assumes g is a gap element in parent (if specified).
We illustrate construction of permutation using several different methods.
First we construct elements by multiplying together generators for a group.
sage: G = PermutationGroup(['(1,2)(3,4)', '(3,4,5,6)']) sage: s = G.gens() sage: s[0] (1,2)(3,4) sage: s[1] (3,4,5,6) sage: s[0]*s[1] (1,2)(3,5,6) sage: (s[0]*s[1]).parent() Permutation Group with generators [(1,2)(3,4), (3,4,5,6)]
Next we illustrate creation of a permutation using coercion into an already-created group.
sage: g = G([(1,2),(3,5,6)]) sage: g (1,2)(3,5,6) sage: g.parent() Permutation Group with generators [(1,2)(3,4), (3,4,5,6)] sage: g == s[0]*s[1] True
We can also use a string instead of a list to specify the permutation.
sage: h = G('(1,2)(3,5,6)') sage: g == h True
We can also make a permutation group element directly
using the PermutationGroupElement
command. Note
that the parent is then the full symmetric group
,
where
is the largest integer that is moved by the
permutation.
sage: k = PermutationGroupElement('(1,2)(3,5,6)') sage: k (1,2)(3,5,6) sage: k.parent() Symmetric group of order 6! as a permutation group
Note the comparison of permutations doesn't require that the parent groups are the same.
sage: k == g True
Arithmetic with permutations having different parents is also defined:
sage: k*g (3,6,5) sage: (k*g).parent() Symmetric group of order 6! as a permutation group
sage: G = PermutationGroup([[(1,2,3),(4,5)],[(3,4)]]) sage: loads(dumps(G.0)) == G.0 True
sage: k = PermutationGroupElement('(1,2)(3,5,6)') sage: k._gap_() (1,2)(3,5,6) sage: k._gap_().parent() Gap
Functions: matrix,
orbit,
order,
sign,
word_problem
self) |
Returns deg x deg permutation matrix associated to the permutation self
sage: G = PermutationGroup(['(1,2,3)(4,5)']) sage: g = G.gen(0) sage: g.matrix() [0 1 0 0 0] [0 0 1 0 0] [1 0 0 0 0] [0 0 0 0 1] [0 0 0 1 0]
self, n) |
Returns the orbit of the integer
under this group element,
as a sorted list of integers.
sage: G = PermutationGroup(['(1,2,3)(4,5)']) sage: g = G.gen(0) sage: g.orbit(4) [4, 5] sage: g.orbit(3) [1, 2, 3] sage: g.orbit(10) [10]
self) |
Return the order of this group element, which is the smallest
positive integer
for which
.
sage: s = PermutationGroupElement('(1,2)(3,5,6)') sage: s.order() 6
self) |
Returns the sign of self, which is
, where
is
the number of swaps.
sage: s = PermutationGroupElement('(1,2)(3,5,6)') sage: s.sign() -1
g, words, [display=True]) |
G and H are permutation groups, g in G, H is a subgroup of G generated by a list (words) of elements of G. If g is in H, return the expression for g as a word in the elements of (words).
This function does not solve the word problem in SAGE. Rather it pushes it over to GAP, which has optimized algorithms for the word problem. Essentially, this function is a wrapper for the GAP functions "EpimorphismFromFreeGroup" and "PreImagesRepresentative".
sage: G = PermutationGroup([[(1,2,3),(4,5)],[(3,4)]]) sage: g1 = G.gens()[0] sage: g2 = G.gens()[1] sage: h = g1^2*g2*g1 sage: h.word_problem([g1,g2], False) '(1,2,3)(4,5)^2*(3,4)^-1*(1,2,3)(4,5)' sage: h.word_problem([g1,g2]) x1^2*x2^-1*x1 [['(1,2,3)(4,5)', 2], ['(3,4)', -1], ['(1,2,3)(4,5)', 1]] '(1,2,3)(4,5)^2*(3,4)^-1*(1,2,3)(4,5)'
Special Functions: __call__,
__getitem__,
__invert__,
_cmp_,
_div_,
_gap_init_,
_latex_,
_mul_,
_r_action,
_repr_
self, i) |
Returns the image of the integer i under this permutation.
sage: G = PermutationGroup(['(1,2,3)(4,5)']) sage: G Permutation Group with generators [(1,2,3)(4,5)] sage: g = G.gen(0) sage: g(5) 4
self, i) |
Return the ith permutation cycle in the disjoint cycle representation of self.
INPUT: i -- integer OUTPUT: a permutation group element
sage: G = PermutationGroup([[(1,2,3),(4,5)]],5) sage: g = G.gen(0) sage: g[0] (1,2,3) sage: g[1] (4,5)
self) |
Return the inverse of this permutation.
sage: g = PermutationGroupElement('(1,2,3)(4,5)') sage: ~g (1,3,2)(4,5) sage: (~g) * g ()
self, right) |
Compare group elements self and right.
sage: G = PermutationGroup([[(1,2,3),(4,5)],[(3,4)]]) sage: G.gen(0) < G.gen(1) False sage: G.gen(0) > G.gen(1) True
self, other) |
Returns self divided by other, i.e., self times the inverse of other.
sage: g = PermutationGroupElement('(1,2,3)(4,5)') sage: h = PermutationGroupElement('(1,2,3)') sage: g/h (4,5)
self, left) |
Return the right action of self on left.
For example, if f=left is a polynomial, then this function returns f(sigma*x), which is image of f under the right action of sigma on the indeterminates. This is a right action since the image of f(sigma*x) under tau is f(sigma*tau*x).
INPUT: left -- element of space on which permutations act from the right
sage: G = PermutationGroup(['(1,2,3)(4,5)', '(1,2,3,4,5)']) sage: R = MPolynomialRing(RationalField(), 5, ["x","y","z","u","v"]) sage: x,y,z,u,v = R.gens() sage: f = x**2 + y**2 - z**2 + 2*u**2 sage: sigma, tau = G.gens() sage: f*sigma 2*v^2 + z^2 + y^2 - x^2 sage: f*tau 2*v^2 - u^2 + z^2 + y^2 sage: f*(sigma*tau) u^2 + z^2 - y^2 + 2*x^2 sage: (f*sigma)*tau u^2 + z^2 - y^2 + 2*x^2
self) |
Return string representation of this permutation.
We create the permutation
and print it.
sage: g = PermutationGroupElement([(1,2,3),(4,5)]) sage: g._repr_() '(1,2,3)(4,5)'
Permutation group elements support renaming them so they print however you want, as illustred below:
sage: g.rename('sigma') sage: g sigma sage: g.rename() sage: g (1,2,3)(4,5)
See About this document... for information on suggesting changes.