Permutation#

class discopy.python.finset.Permutation(inside=(), size=None)[source]#

Bases: Function, discopy.abc.SymmetricCategory

A permutation of a finite set, seen as a bijective finite-set function.

A permutation is represented by its action on range(n).

Examples

>>> Permutation((1, 0, 3, 2)).cycles()
((0, 1), (2, 3))
>>> Permutation.from_cycles([(0, 1), (2, 3)], 4)
(1, 0, 3, 2)
>>> Permutation((1, 0)).is_fixpoint_free_involution()
True
Parameters:
  • inside (list[int]) –

  • size (int | None) –

ob#

alias of int

classmethod id(dom=0)[source]#

The identity permutation on range(size).

Parameters:

dom (int) –

Return type:

Self

classmethod identity(dom=0)#

The identity permutation on range(size).

Parameters:

dom (int) –

Return type:

Self

classmethod from_cycles(cycles, size)[source]#

Build a permutation from cycles.

Parameters:
  • cycles (Cycles) –

  • size (int) –

Return type:

Self

classmethod from_transpositions(transpositions, size)[source]#

Build a permutation from disjoint 2-cycles.

Parameters:
  • transpositions (Cycles) –

  • size (int) –

Return type:

Self

cycles()[source]#

Return the cycles of the permutation.

Return type:

Cycles

cycle(start, seen=None)[source]#

Return the cycle reached from start.

Parameters:
  • start (int) –

  • seen (set[int] | None) –

Return type:

Cycle

then(other)[source]#

Return self ; other, i.e. result[i] == other[self[i]].

Parameters:

other (Self) –

Return type:

Self

dagger()[source]#

Return the inverse permutation.

Return type:

Self

conjugate(other)[source]#

Return other^-1 ; self ; other.

Parameters:

other (Self) –

Return type:

Self

tensor(other=None, *others)[source]#

Return the disjoint union of permutations.

Return type:

Self

embed(injection, size)[source]#

Embed into range(size) along injection.

Parameters:
  • injection (Iterable[int]) –

  • size (int) –

Return type:

Self

coequalizer(other)[source]#

Coequalize two permutations by quotienting generated orbits.

This computes the quotient of range(len(self)) by the equivalence relation generated by i ~ self[i] and i ~ other[i].

Equivalently, it returns the orbits of the subgroup generated by the two permutations. The returned quotient map q satisfies q[i] == q[self[i]] and q[i] == q[other[i]] for every element i, and is minimal with this property.

Parameters:

other (Self) – The second permutation, with the same size as self.

Returns:

A dictionary mapping each element to its quotient component.

Return type:

dict[int, int]

is_fixpoint_free_involution()[source]#

Whether this is a product of disjoint 2-cycles.

Return type:

bool