The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V33. Data structures and computation

Mathlib.Data.List.Nodup

72 declarations and 2 deprecated aliases. Mathlib docs · Source

theorem List.Pairwise.nodup E1 #

∀ {α : Type u} {l : List α} {r : α → α → Prop} [Std.Irrefl r], List.Pairwise r l → l.Nodup

theorem List.rel_nodup E1 #

∀ {α : Type u} {β : Type v} {r : α → β → Prop},
  Relator.BiUnique r → Relator.LiftFun (List.Forall₂ r) (fun x1 x2 ↦ x1 ↔ x2) List.Nodup List.Nodup

theorem List.Nodup.cons E1 #

∀ {α : Type u} {l : List α} {a : α}, a ∉ l → l.Nodup → (a :: l).Nodup

theorem List.nodup_singleton E1 #

∀ {α : Type u} (a : α), [a].Nodup

theorem List.Nodup.of_cons E1 #

∀ {α : Type u} {l : List α} {a : α}, (a :: l).Nodup → l.Nodup

theorem List.Nodup.notMem E1 #

∀ {α : Type u} {l : List α} {a : α}, (a :: l).Nodup → a ∉ l

theorem List.not_nodup_cons_of_mem E1 #

∀ {α : Type u} {l : List α} {a : α}, a ∈ l → ¬(a :: l).Nodup

theorem List.not_nodup_pair E1 #

∀ {α : Type u} (a : α), ¬[a, a].Nodup

theorem List.nodup_iff_sublist E1 #

∀ {α : Type u} {l : List α}, l.Nodup ↔ ∀ (a : α), ¬[a, a].Sublist l

theorem List.nodup_mergeSort E0 #

∀ {α : Type u} {l : List α} {le : α → α → Bool}, (l.mergeSort le).Nodup ↔ l.Nodup

theorem List.Nodup.mergeSort E1 #

∀ {α : Type u} {l : List α} {le : α → α → Bool}, l.Nodup → (l.mergeSort le).Nodup

Alias of the reverse direction of List.nodup_mergeSort.

theorem List.nodup_iff_injective_getElem E1 #

∀ {α : Type u} {l : List α}, l.Nodup ↔ Function.Injective fun i ↦ l[↑i]

theorem List.nodup_iff_injective_get E1 #

∀ {α : Type u} {l : List α}, l.Nodup ↔ Function.Injective l.get

theorem List.Nodup.injective_get E1 #

∀ {α : Type u} {l : List α}, l.Nodup → Function.Injective l.get

theorem Function.Injective.nodup E1 #

∀ {α : Type u} {l : List α}, Function.Injective l.get → l.Nodup

theorem List.Nodup.get_inj_iff E0 #

∀ {α : Type u} {l : List α}, l.Nodup → ∀ {i j : Fin l.length}, l.get i = l.get j ↔ i = j

theorem List.Nodup.getElem_inj_iff E0 #

∀ {α : Type u} {l : List α}, l.Nodup → ∀ {i : ℕ} {hi : i < l.length} {j : ℕ} {hj : j < l.length}, l[i] = l[j] ↔ i = j

theorem List.nodup_iff_getElem?_ne_getElem? E1 #

∀ {α : Type u} {l : List α}, l.Nodup ↔ ∀ (i j : ℕ), i < j → j < l.length → l[i]? ≠ l[j]?

theorem List.Nodup.ne_singleton_iff E0 #

∀ {α : Type u} {l : List α}, l.Nodup → ∀ (x : α), l ≠ [x] ↔ l = [] ∨ ∃ y ∈ l, y ≠ x

theorem List.not_nodup_of_get_eq_of_ne E1 #

∀ {α : Type u} (xs : List α) (n m : Fin xs.length), xs.get n = xs.get m → n ≠ m → ¬xs.Nodup

theorem List.Nodup.head_eq_getLast_iff E0 #

∀ {α : Type u} {l : List α} (hne : l ≠ []), l.Nodup → (l.head hne = l.getLast hne ↔ ∃ x, l = [x])

