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 / V03. Sets, finite structures and big operators

Mathlib.Data.Finset.Powerset

59 declarations. Mathlib docs · Source

The powerset of a finset

powerset

def Finset.powerset E1 #

{α : Type u_1} → Finset α → Finset (Finset α)

When s is a finset, s.powerset is the finset of all subsets of s (seen as finsets).

theorem Finset.mem_powerset E0 #

∀ {α : Type u_1} {s t : Finset α}, s ∈ t.powerset ↔ s ⊆ t

theorem Finset.coe_powerset E0 #

∀ {α : Type u_1} (s : Finset α), ↑s.powerset = SetLike.coe ⁻¹' 𝒫 ↑s

theorem Finset.empty_mem_powerset E1 #

∀ {α : Type u_1} (s : Finset α), ∅ ∈ s.powerset

theorem Finset.mem_powerset_self E0 #

∀ {α : Type u_1} (s : Finset α), s ∈ s.powerset

theorem Finset.powerset_nonempty E1 #

∀ {α : Type u_1} (s : Finset α), s.powerset.Nonempty

theorem Finset.powerset_mono E0 #

∀ {α : Type u_1} {s t : Finset α}, s.powerset ⊆ t.powerset ↔ s ⊆ t

theorem Finset.powerset_injective E1 #

∀ {α : Type u_1}, Function.Injective Finset.powerset

theorem Finset.powerset_inj E0 #

∀ {α : Type u_1} {s t : Finset α}, s.powerset = t.powerset ↔ s = t

theorem Finset.powerset_empty E0 #

∀ {α : Type u_1}, ∅.powerset = {∅}

theorem Finset.powerset_eq_singleton_empty E0 #

∀ {α : Type u_1} {s : Finset α}, s.powerset = {∅} ↔ s = ∅

theorem Finset.image_injOn_powerset_of_injOn E1 #

∀ {α : Type u_1} {s : Finset α} {β : Type u_2} [inst : DecidableEq β] {f : α → β},
  Set.InjOn f ↑s → Set.InjOn (fun x ↦ Finset.image f x) ↑s.powerset

theorem Finset.injOn_image_of_biUnion_injOn E1 #

∀ {α : Type u_1} {β : Type u_2} [inst : DecidableEq α] [inst_1 : DecidableEq β] {S : Finset (Finset α)} {f : α → β},
  Set.InjOn f ↑(S.biUnion id) → Set.InjOn (fun x ↦ Finset.image f x) ↑S

Variant of Finset.image_injOn_powerset_of_injOn for a family S of finsets whose union supports an InjOn hypothesis, rather than the full powerset of a set.

theorem Finset.biUnion_id_subset_iff_subset_powerset E1 #

∀ {α : Type u_1} {t : Finset α} [inst : DecidableEq α] {s : Finset (Finset α)}, s.biUnion id ⊆ t ↔ s ⊆ t.powerset

s.biUnion id ⊆ t iff every member of s is a subset of t, i.e. s ⊆ t.powerset.

theorem Finset.image_surjOn_powerset E1 #

∀ {α : Type u_1} {s : Finset α} {β : Type u_2} [inst : DecidableEq β] {f : α → β},
  Set.SurjOn (fun x ↦ Finset.image f x) ↑s.powerset ↑(Finset.image f s).powerset

theorem Finset.powerset_image E1 #

∀ {α : Type u_1} {s : Finset α} {β : Type u_2} [inst : DecidableEq β] {f : α → β},
  (Finset.image f s).powerset = Finset.image (fun x ↦ Finset.image f x) s.powerset

theorem Finset.card_powerset E3 #

∀ {α : Type u_1} (s : Finset α), s.powerset.card = 2 ^ s.card

Number of Subsets of a Set

theorem Finset.notMem_of_mem_powerset_of_notMem E1 #

∀ {α : Type u_1} {s t : Finset α} {a : α}, t ∈ s.powerset → a ∉ s → a ∉ t

