File: Mathlib/Data/List/Perm.lean

full_name: List.instTransPerm_mathlib
code: instance : Trans (@List.Perm α) (@List.Perm α) List.Perm 
goal: Trans List.Perm List.Perm List.Perm

full_name: List.perm_rfl
code: lemma perm_rfl : l ~ l 
goal: l.Perm l

full_name: List.Perm.subset_congr_left
code: theorem Perm.subset_congr_left {l₁ l₂ l₃ : List α} (h : l₁ ~ l₂) : l₁ ⊆ l₃ ↔ l₂ ⊆ l₃ 
goal: l₁ ⊆ l₃ ↔ l₂ ⊆ l₃

full_name: List.Perm.subset_congr_right
code: theorem Perm.subset_congr_right {l₁ l₂ l₃ : List α} (h : l₁ ~ l₂) : l₃ ⊆ l₁ ↔ l₃ ⊆ l₂ 
goal: l₃ ⊆ l₁ ↔ l₃ ⊆ l₂

full_name: List._aux_Mathlib_Data_List_Perm___unexpand_Relation_Comp_1
code: local infixr:80 " ∘r " => Relation.Comp
goal: Lean.PrettyPrinter.Unexpander

full_name: List.«_aux_Mathlib_Data_List_Perm___macroRules_List_term_∘r__1»
code: local infixr:80 " ∘r " => Relation.Comp
goal: Lean.Macro

full_name: List.perm_comp_perm
code: theorem perm_comp_perm : (Perm ∘r Perm : List α → List α → Prop) = Perm 
goal: Relation.Comp List.Perm List.Perm = List.Perm

full_name: List.perm_comp_forall₂
code: theorem perm_comp_forall₂ {l u v} (hlu : Perm l u) (huv : Forall₂ r u v) :
    (Forall₂ r ∘r Perm) l v 
goal: Relation.Comp (List.Forall₂ r) List.Perm l v

full_name: List.forall₂_comp_perm_eq_perm_comp_forall₂
code: theorem forall₂_comp_perm_eq_perm_comp_forall₂ : Forall₂ r ∘r Perm = Perm ∘r Forall₂ r 
goal: Relation.Comp (List.Forall₂ r) List.Perm = Relation.Comp List.Perm (List.Forall₂ r)

full_name: List.rel_perm_imp
code: theorem rel_perm_imp (hr : RightUnique r) : (Forall₂ r ⇒ Forall₂ r ⇒ (· → ·)) Perm Perm 
goal: (List.Forall₂ r ⇒ List.Forall₂ r ⇒ fun x x_1 => x → x_1) List.Perm List.Perm

full_name: List.rel_perm
code: theorem rel_perm (hr : BiUnique r) : (Forall₂ r ⇒ Forall₂ r ⇒ (· ↔ ·)) Perm Perm 
goal: (List.Forall₂ r ⇒ List.Forall₂ r ⇒ fun x x_1 => x ↔ x_1) List.Perm List.Perm

full_name: List.subperm_iff
code: lemma subperm_iff : l₁ <+~ l₂ ↔ ∃ l, l ~ l₂ ∧ l₁ <+ l 
goal: l₁.Subperm l₂ ↔ ∃ l, l.Perm l₂ ∧ l₁.Sublist l

full_name: List.subperm_singleton_iff
code: @[simp] lemma subperm_singleton_iff : l <+~ [a] ↔ l = [] ∨ l = [a] 
goal: l.Subperm [a] ↔ l = [] ∨ l = [a]

full_name: List.subperm_nil
code: @[simp]
theorem subperm_nil : List.Subperm l [] ↔ l = [] 
goal: l.Subperm [] ↔ l = []

full_name: List.subperm_cons_self
code: lemma subperm_cons_self : l <+~ a :: l 
goal: l.Subperm (a :: l)

full_name: List.count_eq_count_filter_add
code: lemma count_eq_count_filter_add [DecidableEq α] (P : α → Prop) [DecidablePred P]
    (l : List α) (a : α) :
    count a l = count a (l.filter P) + count a (l.filter (¬ P ·)) 
goal: 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)

full_name: List.Perm.foldl_eq
code: theorem Perm.foldl_eq {f : β → α → β} {l₁ l₂ : List α} (rcomm : RightCommutative f) (p : l₁ ~ l₂) :
    ∀ b, foldl f b l₁ = foldl f b l₂ 
goal: List.foldl f b l₁ = List.foldl f b l₂

full_name: List.Perm.foldr_eq
code: theorem Perm.foldr_eq {f : α → β → β} {l₁ l₂ : List α} (lcomm : LeftCommutative f) (p : l₁ ~ l₂) :
    ∀ b, foldr f b l₁ = foldr f b l₂ 