theorem List.get_idxOf E1 #

∀ {α : Type u} [inst : BEq α] [LawfulBEq α] {l : List α}, l.Nodup → ∀ (i : Fin l.length), List.idxOf (l.get i) l = ↑i

theorem List.nodup_iff_count_le_one E1 #

∀ {α : Type u} [inst : BEq α] [LawfulBEq α] {l : List α}, l.Nodup ↔ ∀ (a : α), List.count a l ≤ 1

theorem List.nodup_iff_count_eq_one E1 #

∀ {α : Type u} {l : List α} [inst : BEq α] [LawfulBEq α], l.Nodup ↔ ∀ a ∈ l, List.count a l = 1

theorem List.get_bijective_iff E0 #

∀ {α : Type u} {l : List α} [inst : BEq α] [LawfulBEq α], Function.Bijective l.get ↔ ∀ (a : α), List.count a l = 1

theorem List.getElem_bijective_iff E0 #

∀ {α : Type u} {l : List α} [inst : BEq α] [LawfulBEq α],
  (Function.Bijective fun n ↦ l[n]) ↔ ∀ (a : α), List.count a l = 1

theorem List.count_eq_one_of_mem E0 #

∀ {α : Type u} [inst : BEq α] [LawfulBEq α] {a : α} {l : List α}, l.Nodup → a ∈ l → List.count a l = 1

theorem List.Nodup.of_append_left E1 #

∀ {α : Type u} {l₁ l₂ : List α}, (l₁ ++ l₂).Nodup → l₁.Nodup

theorem List.Nodup.of_append_right E1 #

∀ {α : Type u} {l₁ l₂ : List α}, (l₁ ++ l₂).Nodup → l₂.Nodup

theorem List.nodup_append' E1 #

∀ {α : Type u} {l₁ l₂ : List α}, (l₁ ++ l₂).Nodup ↔ l₁.Nodup ∧ l₂.Nodup ∧ l₁.Disjoint l₂

This is a variant of the nodup_append from the standard library, which does not use Disjoint.

theorem List.disjoint_of_nodup_append E1 #

∀ {α : Type u} {l₁ l₂ : List α}, (l₁ ++ l₂).Nodup → l₁.Disjoint l₂

theorem List.Nodup.disjoint E1 #

∀ {α : Type u} {l₁ l₂ : List α}, (l₁ ++ l₂).Nodup → l₁.Disjoint l₂

Alias of List.disjoint_of_nodup_append.

theorem List.Nodup.append E1 #

∀ {α : Type u} {l₁ l₂ : List α}, l₁.Nodup → l₂.Nodup → l₁.Disjoint l₂ → (l₁ ++ l₂).Nodup

theorem List.nodup_append_comm E1 #

∀ {α : Type u} {l₁ l₂ : List α}, (l₁ ++ l₂).Nodup ↔ (l₂ ++ l₁).Nodup

theorem List.nodup_middle E1 #

∀ {α : Type u} {a : α} {l₁ l₂ : List α}, (l₁ ++ a :: l₂).Nodup ↔ (a :: (l₁ ++ l₂)).Nodup

theorem List.Nodup.of_map E1 #

∀ {α : Type u} {β : Type v} (f : α → β) {l : List α}, (List.map f l).Nodup → l.Nodup

theorem List.Nodup.map_on E0 #

∀ {α : Type u} {β : Type v} {l : List α} {f : α → β},
  (∀ x ∈ l, ∀ y ∈ l, f x = f y → x = y) → l.Nodup → (List.map f l).Nodup

theorem List.inj_on_of_nodup_map E1 #

∀ {α : Type u} {β : Type v} {f : α → β} {l : List α},
  (List.map f l).Nodup → ∀ ⦃x : α⦄, x ∈ l → ∀ ⦃y : α⦄, y ∈ l → f x = f y → x = y

theorem List.nodup_map_iff_inj_on E1 #