theorem Finset.powerset_insert E1 #

∀ {α : Type u_1} [inst : DecidableEq α] (s : Finset α) (a : α),
  (insert a s).powerset = s.powerset ∪ Finset.image (insert a) s.powerset

theorem Finset.pairwiseDisjoint_pair_insert E1 #

∀ {α : Type u_1} {s : Finset α} [inst : DecidableEq α] {a : α},
  a ∉ s → (↑s.powerset).PairwiseDisjoint fun t ↦ {t, insert a t}

instance Finset.decidableExistsOfDecidableSubsets E0 #

{α : Type u_1} →
  {s : Finset α} →
    {p : (t : Finset α) → t ⊆ s → Prop} →
      [(t : Finset α) → (h : t ⊆ s) → Decidable (p t h)] → Decidable (∃ t, ∃ (h : t ⊆ s), p t h)

For predicate p decidable on subsets, it is decidable whether p holds for any subset.

instance Finset.decidableForallOfDecidableSubsets E0 #

{α : Type u_1} →
  {s : Finset α} →
    {p : (t : Finset α) → t ⊆ s → Prop} →
      [(t : Finset α) → (h : t ⊆ s) → Decidable (p t h)] → Decidable (∀ (t : Finset α) (h : t ⊆ s), p t h)

For predicate p decidable on subsets, it is decidable whether p holds for every subset.

instance Finset.decidableExistsOfDecidableSubsets' E0 #

{α : Type u_1} → {s : Finset α} → {p : Finset α → Prop} → [(t : Finset α) → Decidable (p t)] → Decidable (∃ t ⊆ s, p t)

For predicate p decidable on subsets, it is decidable whether p holds for any subset.

instance Finset.decidableForallOfDecidableSubsets' E0 #

{α : Type u_1} → {s : Finset α} → {p : Finset α → Prop} → [(t : Finset α) → Decidable (p t)] → Decidable (∀ t ⊆ s, p t)

For predicate p decidable on subsets, it is decidable whether p holds for every subset.

def Finset.ssubsets E1 #

{α : Type u_1} → [DecidableEq α] → Finset α → Finset (Finset α)

For s a finset, s.ssubsets is the finset comprising strict subsets of s.

theorem Finset.mem_ssubsets E0 #

∀ {α : Type u_1} [inst : DecidableEq α] {s t : Finset α}, t ∈ s.ssubsets ↔ t ⊂ s

theorem Finset.empty_mem_ssubsets E1 #

∀ {α : Type u_1} [inst : DecidableEq α] {s : Finset α}, s.Nonempty → ∅ ∈ s.ssubsets

def Finset.decidableExistsOfDecidableSSubsets E1 #

{α : Type u_1} →
  [DecidableEq α] →
    {s : Finset α} →
      {p : (t : Finset α) → t ⊂ s → Prop} →
        [(t : Finset α) → (h : t ⊂ s) → Decidable (p t h)] → Decidable (∃ t, ∃ (h : t ⊂ s), p t h)

For predicate p decidable on ssubsets, it is decidable whether p holds for any ssubset.

def Finset.decidableForallOfDecidableSSubsets E1 #

{α : Type u_1} →
  [DecidableEq α] →
    {s : Finset α} →
      {p : (t : Finset α) → t ⊂ s → Prop} →
        [(t : Finset α) → (h : t ⊂ s) → Decidable (p t h)] → Decidable (∀ (t : Finset α) (h : t ⊂ s), p t h)

For predicate p decidable on ssubsets, it is decidable whether p holds for every ssubset.

def Finset.decidableExistsOfDecidableSSubsets' E1 #

{α : Type u_1} →
  [DecidableEq α] →
    {s : Finset α} →
      {p : Finset α → Prop} → ((t : Finset α) → t ⊂ s → Decidable (p t)) → Decidable (∃ t, ∃ (_ : t ⊂ s), p t)

