The areas / V03. Sets, finite structures and big operators
Mathlib.Data.Finset.Prod
76 declarations. Mathlib docs · Source
Finsets in product types
This file defines finset constructions on the product type α × β. Beware not to confuse with the
Finset.prod operation which computes the multiplicative product.
Main declarations
Finset.product: Turnss : Finset α,t : Finset βinto their product inFinset (α × β).Finset.diag: Fors : Finset α,s.diagis theFinset (α × α)of pairs(a, a)witha ∈ s.Finset.offDiag: Fors : Finset α,s.offDiagis theFinset (α × α)of pairs(a, b)witha, b ∈ sanda ≠ b.
prod
def Finset.product E3 #
{α : Type u_1} → {β : Type u_2} → Finset α → Finset β → Finset (α × β)
product s t is the set of pairs (a, b) such that a ∈ s and b ∈ t.
instance Finset.instSProd E0 #
{α : Type u_1} → {β : Type u_2} → SProd (Finset α) (Finset β) (Finset (α × β))
theorem Finset.product_eq_sprod E0 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β}, s.product t = s ×ˢ t
theorem Finset.product_val E0 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β}, (s ×ˢ t).val = s.val ×ˢ t.val
theorem Finset.mem_product E0 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} {p : α × β}, p ∈ s ×ˢ t ↔ p.1 ∈ s ∧ p.2 ∈ t
theorem Finset.mk_mem_product E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} {a : α} {b : β}, a ∈ s → b ∈ t → (a, b) ∈ s ×ˢ t
theorem Finset.coe_product E0 #
∀ {α : Type u_1} {β : Type u_2} (s : Finset α) (t : Finset β), ↑(s ×ˢ t) = ↑s ×ˢ ↑t
def Equiv.Finset.prod E1 #
{α : Type u_1} → {β : Type u_2} → (s : Finset α) → (t : Finset β) → ↥(s ×ˢ t) ≃ ↥s × ↥t
The product s ×ˢ t of two finsets, viewed as a subtype, is equivalent to the product of the
subtypes s × t. The Finset analogue of Equiv.Set.prod.
theorem Finset.subset_product_image_fst E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} [inst : DecidableEq α], Finset.image Prod.fst (s ×ˢ t) ⊆ s
theorem Finset.subset_product_image_snd E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} [inst : DecidableEq β], Finset.image Prod.snd (s ×ˢ t) ⊆ t
theorem Finset.product_image_fst E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} [inst : DecidableEq α],
t.Nonempty → Finset.image Prod.fst (s ×ˢ t) = s
theorem Finset.product_image_snd E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} [inst : DecidableEq β],
s.Nonempty → Finset.image Prod.snd (s ×ˢ t) = t
theorem Finset.subset_product E1 #
∀ {α : Type u_1} {β : Type u_2} [inst : DecidableEq α] [inst_1 : DecidableEq β] {s : Finset (α × β)},
s ⊆ Finset.image Prod.fst s ×ˢ Finset.image Prod.snd s
theorem Finset.product_subset_product E1 #
∀ {α : Type u_1} {β : Type u_2} {s s' : Finset α} {t t' : Finset β}, s ⊆ s' → t ⊆ t' → s ×ˢ t ⊆ s' ×ˢ t'
theorem Finset.product_subset_product_left E1 #
∀ {α : Type u_1} {β : Type u_2} {s s' : Finset α} {t : Finset β}, s ⊆ s' → s ×ˢ t ⊆ s' ×ˢ t
theorem Finset.product_subset_product_right E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t t' : Finset β}, t ⊆ t' → s ×ˢ t ⊆ s ×ˢ t'
theorem Finset.prodMap_image_product E1 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} [inst : DecidableEq β] [inst_1 : DecidableEq δ]
(f : α → β) (g : γ → δ) (s : Finset α) (t : Finset γ),
Finset.image (Prod.map f g) (s ×ˢ t) = Finset.image f s ×ˢ Finset.image g t
theorem Finset.prodMap_map_product E1 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} (f : α ↪ β) (g : γ ↪ δ) (s : Finset α) (t : Finset γ),
Finset.map (f.prodMap g) (s ×ˢ t) = Finset.map f s ×ˢ Finset.map g t
theorem Finset.map_swap_product E0 #
∀ {α : Type u_1} {β : Type u_2} (s : Finset α) (t : Finset β),
Finset.map { toFun := Prod.swap, inj' := ⋯ } (t ×ˢ s) = s ×ˢ t
theorem Finset.image_swap_product E0 #
∀ {α : Type u_1} {β : Type u_2} [inst : DecidableEq (α × β)] (s : Finset α) (t : Finset β),
Finset.image Prod.swap (t ×ˢ s) = s ×ˢ t
theorem Finset.product_eq_biUnion E1 #
∀ {α : Type u_1} {β : Type u_2} [inst : DecidableEq (α × β)] (s : Finset α) (t : Finset β),
s ×ˢ t = s.biUnion fun a ↦ Finset.image (fun b ↦ (a, b)) t
theorem Finset.product_eq_biUnion_right E1 #
∀ {α : Type u_1} {β : Type u_2} [inst : DecidableEq (α × β)] (s : Finset α) (t : Finset β),
s ×ˢ t = t.biUnion fun b ↦ Finset.image (fun a ↦ (a, b)) s
theorem Finset.product_biUnion E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} [inst : DecidableEq γ] (s : Finset α) (t : Finset β)
(f : α × β → Finset γ), (s ×ˢ t).biUnion f = s.biUnion fun a ↦ t.biUnion fun b ↦ f (a, b)
See also Finset.sup_product_left.
theorem Finset.card_product E0 #
∀ {α : Type u_1} {β : Type u_2} (s : Finset α) (t : Finset β), (s ×ˢ t).card = s.card * t.card
theorem Finset.nontrivial_prod_iff E0 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β},
(s ×ˢ t).Nontrivial ↔ s.Nonempty ∧ t.Nonempty ∧ (s.Nontrivial ∨ t.Nontrivial)
The product of two Finsets is nontrivial iff both are nonempty at least one of them is nontrivial.
theorem Finset.filter_product E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} (p : α → Prop) (q : β → Prop) [inst : DecidablePred p]
[inst_1 : DecidablePred q], {x ∈ s ×ˢ t | p x.1 ∧ q x.2} = Finset.filter p s ×ˢ Finset.filter q t
theorem Finset.filter_product_left E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} (p : α → Prop) [inst : DecidablePred p],
{x ∈ s ×ˢ t | p x.1} = Finset.filter p s ×ˢ t
theorem Finset.filter_product_right E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β} (q : β → Prop) [inst : DecidablePred q],
{x ∈ s ×ˢ t | q x.2} = s ×ˢ Finset.filter q t
theorem Finset.filter_product_card E1 #
∀ {α : Type u_1} {β : Type u_2} (s : Finset α) (t : Finset β) (p : α → Prop) (q : β → Prop) [inst : DecidablePred p]
[inst_1 : DecidablePred q],
{x ∈ s ×ˢ t | p x.1 = q x.2}.card =
(Finset.filter p s).card * (Finset.filter q t).card + {x ∈ s | ¬p x}.card * {x ∈ t | ¬q x}.card
theorem Finset.empty_product E0 #
∀ {α : Type u_1} {β : Type u_2} (t : Finset β), ∅ ×ˢ t = ∅
theorem Finset.product_empty E0 #
∀ {α : Type u_1} {β : Type u_2} (s : Finset α), s ×ˢ ∅ = ∅
theorem Finset.Nonempty.product E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β}, s.Nonempty → t.Nonempty → (s ×ˢ t).Nonempty
theorem Finset.Nonempty.fst E2 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β}, (s ×ˢ t).Nonempty → s.Nonempty
theorem Finset.Nonempty.snd E2 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β}, (s ×ˢ t).Nonempty → t.Nonempty
theorem Finset.nonempty_product E0 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β}, (s ×ˢ t).Nonempty ↔ s.Nonempty ∧ t.Nonempty
theorem Finset.product_eq_empty E0 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t : Finset β}, s ×ˢ t = ∅ ↔ s = ∅ ∨ t = ∅
theorem Finset.singleton_product E0 #
∀ {α : Type u_1} {β : Type u_2} {t : Finset β} {a : α}, {a} ×ˢ t = Finset.map (Function.Embedding.sectR a β) t
theorem Finset.product_singleton E0 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {b : β}, s ×ˢ {b} = Finset.map (Function.Embedding.sectL α b) s
theorem Finset.singleton_product_singleton E1 #
∀ {α : Type u_1} {β : Type u_2} {a : α} {b : β}, {a} ×ˢ {b} = {(a, b)}
theorem Finset.union_product E0 #
∀ {α : Type u_1} {β : Type u_2} {s s' : Finset α} {t : Finset β} [inst : DecidableEq α] [inst_1 : DecidableEq β],
(s ∪ s') ×ˢ t = s ×ˢ t ∪ s' ×ˢ t
theorem Finset.product_union E0 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t t' : Finset β} [inst : DecidableEq α] [inst_1 : DecidableEq β],
s ×ˢ (t ∪ t') = s ×ˢ t ∪ s ×ˢ t'
theorem Finset.inter_product E1 #
∀ {α : Type u_1} {β : Type u_2} {s s' : Finset α} {t : Finset β} [inst : DecidableEq α] [inst_1 : DecidableEq β],
(s ∩ s') ×ˢ t = s ×ˢ t ∩ s' ×ˢ t
theorem Finset.product_inter E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t t' : Finset β} [inst : DecidableEq α] [inst_1 : DecidableEq β],
s ×ˢ (t ∩ t') = s ×ˢ t ∩ s ×ˢ t'
theorem Finset.product_inter_product E1 #
∀ {α : Type u_1} {β : Type u_2} {s s' : Finset α} {t t' : Finset β} [inst : DecidableEq α] [inst_1 : DecidableEq β],
s ×ˢ t ∩ s' ×ˢ t' = (s ∩ s') ×ˢ (t ∩ t')
theorem Finset.disjoint_product E1 #
∀ {α : Type u_1} {β : Type u_2} {s s' : Finset α} {t t' : Finset β},
Disjoint (s ×ˢ t) (s' ×ˢ t') ↔ Disjoint s s' ∨ Disjoint t t'
theorem Finset.disjUnion_product E0 #
∀ {α : Type u_1} {β : Type u_2} {s s' : Finset α} {t : Finset β} (hs : Disjoint s s'),
s.disjUnion s' hs ×ˢ t = (s ×ˢ t).disjUnion (s' ×ˢ t) ⋯
theorem Finset.product_disjUnion E0 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} {t t' : Finset β} (ht : Disjoint t t'),
s ×ˢ t.disjUnion t' ht = (s ×ˢ t).disjUnion (s ×ˢ t') ⋯
def Finset.diag E3 #
{α : Type u_1} → Finset α → Finset (α × α)
Given a finite set s, the diagonal, s.diag is the set of pairs of the form (a, a) for
a ∈ s.
def Finset.offDiag E3 #
{α : Type u_1} → Finset α → Finset (α × α)
Given a finite set s, the off-diagonal, s.offDiag is the set of pairs (a, b) with a ≠ b
for a, b ∈ s.
theorem Finset.mem_diag E0 #
∀ {α : Type u_1} {s : Finset α} {x : α × α}, x ∈ s.diag ↔ x.1 ∈ s ∧ x.1 = x.2
theorem Finset.mem_offDiag E0 #
∀ {α : Type u_1} {s : Finset α} {x : α × α}, x ∈ s.offDiag ↔ x.1 ∈ s ∧ x.2 ∈ s ∧ x.1 ≠ x.2
theorem Finset.diag_nonempty E0 #
∀ {α : Type u_1} {s : Finset α}, s.diag.Nonempty ↔ s.Nonempty
theorem Finset.diag_eq_empty E0 #
∀ {α : Type u_1} {s : Finset α}, s.diag = ∅ ↔ s = ∅
theorem Finset.diag_eq_filter E1 #
∀ {α : Type u_1} {s : Finset α} [inst : DecidableEq α], s.diag = {a ∈ s ×ˢ s | a.1 = a.2}
theorem Finset.image_diag E0 #
∀ {α : Type u_1} {β : Type u_2} [inst : DecidableEq β] (f : α × α → β) (s : Finset α),
Finset.image f s.diag = Finset.image (fun x ↦ f (x, x)) s
theorem Finset.coe_offDiag E0 #
∀ {α : Type u_1} (s : Finset α), ↑s.offDiag = (↑s).offDiag
theorem Finset.diag_card E0 #
∀ {α : Type u_1} (s : Finset α), s.diag.card = s.card
theorem Finset.offDiag_card E0 #
∀ {α : Type u_1} (s : Finset α), s.offDiag.card = s.card * s.card - s.card
theorem Finset.diag_mono E1 #
∀ {α : Type u_1}, Monotone Finset.diag
theorem Finset.offDiag_mono E1 #
∀ {α : Type u_1}, Monotone Finset.offDiag
theorem Finset.diag_empty E0 #
∀ {α : Type u_1}, ∅.diag = ∅
theorem Finset.offDiag_empty E0 #
∀ {α : Type u_1}, ∅.offDiag = ∅
theorem Finset.diag_union_offDiag E0 #
∀ {α : Type u_1} (s : Finset α) [inst : DecidableEq α], s.diag ∪ s.offDiag = s ×ˢ s
theorem Finset.disjoint_diag_offDiag E0 #
∀ {α : Type u_1} (s : Finset α), Disjoint s.diag s.offDiag
theorem Finset.product_sdiff_diag E1 #
∀ {α : Type u_1} (s : Finset α) [inst : DecidableEq α], s ×ˢ s \ s.diag = s.offDiag
theorem Finset.product_sdiff_offDiag E1 #
∀ {α : Type u_1} (s : Finset α) [inst : DecidableEq α], s ×ˢ s \ s.offDiag = s.diag
theorem Finset.diag_inter E1 #
∀ {α : Type u_1} (s t : Finset α) [inst : DecidableEq α], (s ∩ t).diag = s.diag ∩ t.diag
theorem Finset.offDiag_inter E1 #
∀ {α : Type u_1} (s t : Finset α) [inst : DecidableEq α], (s ∩ t).offDiag = s.offDiag ∩ t.offDiag
theorem Finset.diag_union E1 #
∀ {α : Type u_1} (s t : Finset α) [inst : DecidableEq α], (s ∪ t).diag = s.diag ∪ t.diag
theorem Finset.offDiag_union E1 #
∀ {α : Type u_1} {s t : Finset α} [inst : DecidableEq α],
Disjoint s t → (s ∪ t).offDiag = s.offDiag ∪ t.offDiag ∪ s ×ˢ t ∪ t ×ˢ s
theorem Finset.offDiag_singleton E0 #
∀ {α : Type u_1} (a : α), {a}.offDiag = ∅
theorem Finset.diag_singleton E1 #
∀ {α : Type u_1} (a : α), {a}.diag = {(a, a)}
theorem Finset.diag_insert E1 #
∀ {α : Type u_1} {s : Finset α} [inst : DecidableEq α] (a : α), (insert a s).diag = insert (a, a) s.diag
theorem Finset.offDiag_insert E1 #
∀ {α : Type u_1} {s : Finset α} [inst : DecidableEq α] {a : α},
a ∉ s → (insert a s).offDiag = s.offDiag ∪ {a} ×ˢ s ∪ s ×ˢ {a}
theorem Finset.offDiag_filter_lt_eq_filter_le E1 #
∀ {ι : Type u_4} [inst : PartialOrder ι] [inst_1 : DecidableLE ι] [inst_2 : DecidableLT ι] (s : Finset ι),
{i ∈ s.offDiag | i.1 < i.2} = {i ∈ s.offDiag | i.1 ≤ i.2}
theorem Finset.card_product_filter_lt E1 #
∀ {α : Type u_1} {s : Finset α} [inst : LinearOrder α], {x ∈ s ×ˢ s | x.1 < x.2}.card = s.card.choose 2
The number of strictly ordered pairs (a, b) with a, b ∈ s is (#s).choose 2.