∀ {α : Type u} {β : Type v} {f : α → β} {l : List α},
  l.Nodup → ((List.map f l).Nodup ↔ ∀ x ∈ l, ∀ y ∈ l, f x = f y → x = y)

theorem List.Nodup.map E1 #

∀ {α : Type u} {β : Type v} {l : List α} {f : α → β}, Function.Injective f → l.Nodup → (List.map f l).Nodup

theorem List.nodup_map_iff E0 #

∀ {α : Type u} {β : Type v} {f : α → β} {l : List α}, Function.Injective f → ((List.map f l).Nodup ↔ l.Nodup)

theorem List.nodup_attach E0 #

∀ {α : Type u} {l : List α}, l.attach.Nodup ↔ l.Nodup

theorem List.Nodup.of_attach E1 #

∀ {α : Type u} {l : List α}, l.attach.Nodup → l.Nodup

Alias of the forward direction of List.nodup_attach.

theorem List.Nodup.attach E1 #

∀ {α : Type u} {l : List α}, l.Nodup → l.attach.Nodup

Alias of the reverse direction of List.nodup_attach.

theorem List.Nodup.pmap E1 #

∀ {α : Type u} {β : Type v} {p : α → Prop} {f : (a : α) → p a → β} {l : List α} {H : ∀ a ∈ l, p a},
  (∀ (a : α) (ha : p a) (b : α) (hb : p b), f a ha = f b hb → a = b) → l.Nodup → (List.pmap f l H).Nodup

theorem List.nodup_attachWith E0 #

∀ {α : Type u} {l : List α} {P : α → Prop} {h : ∀ x ∈ l, P x}, (l.attachWith P h).Nodup ↔ l.Nodup

theorem List.Nodup.filter E1 #

∀ {α : Type u} (p : α → Bool) {l : List α}, l.Nodup → (List.filter p l).Nodup

theorem List.nodup_reverse E0 #

∀ {α : Type u} {l : List α}, l.reverse.Nodup ↔ l.Nodup

theorem List.nodup_concat E1 #

∀ {α : Type u} (l : List α) (u : α), (l.concat u).Nodup ↔ u ∉ l ∧ l.Nodup

theorem List.Nodup.tail E0 #

∀ {α : Type u} {l : List α}, l.Nodup → l.tail.Nodup

theorem List.nodup_tail_reverse E1 #

∀ {α : Type u} (l : List α), l[0]? = l.getLast? → (l.reverse.tail.Nodup ↔ l.tail.Nodup)

theorem List.Nodup.prefix_of_head_mem_of_infix E1 #

∀ {α : Type u} {l₁ l₂ : List α}, l₁ <:+: l₂ → ∀ {hne : l₂ ≠ []}, l₂.head hne ∈ l₁ → l₂.Nodup → l₁ <+: l₂

theorem List.Nodup.suffix_of_getLast_mem_of_infix E1 #

∀ {α : Type u} {l₁ l₂ : List α}, l₁ <:+: l₂ → ∀ {hne : l₂ ≠ []}, l₂.getLast hne ∈ l₁ → l₂.Nodup → l₁ <:+ l₂

theorem List.Nodup.erase_getElem E1 #

∀ {α : Type u} [inst : BEq α] [LawfulBEq α] {l : List α},
  l.Nodup → ∀ (i : ℕ) (h : i < l.length), l.erase l[i] = l.eraseIdx i

theorem List.Nodup.erase_get E1 #

∀ {α : Type u} [inst : BEq α] [LawfulBEq α] {l : List α},
  l.Nodup → ∀ (i : Fin l.length), l.erase (l.get i) = l.eraseIdx ↑i

theorem List.Nodup.diff E1 #

∀ {α : Type u} {l₁ l₂ : List α} [inst : BEq α] [LawfulBEq α], l₁.Nodup → (l₁.diff l₂).Nodup

theorem List.nodup_flatten E1 #

∀ {α : Type u} {L : List (List α)}, L.flatten.Nodup ↔ (∀ l ∈ L, l.Nodup) ∧ List.Pairwise List.Disjoint L