A version of Finset.decidableExistsOfDecidableSSubsets with a non-dependent p. Typeclass inference cannot find hu here, so this is not an instance.

def Finset.decidableForallOfDecidableSSubsets' E1 #

{α : Type u_1} →
  [DecidableEq α] →
    {s : Finset α} → {p : Finset α → Prop} → ((t : Finset α) → t ⊂ s → Decidable (p t)) → Decidable (∀ t ⊂ s, p t)

A version of Finset.decidableForallOfDecidableSSubsets with a non-dependent p. Typeclass inference cannot find hu here, so this is not an instance.

def Finset.powersetCard E1 #

{α : Type u_1} → ℕ → Finset α → Finset (Finset α)

Given an integer n and a finset s, then powersetCard n s is the finset of subsets of s of cardinality n.

theorem Finset.mem_powersetCard E3 #

∀ {α : Type u_1} {n : ℕ} {s t : Finset α}, s ∈ Finset.powersetCard n t ↔ s ⊆ t ∧ s.card = n

theorem Finset.powersetCard_mono E0 #

∀ {α : Type u_1} {n : ℕ} {s t : Finset α}, s ⊆ t → Finset.powersetCard n s ⊆ Finset.powersetCard n t

theorem Finset.card_powersetCard E3 #

∀ {α : Type u_1} (n : ℕ) (s : Finset α), (Finset.powersetCard n s).card = s.card.choose n

Formula for the Number of Combinations

theorem Finset.filter_powersetCard_subset E1 #

∀ {α : Type u_1} [inst : DecidableEq α] (s t : Finset α) (n : ℕ),
  s ⊆ t →
    s.card ≤ n →
      {x ∈ Finset.powersetCard n t | s ⊆ x} = Finset.image (fun x ↦ x ∪ s) (Finset.powersetCard (n - s.card) (t \ s))

The n-element subsets of t containing s are exactly the (n - s.card)-element subsets of t \ s, unioned with s.

theorem Finset.card_filter_powersetCard_subset E1 #

∀ {α : Type u_1} [inst : DecidableEq α] (s t : Finset α) (n : ℕ),
  s ⊆ t → s.card ≤ n → {x ∈ Finset.powersetCard n t | s ⊆ x}.card = (t.card - s.card).choose (n - s.card)