goal: List.foldr f b l₁ = List.foldr f b l₂

full_name: List.«_aux_Mathlib_Data_List_Perm___macroRules_List_term_*__1»
code: local notation a " * " b => op a b
goal: Lean.Macro

full_name: List.«_aux_Mathlib_Data_List_Perm___macroRules_List_term_<*>__1»
code: local notation l " <*> " a => foldl op a l
goal: Lean.Macro

full_name: List._aux_Mathlib_Data_List_Perm___unexpand_List_foldl_1
code: local notation l " <*> " a => foldl op a l
goal: Lean.PrettyPrinter.Unexpander

full_name: List.Perm.fold_op_eq
code: theorem Perm.fold_op_eq {l₁ l₂ : List α} {a : α} (h : l₁ ~ l₂) : (l₁ <*> a) = l₂ <*> a 
goal: List.foldl op a l₁ = List.foldl op a l₂

full_name: List.perm_option_to_list
code: theorem perm_option_to_list {o₁ o₂ : Option α} : o₁.toList ~ o₂.toList ↔ o₁ = o₂ 
goal: o₁.toList.Perm o₂.toList ↔ o₁ = o₂

full_name: List.cons_subperm_of_mem
code: theorem cons_subperm_of_mem {a : α} {l₁ l₂ : List α} (d₁ : Nodup l₁) (h₁ : a ∉ l₁) (h₂ : a ∈ l₂)
    (s : l₁ <+~ l₂) : a :: l₁ <+~ l₂ 
goal: (a :: l₁).Subperm l₂

full_name: List.Nodup.subperm
code: protected theorem Nodup.subperm (d : Nodup l₁) (H : l₁ ⊆ l₂) : l₁ <+~ l₂ 
goal: l₁.Subperm l₂

full_name: List.Perm.bagInter_right
code: theorem Perm.bagInter_right {l₁ l₂ : List α} (t : List α) (h : l₁ ~ l₂) :
    l₁.bagInter t ~ l₂.bagInter t 
goal: (l₁.bagInter t).Perm (l₂.bagInter t)

full_name: List.Perm.bagInter_left
code: theorem Perm.bagInter_left (l : List α) {t₁ t₂ : List α} (p : t₁ ~ t₂) :
    l.bagInter t₁ = l.bagInter t₂ 
goal: l.bagInter t₁ = l.bagInter t₂

full_name: List.Perm.bagInter
code: theorem Perm.bagInter {l₁ l₂ t₁ t₂ : List α} (hl : l₁ ~ l₂) (ht : t₁ ~ t₂) :
    l₁.bagInter t₁ ~ l₂.bagInter t₂ 
goal: (l₁.bagInter t₁).Perm (l₂.bagInter t₂)

full_name: List.perm_replicate_append_replicate
code: theorem perm_replicate_append_replicate {l : List α} {a b : α} {m n : ℕ} (h : a ≠ b) :
    l ~ replicate m a ++ replicate n b ↔ count a l = m ∧ count b l = n ∧ l ⊆ [a, b] 
goal: l.Perm (List.replicate m a ++ List.replicate n b) ↔ List.count a l = m ∧ List.count b l = n ∧ l ⊆ [a, b]

full_name: List.Perm.dedup
code: theorem Perm.dedup {l₁ l₂ : List α} (p : l₁ ~ l₂) : dedup l₁ ~ dedup l₂ 
goal: l₁.dedup.Perm l₂.dedup

full_name: List.Perm.inter_append
code: theorem Perm.inter_append {l t₁ t₂ : List α} (h : Disjoint t₁ t₂) :
    l ∩ (t₁ ++ t₂) ~ l ∩ t₁ ++ l ∩ t₂ 
goal: (l ∩ (t₁ ++ t₂)).Perm (l ∩ t₁ ++ l ∩ t₂)

full_name: List.Perm.bind_left
code: theorem Perm.bind_left (l : List α) {f g : α → List β} (h : ∀ a ∈ l, f a ~ g a) :
    l.bind f ~ l.bind g 
goal: (l.bind f).Perm (l.bind g)

full_name: List.bind_append_perm
code: theorem bind_append_perm (l : List α) (f g : α → List β) :
    l.bind f ++ l.bind g ~ l.bind fun x => f x ++ g x 
goal: (l.bind f ++ l.bind g).Perm (l.bind fun x => f x ++ g x)

full_name: List.map_append_bind_perm
code: theorem map_append_bind_perm (l : List α) (f : α → β) (g : α → List β) :
    l.map f ++ l.bind g ~ l.bind fun x => f x :: g x 
goal: (List.map f l ++ l.bind g).Perm (l.bind fun x => f x :: g x)