theorem List.nodup_flatMap E1 #

∀ {α : Type u} {β : Type v} {l₁ : List α} {f : α → List β},
  (List.flatMap f l₁).Nodup ↔ (∀ x ∈ l₁, (f x).Nodup) ∧ List.Pairwise (Function.onFun List.Disjoint f) l₁

theorem List.Nodup.product E1 #

∀ {α : Type u} {β : Type v} {l₁ : List α} {l₂ : List β}, l₁.Nodup → l₂.Nodup → (l₁ ×ˢ l₂).Nodup

theorem List.Nodup.sigma E1 #

∀ {α : Type u} {l₁ : List α} {σ : α → Type u_1} {l₂ : (a : α) → List (σ a)},
  l₁.Nodup → (∀ (a : α), (l₂ a).Nodup) → (l₁.sigma l₂).Nodup

theorem List.Nodup.filterMap E1 #

∀ {α : Type u} {β : Type v} {l : List α} {f : α → Option β},
  (∀ (a a' : α), ∀ b ∈ f a, b ∈ f a' → a = a') → l.Nodup → (List.filterMap f l).Nodup

theorem List.Nodup.concat E1 #

∀ {α : Type u} {l : List α} {a : α}, a ∉ l → l.Nodup → (l.concat a).Nodup

theorem List.Nodup.insert E1 #

∀ {α : Type u} {l : List α} {a : α} [inst : BEq α] [LawfulBEq α], l.Nodup → (List.insert a l).Nodup

theorem List.Nodup.union E1 #

∀ {α : Type u} {l₂ : List α} [inst : BEq α] [LawfulBEq α] (l₁ : List α), l₂.Nodup → (l₁ ∪ l₂).Nodup

theorem List.Nodup.inter E1 #

∀ {α : Type u} {l₁ : List α} [inst : BEq α] (l₂ : List α), l₁.Nodup → (l₁ ∩ l₂).Nodup

theorem List.Nodup.sdiff_eq_filter E1 #

∀ {α : Type u} [inst : BEq α] [inst_1 : LawfulBEq α] {l₁ l₂ : List α},
  l₁.Nodup → l₁.diff l₂ = List.filter (fun x ↦ decide (x ∉ l₂)) l₁

theorem List.Nodup.mem_sdiff_iff E0 #

∀ {α : Type u} {l₁ l₂ : List α} {a : α} [inst : BEq α] [LawfulBEq α], l₁.Nodup → (a ∈ l₁.diff l₂ ↔ a ∈ l₁ ∧ a ∉ l₂)

theorem List.Nodup.set E1 #

∀ {α : Type u} {l : List α} {n : ℕ} {a : α}, l.Nodup → a ∉ l → (l.set n a).Nodup

theorem List.Nodup.map_update E0 #

∀ {α : Type u} {β : Type v} [inst : DecidableEq α] {l : List α},
  l.Nodup →
    ∀ (f : α → β) (x : α) (y : β),
      List.map (Function.update f x y) l = if x ∈ l then (List.map f l).set (List.idxOf x l) y else List.map f l

theorem List.Nodup.pairwise_of_forall_ne E1 #

∀ {α : Type u} {l : List α} {r : α → α → Prop}, l.Nodup → (∀ a ∈ l, ∀ b ∈ l, a ≠ b → r a b) → List.Pairwise r l

theorem List.Nodup.take_eq_filter_mem E1 #

∀ {α : Type u} [inst : BEq α] [LawfulBEq α] {l : List α} {n : ℕ},
  l.Nodup → List.take n l = List.filter (fun a ↦ List.elem a (List.take n l)) l

theorem Option.toList_nodup E1 #

∀ {α : Type u} (o : Option α), o.toList.Nodup

Deprecated aliases

NameNew nameSince
List.Nodup.diff_eq_filterList.Nodup.sdiff_eq_filter2026-06-03
List.Nodup.mem_diff_iffList.Nodup.mem_sdiff_iff2026-06-03