The number of n-element subsets of t containing s equals Nat.choose (#t - #s) (n - #s).

theorem Finset.powersetCard_zero E0 #

∀ {α : Type u_1} (s : Finset α), Finset.powersetCard 0 s = {∅}

theorem Finset.powersetCard_empty_subsingleton E1 #

∀ {α : Type u_1} (n : ℕ), (↑(Finset.powersetCard n ∅)).Subsingleton

theorem Finset.map_val_val_powersetCard E0 #

∀ {α : Type u_1} (s : Finset α) (i : ℕ),
  Multiset.map Finset.val (Finset.powersetCard i s).val = Multiset.powersetCard i s.val

theorem Finset.powersetCard_one E1 #

∀ {α : Type u_1} (s : Finset α), Finset.powersetCard 1 s = Finset.map { toFun := singleton, inj' := ⋯ } s

theorem Finset.powersetCard_eq_empty E0 #

∀ {α : Type u_1} {n : ℕ} {s : Finset α}, Finset.powersetCard n s = ∅ ↔ s.card < n

theorem Finset.powersetCard_card_add E0 #

∀ {α : Type u_1} {n : ℕ} (s : Finset α), 0 < n → Finset.powersetCard (s.card + n) s = ∅

theorem Finset.powersetCard_inter E1 #

∀ {α : Type u_1} [inst : DecidableEq α] (s t : Finset α) (n : ℕ),
  Finset.powersetCard n (s ∩ t) = Finset.powersetCard n s ∩ Finset.powersetCard n t

theorem Finset.disjoint_powersetCard_powersetCard E0 #

∀ {α : Type u_1} [inst : DecidableEq α] (s t : Finset α) (n : ℕ),
  Disjoint (Finset.powersetCard n s) (Finset.powersetCard n t) ↔ (s ∩ t).card < n

theorem Finset.powersetCard_eq_filter E1 #

∀ {α : Type u_1} {n : ℕ} {s : Finset α}, Finset.powersetCard n s = {x ∈ s.powerset | x.card = n}

theorem Finset.powersetCard_succ_insert E1 #

∀ {α : Type u_1} [inst : DecidableEq α] {x : α} {s : Finset α},
  x ∉ s →
    ∀ (n : ℕ),
      Finset.powersetCard n.succ (insert x s) =
        Finset.powersetCard n.succ s ∪ Finset.image (insert x) (Finset.powersetCard n s)

theorem Finset.powersetCard_nonempty E0 #

∀ {α : Type u_1} {n : ℕ} {s : Finset α}, (Finset.powersetCard n s).Nonempty ↔ n ≤ s.card

theorem Finset.powersetCard_nonempty_of_le E1 #

∀ {α : Type u_1} {n : ℕ} {s : Finset α}, n ≤ s.card → (Finset.powersetCard n s).Nonempty

Alias of the reverse direction of Finset.powersetCard_nonempty.

theorem Finset.powersetCard_self E0 #

∀ {α : Type u_1} (s : Finset α), Finset.powersetCard s.card s = {s}

theorem Disjoint.powersetCard_powersetCard_finset E1 #

∀ {α : Type u_1} {n : ℕ} {s t : Finset α},
  Disjoint s t → ∀ {m : ℕ}, n ≠ 0 ∨ m ≠ 0 → Disjoint (Finset.powersetCard n s) (Finset.powersetCard m t)

theorem Finset.disjoint_powersetCard_of_ne E1 #

∀ {α : Type u_1} {m n : ℕ}, m ≠ n → ∀ (s t : Finset α), Disjoint (Finset.powersetCard m s) (Finset.powersetCard n t)

theorem Finset.pairwise_disjoint_powersetCard E1 #

∀ {α : Type u_1} (s : Finset α), Pairwise fun i j ↦ Disjoint (Finset.powersetCard i s) (Finset.powersetCard j s)

theorem Finset.powerset_card_disjiUnion E1 #

∀ {α : Type u_1} (s : Finset α), s.powerset = (Finset.range (s.card + 1)).disjiUnion (fun i ↦ Finset.powersetCard i s) ⋯

theorem Finset.powerset_card_biUnion E1 #

∀ {α : Type u_1} [inst : DecidableEq (Finset α)] (s : Finset α),
  s.powerset = (Finset.range (s.card + 1)).biUnion fun i ↦ Finset.powersetCard i s

theorem Finset.powersetCard_sup E1 #

∀ {α : Type u_1} [inst : DecidableEq α] (u : Finset α), ∀ n < u.card, (Finset.powersetCard n.succ u).sup id = u

theorem Finset.powersetCard_biUnion E1 #

∀ {α : Type u_1} {s : Finset α} [inst : DecidableEq α] {r : ℕ},
  r ≠ 0 → r ≤ s.card → (Finset.powersetCard r s).biUnion id = s

The union of all r-element subsets of s is s, provided 1 ≤ r ≤ #s.

theorem Finset.powersetCard_injOn E1 #

∀ {α : Type u_1} {q r : ℕ}, r ≠ 0 → r ≤ q → Set.InjOn (fun a ↦ Finset.powersetCard r a) {a | a.card = q}

For 1 ≤ r ≤ q, the map powersetCard r is injective on the finsets of cardinality q.

theorem Finset.powersetCard_map E1 #

∀ {α : Type u_1} {β : Type u_2} (f : α ↪ β) (n : ℕ) (s : Finset α),
  Finset.powersetCard n (Finset.map f s) = Finset.map (Finset.mapEmbedding f).toEmbedding (Finset.powersetCard n s)