full_name: List.Perm.product_right
code: theorem Perm.product_right {l₁ l₂ : List α} (t₁ : List β) (p : l₁ ~ l₂) :
    product l₁ t₁ ~ product l₂ t₁ 
goal: (l₁.product t₁).Perm (l₂.product t₁)

full_name: List.Perm.product_left
code: theorem Perm.product_left (l : List α) {t₁ t₂ : List β} (p : t₁ ~ t₂) :
    product l t₁ ~ product l t₂ 
goal: (l.product t₁).Perm (l.product t₂)

full_name: List.Perm.product
code: theorem Perm.product {l₁ l₂ : List α} {t₁ t₂ : List β} (p₁ : l₁ ~ l₂) (p₂ : t₁ ~ t₂) :
    product l₁ t₁ ~ product l₂ t₂ 
goal: (l₁.product t₁).Perm (l₂.product t₂)

full_name: List.perm_lookmap
code: theorem perm_lookmap (f : α → Option α) {l₁ l₂ : List α}
    (H : Pairwise (fun a b => ∀ c ∈ f a, ∀ d ∈ f b, a = b ∧ c = d) l₁) (p : l₁ ~ l₂) :
    lookmap f l₁ ~ lookmap f l₂ 
goal: (List.lookmap f l₁).Perm (List.lookmap f l₂)

