Skip to content

Commit

Permalink
feat: port Algebra.BigOperators.Multiset.Lemmas (#1536)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben-VandeVelde committed Jan 13, 2023
1 parent 40d6bcd commit 5f003c0
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions Mathlib.lean
@@ -1,6 +1,7 @@
import Mathlib.Algebra.Abs
import Mathlib.Algebra.Associated
import Mathlib.Algebra.BigOperators.Multiset.Basic
import Mathlib.Algebra.BigOperators.Multiset.Lemmas
import Mathlib.Algebra.Bounds
import Mathlib.Algebra.CharZero.Defs
import Mathlib.Algebra.CharZero.Lemmas
Expand Down
49 changes: 49 additions & 0 deletions Mathlib/Algebra/BigOperators/Multiset/Lemmas.lean
@@ -0,0 +1,49 @@
/-
Copyright (c) 2019 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Bhavik Mehta, Eric Wieser
! This file was ported from Lean 3 source module algebra.big_operators.multiset.lemmas
! leanprover-community/mathlib commit 9003f28797c0664a49e4179487267c494477d853
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathlib.Data.List.BigOperators.Lemmas
import Mathlib.Algebra.BigOperators.Multiset.Basic

/-! # Lemmas about `Multiset.sum` and `Multiset.prod` requiring extra algebra imports -/


variable {α : Type _}

namespace Multiset

theorem dvd_prod [CommMonoid α] {s : Multiset α} {a : α} : a ∈ s → a ∣ s.prod :=
Quotient.inductionOn s (fun l a h => by simpa using List.dvd_prod h) a
#align multiset.dvd_prod Multiset.dvd_prod

@[to_additive]
theorem prod_eq_one_iff [CanonicallyOrderedMonoid α] {m : Multiset α} :
m.prod = 1 ↔ ∀ x ∈ m, x = (1 : α) :=
Quotient.inductionOn m fun l => by simpa using List.prod_eq_one_iff l
#align multiset.prod_eq_one_iff Multiset.prod_eq_one_iff

end Multiset

open Multiset

namespace Commute

variable [NonUnitalNonAssocSemiring α] (s : Multiset α)

theorem multiset_sum_right (a : α) (h : ∀ b ∈ s, Commute a b) : Commute a s.sum := by
induction s using Quotient.inductionOn
rw [quot_mk_to_coe, coe_sum]
exact Commute.list_sum_right _ _ h
#align commute.multiset_sum_right Commute.multiset_sum_right

theorem multiset_sum_left (b : α) (h : ∀ a ∈ s, Commute a b) : Commute s.sum b :=
((Commute.multiset_sum_right _ _) fun _ ha => (h _ ha).symm).symm
#align commute.multiset_sum_left Commute.multiset_sum_left

end Commute

0 comments on commit 5f003c0

Please sign in to comment.