Permutation#
- class discopy.python.finset.Permutation(inside=(), size=None)[source]#
Bases:
Function,discopy.abc.SymmetricCategoryA 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
- 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
- conjugate(other)[source]#
Return
other^-1 ; self ; other.- Parameters:
other (Self) –
- Return type:
Self
- embed(injection, size)[source]#
Embed into
range(size)alonginjection.- 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 byi ~ self[i]andi ~ other[i].Equivalently, it returns the orbits of the subgroup generated by the two permutations. The returned quotient map
qsatisfiesq[i] == q[self[i]]andq[i] == q[other[i]]for every elementi, 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]