Documentation

Mathlib.Data.List.Perm.Basic

List Permutations #

This file develops theory about the List.Perm relation.

Notation #

The notation ~ is used for permutation equivalence.

theorem List.perm_rfl {α : Type u_1} {l : List α} :
l.Perm l
theorem List.Perm.subset_congr_left {α : Type u_1} {l₁ l₂ l₃ : List α} (h : l₁.Perm l₂) :
l₁ l₃ l₂ l₃
theorem List.Perm.subset_congr_right {α : Type u_1} {l₁ l₂ l₃ : List α} (h : l₁.Perm l₂) :
l₃ l₁ l₃ l₂
theorem List.perm_comp_forall₂ {α : Type u_1} {β : Type u_2} {r : αβProp} {l u : List α} {v : List β} (hlu : l.Perm u) (huv : Forall₂ r u v) :
theorem List.rel_perm_imp {α : Type u_1} {β : Type u_2} {r : αβProp} (hr : Relator.RightUnique r) :
(Forall₂ r Forall₂ r fun (x1 x2 : Prop) => x1x2) Perm Perm
theorem List.rel_perm {α : Type u_1} {β : Type u_2} {r : αβProp} (hr : Relator.BiUnique r) :
(Forall₂ r Forall₂ r fun (x1 x2 : Prop) => x1 x2) Perm Perm
theorem List.count_eq_count_filter_add {α : Type u_1} [DecidableEq α] (P : αProp) [DecidablePred P] (l : List α) (a : α) :
count a l = count a (filter (fun (b : α) => decide (P b)) l) + count a (filter (fun (x : α) => decide ¬P x) l)
theorem List.Perm.foldl_eq {α : Type u_1} {β : Type u_2} {f : βαβ} {l₁ l₂ : List α} [rcomm : RightCommutative f] (p : l₁.Perm l₂) (b : β) :
foldl f b l₁ = foldl f b l₂
theorem List.Perm.foldr_eq {α : Type u_1} {β : Type u_2} {f : αββ} {l₁ l₂ : List α} [lcomm : LeftCommutative f] (p : l₁.Perm l₂) (b : β) :
foldr f b l₁ = foldr f b l₂
theorem List.Perm.foldl_op_eq {α : Type u_1} {op : ααα} [IA : Std.Associative op] [IC : Std.Commutative op] {l₁ l₂ : List α} {a : α} (h : l₁.Perm l₂) :
foldl op a l₁ = foldl op a l₂
theorem List.Perm.foldr_op_eq {α : Type u_1} {op : ααα} [IA : Std.Associative op] [IC : Std.Commutative op] {l₁ l₂ : List α} {a : α} (h : l₁.Perm l₂) :
foldr op a l₁ = foldr op a l₂
@[deprecated List.Perm.foldl_op_eq (since := "2024-09-28")]
theorem List.Perm.fold_op_eq {α : Type u_1} {op : ααα} [IA : Std.Associative op] [IC : Std.Commutative op] {l₁ l₂ : List α} {a : α} (h : l₁.Perm l₂) :
foldl op a l₁ = foldl op a l₂

Alias of List.Perm.foldl_op_eq.

theorem List.perm_option_toList {α : Type u_1} {o₁ o₂ : Option α} :
o₁.toList.Perm o₂.toList o₁ = o₂
@[deprecated List.perm_option_toList (since := "2024-10-16")]
theorem List.perm_option_to_list {α : Type u_1} {o₁ o₂ : Option α} :
o₁.toList.Perm o₂.toList o₁ = o₂

Alias of List.perm_option_toList.

theorem List.perm_replicate_append_replicate {α : Type u_1} [DecidableEq α] {l : List α} {a b : α} {m n : } (h : a b) :
l.Perm (replicate m a ++ replicate n b) count a l = m count b l = n l [a, b]
theorem List.Perm.flatMap_left {α : Type u_1} {β : Type u_2} (l : List α) {f g : αList β} (h : ∀ (a : α), a l(f a).Perm (g a)) :
(l.flatMap f).Perm (l.flatMap g)
@[deprecated List.Perm.flatMap_left (since := "2024-10-16")]
theorem List.Perm.bind_left {α : Type u_1} {β : Type u_2} (l : List α) {f g : αList β} (h : ∀ (a : α), a l(f a).Perm (g a)) :
(l.flatMap f).Perm (l.flatMap g)

Alias of List.Perm.flatMap_left.

theorem List.flatMap_append_perm {α : Type u_1} {β : Type u_2} (l : List α) (f g : αList β) :
(l.flatMap f ++ l.flatMap g).Perm (l.flatMap fun (x : α) => f x ++ g x)
@[deprecated List.flatMap_append_perm (since := "2024-10-16")]
theorem List.bind_append_perm {α : Type u_1} {β : Type u_2} (l : List α) (f g : αList β) :
(l.flatMap f ++ l.flatMap g).Perm (l.flatMap fun (x : α) => f x ++ g x)

Alias of List.flatMap_append_perm.

theorem List.map_append_flatMap_perm {α : Type u_1} {β : Type u_2} (l : List α) (f : αβ) (g : αList β) :
(map f l ++ l.flatMap g).Perm (l.flatMap fun (x : α) => f x :: g x)
@[deprecated List.map_append_flatMap_perm (since := "2024-10-16")]
theorem List.map_append_bind_perm {α : Type u_1} {β : Type u_2} (l : List α) (f : αβ) (g : αList β) :
(map f l ++ l.flatMap g).Perm (l.flatMap fun (x : α) => f x :: g x)

Alias of List.map_append_flatMap_perm.

theorem List.Perm.product_right {α : Type u_1} {β : Type u_2} {l₁ l₂ : List α} (t₁ : List β) (p : l₁.Perm l₂) :
(l₁.product t₁).Perm (l₂.product t₁)
theorem List.Perm.product_left {α : Type u_1} {β : Type u_2} (l : List α) {t₁ t₂ : List β} (p : t₁.Perm t₂) :
(l.product t₁).Perm (l.product t₂)
theorem List.Perm.product {α : Type u_1} {β : Type u_2} {l₁ l₂ : List α} {t₁ t₂ : List β} (p₁ : l₁.Perm l₂) (p₂ : t₁.Perm t₂) :
(l₁.product t₁).Perm (l₂.product t₂)
theorem List.perm_lookmap {α : Type u_1} (f : αOption α) {l₁ l₂ : List α} (H : Pairwise (fun (a b : α) => ∀ (c : α), c f a∀ (d : α), d f ba = b c = d) l₁) (p : l₁.Perm l₂) :
(lookmap f l₁).Perm (lookmap f l₂)