The areas / V33. Data structures and computation
Mathlib.Data.List.Perm.Basic
34 declarations. Mathlib docs · Source
theorem List.perm_rfl E1 #
∀ {α : Type u_1} {l : List α}, l.Perm l
instance List.instIsEquivPerm E0 #
∀ {α : Type u_1}, IsEquiv (List α) List.Perm
instance List.instIsPreorderSubperm E0 #
∀ {α : Type u_1}, IsPreorder (List α) List.Subperm
theorem List.Perm.subset_congr_left E1 #
∀ {α : Type u_1} {l₁ l₂ l₃ : List α}, l₁.Perm l₂ → (l₁ ⊆ l₃ ↔ l₂ ⊆ l₃)
theorem List.Perm.subset_congr_right E1 #
∀ {α : Type u_1} {l₁ l₂ l₃ : List α}, l₁.Perm l₂ → (l₃ ⊆ l₁ ↔ l₃ ⊆ l₂)
theorem List.set_perm_cons_eraseIdx E1 #
∀ {α : Type u_1} {l : List α} {n : ℕ}, n < l.length → ∀ (a : α), (l.set n a).Perm (a :: l.eraseIdx n)
theorem List.getElem_cons_eraseIdx_perm E1 #
∀ {α : Type u_1} {l : List α} {n : ℕ} (h : n < l.length), (l[n] :: l.eraseIdx n).Perm l
theorem List.insertIdx_eraseIdx_getElem_perm E1 #
∀ {α : Type u_1} {l : List α} {m n : ℕ} (hm : m < l.length),
n ≤ (l.eraseIdx m).length → ((l.eraseIdx m).insertIdx n l[m]).Perm l
theorem List.perm_insertIdx_iff_of_le E1 #
∀ {α : Type u_1} {l₁ l₂ : List α} {m n : ℕ},
m ≤ l₁.length → n ≤ l₂.length → ∀ (a : α), (l₁.insertIdx m a).Perm (l₂.insertIdx n a) ↔ l₁.Perm l₂
theorem List.Perm.insertIdx_of_le E1 #
∀ {α : Type u_1} {l₁ l₂ : List α} {m n : ℕ},
m ≤ l₁.length → n ≤ l₂.length → ∀ (a : α), l₁.Perm l₂ → (l₁.insertIdx m a).Perm (l₂.insertIdx n a)
Alias of the reverse direction of List.perm_insertIdx_iff_of_le.
theorem List.perm_insertIdx_iff E0 #
∀ {α : Type u_1} {l₁ l₂ : List α} {n : ℕ} {a : α}, (l₁.insertIdx n a).Perm (l₂.insertIdx n a) ↔ l₁.Perm l₂
theorem List.Perm.insertIdx E1 #
∀ {α : Type u_1} {l₁ l₂ : List α}, l₁.Perm l₂ → ∀ (n : ℕ) (a : α), (l₁.insertIdx n a).Perm (l₂.insertIdx n a)
theorem List.perm_eraseIdx_of_getElem?_eq E0 #
∀ {α : Type u_1} {l₁ l₂ : List α} {m n : ℕ}, l₁[m]? = l₂[n]? → ((l₁.eraseIdx m).Perm (l₂.eraseIdx n) ↔ l₁.Perm l₂)
theorem List.Perm.eraseIdx_of_getElem?_eq E0 #
∀ {α : Type u_1} {l₁ l₂ : List α} {m n : ℕ}, l₁[m]? = l₂[n]? → l₁.Perm l₂ → (l₁.eraseIdx m).Perm (l₂.eraseIdx n)
Alias of the reverse direction of List.perm_eraseIdx_of_getElem?_eq.
theorem List.perm_comp_perm E1 #
∀ {α : Type u_1}, Relation.Comp List.Perm List.Perm = List.Perm
theorem List.perm_comp_forall₂ E1 #
∀ {α : Type u_1} {β : Type u_2} {r : α → β → Prop} {l u : List α} {v : List β},
l.Perm u → List.Forall₂ r u v → Relation.Comp (List.Forall₂ r) List.Perm l v
theorem List.forall₂_comp_perm_eq_perm_comp_forall₂ E1 #
∀ {α : Type u_1} {β : Type u_2} {r : α → β → Prop},
Relation.Comp (List.Forall₂ r) List.Perm = Relation.Comp List.Perm (List.Forall₂ r)
theorem List.rel_perm_imp E1 #
∀ {α : Type u_1} {β : Type u_2} {r : α → β → Prop},
Relator.RightUnique r →
Relator.LiftFun (List.Forall₂ r) (Relator.LiftFun (List.Forall₂ r) fun x1 x2 ↦ x1 → x2) List.Perm List.Perm
theorem List.rel_perm E1 #
∀ {α : Type u_1} {β : Type u_2} {r : α → β → Prop},
Relator.BiUnique r →
Relator.LiftFun (List.Forall₂ r) (Relator.LiftFun (List.Forall₂ r) fun x1 x2 ↦ x1 ↔ x2) List.Perm List.Perm
theorem List.count_eq_count_filter_add E1 #
∀ {α : Type u_1} [inst : DecidableEq α] (P : α → Prop) [inst_1 : DecidablePred P] (l : List α) (a : α),
List.count a l =
List.count a (List.filter (fun b ↦ decide (P b)) l) + List.count a (List.filter (fun x ↦ decide ¬P x) l)
theorem List.Perm.foldl_eq E0 #
∀ {α : Type u_1} {β : Type u_2} {f : β → α → β} {l₁ l₂ : List α} [rcomm : RightCommutative f],
l₁.Perm l₂ → ∀ (b : β), List.foldl f b l₁ = List.foldl f b l₂
theorem List.Perm.foldr_eq E0 #
∀ {α : Type u_1} {β : Type u_2} {f : α → β → β} {l₁ l₂ : List α} [lcomm : LeftCommutative f],
l₁.Perm l₂ → ∀ (b : β), List.foldr f b l₁ = List.foldr f b l₂
theorem List.Perm.foldl_op_eq E0 #
∀ {α : Type u_1} {op : α → α → α} [IA : Std.Associative op] [IC : Std.Commutative op] {l₁ l₂ : List α} {a : α},
l₁.Perm l₂ → List.foldl op a l₁ = List.foldl op a l₂
theorem List.Perm.foldr_op_eq E0 #
∀ {α : Type u_1} {op : α → α → α} [IA : Std.Associative op] [IC : Std.Commutative op] {l₁ l₂ : List α} {a : α},
l₁.Perm l₂ → List.foldr op a l₁ = List.foldr op a l₂
theorem List.perm_option_toList E1 #
∀ {α : Type u_1} {o₁ o₂ : Option α}, o₁.toList.Perm o₂.toList ↔ o₁ = o₂
theorem List.perm_replicate_append_replicate E1 #
∀ {α : Type u_1} [inst : DecidableEq α] {l : List α} {a b : α} {m n : ℕ},
a ≠ b → (l.Perm (List.replicate m a ++ List.replicate n b) ↔ List.count a l = m ∧ List.count b l = n ∧ l ⊆ [a, b])
theorem List.map_perm_map_iff E0 #
∀ {α : Type u_1} {β : Type u_2} {l l' : List α} {f : α → β},
Function.Injective f → ((List.map f l).Perm (List.map f l') ↔ l.Perm l')
theorem List.Perm.flatMap_left E1 #
∀ {α : Type u_1} {β : Type u_2} (l : List α) {f g : α → List β},
(∀ a ∈ l, (f a).Perm (g a)) → (List.flatMap f l).Perm (List.flatMap g l)
theorem List.Perm.flatMap E1 #
∀ {α : Type u_1} {β : Type u_2} {l₁ l₂ : List α} {f g : α → List β},
l₁.Perm l₂ → (∀ a ∈ l₁, (f a).Perm (g a)) → (List.flatMap f l₁).Perm (List.flatMap g l₂)
theorem List.flatMap_append_perm E1 #
∀ {α : Type u_1} {β : Type u_2} (l : List α) (f g : α → List β),
(List.flatMap f l ++ List.flatMap g l).Perm (List.flatMap (fun x ↦ f x ++ g x) l)
theorem List.map_append_flatMap_perm E0 #
∀ {α : Type u_1} {β : Type u_2} (l : List α) (f : α → β) (g : α → List β),
(List.map f l ++ List.flatMap g l).Perm (List.flatMap (fun x ↦ f x :: g x) l)
theorem List.Perm.product_right E1 #
∀ {α : Type u_1} {β : Type u_2} {l₁ l₂ : List α} (t₁ : List β), l₁.Perm l₂ → (l₁.product t₁).Perm (l₂.product t₁)
theorem List.Perm.product_left E1 #
∀ {α : Type u_1} {β : Type u_2} (l : List α) {t₁ t₂ : List β}, t₁.Perm t₂ → (l.product t₁).Perm (l.product t₂)
theorem List.Perm.product E1 #
∀ {α : Type u_1} {β : Type u_2} {l₁ l₂ : List α} {t₁ t₂ : List β},
l₁.Perm l₂ → t₁.Perm t₂ → (l₁.product t₁).Perm (l₂.product t₂)