full_name: List.Perm.take_inter
code: theorem Perm.take_inter [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys)
    (h' : ys.Nodup) : xs.take n ~ ys.inter (xs.take n) 
goal: (List.take n xs).Perm (ys.inter (List.take n xs))

full_name: List.Perm.drop_inter
code: theorem Perm.drop_inter [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys) (h' : ys.Nodup) :
    xs.drop n ~ ys.inter (xs.drop n) 
goal: (List.drop n xs).Perm (ys.inter (List.drop n xs))

full_name: List.Perm.dropSlice_inter
code: theorem Perm.dropSlice_inter [DecidableEq α] {xs ys : List α} (n m : ℕ) (h : xs ~ ys)
    (h' : ys.Nodup) : List.dropSlice n m xs ~ ys ∩ List.dropSlice n m xs 
goal: (List.dropSlice n m xs).Perm (ys ∩ List.dropSlice n m xs)

full_name: List.perm_of_mem_permutationsAux
code: theorem perm_of_mem_permutationsAux :
    ∀ {ts is l : List α}, l ∈ permutationsAux ts is → l ~ ts ++ is 
goal: l ∈ ts.permutationsAux is → l.Perm (ts ++ is)

full_name: List.perm_of_mem_permutations
code: theorem perm_of_mem_permutations {l₁ l₂ : List α} (h : l₁ ∈ permutations l₂) : l₁ ~ l₂ 
goal: l₁.Perm l₂

full_name: List.length_permutationsAux
code: theorem length_permutationsAux :
    ∀ ts is : List α, length (permutationsAux ts is) + is.length ! = (length ts + length is)! 
goal: (ts.permutationsAux is).length + is.length ! = (ts.length + is.length)!

full_name: List.length_permutations
code: theorem length_permutations (l : List α) : length (permutations l) = (length l)! 
goal: l.permutations.length = l.length !

full_name: List.mem_permutations_of_perm_lemma
code: theorem mem_permutations_of_perm_lemma {is l : List α}
    (H : l ~ [] ++ is → (∃ (ts' : _) (_ : ts' ~ []), l = ts' ++ is) ∨ l ∈ permutationsAux is []) :
    l ~ is → l ∈ permutations is 
goal: l.Perm is → l ∈ is.permutations

full_name: List.mem_permutationsAux_of_perm
code: theorem mem_permutationsAux_of_perm :
    ∀ {ts is l : List α},
      l ~ is ++ ts → (∃ (is' : _) (_ : is' ~ is), l = is' ++ ts) ∨ l ∈ permutationsAux ts is 
goal: l.Perm (is ++ ts) → (∃ is', ∃ (_ : is'.Perm is), l = is' ++ ts) ∨ l ∈ ts.permutationsAux is

full_name: List.mem_permutations
code: @[simp]
theorem mem_permutations {s t : List α} : s ∈ permutations t ↔ s ~ t 
goal: s ∈ t.permutations ↔ s.Perm t

full_name: _private.Mathlib.Data.List.Perm.0.List.DecEq_eq
code: private theorem DecEq_eq [DecidableEq α] :
    List.instBEq = @instBEqOfDecidableEq (List α) instDecidableEqList 
goal: List.instBEq = instBEqOfDecidableEq

full_name: List.perm_permutations'Aux_comm
code: theorem perm_permutations'Aux_comm (a b : α) (l : List α) :
    (permutations'Aux a l).bind (permutations'Aux b) ~
      (permutations'Aux b l).bind (permutations'Aux a) 
goal: ((List.permutations'Aux a l).bind (List.permutations'Aux b)).Perm
  ((List.permutations'Aux b l).bind (List.permutations'Aux a))

full_name: List.Perm.permutations'
code: theorem Perm.permutations' {s t : List α} (p : s ~ t) : permutations' s ~ permutations' t 
goal: s.permutations'.Perm t.permutations'

full_name: List.permutations_perm_permutations'
code: theorem permutations_perm_permutations' (ts : List α) : ts.permutations ~ ts.permutations' 
goal: ts.permutations.Perm ts.permutations'

full_name: List.mem_permutations'
code: @[simp]
theorem mem_permutations' {s t : List α} : s ∈ permutations' t ↔ s ~ t 
goal: s ∈ t.permutations' ↔ s.Perm t

full_name: List.Perm.permutations
code: theorem Perm.permutations {s t : List α} (h : s ~ t) : permutations s ~ permutations t 
goal: s.permutations.Perm t.permutations

full_name: List.perm_permutations_iff
code: @[simp]
theorem perm_permutations_iff {s t : List α} : permutations s ~ permutations t ↔ s ~ t 
goal: s.permutations.Perm t.permutations ↔ s.Perm t

full_name: List.perm_permutations'_iff
code: @[simp]
theorem perm_permutations'_iff {s t : List α} : permutations' s ~ permutations' t ↔ s ~ t 
goal: s.permutations'.Perm t.permutations' ↔ s.Perm t

full_name: List.getElem_permutations'Aux
code: theorem getElem_permutations'Aux (s : List α) (x : α) (n : ℕ)
    (hn : n < length (permutations'Aux x s)) :
    (permutations'Aux x s)[n] = s.insertNth n x 
goal: (List.permutations'Aux x s)[n] = List.insertNth n x s

full_name: List.get_permutations'Aux
code: theorem get_permutations'Aux (s : List α) (x : α) (n : ℕ)
    (hn : n < length (permutations'Aux x s)) :
    (permutations'Aux x s).get ⟨n, hn⟩ = s.insertNth n x 
goal: (List.permutations'Aux x s).get ⟨n, hn⟩ = List.insertNth n x s

full_name: List.nthLe_permutations'Aux
code: @[deprecated get_permutations'Aux (since := "2024-04-23")]
theorem nthLe_permutations'Aux (s : List α) (x : α) (n : ℕ)
    (hn : n < length (permutations'Aux x s)) :
    (permutations'Aux x s).nthLe n hn = s.insertNth n x 
goal: (List.permutations'Aux x s).nthLe n hn = List.insertNth n x s

full_name: List.count_permutations'Aux_self
code: theorem count_permutations'Aux_self [DecidableEq α] (l : List α) (x : α) :
    count (x :: l) (permutations'Aux x l) = length (takeWhile (x = ·) l) + 1 
goal: List.count (x :: l) (List.permutations'Aux x l) = (List.takeWhile (fun x_1 => decide (x = x_1)) l).length + 1

full_name: List.length_permutations'Aux
code: @[simp]
theorem length_permutations'Aux (s : List α) (x : α) :
    length (permutations'Aux x s) = length s + 1 
goal: (List.permutations'Aux x s).length = s.length + 1

full_name: List.permutations'Aux_get_zero
code: @[deprecated (since := "2024-06-12")]
theorem permutations'Aux_get_zero (s : List α) (x : α)
    (hn : 0 < length (permutations'Aux x s) := (by simp)) :
    (permutations'Aux x s).get ⟨0, hn⟩ = x :: s 
goal: (List.permutations'Aux x s).get ⟨0, hn⟩ = x :: s

full_name: List.injective_permutations'Aux
code: theorem injective_permutations'Aux (x : α) : Function.Injective (permutations'Aux x) 
goal: Function.Injective (List.permutations'Aux x)

full_name: List.nodup_permutations'Aux_of_not_mem
code: theorem nodup_permutations'Aux_of_not_mem (s : List α) (x : α) (hx : x ∉ s) :
    Nodup (permutations'Aux x s) 
goal: (List.permutations'Aux x s).Nodup

full_name: List.nodup_permutations'Aux_iff
code: theorem nodup_permutations'Aux_iff {s : List α} {x : α} : Nodup (permutations'Aux x s) ↔ x ∉ s 
goal: (List.permutations'Aux x s).Nodup ↔ x ∉ s

full_name: List.nodup_permutations
code: theorem nodup_permutations (s : List α) (hs : Nodup s) : Nodup s.permutations 
goal: s.permutations.Nodup