# Revision history [back]

Let us use names for the objects, i am working with particular examples.

P = Permutations(7)
Q = Permutations(9)

s = Permutation([(1,2,3), (4,5,6)])


Then we have:

sage: s.parent()
Standard permutations of 6
sage: P(s)
[2, 3, 1, 5, 6, 4, 7]
sage: P(s).parent()
Standard permutations of 7
sage: Q(s)
[2, 3, 1, 5, 6, 4, 7, 8, 9]
sage: Q(s).parent()
Standard permutations of 9
sage: s.cycle_type()
[3, 3]


When $s$ is moved to the group of permutations of seven symbols, its cycle type changes:

sage: P(s).cycle_type()
[3, 3, 1]


It turns out, that there are some "glitches" when we coerce the element $Q(s)$ (a permutation of nine elements) "back to" $P$ (permutations of seven elements):

sage: P(Q(s))
[2, 3, 1, 5, 6, 4, 7, 8, 9]
sage: P(Q(s)).parent()
Standard permutations of 7


In the background there is a dictionary that also knows about the values in 7,8,9.

sage: s.dict()
{1: 2, 2: 3, 3: 1, 4: 5, 5: 6, 6: 4}
sage: Q(s).dict()
{1: 2, 2: 3, 3: 1, 4: 5, 5: 6, 6: 4, 7: 7, 8: 8, 9: 9}
sage: P(Q(s)).dict()
{1: 2, 2: 3, 3: 1, 4: 5, 5: 6, 6: 4, 7: 7, 8: 8, 9: 9}
sage: P(s).dict()
{1: 2, 2: 3, 3: 1, 4: 5, 5: 6, 6: 4, 7: 7}


But as a rule, always find a large level that will cover all needed levels and work directly in there. Coercions to this bigger group of permutations will always work. An other way of working with permutations is by working in the symmetric group. For instance:

sage: S6 = SymmetricGroup(6)
sage: S7 = SymmetricGroup(7)
sage: S9 = SymmetricGroup(9)


And now the way elements are printed makes it easier to avoid the glitch.

sage: S6(s)
(1,2,3)(4,5,6)
sage: S7(s)
(1,2,3)(4,5,6)
sage: S9(s)
(1,2,3)(4,5,6)


We also compare dictionaries, and they match the parent:

sage: S6(s).dict()
{1: 2, 2: 3, 3: 1, 4: 5, 5: 6, 6: 4}
sage: S7(s).dict()
{1: 2, 2: 3, 3: 1, 4: 5, 5: 6, 6: 4, 7: 7}
sage: S9(s).dict()
{1: 2, 2: 3, 3: 1, 4: 5, 5: 6, 6: 4, 7: 7, 8: 8, 9: 9}
sage: S7(S9(s)).dict()
{1: 2, 2: 3, 3: 1, 4: 5, 5: 6, 6: 4, 7: 7}