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.Sym

33 declarations and 1 deprecated aliases. Mathlib docs · Source

Unordered tuples of elements of a list

Defines List.sym and the specialized List.sym2 for computing lists of all unordered n-tuples from a given list. These are list versions of Nat.multichoose.

Main declarations

  • List.sym: xs.sym n is a list of all unordered n-tuples of elements from xs, with multiplicity. The list's values are in Sym α n.
  • List.sym2: xs.sym2 is a list of all unordered pairs of elements from xs, with multiplicity. The list's values are in Sym2 α.

TODO

  • Prove protected theorem Perm.sym (n : ℕ) {xs ys : List α} (h : xs ~ ys) : xs.sym n ~ ys.sym n and lift the result to Multiset and Finset.

theorem List.sym.match_1.congr_eq_3 E1 #

∀ {α : Type u_1} (motive : ℕ → List α → Sort u_2) (x : ℕ) (x_1 : List α) (h_1 : (x : List α) → motive 0 x)
  (h_2 : (x : ℕ) → motive x []) (h_3 : (n : ℕ) → (x : α) → (xs : List α) → motive n.succ (x :: xs)) (n : ℕ) (x_2 : α)
  (xs : List α),
  x = n.succ →
    x_1 = x_2 :: xs →
      (match x, x_1 with
        | 0, x => h_1 x
        | x, [] => h_2 x
        | n.succ, x :: xs => h_3 n x xs) ≍
        h_3 n x_2 xs

theorem List.sym.match_1.congr_eq_1 E1 #

∀ {α : Type u_1} (motive : ℕ → List α → Sort u_2) (x : ℕ) (x_1 : List α) (h_1 : (x : List α) → motive 0 x)
  (h_2 : (x : ℕ) → motive x []) (h_3 : (n : ℕ) → (x : α) → (xs : List α) → motive n.succ (x :: xs)) (x_2 : List α),
  x = 0 →
    x_1 = x_2 →
      (match x, x_1 with
        | 0, x => h_1 x
        | x, [] => h_2 x
        | n.succ, x :: xs => h_3 n x xs) ≍
        h_1 x_2

theorem List.sym2.match_1.congr_eq_1 E1 #

∀ {α : Type u_1} (motive : List α → Sort u_2) (x : List α) (h_1 : Unit → motive [])
  (h_2 : (x : α) → (xs : List α) → motive (x :: xs)),
  x = [] →
    (match x with
      | [] => h_1 ()
      | x :: xs => h_2 x xs) ≍
      h_1 ()

theorem List.sym.match_1.congr_eq_2 E1 #

∀ {α : Type u_1} (motive : ℕ → List α → Sort u_2) (x : ℕ) (x_1 : List α) (h_1 : (x : List α) → motive 0 x)
  (h_2 : (x : ℕ) → motive x []) (h_3 : (n : ℕ) → (x : α) → (xs : List α) → motive n.succ (x :: xs)) (x_2 : ℕ),
  x = x_2 →
    x_1 = [] →
      (x_2 = 0 → False) →
        (match x, x_1 with
          | 0, x => h_1 x
          | x, [] => h_2 x
          | n.succ, x :: xs => h_3 n x xs) ≍
          h_2 x_2

theorem List.sym2.match_1.congr_eq_2 E1 #

∀ {α : Type u_1} (motive : List α → Sort u_2) (x : List α) (h_1 : Unit → motive [])
  (h_2 : (x : α) → (xs : List α) → motive (x :: xs)) (x_1 : α) (xs : List α),
  x = x_1 :: xs →
    (match x with
      | [] => h_1 ()
      | x :: xs => h_2 x xs) ≍
      h_2 x_1 xs

def List.sym2 E3 #

{α : Type u_1} → List α → List (Sym2 α)

xs.sym2 is a list of all unordered pairs of elements from xs. If xs has no duplicates then neither does xs.sym2.

theorem List.sym2_map E1 #

∀ {α : Type u_1} {β : Type u_2} (f : α → β) (xs : List α), (List.map f xs).sym2 = List.map (Sym2.map f) xs.sym2

theorem List.mem_sym2_cons_iff E0 #

∀ {α : Type u_1} {x : α} {xs : List α} {z : Sym2 α},
  z ∈ (x :: xs).sym2 ↔ z = s(x, x) ∨ (∃ y ∈ xs, z = s(x, y)) ∨ z ∈ xs.sym2

theorem List.sym2_eq_nil_iff E0 #

∀ {α : Type u_1} {xs : List α}, xs.sym2 = [] ↔ xs = []

theorem List.left_mem_of_mk_mem_sym2 E1 #

