List Permutations #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
This file introduces the list.perm
relation, which is true if two lists are permutations of one
another.
Notation #
The notation ~
is used for permutation equivalence.
- nil : ∀ {α : Type uu}, list.nil ~ list.nil
- cons : ∀ {α : Type uu} (x : α) {l₁ l₂ : list α}, l₁ ~ l₂ → x :: l₁ ~ x :: l₂
- swap : ∀ {α : Type uu} (x y : α) (l : list α), y :: x :: l ~ x :: y :: l
- trans : ∀ {α : Type uu} {l₁ l₂ l₃ : list α}, l₁ ~ l₂ → l₂ ~ l₃ → l₁ ~ l₃
perm l₁ l₂
or l₁ ~ l₂
asserts that l₁
and l₂
are permutations
of each other. This is defined by induction using pairwise swaps.
Instances for list.perm
Alias of the forward direction of list.perm_singleton
.
Alias of the forward direction of list.singleton_perm
.
subperm l₁ l₂
, denoted l₁ <+~ l₂
, means that l₁
is a sublist of
a permutation of l₂
. This is an analogue of l₁ ⊆ l₂
which respects
multiplicities of elements, and is used for the ≤
relation on multisets.
Instances for list.subperm
If elements of a list additively commute with each other, then their sum does not depend on the order of elements.
Alias of the forward direction of list.subperm_cons
.
Alias of the reverse direction of list.subperm_cons
.
The list version of add_tsub_cancel_of_le
for multisets.
The list version of multiset.le_iff_count
.
Equations
- list.decidable_subperm = λ (l₁ l₂ : list α), decidable_of_iff (∀ (x : α), x ∈ l₁ → list.count x l₁ ≤ list.count x l₂) _
Equations
- (a :: l₁).decidable_perm l₂ = decidable_of_iff' (a ∈ l₂ ∧ l₁ ~ l₂.erase a) _
- list.nil.decidable_perm (b :: l₂) = decidable.is_false _
- list.nil.decidable_perm list.nil = decidable.is_true list.decidable_perm._main._proof_1