Skip to content

Commit

Permalink
refactor: use the typeclass SProd to implement overloaded notation …
Browse files Browse the repository at this point in the history
…`· ×ˢ ·` (#4200)

Currently, the following notations are changed from `· ×ˢ ·` because Lean 4 can't deal with ambiguous notations.
| Definition | Notation |
| :

Co-authored-by: Jeremy Tan Jie Rui <reddeloostw@gmail.com>
Co-authored-by: Kyle Miller <kmill31415@gmail.com>
Co-authored-by: Chris Hughes <chrishughes24@gmail.com>
  • Loading branch information
4 people committed May 28, 2023
1 parent 3e1d33f commit 6c01dc6
Show file tree
Hide file tree
Showing 88 changed files with 509 additions and 470 deletions.
1 change: 1 addition & 0 deletions Mathlib.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,7 @@ import Mathlib.Data.Real.Pointwise
import Mathlib.Data.Real.Sign
import Mathlib.Data.Real.Sqrt
import Mathlib.Data.Rel
import Mathlib.Data.SProd
import Mathlib.Data.Semiquot
import Mathlib.Data.Seq.Computation
import Mathlib.Data.Seq.Parallel
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Algebra/Algebra/Subalgebra/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@ def prod : Subalgebra R (A × B) :=
#align subalgebra.prod Subalgebra.prod

@[simp]
theorem coe_prod : (prod S S₁ : Set (A × B)) = S ×ˢ S₁ :=
theorem coe_prod : (prod S S₁ : Set (A × B)) = (S : Set A) ×ˢ (S₁ : Set B) :=
rfl
#align subalgebra.coe_prod Subalgebra.coe_prod

Expand Down
12 changes: 6 additions & 6 deletions Mathlib/Algebra/BigOperators/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -664,30 +664,30 @@ theorem prod_mul_distrib : (∏ x in s, f x * g x) = (∏ x in s, f x) * ∏ x i

@[to_additive]
theorem prod_product {s : Finset γ} {t : Finset α} {f : γ × α → β} :
(∏ x in s × t, f x) = ∏ x in s, ∏ y in t, f (x, y) :=
prod_finset_product (s × t) s (fun _a => t) fun _p => mem_product
(∏ x in s ×ˢ t, f x) = ∏ x in s, ∏ y in t, f (x, y) :=
prod_finset_product (s ×ˢ t) s (fun _a => t) fun _p => mem_product
#align finset.prod_product Finset.prod_product
#align finset.sum_product Finset.sum_product

/-- An uncurried version of `Finset.prod_product`. -/
@[to_additive "An uncurried version of `Finset.sum_product`"]
theorem prod_product' {s : Finset γ} {t : Finset α} {f : γ → α → β} :
(∏ x in s × t, f x.1 x.2) = ∏ x in s, ∏ y in t, f x y :=
(∏ x in s ×ˢ t, f x.1 x.2) = ∏ x in s, ∏ y in t, f x y :=
prod_product
#align finset.prod_product' Finset.prod_product'
#align finset.sum_product' Finset.sum_product'

@[to_additive]
theorem prod_product_right {s : Finset γ} {t : Finset α} {f : γ × α → β} :
(∏ x in s × t, f x) = ∏ y in t, ∏ x in s, f (x, y) :=
prod_finset_product_right (s × t) t (fun _a => s) fun _p => mem_product.trans and_comm
(∏ x in s ×ˢ t, f x) = ∏ y in t, ∏ x in s, f (x, y) :=
prod_finset_product_right (s ×ˢ t) t (fun _a => s) fun _p => mem_product.trans and_comm
#align finset.prod_product_right Finset.prod_product_right
#align finset.sum_product_right Finset.sum_product_right

/-- An uncurried version of `Finset.prod_product_right`. -/
@[to_additive "An uncurried version of `Finset.prod_product_right`"]
theorem prod_product_right' {s : Finset γ} {t : Finset α} {f : γ → α → β} :
(∏ x in s × t, f x.1 x.2) = ∏ y in t, ∏ x in s, f x y :=
(∏ x in s ×ˢ t, f x.1 x.2) = ∏ y in t, ∏ x in s, f x y :=
prod_product_right
#align finset.prod_product_right' Finset.prod_product_right'
#align finset.sum_product_right' Finset.sum_product_right'
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Algebra/BigOperators/Ring.lean
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ theorem mul_sum : (b * ∑ x in s, f x) = ∑ x in s, b * f x :=

theorem sum_mul_sum {ι₁ : Type _} {ι₂ : Type _} (s₁ : Finset ι₁) (s₂ : Finset ι₂) (f₁ : ι₁ → β)
(f₂ : ι₂ → β) :
((∑ x₁ in s₁, f₁ x₁) * ∑ x₂ in s₂, f₂ x₂) = ∑ p in s₁ × s₂, f₁ p.1 * f₂ p.2 := by
((∑ x₁ in s₁, f₁ x₁) * ∑ x₂ in s₂, f₂ x₂) = ∑ p in s₁ ×ˢ s₂, f₁ p.1 * f₂ p.2 := by
rw [sum_product, sum_mul, sum_congr rfl]
intros
rw [mul_sum]
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Algebra/DirectSum/Internal.lean
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ theorem coeRingHom_of [AddMonoid ι] [SetLike.GradedMonoid A] (i : ι) (x : A i)
theorem coe_mul_apply [AddMonoid ι] [SetLike.GradedMonoid A]
[∀ (i : ι) (x : A i), Decidable (x ≠ 0)] (r r' : ⨁ i, A i) (n : ι) :
((r * r') n : R) =
∑ ij in (r.support × r'.support).filter (fun ij : ι × ι => ij.1 + ij.2 = n),
∑ ij in (r.support ×ˢ r'.support).filter (fun ij : ι × ι => ij.1 + ij.2 = n),
(r ij.1 * r' ij.2 : R) := by
rw [mul_eq_sum_support_ghas_mul, Dfinsupp.finset_sum_apply, AddSubmonoidClass.coe_finset_sum]
simp_rw [coe_of_apply, apply_ite, ZeroMemClass.coe_zero, ← Finset.sum_filter, SetLike.coe_gMul]
Expand Down
3 changes: 1 addition & 2 deletions Mathlib/Algebra/DirectSum/Ring.lean
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ theorem mul_eq_dfinsupp_sum [∀ (i : ι) (x : A i), Decidable (x ≠ 0)] (a a'
/-- A heavily unfolded version of the definition of multiplication -/
theorem mul_eq_sum_support_ghas_mul [∀ (i : ι) (x : A i), Decidable (x ≠ 0)] (a a' : ⨁ i, A i) :
a * a' =
∑ ij in Dfinsupp.support a × Dfinsupp.support a',
∑ ij in Dfinsupp.support a ×ˢ Dfinsupp.support a',
DirectSum.of _ _ (GradedMonoid.GMul.mul (a ij.fst) (a' ij.snd)) :=
by simp only [mul_eq_dfinsupp_sum, Dfinsupp.sum, Finset.sum_product]
#align direct_sum.mul_eq_sum_support_ghas_mul DirectSum.mul_eq_sum_support_ghas_mul
Expand Down Expand Up @@ -716,4 +716,3 @@ instance CommSemiring.directSumGCommSemiring {R : Type _} [AddCommMonoid ι] [Co
#align comm_semiring.direct_sum_gcomm_semiring CommSemiring.directSumGCommSemiring

end Uniform

6 changes: 2 additions & 4 deletions Mathlib/Algebra/Group/UniqueProds.lean
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ theorem set_subsingleton (A B : Finset G) (a0 b0 : G) (h : UniqueMul A B a0 b0)

-- Porting note: mathport warning: expanding binder collection
-- (ab «expr ∈ » [finset.product/multiset.product/set.prod/list.product](A, B)) -/
-- Porting note: replaced `xˢ` by `xᶠ`
@[to_additive]
theorem iff_existsUnique (aA : a0 ∈ A) (bB : b0 ∈ B) :
UniqueMul A B a0 b0 ↔ ∃! (ab : _)(_ : ab ∈ A × B), ab.1 * ab.2 = a0 * b0 :=
UniqueMul A B a0 b0 ↔ ∃! (ab : _)(_ : ab ∈ A ×ˢ B), ab.1 * ab.2 = a0 * b0 :=
fun _ ↦ ⟨(a0, b0), ⟨Finset.mem_product.mpr ⟨aA, bB⟩, rfl, by simp⟩, by simpa⟩,
fun h ↦ h.elim₂
(by
Expand All @@ -97,11 +96,10 @@ theorem iff_existsUnique (aA : a0 ∈ A) (bB : b0 ∈ B) :

-- Porting note: mathport warning: expanding binder collection
-- (ab «expr ∈ » [finset.product/multiset.product/set.prod/list.product](A, B)) -/
-- Porting note: replaced `xˢ` by `xᶠ`
@[to_additive]
theorem exists_iff_exists_existsUnique :
(∃ a0 b0 : G, a0 ∈ A ∧ b0 ∈ B ∧ UniqueMul A B a0 b0) ↔
∃ g : G, ∃! (ab : _)(_ : ab ∈ A × B), ab.1 * ab.2 = g :=
∃ g : G, ∃! (ab : _)(_ : ab ∈ A ×ˢ B), ab.1 * ab.2 = g :=
fun ⟨a0, b0, hA, hB, h⟩ ↦ ⟨_, (iff_existsUnique hA hB).mp h⟩, fun ⟨g, h⟩ ↦ by
have h' := h
rcases h' with ⟨⟨a, b⟩, ⟨hab, rfl, -⟩, -⟩
Expand Down
3 changes: 1 addition & 2 deletions Mathlib/Algebra/Module/BigOperators.lean
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ theorem Finset.sum_smul {f : ι → R} {s : Finset ι} {x : M} :
(∑ i in s, f i) • x = ∑ i in s, f i • x := ((smulAddHom R M).flip x).map_sum f s
#align finset.sum_smul Finset.sum_smul

-- Porting note: changed `×ˢ` to `xᶠ` in the statement of the theorem to fix ambiguous notation
theorem Finset.sum_smul_sum {f : α → R} {g : β → M} {s : Finset α} {t : Finset β} :
((∑ i in s, f i) • ∑ i in t, g i) = ∑ p in s × t, f p.fst • g p.snd := by
((∑ i in s, f i) • ∑ i in t, g i) = ∑ p in s ×ˢ t, f p.fst • g p.snd := by
rw [Finset.sum_product, Finset.sum_smul, Finset.sum_congr rfl]
intros
rw [Finset.smul_sum]
Expand Down
4 changes: 2 additions & 2 deletions Mathlib/Algebra/MonoidAlgebra/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,8 @@ theorem mul_apply_antidiagonal [Mul G] (f g : MonoidAlgebra k G) (x : G) (s : Fi
let F : G × G → k := fun p => if p.1 * p.2 = x then f p.1 * g p.2 else 0
calc
(f * g) x = ∑ a₁ in f.support, ∑ a₂ in g.support, F (a₁, a₂) := mul_apply f g x
_ = ∑ p in f.support × g.support, F p := Finset.sum_product.symm
_ = ∑ p in (f.support × g.support).filter fun p : G × G => p.1 * p.2 = x, f p.1 * g p.2 :=
_ = ∑ p in f.support ×ˢ g.support, F p := Finset.sum_product.symm
_ = ∑ p in (f.support ×ˢ g.support).filter fun p : G × G => p.1 * p.2 = x, f p.1 * g p.2 :=
(Finset.sum_filter _ _).symm
_ = ∑ p in s.filter fun p : G × G => p.1 ∈ f.support ∧ p.2 ∈ g.support, f p.1 * g p.2 :=
(sum_congr
Expand Down
6 changes: 2 additions & 4 deletions Mathlib/Analysis/Convex/Combination.lean
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,7 @@ theorem mk_mem_convexHull_prod {t : Set F} {x : E} {y : F} (hx : x ∈ convexHul
-- Porting note: We have to specify the universe of `ι` and `κ`
obtain ⟨ι : Type u_1, a, w, S, hw, hw', hS, hSp⟩ := hx
obtain ⟨κ : Type u_1, b, v, T, hv, hv', hT, hTp⟩ := hy
-- Porting note: Changed `×ˢ` to `×ᶠ`
have h_sum : (∑ i : ι × κ in a ×ᶠ b, w i.fst * v i.snd) = 1 := by
have h_sum : (∑ i : ι × κ in a ×ˢ b, w i.fst * v i.snd) = 1 := by
rw [Finset.sum_product, ← hw']
congr
ext i
Expand All @@ -391,9 +390,8 @@ theorem mk_mem_convexHull_prod {t : Set F} {x : E} {y : F} (hx : x ∈ convexHul
simp [mul_comm]
rw [this, ← Finset.sum_mul, hv']
simp
-- Porting note: Changed `×ˢ` to `×ᶠ`
refine'
⟨ι × κ, a × b, fun p => w p.1 * v p.2, fun p => (S p.1, T p.2), fun p hp => _, h_sum,
⟨ι × κ, a ×ˢ b, fun p => w p.1 * v p.2, fun p => (S p.1, T p.2), fun p hp => _, h_sum,
fun p hp => _, _⟩
· rw [mem_product] at hp
exact mul_nonneg (hw p.1 hp.1) (hv p.2 hp.2)
Expand Down
4 changes: 2 additions & 2 deletions Mathlib/Analysis/Normed/Group/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ theorem SeminormedGroup.tendstoUniformlyOn_one {f : ι → κ → G} {s : Set κ
theorem SeminormedGroup.uniformCauchySeqOnFilter_iff_tendstoUniformlyOnFilter_one {f : ι → κ → G}
{l : Filter ι} {l' : Filter κ} :
UniformCauchySeqOnFilter f l l' ↔
TendstoUniformlyOnFilter (fun n : ι × ι => fun z => f n.fst z / f n.snd z) 1 (l × l) l' := by
TendstoUniformlyOnFilter (fun n : ι × ι => fun z => f n.fst z / f n.snd z) 1 (l ×ˢ l) l' := by
refine' ⟨fun hf u hu => _, fun hf u hu => _⟩
· obtain ⟨ε, hε, H⟩ := uniformity_basis_dist.mem_uniformity_iff.mp hu
refine'
Expand All @@ -1319,7 +1319,7 @@ theorem SeminormedGroup.uniformCauchySeqOnFilter_iff_tendstoUniformlyOnFilter_on
theorem SeminormedGroup.uniformCauchySeqOn_iff_tendstoUniformlyOn_one {f : ι → κ → G} {s : Set κ}
{l : Filter ι} :
UniformCauchySeqOn f l s ↔
TendstoUniformlyOn (fun n : ι × ι => fun z => f n.fst z / f n.snd z) 1 (l × l) s := by
TendstoUniformlyOn (fun n : ι × ι => fun z => f n.fst z / f n.snd z) 1 (l ×ˢ l) s := by
rw [tendstoUniformlyOn_iff_tendstoUniformlyOnFilter,
uniformCauchySeqOn_iff_uniformCauchySeqOnFilter,
SeminormedGroup.uniformCauchySeqOnFilter_iff_tendstoUniformlyOnFilter_one]
Expand Down
6 changes: 3 additions & 3 deletions Mathlib/Analysis/SpecialFunctions/Pow/Continuity.lean
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,12 @@ theorem continuousAt_rpow_of_pos (p : ℝ × ℝ) (hp : 0 < p.2) :
dsimp only at hp
obtain hx | rfl := ne_or_eq x 0
· exact continuousAt_rpow_of_ne (x, y) hx
have A : Tendsto (fun p : ℝ × ℝ => exp (log p.1 * p.2)) (𝓝[≠] 0 × 𝓝 y) (𝓝 0) :=
have A : Tendsto (fun p : ℝ × ℝ => exp (log p.1 * p.2)) (𝓝[≠] 0 ×ˢ 𝓝 y) (𝓝 0) :=
tendsto_exp_atBot.comp
((tendsto_log_nhdsWithin_zero.comp tendsto_fst).atBot_mul hp tendsto_snd)
have B : Tendsto (fun p : ℝ × ℝ => p.1 ^ p.2) (𝓝[≠] 0 × 𝓝 y) (𝓝 0) :=
have B : Tendsto (fun p : ℝ × ℝ => p.1 ^ p.2) (𝓝[≠] 0 ×ˢ 𝓝 y) (𝓝 0) :=
squeeze_zero_norm (fun p => abs_rpow_le_exp_log_mul p.1 p.2) A
have C : Tendsto (fun p : ℝ × ℝ => p.1 ^ p.2) (𝓝[{0}] 0 × 𝓝 y) (pure 0) := by
have C : Tendsto (fun p : ℝ × ℝ => p.1 ^ p.2) (𝓝[{0}] 0 ×ˢ 𝓝 y) (pure 0) := by
rw [nhdsWithin_singleton, tendsto_pure, pure_prod, eventually_map]
exact (lt_mem_nhds hp).mono fun y hy => zero_rpow hy.ne'
simpa only [← sup_prod, ← nhdsWithin_union, compl_union_self, nhdsWithin_univ, nhds_prod_eq,
Expand Down
10 changes: 4 additions & 6 deletions Mathlib/Combinatorics/Additive/Energy.lean
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ additive combinatorics.
## TODO
It's possibly interesting to have
`(s ×ˢ s) × t × t).filter (λ x : (α × α) × α × α, x.1.1 * x.2.1 = x.1.2 * x.2.2)` (whose `card` is
`multiplicativeEnergy s t`) as a standalone definition.
`(s ×ˢ s) ×ˢ t ×ˢ t).filter (λ x : (α × α) × α × α, x.1.1 * x.2.1 = x.1.2 * x.2.2)` (whose `card`
is `multiplicativeEnergy s t`) as a standalone definition.
-/


Expand All @@ -38,14 +38,13 @@ namespace Finset
section Mul

variable [Mul α] {s s₁ s₂ t t₁ t₂ : Finset α}
-- porting note: replaced `xˢ` by `xᶠ`
/-- The multiplicative energy of two finsets `s` and `t` in a group is the number of quadruples
`(a₁, a₂, b₁, b₂) ∈ s × s × t × t` such that `a₁ * b₁ = a₂ * b₂`. -/
@[to_additive additiveEnergy
"The additive energy of two finsets `s` and `t` in a group is the
number of quadruples `(a₁, a₂, b₁, b₂) ∈ s × s × t × t` such that `a₁ + b₁ = a₂ + b₂`."]
def multiplicativeEnergy (s t : Finset α) : ℕ :=
(((s × s) × t × t).filter fun x : (α × α) × α × α => x.1.1 * x.2.1 = x.1.2 * x.2.2).card
(((s ×ˢ s) ×ˢ t ×ˢ t).filter fun x : (α × α) × α × α => x.1.1 * x.2.1 = x.1.2 * x.2.2).card
#align finset.multiplicative_energy Finset.multiplicativeEnergy
#align finset.additive_energy Finset.additiveEnergy

Expand Down Expand Up @@ -144,13 +143,12 @@ section CommGroup

variable [CommGroup α] [Fintype α] (s t : Finset α)

-- porting note: replaced `xˢ` by `xᶠ`
@[to_additive (attr := simp) additiveEnergy_univ_left]
theorem multiplicativeEnergy_univ_left :
multiplicativeEnergy univ t = Fintype.card α * t.card ^ 2 := by
simp only [multiplicativeEnergy, univ_product_univ, Fintype.card, sq, ← card_product]
let f : α × α × α → (α × α) × α × α := fun x => ((x.1 * x.2.2, x.1 * x.2.1), x.2)
have : (↑((univ : Finset α) × t × t) : Set (α × α × α)).InjOn f := by
have : (↑((univ : Finset α) ×ˢ t ×ˢ t) : Set (α × α × α)).InjOn f := by
rintro ⟨a₁, b₁, c₁⟩ _ ⟨a₂, b₂, c₂⟩ h₂ h
simp_rw [Prod.ext_iff] at h
obtain ⟨h, rfl, rfl⟩ := h
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Combinatorics/Additive/PluenneckeRuzsa.lean
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ variable {α : Type _} [CommGroup α] [DecidableEq α] {A B C : Finset α}
"**Ruzsa's triangle inequality**. Subtraction version."]
theorem card_div_mul_le_card_div_mul_card_div (A B C : Finset α) :
(A / C).card * B.card ≤ (A / B).card * (B / C).card := by
rw [← card_product (A / B), ← mul_one (Finset.product _ _).card]
rw [← card_product (A / B), ← mul_one ((A / B) ×ˢ (B / C)).card]
refine' card_mul_le_card_mul (fun b ac ↦ ac.1 * ac.2 = b) (fun x hx ↦ _)
fun x _ ↦ card_le_one_iff.2 fun hu hv ↦
((mem_bipartiteBelow _).1 hu).2.symm.trans ((mem_bipartiteBelow _).1 hv).2
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Combinatorics/Additive/SalemSpencer.lean
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ theorem mulRothNumber_union_le (s t : Finset α) :

@[to_additive]
theorem le_mulRothNumber_product (s : Finset α) (t : Finset β) :
mulRothNumber s * mulRothNumber t ≤ mulRothNumber (s × t) := by
mulRothNumber s * mulRothNumber t ≤ mulRothNumber (s ×ˢ t) := by
obtain ⟨u, hus, hucard, hu⟩ := mulRothNumber_spec s
obtain ⟨v, hvt, hvcard, hv⟩ := mulRothNumber_spec t
rw [← hucard, ← hvcard, ← card_product]
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Combinatorics/Catalan.lean
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ open Tree
left child in `a` and right child in `b` -/
@[reducible]
def pairwiseNode (a b : Finset (Tree Unit)) : Finset (Tree Unit) :=
(a × b).map ⟨fun x => x.1 △ x.2, fun ⟨x₁, x₂⟩ ⟨y₁, y₂⟩ => fun h => by simpa using h⟩
(a ×ˢ b).map ⟨fun x => x.1 △ x.2, fun ⟨x₁, x₂⟩ ⟨y₁, y₂⟩ => fun h => by simpa using h⟩
#align tree.pairwise_node Tree.pairwiseNode

/-- A Finset of all trees with `n` nodes. See `mem_treesOfNodesEq` -/
Expand Down
12 changes: 6 additions & 6 deletions Mathlib/Combinatorics/SimpleGraph/Density.lean
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ variable [LinearOrderedField 𝕜] (r : α → β → Prop) [∀ a, DecidablePre

/-- Finset of edges of a relation between two finsets of vertices. -/
def interedges (s : Finset α) (t : Finset β) : Finset (α × β) :=
(s × t).filter fun e ↦ r e.1 e.2
(s ×ˢ t).filter fun e ↦ r e.1 e.2
#align rel.interedges Rel.interedges

/-- Edge density of a relation between two finsets of vertices. -/
Expand Down Expand Up @@ -120,7 +120,7 @@ theorem interedges_biUnion_right (s : Finset α) (t : Finset ι) (f : ι → Fin

theorem interedges_biUnion (s : Finset ι) (t : Finset κ) (f : ι → Finset α) (g : κ → Finset β) :
interedges r (s.biUnion f) (t.biUnion g) =
(s × t).biUnion fun ab ↦ interedges r (f ab.1) (g ab.2) := by
(s ×ˢ t).biUnion fun ab ↦ interedges r (f ab.1) (g ab.2) := by
simp_rw [product_biUnion, interedges_biUnion_left, interedges_biUnion_right]
#align rel.interedges_bUnion Rel.interedges_biUnion

Expand Down Expand Up @@ -176,7 +176,7 @@ theorem card_interedges_finpartition_right [DecidableEq β] (s : Finset α) (P :

theorem card_interedges_finpartition [DecidableEq α] [DecidableEq β] (P : Finpartition s)
(Q : Finpartition t) :
(interedges r s t).card = ∑ ab in P.parts × Q.parts, (interedges r ab.1 ab.2).card := by
(interedges r s t).card = ∑ ab in P.parts ×ˢ Q.parts, (interedges r ab.1 ab.2).card := by
rw [card_interedges_finpartition_left _ P, sum_product]
congr; ext
rw [card_interedges_finpartition_right]
Expand Down Expand Up @@ -309,7 +309,7 @@ def edgeDensity : Finset α → Finset α → ℚ :=
#align simple_graph.edge_density SimpleGraph.edgeDensity

theorem interedges_def (s t : Finset α) :
G.interedges s t = (s × t).filter fun e ↦ G.Adj e.1 e.2 :=
G.interedges s t = (s ×ˢ t).filter fun e ↦ G.Adj e.1 e.2 :=
rfl
#align simple_graph.interedges_def SimpleGraph.interedges_def

Expand Down Expand Up @@ -367,14 +367,14 @@ theorem interedges_biUnion_right (s : Finset α) (t : Finset ι) (f : ι → Fin

theorem interedges_biUnion (s : Finset ι) (t : Finset κ) (f : ι → Finset α) (g : κ → Finset α) :
G.interedges (s.biUnion f) (t.biUnion g) =
(s × t).biUnion fun ab ↦ G.interedges (f ab.1) (g ab.2) :=
(s ×ˢ t).biUnion fun ab ↦ G.interedges (f ab.1) (g ab.2) :=
Rel.interedges_biUnion _ _ _ _ _
#align simple_graph.interedges_bUnion SimpleGraph.interedges_biUnion

theorem card_interedges_add_card_interedges_compl (h : Disjoint s t) :
(G.interedges s t).card + (Gᶜ.interedges s t).card = s.card * t.card := by
rw [← card_product, interedges_def, interedges_def]
have : ((s × t).filter fun e ↦ Gᶜ.Adj e.1 e.2) = (s × t).filter fun e ↦ ¬G.Adj e.1 e.2 := by
have : ((s ×ˢ t).filter fun e ↦ Gᶜ.Adj e.1 e.2) = (s ×ˢ t).filter fun e ↦ ¬G.Adj e.1 e.2 := by
refine' filter_congr fun x hx ↦ _
rw [mem_product] at hx
rw [compl_adj, and_iff_right (h.forall_ne_finset hx.1 hx.2)]
Expand Down
8 changes: 3 additions & 5 deletions Mathlib/Combinatorics/SimpleGraph/Prod.lean
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,8 @@ instance boxProdFintypeNeighborSet (x : α × β)
[Fintype (G.neighborSet x.1)] [Fintype (H.neighborSet x.2)] :
Fintype ((G □ H).neighborSet x) :=
Fintype.ofEquiv
-- porting note: was `×ˢ`
((G.neighborFinset x.1 ×ᶠ {x.2}).disjUnion ({x.1} ×ᶠ H.neighborFinset x.2) <|
Finset.disjoint_product.mpr <| Or.inl <| neighborFinset_disjoint_singleton _ _)
((G.neighborFinset x.1 ×ˢ {x.2}).disjUnion ({x.1} ×ˢ H.neighborFinset x.2) <|
Finset.disjoint_product.mpr <| Or.inl <| neighborFinset_disjoint_singleton _ _)
((Equiv.refl _).subtypeEquiv fun y => by
simp_rw [Finset.mem_disjUnion, Finset.mem_product, Finset.mem_singleton, mem_neighborFinset,
mem_neighborSet, Equiv.refl_apply, boxProd_adj]
Expand All @@ -233,8 +232,7 @@ instance boxProdFintypeNeighborSet (x : α × β)
theorem boxProd_neighborFinset (x : α × β)
[Fintype (G.neighborSet x.1)] [Fintype (H.neighborSet x.2)] [Fintype ((G □ H).neighborSet x)] :
(G □ H).neighborFinset x =
-- porting note: was `×ˢ`
(G.neighborFinset x.1 ×ᶠ {x.2}).disjUnion ({x.1} ×ᶠ H.neighborFinset x.2)
(G.neighborFinset x.1 ×ˢ {x.2}).disjUnion ({x.1} ×ˢ H.neighborFinset x.2)
(Finset.disjoint_product.mpr <| Or.inl <| neighborFinset_disjoint_singleton _ _) := by
-- swap out the fintype instance for the canonical one
letI : Fintype ((G □ H).neighborSet x) := SimpleGraph.boxProdFintypeNeighborSet _
Expand Down
Loading

0 comments on commit 6c01dc6

Please sign in to comment.