Permutations from a list #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
A list l : list α
can be interpreted as a equiv.perm α
where each element in the list
is permuted to the next one, defined as form_perm
. When we have that nodup l
,
we prove that equiv.perm.support (form_perm l) = l.to_finset
, and that
form_perm l
is rotationally invariant, in form_perm_rotate
.
When there are duplicate elements in l
, how and in what arrangement with respect to the other
elements they appear in the list determines the formed permutation.
This is because list.form_perm
is implemented as a product of equiv.swap
s.
That means that presence of a sublist of two adjacent duplicates like [..., x, x, ...]
will produce the same permutation as if the adjacent duplicates were not present.
The list.form_perm
definition is meant to primarily be used with nodup l
, so that
the resulting permutation is cyclic (if l
has at least two elements).
The presence of duplicates in a particular placement can lead list.form_perm
to produce a
nontrivial permutation that is noncyclic.
A list l : list α
can be interpreted as a equiv.perm α
where each element in the list
is permuted to the next one, defined as form_perm
. When we have that nodup l
,
we prove that equiv.perm.support (form_perm l) = l.to_finset
, and that
form_perm l
is rotationally invariant, in form_perm_rotate
.
Equations
- l.form_perm = (list.zip_with equiv.swap l l.tail).prod