∀ {α : Type u_1} {xs : List α} {a b : α}, s(a, b) ∈ xs.sym2 → a ∈ xs

theorem List.right_mem_of_mk_mem_sym2 E1 #

∀ {α : Type u_1} {xs : List α} {a b : α}, s(a, b) ∈ xs.sym2 → b ∈ xs

theorem List.mk_mem_sym2 E1 #

∀ {α : Type u_1} {xs : List α} {a b : α}, a ∈ xs → b ∈ xs → s(a, b) ∈ xs.sym2

theorem List.mk_mem_sym2_iff E0 #

∀ {α : Type u_1} {xs : List α} {a b : α}, s(a, b) ∈ xs.sym2 ↔ a ∈ xs ∧ b ∈ xs

theorem List.mem_sym2_iff E0 #

∀ {α : Type u_1} {xs : List α} {z : Sym2 α}, z ∈ xs.sym2 ↔ ∀ y ∈ z, y ∈ xs

theorem List.setOfPred_mem_sym2 E1 #

∀ {α : Type u_1} {xs : List α}, {z | z ∈ xs.sym2} = {x | x ∈ xs}.sym2

theorem List.Nodup.sym2 E1 #

∀ {α : Type u_1} {xs : List α}, xs.Nodup → xs.sym2.Nodup

theorem List.map_mk_sublist_sym2 E0 #

∀ {α : Type u_1} (x : α) (xs : List α), x ∈ xs → (List.map (fun y ↦ s(x, y)) xs).Sublist xs.sym2

theorem List.map_mk_disjoint_sym2 E0 #

∀ {α : Type u_1} (x : α) (xs : List α), x ∉ xs → (List.map (fun y ↦ s(x, y)) xs).Disjoint xs.sym2

theorem List.dedup_sym2 E1 #

∀ {α : Type u_1} [inst : DecidableEq α] (xs : List α), xs.sym2.dedup = xs.dedup.sym2

theorem List.Perm.sym2 E1 #

∀ {α : Type u_1} {xs ys : List α}, xs.Perm ys → xs.sym2.Perm ys.sym2

theorem List.Sublist.sym2 E1 #

∀ {α : Type u_1} {xs ys : List α}, xs.Sublist ys → xs.sym2.Sublist ys.sym2

theorem List.Subperm.sym2 E1 #

∀ {α : Type u_1} {xs ys : List α}, xs.Subperm ys → xs.sym2.Subperm ys.sym2

theorem List.length_sym2 E1 #

∀ {α : Type u_1} {xs : List α}, xs.sym2.length = (xs.length + 1).choose 2

def List.sym E3 #

{α : Type u_1} → (n : ℕ) → List α → List (Sym α n)

xs.sym n is all unordered n-tuples from the list xs in some order.

theorem List.sym_one_eq E0 #

∀ {α : Type u_1} {xs : List α}, List.sym 1 xs = List.map (fun x ↦ x ::ₛ Sym.nil) xs

theorem List.sym2_eq_sym_two E1 #

∀ {α : Type u_1} {xs : List α}, List.map (⇑(Sym2.equivSym α)) xs.sym2 = List.sym 2 xs

theorem List.sym_map E1 #

∀ {α : Type u_1} {β : Type u_3} (f : α → β) (n : ℕ) (xs : List α),
  List.sym n (List.map f xs) = List.map (Sym.map f) (List.sym n xs)

theorem List.Sublist.sym E1 #

∀ {α : Type u_1} (n : ℕ) {xs ys : List α}, xs.Sublist ys → (List.sym n xs).Sublist (List.sym n ys)

theorem List.sym_sublist_sym_cons E1 #

∀ {α : Type u_1} {xs : List α} {n : ℕ} {a : α}, (List.sym n xs).Sublist (List.sym n (a :: xs))

theorem List.mem_of_mem_of_mem_sym E0 #

∀ {α : Type u_1} {n : ℕ} {xs : List α} {a : α} {z : Sym α n}, a ∈ z → z ∈ List.sym n xs → a ∈ xs

theorem List.first_mem_of_cons_mem_sym E1 #

∀ {α : Type u_1} {xs : List α} {n : ℕ} {a : α} {z : Sym α n}, a ::ₛ z ∈ List.sym (n + 1) xs → a ∈ xs

theorem List.Nodup.sym E1 #

∀ {α : Type u_1} (n : ℕ) {xs : List α}, xs.Nodup → (List.sym n xs).Nodup

theorem List.length_sym E1 #

∀ {α : Type u_1} {n : ℕ} {xs : List α}, (List.sym n xs).length = xs.length.multichoose n

Deprecated aliases

NameNew nameSince
List.setOf_mem_sym2List.setOfPred_mem_sym22026-07-09