Finsets in product types #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
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.diag
is thefinset (α × α)
of pairs(a, a)
witha ∈ s
.finset.off_diag
: Fors : finset α
,s.off_diag
is thefinset (α × α)
of pairs(a, b)
witha, b ∈ s
anda ≠ b
.
prod #
theorem
finset.subset_product_image_fst
{α : Type u_1}
{β : Type u_2}
{s : finset α}
{t : finset β}
[decidable_eq α] :
finset.image prod.fst (s ×ˢ t) ⊆ s
theorem
finset.subset_product_image_snd
{α : Type u_1}
{β : Type u_2}
{s : finset α}
{t : finset β}
[decidable_eq β] :
finset.image prod.snd (s ×ˢ t) ⊆ t
theorem
finset.product_image_fst
{α : Type u_1}
{β : Type u_2}
{s : finset α}
{t : finset β}
[decidable_eq α]
(ht : t.nonempty) :
finset.image prod.fst (s ×ˢ t) = s
theorem
finset.product_image_snd
{α : Type u_1}
{β : Type u_2}
{s : finset α}
{t : finset β}
[decidable_eq β]
(ht : s.nonempty) :
finset.image prod.snd (s ×ˢ t) = t
theorem
finset.subset_product
{α : Type u_1}
{β : Type u_2}
[decidable_eq α]
[decidable_eq β]
{s : finset (α × β)} :
s ⊆ finset.image prod.fst s ×ˢ finset.image prod.snd s
@[simp]
theorem
finset.image_swap_product
{α : Type u_1}
{β : Type u_2}
[decidable_eq α]
[decidable_eq β]
(s : finset α)
(t : finset β) :
finset.image prod.swap (t ×ˢ s) = s ×ˢ t
theorem
finset.product_eq_bUnion
{α : Type u_1}
{β : Type u_2}
[decidable_eq α]
[decidable_eq β]
(s : finset α)
(t : finset β) :
s ×ˢ t = s.bUnion (λ (a : α), finset.image (λ (b : β), (a, b)) t)
theorem
finset.product_eq_bUnion_right
{α : Type u_1}
{β : Type u_2}
[decidable_eq α]
[decidable_eq β]
(s : finset α)
(t : finset β) :
s ×ˢ t = t.bUnion (λ (b : β), finset.image (λ (a : α), (a, b)) s)
theorem
finset.filter_product
{α : Type u_1}
{β : Type u_2}
{s : finset α}
{t : finset β}
(p : α → Prop)
(q : β → Prop)
[decidable_pred p]
[decidable_pred q] :
finset.filter (λ (x : α × β), p x.fst ∧ q x.snd) (s ×ˢ t) = finset.filter p s ×ˢ finset.filter q t
theorem
finset.filter_product_left
{α : Type u_1}
{β : Type u_2}
{s : finset α}
{t : finset β}
(p : α → Prop)
[decidable_pred p] :
finset.filter (λ (x : α × β), p x.fst) (s ×ˢ t) = finset.filter p s ×ˢ t
theorem
finset.filter_product_right
{α : Type u_1}
{β : Type u_2}
{s : finset α}
{t : finset β}
(q : β → Prop)
[decidable_pred q] :
finset.filter (λ (x : α × β), q x.snd) (s ×ˢ t) = s ×ˢ finset.filter q t
theorem
finset.filter_product_card
{α : Type u_1}
{β : Type u_2}
(s : finset α)
(t : finset β)
(p : α → Prop)
(q : β → Prop)
[decidable_pred p]
[decidable_pred q] :
(finset.filter (λ (x : α × β), p x.fst ↔ q x.snd) (s ×ˢ t)).card = (finset.filter p s).card * (finset.filter q t).card + (finset.filter (not ∘ p) s).card * (finset.filter (not ∘ q) t).card
@[simp]
theorem
finset.union_product
{α : Type u_1}
{β : Type u_2}
{s s' : finset α}
{t : finset β}
[decidable_eq α]
[decidable_eq β] :
@[simp]
theorem
finset.product_union
{α : Type u_1}
{β : Type u_2}
{s : finset α}
{t t' : finset β}
[decidable_eq α]
[decidable_eq β] :
theorem
finset.inter_product
{α : Type u_1}
{β : Type u_2}
{s s' : finset α}
{t : finset β}
[decidable_eq α]
[decidable_eq β] :
theorem
finset.product_inter
{α : Type u_1}
{β : Type u_2}
{s : finset α}
{t t' : finset β}
[decidable_eq α]
[decidable_eq β] :
theorem
finset.product_inter_product
{α : Type u_1}
{β : Type u_2}
{s s' : finset α}
{t t' : finset β}
[decidable_eq α]
[decidable_eq β] :
@[simp]
theorem
finset.disj_union_product
{α : Type u_1}
{β : Type u_2}
{s s' : finset α}
{t : finset β}
(hs : disjoint s s') :
s.disj_union s' hs ×ˢ t = (s ×ˢ t).disj_union (s' ×ˢ t) _
@[simp]
theorem
finset.product_disj_union
{α : Type u_1}
{β : Type u_2}
{s : finset α}
{t t' : finset β}
(ht : disjoint t t') :
s ×ˢ t.disj_union t' ht = (s ×ˢ t).disj_union (s ×ˢ t') _
Given a finite set s
, the diagonal, s.diag
is the set of pairs of the form (a, a)
for
a ∈ s
.
Given a finite set s
, the off-diagonal, s.off_diag
is the set of pairs (a, b)
with a ≠ b
for a, b ∈ s
.
@[simp, norm_cast]
@[simp]
@[simp]
@[simp]
@[simp]
theorem
finset.diag_insert
{α : Type u_1}
[decidable_eq α]
{s : finset α}
(a : α) :
(has_insert.insert a s).diag = has_insert.insert (a, a) s.diag
theorem
finset.off_diag_insert
{α : Type u_1}
[decidable_eq α]
{s : finset α}
(a : α)
(has : a ∉ s) :