List Permutations #
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.
Equations
- List.instTransPerm = { trans := ⋯ }
theorem
List.Perm.recOnSwap'
{α : Type u_1}
{motive : (l₁ l₂ : List α) → l₁.Perm l₂ → Prop}
{l₁ l₂ : List α}
(p : l₁.Perm l₂)
(nil : motive [] [] ⋯)
(cons : ∀ (x : α) {l₁ l₂ : List α} (h : l₁.Perm l₂), motive l₁ l₂ h → motive (x :: l₁) (x :: l₂) ⋯)
(swap' : ∀ (x y : α) {l₁ l₂ : List α} (h : l₁.Perm l₂), motive l₁ l₂ h → motive (y :: x :: l₁) (x :: y :: l₂) ⋯)
(trans : ∀ {l₁ l₂ l₃ : List α} (h₁ : l₁.Perm l₂) (h₂ : l₂.Perm l₃), motive l₁ l₂ h₁ → motive l₂ l₃ h₂ → motive l₁ l₃ ⋯)
:
motive l₁ l₂ p
Similar to Perm.recOn
, but the swap
case is generalized to Perm.swap'
,
where the tail of the lists are not necessarily the same.
Equations
- List.isSetoid α = { r := List.Perm, iseqv := ⋯ }
theorem
List.perm_cons_erase
{α : Type u_1}
[DecidableEq α]
{a : α}
{l : List α}
(h : a ∈ l)
:
l.Perm (a :: l.erase a)
theorem
List.Perm.filterMap
{α : Type u_1}
{β : Type u_2}
(f : α → Option β)
{l₁ l₂ : List α}
(p : l₁.Perm l₂)
:
(List.filterMap f l₁).Perm (List.filterMap f l₂)
theorem
List.Perm.filter
{α : Type u_1}
(p : α → Bool)
{l₁ l₂ : List α}
(s : l₁.Perm l₂)
:
(List.filter p l₁).Perm (List.filter p l₂)
theorem
List.Perm.count_eq
{α : Type u_1}
[DecidableEq α]
{l₁ l₂ : List α}
(p : l₁.Perm l₂)
(a : α)
:
theorem
List.Perm.rec_heq
{α : Type u_1}
{β : List α → Sort u_2}
{f : (a : α) → (l : List α) → β l → β (a :: l)}
{b : β []}
{l l' : List α}
(hl : l.Perm l')
(f_congr : ∀ {a : α} {l l' : List α} {b : β l} {b' : β l'}, l.Perm l' → HEq b b' → HEq (f a l b) (f a l' b'))
(f_swap : ∀ {a a' : α} {l : List α} {b : β l}, HEq (f a (a' :: l) (f a' l b)) (f a' (a :: l) (f a l b)))
:
theorem
List.Perm.erase
{α : Type u_1}
[DecidableEq α]
(a : α)
{l₁ l₂ : List α}
(p : l₁.Perm l₂)
:
(l₁.erase a).Perm (l₂.erase a)
Equations
- l₁.decidablePerm l₂ = decidable_of_iff (l₁.isPerm l₂ = true) ⋯
theorem
List.Perm.insert
{α : Type u_1}
[DecidableEq α]
(a : α)
{l₁ l₂ : List α}
(p : l₁.Perm l₂)
:
(List.insert a l₁).Perm (List.insert a l₂)
theorem
List.perm_insert_swap
{α : Type u_1}
[DecidableEq α]
(x y : α)
(l : List α)
:
(List.insert x (List.insert y l)).Perm (List.insert y (List.insert x l))
If two lists are sorted by an antisymmetric relation, and permutations of each other, they must be equal.
theorem
List.Perm.flatten
{α : Type u_1}
{l₁ l₂ : List (List α)}
(h : l₁.Perm l₂)
:
l₁.flatten.Perm l₂.flatten
@[reducible, inline, deprecated List.Perm.flatten (since := "2024-10-14")]
abbrev
List.Perm.join
{α : Type u_1}
{l₁ l₂ : List (List α)}
(h : l₁.Perm l₂)
:
l₁.flatten.Perm l₂.flatten
Equations
Instances For
@[reducible, inline, deprecated List.Perm.flatMap_right (since := "2024-10-16")]
abbrev
List.Perm.bind_right
{α : Type u_1}
{β : Type u_2}
{l₁ l₂ : List α}
(f : α → List β)
(p : l₁.Perm l₂)
:
(l₁.flatMap f).Perm (l₂.flatMap f)
Instances For
theorem
List.Perm.eraseP
{α : Type u_1}
(f : α → Bool)
{l₁ l₂ : List α}
(H : Pairwise (fun (a b : α) => f a = true → f b = true → False) l₁)
(p : l₁.Perm l₂)
:
(List.eraseP f l₁).Perm (List.eraseP f l₂)