state
stringlengths
0
159k
srcUpToTactic
stringlengths
387
167k
nextTactic
stringlengths
3
9k
declUpToTactic
stringlengths
22
11.5k
declId
stringlengths
38
95
decl
stringlengths
16
1.89k
file_tag
stringlengths
17
73
M : Type u_1 inst✝ : MulOneClass M x✝¹ x✝ : M ⊢ 1 * (x✝¹ * x✝) = 1 * x✝¹ * x✝
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by
rw [one_mul, one_mul]
@[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by
Mathlib.GroupTheory.Subsemigroup.Center.160_0.vKbtzx3rREtft3E
@[to_additive (attr
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : MulOneClass M x✝¹ x✝ : M ⊢ x✝¹ * 1 * x✝ = x✝¹ * (1 * x✝)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by
rw [mul_one, one_mul]
@[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by
Mathlib.GroupTheory.Subsemigroup.Center.160_0.vKbtzx3rREtft3E
@[to_additive (attr
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : MulOneClass M x✝¹ x✝ : M ⊢ x✝¹ * x✝ * 1 = x✝¹ * (x✝ * 1)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by
rw [mul_one, mul_one]
@[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by
Mathlib.GroupTheory.Subsemigroup.Center.160_0.vKbtzx3rREtft3E
@[to_additive (attr
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : MulZeroClass M x✝ : M ⊢ 0 * x✝ = x✝ * 0
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by
rw [zero_mul, mul_zero]
@[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by
Mathlib.GroupTheory.Subsemigroup.Center.169_0.vKbtzx3rREtft3E
@[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : MulZeroClass M x✝¹ x✝ : M ⊢ 0 * (x✝¹ * x✝) = 0 * x✝¹ * x✝
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by
rw [zero_mul, zero_mul, zero_mul]
@[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by
Mathlib.GroupTheory.Subsemigroup.Center.169_0.vKbtzx3rREtft3E
@[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : MulZeroClass M x✝¹ x✝ : M ⊢ x✝¹ * 0 * x✝ = x✝¹ * (0 * x✝)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by
rw [mul_zero, zero_mul, mul_zero]
@[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by
Mathlib.GroupTheory.Subsemigroup.Center.169_0.vKbtzx3rREtft3E
@[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : MulZeroClass M x✝¹ x✝ : M ⊢ x✝¹ * x✝ * 0 = x✝¹ * (x✝ * 0)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by
rw [mul_zero, mul_zero, mul_zero]
@[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by
Mathlib.GroupTheory.Subsemigroup.Center.169_0.vKbtzx3rREtft3E
@[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : NonAssocSemiring M n : ℕ x✝ : M ⊢ ↑n * x✝ = x✝ * ↑n
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by
rw [Nat.commute_cast]
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by
Mathlib.GroupTheory.Subsemigroup.Center.177_0.vKbtzx3rREtft3E
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : NonAssocSemiring M n : ℕ x✝¹ x✝ : M ⊢ ↑n * (x✝¹ * x✝) = ↑n * x✝¹ * x✝
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by
induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul]
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by
Mathlib.GroupTheory.Subsemigroup.Center.177_0.vKbtzx3rREtft3E
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : NonAssocSemiring M n : ℕ x✝¹ x✝ : M ⊢ ↑n * (x✝¹ * x✝) = ↑n * x✝¹ * x✝
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by
induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul]
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by
Mathlib.GroupTheory.Subsemigroup.Center.177_0.vKbtzx3rREtft3E
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
case zero M : Type u_1 inst✝ : NonAssocSemiring M x✝¹ x✝ : M ⊢ ↑Nat.zero * (x✝¹ * x✝) = ↑Nat.zero * x✝¹ * x✝
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with
| zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul]
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with
Mathlib.GroupTheory.Subsemigroup.Center.177_0.vKbtzx3rREtft3E
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
case zero M : Type u_1 inst✝ : NonAssocSemiring M x✝¹ x✝ : M ⊢ ↑Nat.zero * (x✝¹ * x✝) = ↑Nat.zero * x✝¹ * x✝
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero =>
rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul]
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero =>
Mathlib.GroupTheory.Subsemigroup.Center.177_0.vKbtzx3rREtft3E
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
case succ M : Type u_1 inst✝ : NonAssocSemiring M x✝¹ x✝ : M n : ℕ ihn : ↑n * (x✝¹ * x✝) = ↑n * x✝¹ * x✝ ⊢ ↑(Nat.succ n) * (x✝¹ * x✝) = ↑(Nat.succ n) * x✝¹ * x✝
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul]
| succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul]
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul]
Mathlib.GroupTheory.Subsemigroup.Center.177_0.vKbtzx3rREtft3E
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
case succ M : Type u_1 inst✝ : NonAssocSemiring M x✝¹ x✝ : M n : ℕ ihn : ↑n * (x✝¹ * x✝) = ↑n * x✝¹ * x✝ ⊢ ↑(Nat.succ n) * (x✝¹ * x✝) = ↑(Nat.succ n) * x✝¹ * x✝
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn =>
rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul]
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn =>
Mathlib.GroupTheory.Subsemigroup.Center.177_0.vKbtzx3rREtft3E
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : NonAssocSemiring M n : ℕ x✝¹ x✝ : M ⊢ x✝¹ * ↑n * x✝ = x✝¹ * (↑n * x✝)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by
induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one]
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by
Mathlib.GroupTheory.Subsemigroup.Center.177_0.vKbtzx3rREtft3E
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : NonAssocSemiring M n : ℕ x✝¹ x✝ : M ⊢ x✝¹ * ↑n * x✝ = x✝¹ * (↑n * x✝)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by
induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one]
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by
Mathlib.GroupTheory.Subsemigroup.Center.177_0.vKbtzx3rREtft3E
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
case zero M : Type u_1 inst✝ : NonAssocSemiring M x✝¹ x✝ : M ⊢ x✝¹ * ↑Nat.zero * x✝ = x✝¹ * (↑Nat.zero * x✝)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with
| zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul]
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with
Mathlib.GroupTheory.Subsemigroup.Center.177_0.vKbtzx3rREtft3E
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
case zero M : Type u_1 inst✝ : NonAssocSemiring M x✝¹ x✝ : M ⊢ x✝¹ * ↑Nat.zero * x✝ = x✝¹ * (↑Nat.zero * x✝)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero =>
rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul]
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero =>
Mathlib.GroupTheory.Subsemigroup.Center.177_0.vKbtzx3rREtft3E
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
case succ M : Type u_1 inst✝ : NonAssocSemiring M x✝¹ x✝ : M n : ℕ ihn : x✝¹ * ↑n * x✝ = x✝¹ * (↑n * x✝) ⊢ x✝¹ * ↑(Nat.succ n) * x✝ = x✝¹ * (↑(Nat.succ n) * x✝)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul]
| succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one]
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul]
Mathlib.GroupTheory.Subsemigroup.Center.177_0.vKbtzx3rREtft3E
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
case succ M : Type u_1 inst✝ : NonAssocSemiring M x✝¹ x✝ : M n : ℕ ihn : x✝¹ * ↑n * x✝ = x✝¹ * (↑n * x✝) ⊢ x✝¹ * ↑(Nat.succ n) * x✝ = x✝¹ * (↑(Nat.succ n) * x✝)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn =>
rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one]
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn =>
Mathlib.GroupTheory.Subsemigroup.Center.177_0.vKbtzx3rREtft3E
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : NonAssocSemiring M n : ℕ x✝¹ x✝ : M ⊢ x✝¹ * x✝ * ↑n = x✝¹ * (x✝ * ↑n)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by
induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one]
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by
Mathlib.GroupTheory.Subsemigroup.Center.177_0.vKbtzx3rREtft3E
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : NonAssocSemiring M n : ℕ x✝¹ x✝ : M ⊢ x✝¹ * x✝ * ↑n = x✝¹ * (x✝ * ↑n)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by
induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one]
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by
Mathlib.GroupTheory.Subsemigroup.Center.177_0.vKbtzx3rREtft3E
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
case zero M : Type u_1 inst✝ : NonAssocSemiring M x✝¹ x✝ : M ⊢ x✝¹ * x✝ * ↑Nat.zero = x✝¹ * (x✝ * ↑Nat.zero)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with
| zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero]
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with
Mathlib.GroupTheory.Subsemigroup.Center.177_0.vKbtzx3rREtft3E
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
case zero M : Type u_1 inst✝ : NonAssocSemiring M x✝¹ x✝ : M ⊢ x✝¹ * x✝ * ↑Nat.zero = x✝¹ * (x✝ * ↑Nat.zero)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero =>
rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero]
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero =>
Mathlib.GroupTheory.Subsemigroup.Center.177_0.vKbtzx3rREtft3E
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
case succ M : Type u_1 inst✝ : NonAssocSemiring M x✝¹ x✝ : M n : ℕ ihn : x✝¹ * x✝ * ↑n = x✝¹ * (x✝ * ↑n) ⊢ x✝¹ * x✝ * ↑(Nat.succ n) = x✝¹ * (x✝ * ↑(Nat.succ n))
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero]
| succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one]
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero]
Mathlib.GroupTheory.Subsemigroup.Center.177_0.vKbtzx3rREtft3E
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
case succ M : Type u_1 inst✝ : NonAssocSemiring M x✝¹ x✝ : M n : ℕ ihn : x✝¹ * x✝ * ↑n = x✝¹ * (x✝ * ↑n) ⊢ x✝¹ * x✝ * ↑(Nat.succ n) = x✝¹ * (x✝ * ↑(Nat.succ n))
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn =>
rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one]
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn =>
Mathlib.GroupTheory.Subsemigroup.Center.177_0.vKbtzx3rREtft3E
@[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : NonAssocRing M n : ℤ x✝ : M ⊢ ↑n * x✝ = x✝ * ↑n
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by
rw [Int.commute_cast]
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by
Mathlib.GroupTheory.Subsemigroup.Center.199_0.vKbtzx3rREtft3E
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : NonAssocRing M n✝ : ℤ x✝¹ x✝ : M n : ℕ ⊢ ↑↑n * (x✝¹ * x✝) = ↑↑n * x✝¹ * x✝
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by
rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _]
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by
Mathlib.GroupTheory.Subsemigroup.Center.199_0.vKbtzx3rREtft3E
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : NonAssocRing M n✝ : ℤ x✝¹ x✝ : M n : ℕ ⊢ ↑(Int.negSucc n) * (x✝¹ * x✝) = ↑(Int.negSucc n) * x✝¹ * x✝
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by
rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul]
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by
Mathlib.GroupTheory.Subsemigroup.Center.199_0.vKbtzx3rREtft3E
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : NonAssocRing M n✝ : ℤ x✝¹ x✝ : M n : ℕ ⊢ x✝¹ * ↑↑n * x✝ = x✝¹ * (↑↑n * x✝)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by
rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _]
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by
Mathlib.GroupTheory.Subsemigroup.Center.199_0.vKbtzx3rREtft3E
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : NonAssocRing M n✝ : ℤ x✝¹ x✝ : M n : ℕ ⊢ x✝¹ * ↑(Int.negSucc n) * x✝ = x✝¹ * (↑(Int.negSucc n) * x✝)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by
simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev]
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by
Mathlib.GroupTheory.Subsemigroup.Center.199_0.vKbtzx3rREtft3E
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : NonAssocRing M n✝ : ℤ x✝¹ x✝ : M n : ℕ ⊢ x✝¹ * (-1 + -↑n) * x✝ = x✝¹ * ((-1 + -↑n) * x✝)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev]
rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul]
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev]
Mathlib.GroupTheory.Subsemigroup.Center.199_0.vKbtzx3rREtft3E
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : NonAssocRing M n✝ : ℤ x✝¹ x✝ : M n : ℕ ⊢ x✝¹ * -1 * x✝ + x✝¹ * -↑n * x✝ = x✝¹ * -x✝ + x✝¹ * (-↑n * x✝)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul]
rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul]
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul]
Mathlib.GroupTheory.Subsemigroup.Center.199_0.vKbtzx3rREtft3E
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : NonAssocRing M n✝ : ℤ x✝¹ x✝ : M n : ℕ ⊢ -(x✝¹ * x✝) + -(x✝¹ * ↑n * x✝) = x✝¹ * -x✝ + x✝¹ * -(↑n * x✝)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul]
rw [(natCast_mem_center _ n).mid_assoc _ _]
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul]
Mathlib.GroupTheory.Subsemigroup.Center.199_0.vKbtzx3rREtft3E
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : NonAssocRing M n✝ : ℤ x✝¹ x✝ : M n : ℕ ⊢ -(x✝¹ * x✝) + -(x✝¹ * (↑n * x✝)) = x✝¹ * -x✝ + x✝¹ * -(↑n * x✝)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _]
simp only [mul_neg]
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _]
Mathlib.GroupTheory.Subsemigroup.Center.199_0.vKbtzx3rREtft3E
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : NonAssocRing M n✝ : ℤ x✝¹ x✝ : M n : ℕ ⊢ x✝¹ * x✝ * ↑↑n = x✝¹ * (x✝ * ↑↑n)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by
rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _]
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by
Mathlib.GroupTheory.Subsemigroup.Center.199_0.vKbtzx3rREtft3E
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : NonAssocRing M n✝ : ℤ x✝¹ x✝ : M n : ℕ ⊢ x✝¹ * x✝ * ↑(Int.negSucc n) = x✝¹ * (x✝ * ↑(Int.negSucc n))
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by
simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev]
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by
Mathlib.GroupTheory.Subsemigroup.Center.199_0.vKbtzx3rREtft3E
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : NonAssocRing M n✝ : ℤ x✝¹ x✝ : M n : ℕ ⊢ x✝¹ * x✝ * (-1 + -↑n) = x✝¹ * (x✝ * (-1 + -↑n))
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev]
rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg]
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev]
Mathlib.GroupTheory.Subsemigroup.Center.199_0.vKbtzx3rREtft3E
@[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : Group M a : M ha : a ∈ center M ⊢ a⁻¹ ∈ center M
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by
rw [_root_.Semigroup.mem_center_iff]
@[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by
Mathlib.GroupTheory.Subsemigroup.Center.225_0.vKbtzx3rREtft3E
@[to_additive (attr
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : Group M a : M ha : a ∈ center M ⊢ ∀ (g : M), g * a⁻¹ = a⁻¹ * g
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff]
intro _
@[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff]
Mathlib.GroupTheory.Subsemigroup.Center.225_0.vKbtzx3rREtft3E
@[to_additive (attr
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : Group M a : M ha : a ∈ center M g✝ : M ⊢ g✝ * a⁻¹ = a⁻¹ * g✝
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _
rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv]
@[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _
Mathlib.GroupTheory.Subsemigroup.Center.225_0.vKbtzx3rREtft3E
@[to_additive (attr
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : Distrib M a b : M ha : a ∈ center M hb : b ∈ center M x✝ : M ⊢ (a + b) * x✝ = x✝ * (a + b)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by
rw [add_mul, mul_add, ha.comm, hb.comm]
@[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by
Mathlib.GroupTheory.Subsemigroup.Center.233_0.vKbtzx3rREtft3E
@[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : Distrib M a b : M ha : a ∈ center M hb : b ∈ center M x✝¹ x✝ : M ⊢ (a + b) * (x✝¹ * x✝) = (a + b) * x✝¹ * x✝
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by
rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul]
@[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by
Mathlib.GroupTheory.Subsemigroup.Center.233_0.vKbtzx3rREtft3E
@[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : Distrib M a b : M ha : a ∈ center M hb : b ∈ center M x✝¹ x✝ : M ⊢ x✝¹ * (a + b) * x✝ = x✝¹ * ((a + b) * x✝)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by
rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul]
@[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by
Mathlib.GroupTheory.Subsemigroup.Center.233_0.vKbtzx3rREtft3E
@[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : Distrib M a b : M ha : a ∈ center M hb : b ∈ center M x✝¹ x✝ : M ⊢ x✝¹ * x✝ * (a + b) = x✝¹ * (x✝ * (a + b))
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by
rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add]
@[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by
Mathlib.GroupTheory.Subsemigroup.Center.233_0.vKbtzx3rREtft3E
@[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : NonUnitalNonAssocRing M a : M ha : a ∈ center M x✝ : M ⊢ -a * x✝ = x✝ * -a
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by
rw [← neg_mul_comm, ← ha.comm, neg_mul_comm]
@[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by
Mathlib.GroupTheory.Subsemigroup.Center.242_0.vKbtzx3rREtft3E
@[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : NonUnitalNonAssocRing M a : M ha : a ∈ center M x✝¹ x✝ : M ⊢ -a * (x✝¹ * x✝) = -a * x✝¹ * x✝
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by
rw [neg_mul, ha.left_assoc, neg_mul, neg_mul]
@[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by
Mathlib.GroupTheory.Subsemigroup.Center.242_0.vKbtzx3rREtft3E
@[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : NonUnitalNonAssocRing M a : M ha : a ∈ center M x✝¹ x✝ : M ⊢ x✝¹ * -a * x✝ = x✝¹ * (-a * x✝)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by
rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul]
@[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by
Mathlib.GroupTheory.Subsemigroup.Center.242_0.vKbtzx3rREtft3E
@[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : NonUnitalNonAssocRing M a : M ha : a ∈ center M x✝¹ x✝ : M ⊢ x✝¹ * x✝ * -a = x✝¹ * (x✝ * -a)
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by
rw [mul_neg, ha.right_assoc, mul_neg, mul_neg]
@[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by
Mathlib.GroupTheory.Subsemigroup.Center.242_0.vKbtzx3rREtft3E
@[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : Monoid M x✝ : Mˣ ha : x✝ ∈ Units.val ⁻¹' center M ⊢ x✝ ∈ center Mˣ
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by rw [mul_neg, ha.right_assoc, mul_neg, mul_neg] #align set.neg_mem_center Set.neg_mem_centerₓ @[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by
rw [_root_.Semigroup.mem_center_iff]
@[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by
Mathlib.GroupTheory.Subsemigroup.Center.251_0.vKbtzx3rREtft3E
@[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : Monoid M x✝ : Mˣ ha : x✝ ∈ Units.val ⁻¹' center M ⊢ ∀ (g : Mˣ), g * x✝ = x✝ * g
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by rw [mul_neg, ha.right_assoc, mul_neg, mul_neg] #align set.neg_mem_center Set.neg_mem_centerₓ @[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff]
intro _
@[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff]
Mathlib.GroupTheory.Subsemigroup.Center.251_0.vKbtzx3rREtft3E
@[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : Monoid M x✝ : Mˣ ha : x✝ ∈ Units.val ⁻¹' center M g✝ : Mˣ ⊢ g✝ * x✝ = x✝ * g✝
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by rw [mul_neg, ha.right_assoc, mul_neg, mul_neg] #align set.neg_mem_center Set.neg_mem_centerₓ @[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff] intro _
rw [← Units.eq_iff, Units.val_mul, Units.val_mul, ha.comm]
@[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff] intro _
Mathlib.GroupTheory.Subsemigroup.Center.251_0.vKbtzx3rREtft3E
@[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : GroupWithZero M x✝ : Mˣ ha : x✝ ∈ center Mˣ ⊢ x✝ ∈ Units.val ⁻¹' center M
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by rw [mul_neg, ha.right_assoc, mul_neg, mul_neg] #align set.neg_mem_center Set.neg_mem_centerₓ @[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← Units.eq_iff, Units.val_mul, Units.val_mul, ha.comm] #align set.subset_center_units Set.subset_center_units #align set.subset_add_center_add_units Set.subset_addCenter_add_units theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by
rw [mem_preimage, _root_.Semigroup.mem_center_iff]
theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by
Mathlib.GroupTheory.Subsemigroup.Center.260_0.vKbtzx3rREtft3E
theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : GroupWithZero M x✝ : Mˣ ha : x✝ ∈ center Mˣ ⊢ ∀ (g : M), g * ↑x✝ = ↑x✝ * g
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by rw [mul_neg, ha.right_assoc, mul_neg, mul_neg] #align set.neg_mem_center Set.neg_mem_centerₓ @[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← Units.eq_iff, Units.val_mul, Units.val_mul, ha.comm] #align set.subset_center_units Set.subset_center_units #align set.subset_add_center_add_units Set.subset_addCenter_add_units theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by rw [mem_preimage, _root_.Semigroup.mem_center_iff]
intro b
theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by rw [mem_preimage, _root_.Semigroup.mem_center_iff]
Mathlib.GroupTheory.Subsemigroup.Center.260_0.vKbtzx3rREtft3E
theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : GroupWithZero M x✝ : Mˣ ha : x✝ ∈ center Mˣ b : M ⊢ b * ↑x✝ = ↑x✝ * b
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by rw [mul_neg, ha.right_assoc, mul_neg, mul_neg] #align set.neg_mem_center Set.neg_mem_centerₓ @[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← Units.eq_iff, Units.val_mul, Units.val_mul, ha.comm] #align set.subset_center_units Set.subset_center_units #align set.subset_add_center_add_units Set.subset_addCenter_add_units theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by rw [mem_preimage, _root_.Semigroup.mem_center_iff] intro b
obtain rfl | hb := eq_or_ne b 0
theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by rw [mem_preimage, _root_.Semigroup.mem_center_iff] intro b
Mathlib.GroupTheory.Subsemigroup.Center.260_0.vKbtzx3rREtft3E
theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M
Mathlib_GroupTheory_Subsemigroup_Center
case inl M : Type u_1 inst✝ : GroupWithZero M x✝ : Mˣ ha : x✝ ∈ center Mˣ ⊢ 0 * ↑x✝ = ↑x✝ * 0
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by rw [mul_neg, ha.right_assoc, mul_neg, mul_neg] #align set.neg_mem_center Set.neg_mem_centerₓ @[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← Units.eq_iff, Units.val_mul, Units.val_mul, ha.comm] #align set.subset_center_units Set.subset_center_units #align set.subset_add_center_add_units Set.subset_addCenter_add_units theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by rw [mem_preimage, _root_.Semigroup.mem_center_iff] intro b obtain rfl | hb := eq_or_ne b 0 ·
rw [zero_mul, mul_zero]
theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by rw [mem_preimage, _root_.Semigroup.mem_center_iff] intro b obtain rfl | hb := eq_or_ne b 0 ·
Mathlib.GroupTheory.Subsemigroup.Center.260_0.vKbtzx3rREtft3E
theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M
Mathlib_GroupTheory_Subsemigroup_Center
case inr M : Type u_1 inst✝ : GroupWithZero M x✝ : Mˣ ha : x✝ ∈ center Mˣ b : M hb : b ≠ 0 ⊢ b * ↑x✝ = ↑x✝ * b
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by rw [mul_neg, ha.right_assoc, mul_neg, mul_neg] #align set.neg_mem_center Set.neg_mem_centerₓ @[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← Units.eq_iff, Units.val_mul, Units.val_mul, ha.comm] #align set.subset_center_units Set.subset_center_units #align set.subset_add_center_add_units Set.subset_addCenter_add_units theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by rw [mem_preimage, _root_.Semigroup.mem_center_iff] intro b obtain rfl | hb := eq_or_ne b 0 · rw [zero_mul, mul_zero] ·
exact Units.ext_iff.mp (ha.comm (Units.mk0 b hb)).symm
theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by rw [mem_preimage, _root_.Semigroup.mem_center_iff] intro b obtain rfl | hb := eq_or_ne b 0 · rw [zero_mul, mul_zero] ·
Mathlib.GroupTheory.Subsemigroup.Center.260_0.vKbtzx3rREtft3E
theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : Monoid M a : Mˣ ha : ↑a ∈ center M ⊢ ↑a⁻¹ ∈ center M
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by rw [mul_neg, ha.right_assoc, mul_neg, mul_neg] #align set.neg_mem_center Set.neg_mem_centerₓ @[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← Units.eq_iff, Units.val_mul, Units.val_mul, ha.comm] #align set.subset_center_units Set.subset_center_units #align set.subset_add_center_add_units Set.subset_addCenter_add_units theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by rw [mem_preimage, _root_.Semigroup.mem_center_iff] intro b obtain rfl | hb := eq_or_ne b 0 · rw [zero_mul, mul_zero] · exact Units.ext_iff.mp (ha.comm (Units.mk0 b hb)).symm #align set.center_units_subset Set.center_units_subset /-- In a group with zero, the center of the units is the preimage of the center. -/ theorem center_units_eq [GroupWithZero M] : Set.center Mˣ = ((↑) : Mˣ → M) ⁻¹' center M := Subset.antisymm center_units_subset subset_center_units #align set.center_units_eq Set.center_units_eq @[simp] theorem units_inv_mem_center [Monoid M] {a : Mˣ} (ha : ↑a ∈ Set.center M) : ↑a⁻¹ ∈ Set.center M := by
rw [Semigroup.mem_center_iff] at *
@[simp] theorem units_inv_mem_center [Monoid M] {a : Mˣ} (ha : ↑a ∈ Set.center M) : ↑a⁻¹ ∈ Set.center M := by
Mathlib.GroupTheory.Subsemigroup.Center.274_0.vKbtzx3rREtft3E
@[simp] theorem units_inv_mem_center [Monoid M] {a : Mˣ} (ha : ↑a ∈ Set.center M) : ↑a⁻¹ ∈ Set.center M
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : Monoid M a : Mˣ ha : ∀ (g : M), g * ↑a = ↑a * g ⊢ ∀ (g : M), g * ↑a⁻¹ = ↑a⁻¹ * g
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by rw [mul_neg, ha.right_assoc, mul_neg, mul_neg] #align set.neg_mem_center Set.neg_mem_centerₓ @[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← Units.eq_iff, Units.val_mul, Units.val_mul, ha.comm] #align set.subset_center_units Set.subset_center_units #align set.subset_add_center_add_units Set.subset_addCenter_add_units theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by rw [mem_preimage, _root_.Semigroup.mem_center_iff] intro b obtain rfl | hb := eq_or_ne b 0 · rw [zero_mul, mul_zero] · exact Units.ext_iff.mp (ha.comm (Units.mk0 b hb)).symm #align set.center_units_subset Set.center_units_subset /-- In a group with zero, the center of the units is the preimage of the center. -/ theorem center_units_eq [GroupWithZero M] : Set.center Mˣ = ((↑) : Mˣ → M) ⁻¹' center M := Subset.antisymm center_units_subset subset_center_units #align set.center_units_eq Set.center_units_eq @[simp] theorem units_inv_mem_center [Monoid M] {a : Mˣ} (ha : ↑a ∈ Set.center M) : ↑a⁻¹ ∈ Set.center M := by rw [Semigroup.mem_center_iff] at *
exact (Commute.units_inv_right <| ha ·)
@[simp] theorem units_inv_mem_center [Monoid M] {a : Mˣ} (ha : ↑a ∈ Set.center M) : ↑a⁻¹ ∈ Set.center M := by rw [Semigroup.mem_center_iff] at *
Mathlib.GroupTheory.Subsemigroup.Center.274_0.vKbtzx3rREtft3E
@[simp] theorem units_inv_mem_center [Monoid M] {a : Mˣ} (ha : ↑a ∈ Set.center M) : ↑a⁻¹ ∈ Set.center M
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝¹ : Monoid M a : M inst✝ : Invertible a ha : a ∈ center M ⊢ ⅟a ∈ center M
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by rw [mul_neg, ha.right_assoc, mul_neg, mul_neg] #align set.neg_mem_center Set.neg_mem_centerₓ @[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← Units.eq_iff, Units.val_mul, Units.val_mul, ha.comm] #align set.subset_center_units Set.subset_center_units #align set.subset_add_center_add_units Set.subset_addCenter_add_units theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by rw [mem_preimage, _root_.Semigroup.mem_center_iff] intro b obtain rfl | hb := eq_or_ne b 0 · rw [zero_mul, mul_zero] · exact Units.ext_iff.mp (ha.comm (Units.mk0 b hb)).symm #align set.center_units_subset Set.center_units_subset /-- In a group with zero, the center of the units is the preimage of the center. -/ theorem center_units_eq [GroupWithZero M] : Set.center Mˣ = ((↑) : Mˣ → M) ⁻¹' center M := Subset.antisymm center_units_subset subset_center_units #align set.center_units_eq Set.center_units_eq @[simp] theorem units_inv_mem_center [Monoid M] {a : Mˣ} (ha : ↑a ∈ Set.center M) : ↑a⁻¹ ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.units_inv_right <| ha ·) @[simp] theorem invOf_mem_center [Monoid M] {a : M} [Invertible a] (ha : a ∈ Set.center M) : ⅟a ∈ Set.center M := by
rw [Semigroup.mem_center_iff] at *
@[simp] theorem invOf_mem_center [Monoid M] {a : M} [Invertible a] (ha : a ∈ Set.center M) : ⅟a ∈ Set.center M := by
Mathlib.GroupTheory.Subsemigroup.Center.280_0.vKbtzx3rREtft3E
@[simp] theorem invOf_mem_center [Monoid M] {a : M} [Invertible a] (ha : a ∈ Set.center M) : ⅟a ∈ Set.center M
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝¹ : Monoid M a : M inst✝ : Invertible a ha : ∀ (g : M), g * a = a * g ⊢ ∀ (g : M), g * ⅟a = ⅟a * g
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by rw [mul_neg, ha.right_assoc, mul_neg, mul_neg] #align set.neg_mem_center Set.neg_mem_centerₓ @[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← Units.eq_iff, Units.val_mul, Units.val_mul, ha.comm] #align set.subset_center_units Set.subset_center_units #align set.subset_add_center_add_units Set.subset_addCenter_add_units theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by rw [mem_preimage, _root_.Semigroup.mem_center_iff] intro b obtain rfl | hb := eq_or_ne b 0 · rw [zero_mul, mul_zero] · exact Units.ext_iff.mp (ha.comm (Units.mk0 b hb)).symm #align set.center_units_subset Set.center_units_subset /-- In a group with zero, the center of the units is the preimage of the center. -/ theorem center_units_eq [GroupWithZero M] : Set.center Mˣ = ((↑) : Mˣ → M) ⁻¹' center M := Subset.antisymm center_units_subset subset_center_units #align set.center_units_eq Set.center_units_eq @[simp] theorem units_inv_mem_center [Monoid M] {a : Mˣ} (ha : ↑a ∈ Set.center M) : ↑a⁻¹ ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.units_inv_right <| ha ·) @[simp] theorem invOf_mem_center [Monoid M] {a : M} [Invertible a] (ha : a ∈ Set.center M) : ⅟a ∈ Set.center M := by rw [Semigroup.mem_center_iff] at *
exact (Commute.invOf_right <| ha ·)
@[simp] theorem invOf_mem_center [Monoid M] {a : M} [Invertible a] (ha : a ∈ Set.center M) : ⅟a ∈ Set.center M := by rw [Semigroup.mem_center_iff] at *
Mathlib.GroupTheory.Subsemigroup.Center.280_0.vKbtzx3rREtft3E
@[simp] theorem invOf_mem_center [Monoid M] {a : M} [Invertible a] (ha : a ∈ Set.center M) : ⅟a ∈ Set.center M
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : GroupWithZero M a : M ha : a ∈ center M ⊢ a⁻¹ ∈ center M
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by rw [mul_neg, ha.right_assoc, mul_neg, mul_neg] #align set.neg_mem_center Set.neg_mem_centerₓ @[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← Units.eq_iff, Units.val_mul, Units.val_mul, ha.comm] #align set.subset_center_units Set.subset_center_units #align set.subset_add_center_add_units Set.subset_addCenter_add_units theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by rw [mem_preimage, _root_.Semigroup.mem_center_iff] intro b obtain rfl | hb := eq_or_ne b 0 · rw [zero_mul, mul_zero] · exact Units.ext_iff.mp (ha.comm (Units.mk0 b hb)).symm #align set.center_units_subset Set.center_units_subset /-- In a group with zero, the center of the units is the preimage of the center. -/ theorem center_units_eq [GroupWithZero M] : Set.center Mˣ = ((↑) : Mˣ → M) ⁻¹' center M := Subset.antisymm center_units_subset subset_center_units #align set.center_units_eq Set.center_units_eq @[simp] theorem units_inv_mem_center [Monoid M] {a : Mˣ} (ha : ↑a ∈ Set.center M) : ↑a⁻¹ ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.units_inv_right <| ha ·) @[simp] theorem invOf_mem_center [Monoid M] {a : M} [Invertible a] (ha : a ∈ Set.center M) : ⅟a ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.invOf_right <| ha ·) @[simp] theorem inv_mem_center₀ [GroupWithZero M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by
obtain rfl | ha0 := eq_or_ne a 0
@[simp] theorem inv_mem_center₀ [GroupWithZero M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by
Mathlib.GroupTheory.Subsemigroup.Center.286_0.vKbtzx3rREtft3E
@[simp] theorem inv_mem_center₀ [GroupWithZero M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M
Mathlib_GroupTheory_Subsemigroup_Center
case inl M : Type u_1 inst✝ : GroupWithZero M ha : 0 ∈ center M ⊢ 0⁻¹ ∈ center M
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by rw [mul_neg, ha.right_assoc, mul_neg, mul_neg] #align set.neg_mem_center Set.neg_mem_centerₓ @[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← Units.eq_iff, Units.val_mul, Units.val_mul, ha.comm] #align set.subset_center_units Set.subset_center_units #align set.subset_add_center_add_units Set.subset_addCenter_add_units theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by rw [mem_preimage, _root_.Semigroup.mem_center_iff] intro b obtain rfl | hb := eq_or_ne b 0 · rw [zero_mul, mul_zero] · exact Units.ext_iff.mp (ha.comm (Units.mk0 b hb)).symm #align set.center_units_subset Set.center_units_subset /-- In a group with zero, the center of the units is the preimage of the center. -/ theorem center_units_eq [GroupWithZero M] : Set.center Mˣ = ((↑) : Mˣ → M) ⁻¹' center M := Subset.antisymm center_units_subset subset_center_units #align set.center_units_eq Set.center_units_eq @[simp] theorem units_inv_mem_center [Monoid M] {a : Mˣ} (ha : ↑a ∈ Set.center M) : ↑a⁻¹ ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.units_inv_right <| ha ·) @[simp] theorem invOf_mem_center [Monoid M] {a : M} [Invertible a] (ha : a ∈ Set.center M) : ⅟a ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.invOf_right <| ha ·) @[simp] theorem inv_mem_center₀ [GroupWithZero M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by obtain rfl | ha0 := eq_or_ne a 0 ·
rw [inv_zero]
@[simp] theorem inv_mem_center₀ [GroupWithZero M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by obtain rfl | ha0 := eq_or_ne a 0 ·
Mathlib.GroupTheory.Subsemigroup.Center.286_0.vKbtzx3rREtft3E
@[simp] theorem inv_mem_center₀ [GroupWithZero M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M
Mathlib_GroupTheory_Subsemigroup_Center
case inl M : Type u_1 inst✝ : GroupWithZero M ha : 0 ∈ center M ⊢ 0 ∈ center M
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by rw [mul_neg, ha.right_assoc, mul_neg, mul_neg] #align set.neg_mem_center Set.neg_mem_centerₓ @[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← Units.eq_iff, Units.val_mul, Units.val_mul, ha.comm] #align set.subset_center_units Set.subset_center_units #align set.subset_add_center_add_units Set.subset_addCenter_add_units theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by rw [mem_preimage, _root_.Semigroup.mem_center_iff] intro b obtain rfl | hb := eq_or_ne b 0 · rw [zero_mul, mul_zero] · exact Units.ext_iff.mp (ha.comm (Units.mk0 b hb)).symm #align set.center_units_subset Set.center_units_subset /-- In a group with zero, the center of the units is the preimage of the center. -/ theorem center_units_eq [GroupWithZero M] : Set.center Mˣ = ((↑) : Mˣ → M) ⁻¹' center M := Subset.antisymm center_units_subset subset_center_units #align set.center_units_eq Set.center_units_eq @[simp] theorem units_inv_mem_center [Monoid M] {a : Mˣ} (ha : ↑a ∈ Set.center M) : ↑a⁻¹ ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.units_inv_right <| ha ·) @[simp] theorem invOf_mem_center [Monoid M] {a : M} [Invertible a] (ha : a ∈ Set.center M) : ⅟a ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.invOf_right <| ha ·) @[simp] theorem inv_mem_center₀ [GroupWithZero M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by obtain rfl | ha0 := eq_or_ne a 0 · rw [inv_zero]
exact zero_mem_center M
@[simp] theorem inv_mem_center₀ [GroupWithZero M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by obtain rfl | ha0 := eq_or_ne a 0 · rw [inv_zero]
Mathlib.GroupTheory.Subsemigroup.Center.286_0.vKbtzx3rREtft3E
@[simp] theorem inv_mem_center₀ [GroupWithZero M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M
Mathlib_GroupTheory_Subsemigroup_Center
case inr M : Type u_1 inst✝ : GroupWithZero M a : M ha : a ∈ center M ha0 : a ≠ 0 ⊢ a⁻¹ ∈ center M
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by rw [mul_neg, ha.right_assoc, mul_neg, mul_neg] #align set.neg_mem_center Set.neg_mem_centerₓ @[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← Units.eq_iff, Units.val_mul, Units.val_mul, ha.comm] #align set.subset_center_units Set.subset_center_units #align set.subset_add_center_add_units Set.subset_addCenter_add_units theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by rw [mem_preimage, _root_.Semigroup.mem_center_iff] intro b obtain rfl | hb := eq_or_ne b 0 · rw [zero_mul, mul_zero] · exact Units.ext_iff.mp (ha.comm (Units.mk0 b hb)).symm #align set.center_units_subset Set.center_units_subset /-- In a group with zero, the center of the units is the preimage of the center. -/ theorem center_units_eq [GroupWithZero M] : Set.center Mˣ = ((↑) : Mˣ → M) ⁻¹' center M := Subset.antisymm center_units_subset subset_center_units #align set.center_units_eq Set.center_units_eq @[simp] theorem units_inv_mem_center [Monoid M] {a : Mˣ} (ha : ↑a ∈ Set.center M) : ↑a⁻¹ ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.units_inv_right <| ha ·) @[simp] theorem invOf_mem_center [Monoid M] {a : M} [Invertible a] (ha : a ∈ Set.center M) : ⅟a ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.invOf_right <| ha ·) @[simp] theorem inv_mem_center₀ [GroupWithZero M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by obtain rfl | ha0 := eq_or_ne a 0 · rw [inv_zero] exact zero_mem_center M ·
lift a to Mˣ using IsUnit.mk0 _ ha0
@[simp] theorem inv_mem_center₀ [GroupWithZero M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by obtain rfl | ha0 := eq_or_ne a 0 · rw [inv_zero] exact zero_mem_center M ·
Mathlib.GroupTheory.Subsemigroup.Center.286_0.vKbtzx3rREtft3E
@[simp] theorem inv_mem_center₀ [GroupWithZero M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M
Mathlib_GroupTheory_Subsemigroup_Center
case inr.intro M : Type u_1 inst✝ : GroupWithZero M a : Mˣ ha : ↑a ∈ center M ha0 : ↑a ≠ 0 ⊢ (↑a)⁻¹ ∈ center M
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by rw [mul_neg, ha.right_assoc, mul_neg, mul_neg] #align set.neg_mem_center Set.neg_mem_centerₓ @[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← Units.eq_iff, Units.val_mul, Units.val_mul, ha.comm] #align set.subset_center_units Set.subset_center_units #align set.subset_add_center_add_units Set.subset_addCenter_add_units theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by rw [mem_preimage, _root_.Semigroup.mem_center_iff] intro b obtain rfl | hb := eq_or_ne b 0 · rw [zero_mul, mul_zero] · exact Units.ext_iff.mp (ha.comm (Units.mk0 b hb)).symm #align set.center_units_subset Set.center_units_subset /-- In a group with zero, the center of the units is the preimage of the center. -/ theorem center_units_eq [GroupWithZero M] : Set.center Mˣ = ((↑) : Mˣ → M) ⁻¹' center M := Subset.antisymm center_units_subset subset_center_units #align set.center_units_eq Set.center_units_eq @[simp] theorem units_inv_mem_center [Monoid M] {a : Mˣ} (ha : ↑a ∈ Set.center M) : ↑a⁻¹ ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.units_inv_right <| ha ·) @[simp] theorem invOf_mem_center [Monoid M] {a : M} [Invertible a] (ha : a ∈ Set.center M) : ⅟a ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.invOf_right <| ha ·) @[simp] theorem inv_mem_center₀ [GroupWithZero M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by obtain rfl | ha0 := eq_or_ne a 0 · rw [inv_zero] exact zero_mem_center M · lift a to Mˣ using IsUnit.mk0 _ ha0
simpa only [Units.val_inv_eq_inv_val] using units_inv_mem_center ha
@[simp] theorem inv_mem_center₀ [GroupWithZero M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by obtain rfl | ha0 := eq_or_ne a 0 · rw [inv_zero] exact zero_mem_center M · lift a to Mˣ using IsUnit.mk0 _ ha0
Mathlib.GroupTheory.Subsemigroup.Center.286_0.vKbtzx3rREtft3E
@[simp] theorem inv_mem_center₀ [GroupWithZero M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : Group M a b : M ha : a ∈ center M hb : b ∈ center M ⊢ a / b ∈ center M
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by rw [mul_neg, ha.right_assoc, mul_neg, mul_neg] #align set.neg_mem_center Set.neg_mem_centerₓ @[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← Units.eq_iff, Units.val_mul, Units.val_mul, ha.comm] #align set.subset_center_units Set.subset_center_units #align set.subset_add_center_add_units Set.subset_addCenter_add_units theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by rw [mem_preimage, _root_.Semigroup.mem_center_iff] intro b obtain rfl | hb := eq_or_ne b 0 · rw [zero_mul, mul_zero] · exact Units.ext_iff.mp (ha.comm (Units.mk0 b hb)).symm #align set.center_units_subset Set.center_units_subset /-- In a group with zero, the center of the units is the preimage of the center. -/ theorem center_units_eq [GroupWithZero M] : Set.center Mˣ = ((↑) : Mˣ → M) ⁻¹' center M := Subset.antisymm center_units_subset subset_center_units #align set.center_units_eq Set.center_units_eq @[simp] theorem units_inv_mem_center [Monoid M] {a : Mˣ} (ha : ↑a ∈ Set.center M) : ↑a⁻¹ ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.units_inv_right <| ha ·) @[simp] theorem invOf_mem_center [Monoid M] {a : M} [Invertible a] (ha : a ∈ Set.center M) : ⅟a ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.invOf_right <| ha ·) @[simp] theorem inv_mem_center₀ [GroupWithZero M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by obtain rfl | ha0 := eq_or_ne a 0 · rw [inv_zero] exact zero_mem_center M · lift a to Mˣ using IsUnit.mk0 _ ha0 simpa only [Units.val_inv_eq_inv_val] using units_inv_mem_center ha #align set.inv_mem_center₀ Set.inv_mem_center₀ @[to_additive (attr := simp) sub_mem_addCenter] theorem div_mem_center [Group M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a / b ∈ Set.center M := by
rw [div_eq_mul_inv]
@[to_additive (attr := simp) sub_mem_addCenter] theorem div_mem_center [Group M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a / b ∈ Set.center M := by
Mathlib.GroupTheory.Subsemigroup.Center.295_0.vKbtzx3rREtft3E
@[to_additive (attr
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : Group M a b : M ha : a ∈ center M hb : b ∈ center M ⊢ a * b⁻¹ ∈ center M
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by rw [mul_neg, ha.right_assoc, mul_neg, mul_neg] #align set.neg_mem_center Set.neg_mem_centerₓ @[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← Units.eq_iff, Units.val_mul, Units.val_mul, ha.comm] #align set.subset_center_units Set.subset_center_units #align set.subset_add_center_add_units Set.subset_addCenter_add_units theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by rw [mem_preimage, _root_.Semigroup.mem_center_iff] intro b obtain rfl | hb := eq_or_ne b 0 · rw [zero_mul, mul_zero] · exact Units.ext_iff.mp (ha.comm (Units.mk0 b hb)).symm #align set.center_units_subset Set.center_units_subset /-- In a group with zero, the center of the units is the preimage of the center. -/ theorem center_units_eq [GroupWithZero M] : Set.center Mˣ = ((↑) : Mˣ → M) ⁻¹' center M := Subset.antisymm center_units_subset subset_center_units #align set.center_units_eq Set.center_units_eq @[simp] theorem units_inv_mem_center [Monoid M] {a : Mˣ} (ha : ↑a ∈ Set.center M) : ↑a⁻¹ ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.units_inv_right <| ha ·) @[simp] theorem invOf_mem_center [Monoid M] {a : M} [Invertible a] (ha : a ∈ Set.center M) : ⅟a ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.invOf_right <| ha ·) @[simp] theorem inv_mem_center₀ [GroupWithZero M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by obtain rfl | ha0 := eq_or_ne a 0 · rw [inv_zero] exact zero_mem_center M · lift a to Mˣ using IsUnit.mk0 _ ha0 simpa only [Units.val_inv_eq_inv_val] using units_inv_mem_center ha #align set.inv_mem_center₀ Set.inv_mem_center₀ @[to_additive (attr := simp) sub_mem_addCenter] theorem div_mem_center [Group M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a / b ∈ Set.center M := by rw [div_eq_mul_inv]
exact mul_mem_center ha (inv_mem_center hb)
@[to_additive (attr := simp) sub_mem_addCenter] theorem div_mem_center [Group M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a / b ∈ Set.center M := by rw [div_eq_mul_inv]
Mathlib.GroupTheory.Subsemigroup.Center.295_0.vKbtzx3rREtft3E
@[to_additive (attr
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : GroupWithZero M a b : M ha : a ∈ center M hb : b ∈ center M ⊢ a / b ∈ center M
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by rw [mul_neg, ha.right_assoc, mul_neg, mul_neg] #align set.neg_mem_center Set.neg_mem_centerₓ @[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← Units.eq_iff, Units.val_mul, Units.val_mul, ha.comm] #align set.subset_center_units Set.subset_center_units #align set.subset_add_center_add_units Set.subset_addCenter_add_units theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by rw [mem_preimage, _root_.Semigroup.mem_center_iff] intro b obtain rfl | hb := eq_or_ne b 0 · rw [zero_mul, mul_zero] · exact Units.ext_iff.mp (ha.comm (Units.mk0 b hb)).symm #align set.center_units_subset Set.center_units_subset /-- In a group with zero, the center of the units is the preimage of the center. -/ theorem center_units_eq [GroupWithZero M] : Set.center Mˣ = ((↑) : Mˣ → M) ⁻¹' center M := Subset.antisymm center_units_subset subset_center_units #align set.center_units_eq Set.center_units_eq @[simp] theorem units_inv_mem_center [Monoid M] {a : Mˣ} (ha : ↑a ∈ Set.center M) : ↑a⁻¹ ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.units_inv_right <| ha ·) @[simp] theorem invOf_mem_center [Monoid M] {a : M} [Invertible a] (ha : a ∈ Set.center M) : ⅟a ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.invOf_right <| ha ·) @[simp] theorem inv_mem_center₀ [GroupWithZero M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by obtain rfl | ha0 := eq_or_ne a 0 · rw [inv_zero] exact zero_mem_center M · lift a to Mˣ using IsUnit.mk0 _ ha0 simpa only [Units.val_inv_eq_inv_val] using units_inv_mem_center ha #align set.inv_mem_center₀ Set.inv_mem_center₀ @[to_additive (attr := simp) sub_mem_addCenter] theorem div_mem_center [Group M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a / b ∈ Set.center M := by rw [div_eq_mul_inv] exact mul_mem_center ha (inv_mem_center hb) #align set.div_mem_center Set.div_mem_center #align set.sub_mem_add_center Set.sub_mem_addCenter @[simp] theorem div_mem_center₀ [GroupWithZero M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a / b ∈ Set.center M := by
rw [div_eq_mul_inv]
@[simp] theorem div_mem_center₀ [GroupWithZero M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a / b ∈ Set.center M := by
Mathlib.GroupTheory.Subsemigroup.Center.303_0.vKbtzx3rREtft3E
@[simp] theorem div_mem_center₀ [GroupWithZero M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a / b ∈ Set.center M
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : GroupWithZero M a b : M ha : a ∈ center M hb : b ∈ center M ⊢ a * b⁻¹ ∈ center M
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by rw [mul_neg, ha.right_assoc, mul_neg, mul_neg] #align set.neg_mem_center Set.neg_mem_centerₓ @[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← Units.eq_iff, Units.val_mul, Units.val_mul, ha.comm] #align set.subset_center_units Set.subset_center_units #align set.subset_add_center_add_units Set.subset_addCenter_add_units theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by rw [mem_preimage, _root_.Semigroup.mem_center_iff] intro b obtain rfl | hb := eq_or_ne b 0 · rw [zero_mul, mul_zero] · exact Units.ext_iff.mp (ha.comm (Units.mk0 b hb)).symm #align set.center_units_subset Set.center_units_subset /-- In a group with zero, the center of the units is the preimage of the center. -/ theorem center_units_eq [GroupWithZero M] : Set.center Mˣ = ((↑) : Mˣ → M) ⁻¹' center M := Subset.antisymm center_units_subset subset_center_units #align set.center_units_eq Set.center_units_eq @[simp] theorem units_inv_mem_center [Monoid M] {a : Mˣ} (ha : ↑a ∈ Set.center M) : ↑a⁻¹ ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.units_inv_right <| ha ·) @[simp] theorem invOf_mem_center [Monoid M] {a : M} [Invertible a] (ha : a ∈ Set.center M) : ⅟a ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.invOf_right <| ha ·) @[simp] theorem inv_mem_center₀ [GroupWithZero M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by obtain rfl | ha0 := eq_or_ne a 0 · rw [inv_zero] exact zero_mem_center M · lift a to Mˣ using IsUnit.mk0 _ ha0 simpa only [Units.val_inv_eq_inv_val] using units_inv_mem_center ha #align set.inv_mem_center₀ Set.inv_mem_center₀ @[to_additive (attr := simp) sub_mem_addCenter] theorem div_mem_center [Group M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a / b ∈ Set.center M := by rw [div_eq_mul_inv] exact mul_mem_center ha (inv_mem_center hb) #align set.div_mem_center Set.div_mem_center #align set.sub_mem_add_center Set.sub_mem_addCenter @[simp] theorem div_mem_center₀ [GroupWithZero M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a / b ∈ Set.center M := by rw [div_eq_mul_inv]
exact mul_mem_center ha (inv_mem_center₀ hb)
@[simp] theorem div_mem_center₀ [GroupWithZero M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a / b ∈ Set.center M := by rw [div_eq_mul_inv]
Mathlib.GroupTheory.Subsemigroup.Center.303_0.vKbtzx3rREtft3E
@[simp] theorem div_mem_center₀ [GroupWithZero M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a / b ∈ Set.center M
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : Semigroup M z : M ⊢ z ∈ center M ↔ ∀ (g : M), g * z = z * g
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by rw [mul_neg, ha.right_assoc, mul_neg, mul_neg] #align set.neg_mem_center Set.neg_mem_centerₓ @[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← Units.eq_iff, Units.val_mul, Units.val_mul, ha.comm] #align set.subset_center_units Set.subset_center_units #align set.subset_add_center_add_units Set.subset_addCenter_add_units theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by rw [mem_preimage, _root_.Semigroup.mem_center_iff] intro b obtain rfl | hb := eq_or_ne b 0 · rw [zero_mul, mul_zero] · exact Units.ext_iff.mp (ha.comm (Units.mk0 b hb)).symm #align set.center_units_subset Set.center_units_subset /-- In a group with zero, the center of the units is the preimage of the center. -/ theorem center_units_eq [GroupWithZero M] : Set.center Mˣ = ((↑) : Mˣ → M) ⁻¹' center M := Subset.antisymm center_units_subset subset_center_units #align set.center_units_eq Set.center_units_eq @[simp] theorem units_inv_mem_center [Monoid M] {a : Mˣ} (ha : ↑a ∈ Set.center M) : ↑a⁻¹ ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.units_inv_right <| ha ·) @[simp] theorem invOf_mem_center [Monoid M] {a : M} [Invertible a] (ha : a ∈ Set.center M) : ⅟a ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.invOf_right <| ha ·) @[simp] theorem inv_mem_center₀ [GroupWithZero M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by obtain rfl | ha0 := eq_or_ne a 0 · rw [inv_zero] exact zero_mem_center M · lift a to Mˣ using IsUnit.mk0 _ ha0 simpa only [Units.val_inv_eq_inv_val] using units_inv_mem_center ha #align set.inv_mem_center₀ Set.inv_mem_center₀ @[to_additive (attr := simp) sub_mem_addCenter] theorem div_mem_center [Group M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a / b ∈ Set.center M := by rw [div_eq_mul_inv] exact mul_mem_center ha (inv_mem_center hb) #align set.div_mem_center Set.div_mem_center #align set.sub_mem_add_center Set.sub_mem_addCenter @[simp] theorem div_mem_center₀ [GroupWithZero M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a / b ∈ Set.center M := by rw [div_eq_mul_inv] exact mul_mem_center ha (inv_mem_center₀ hb) #align set.div_mem_center₀ Set.div_mem_center₀ end Set /-! ### `Set.center` as a `Subsemigroup`. -/ namespace Subsemigroup section Mul variable (M) [Mul M] /-- The center of a semigroup `M` is the set of elements that commute with everything in `M` -/ @[to_additive "The center of a semigroup `M` is the set of elements that commute with everything in `M`"] def center : Subsemigroup M where carrier := Set.center M mul_mem' := Set.mul_mem_center #align subsemigroup.center Subsemigroup.center #align add_subsemigroup.center AddSubsemigroup.center -- porting note: `coe_center` is now redundant #noalign subsemigroup.coe_center #noalign add_subsemigroup.coe_center variable {M} /-- The center of a magma is commutative and associative. -/ @[to_additive "The center of an additive magma is commutative and associative."] instance center.commSemigroup : CommSemigroup (center M) where mul_assoc _ b _ := Subtype.ext <| b.2.mid_assoc _ _ mul_comm a _ := Subtype.ext <| a.2.comm _ #align subsemigroup.center.comm_semigroup Subsemigroup.center.commSemigroup #align add_subsemigroup.center.add_comm_semigroup AddSubsemigroup.center.addCommSemigroup end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem mem_center_iff {z : M} : z ∈ center M ↔ ∀ g, g * z = z * g := by
rw [← Semigroup.mem_center_iff]
@[to_additive] theorem mem_center_iff {z : M} : z ∈ center M ↔ ∀ g, g * z = z * g := by
Mathlib.GroupTheory.Subsemigroup.Center.347_0.vKbtzx3rREtft3E
@[to_additive] theorem mem_center_iff {z : M} : z ∈ center M ↔ ∀ g, g * z = z * g
Mathlib_GroupTheory_Subsemigroup_Center
M : Type u_1 inst✝ : Semigroup M z : M ⊢ z ∈ center M ↔ z ∈ Set.center M
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jireh Loreaux -/ import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Invertible.Basic import Mathlib.GroupTheory.Subsemigroup.Operations import Mathlib.Data.Int.Cast.Lemmas #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" /-! # Centers of magmas and semigroups ## Main definitions * `Set.center`: the center of a magma * `Subsemigroup.center`: the center of a semigroup * `Set.addCenter`: the center of an additive magma * `AddSubsemigroup.center`: the center of an additive semigroup We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in other files. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] -/ variable {M : Type*} /-- Conditions for an element to be additively central -/ structure IsAddCentral [Add M] (z : M) : Prop where /-- addition commutes -/ comm (a : M) : z + a = a + z /-- associative property for left addition -/ left_assoc (b c : M) : z + (b + c) = (z + b) + c /-- middle associative addition property -/ mid_assoc (a c : M) : (a + z) + c = a + (z + c) /-- associative property for right addition -/ right_assoc (a b : M) : (a + b) + z = a + (b + z) /-- Conditions for an element to be multiplicatively central -/ @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where /-- multiplication commutes -/ comm (a : M) : z * a = a * z /-- associative property for left multiplication -/ left_assoc (b c : M) : z * (b * c) = (z * b) * c /-- middle associative multiplication property -/ mid_assoc (a c : M) : (a * z) * c = a * (z * c) /-- associative property for right multiplication -/ right_assoc (a b : M) : (a * b) * z = a * (b * z) -- TODO: these should have explicit arguments (mathlib4#9129) attribute [mk_iff isMulCentral_iff] IsMulCentral attribute [mk_iff isAddCentral_iff] IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace IsMulCentral variable {a b c : M} [Mul M] -- c.f. Commute.left_comm @[to_additive] protected theorem left_comm (h : IsMulCentral a) (b c) : a * (b * c) = b * (a * c) := by simp only [h.comm, h.right_assoc] -- c.f. Commute.right_comm @[to_additive] protected theorem right_comm (h : IsMulCentral c) (a b) : a * b * c = a * c * b := by simp only [h.right_assoc, h.mid_assoc, h.comm] end IsMulCentral namespace Set section Mul variable (M) [Mul M] /-- The center of a magma. -/ @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter] theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc] #align set.mul_mem_center Set.mul_mem_center #align set.add_mem_add_center Set.add_mem_addCenter end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem _root_.Semigroup.mem_center_iff {z : M} : z ∈ Set.center M ↔ ∀ g, g * z = z * g := ⟨fun a g ↦ by rw [IsMulCentral.comm a g], fun h ↦ ⟨fun _ ↦ (Commute.eq (h _)).symm, fun _ _ ↦ (mul_assoc z _ _).symm, fun _ _ ↦ mul_assoc _ z _, fun _ _ ↦ mul_assoc _ _ z⟩ ⟩ variable (M) -- TODO Add `instance : Decidable (IsMulCentral a)` for `instance decidableMemCenter [Mul M]` instance decidableMemCenter [∀ a : M, Decidable <| ∀ b : M, b * a = a * b] : DecidablePred (· ∈ center M) := fun _ => decidable_of_iff' _ (Semigroup.mem_center_iff) #align set.decidable_mem_center Set.decidableMemCenter end Semigroup section CommSemigroup variable (M) @[to_additive (attr := simp) addCenter_eq_univ] theorem center_eq_univ [CommSemigroup M] : center M = univ := (Subset.antisymm (subset_univ _)) fun _ _ => Semigroup.mem_center_iff.mpr (fun _ => mul_comm _ _) #align set.center_eq_univ Set.center_eq_univ #align set.add_center_eq_univ Set.addCenter_eq_univ end CommSemigroup variable (M) @[to_additive (attr := simp) zero_mem_addCenter] theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M where comm _ := by rw [one_mul, mul_one] left_assoc _ _ := by rw [one_mul, one_mul] mid_assoc _ _ := by rw [mul_one, one_mul] right_assoc _ _ := by rw [mul_one, mul_one] #align set.one_mem_center Set.one_mem_center #align set.zero_mem_add_center Set.zero_mem_addCenter @[simp] theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M where comm _ := by rw [zero_mul, mul_zero] left_assoc _ _ := by rw [zero_mul, zero_mul, zero_mul] mid_assoc _ _ := by rw [mul_zero, zero_mul, mul_zero] right_assoc _ _ := by rw [mul_zero, mul_zero, mul_zero] #align set.zero_mem_center Set.zero_mem_center @[simp] theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M where comm _:= by rw [Nat.commute_cast] left_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_mul, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, one_mul, ihn, add_mul, add_mul, one_mul] mid_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, zero_mul, mul_zero, zero_mul] | succ n ihn => rw [Nat.cast_succ, add_mul, mul_add, add_mul, ihn, mul_add, one_mul, mul_one] right_assoc _ _ := by induction n with | zero => rw [Nat.zero_eq, Nat.cast_zero, mul_zero, mul_zero, mul_zero] | succ n ihn => rw [Nat.cast_succ, mul_add, ihn, mul_add, mul_add, mul_one, mul_one] -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n)) ∈ Set.center M := natCast_mem_center M n @[simp] theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M where comm _ := by rw [Int.commute_cast] left_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).left_assoc _ _] | Int.negSucc n => by rw [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, add_mul, add_mul, add_mul, neg_mul, one_mul, neg_mul 1, one_mul, ← neg_mul, add_right_inj, neg_mul, (natCast_mem_center _ n).left_assoc _ _, neg_mul, neg_mul] mid_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).mid_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [add_mul, mul_add, add_mul, mul_add, neg_mul, one_mul] rw [neg_mul, mul_neg, mul_one, mul_neg, neg_mul, neg_mul] rw [(natCast_mem_center _ n).mid_assoc _ _] simp only [mul_neg] right_assoc _ _ := match n with | (n : ℕ) => by rw [Int.cast_ofNat, (natCast_mem_center _ n).right_assoc _ _] | Int.negSucc n => by simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev] rw [mul_add, mul_add, mul_add, mul_neg, mul_one, mul_neg, mul_neg, mul_one, mul_neg, add_right_inj, (natCast_mem_center _ n).right_assoc _ _, mul_neg, mul_neg] variable {M} @[to_additive (attr := simp) neg_mem_addCenter] theorem inv_mem_center [Group M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← inv_inj, mul_inv_rev, inv_inv, ha.comm, mul_inv_rev, inv_inv] #align set.inv_mem_center Set.inv_mem_center #align set.neg_mem_add_center Set.neg_mem_addCenter @[simp] theorem add_mem_center [Distrib M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a + b ∈ Set.center M where comm _ := by rw [add_mul, mul_add, ha.comm, hb.comm] left_assoc _ _ := by rw [add_mul, ha.left_assoc, hb.left_assoc, ← add_mul, ← add_mul] mid_assoc _ _ := by rw [mul_add, add_mul, ha.mid_assoc, hb.mid_assoc, ← mul_add, ← add_mul] right_assoc _ _ := by rw [mul_add, ha.right_assoc, hb.right_assoc, ← mul_add, ← mul_add] #align set.add_mem_center Set.add_mem_center @[simp] theorem neg_mem_center [NonUnitalNonAssocRing M] {a : M} (ha : a ∈ Set.center M) : -a ∈ Set.center M where comm _ := by rw [← neg_mul_comm, ← ha.comm, neg_mul_comm] left_assoc _ _ := by rw [neg_mul, ha.left_assoc, neg_mul, neg_mul] mid_assoc _ _ := by rw [← neg_mul_comm, ha.mid_assoc, neg_mul_comm, neg_mul] right_assoc _ _ := by rw [mul_neg, ha.right_assoc, mul_neg, mul_neg] #align set.neg_mem_center Set.neg_mem_centerₓ @[to_additive subset_addCenter_add_units] theorem subset_center_units [Monoid M] : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center Mˣ := fun _ ha => by rw [_root_.Semigroup.mem_center_iff] intro _ rw [← Units.eq_iff, Units.val_mul, Units.val_mul, ha.comm] #align set.subset_center_units Set.subset_center_units #align set.subset_add_center_add_units Set.subset_addCenter_add_units theorem center_units_subset [GroupWithZero M] : Set.center Mˣ ⊆ ((↑) : Mˣ → M) ⁻¹' center M := fun _ ha => by rw [mem_preimage, _root_.Semigroup.mem_center_iff] intro b obtain rfl | hb := eq_or_ne b 0 · rw [zero_mul, mul_zero] · exact Units.ext_iff.mp (ha.comm (Units.mk0 b hb)).symm #align set.center_units_subset Set.center_units_subset /-- In a group with zero, the center of the units is the preimage of the center. -/ theorem center_units_eq [GroupWithZero M] : Set.center Mˣ = ((↑) : Mˣ → M) ⁻¹' center M := Subset.antisymm center_units_subset subset_center_units #align set.center_units_eq Set.center_units_eq @[simp] theorem units_inv_mem_center [Monoid M] {a : Mˣ} (ha : ↑a ∈ Set.center M) : ↑a⁻¹ ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.units_inv_right <| ha ·) @[simp] theorem invOf_mem_center [Monoid M] {a : M} [Invertible a] (ha : a ∈ Set.center M) : ⅟a ∈ Set.center M := by rw [Semigroup.mem_center_iff] at * exact (Commute.invOf_right <| ha ·) @[simp] theorem inv_mem_center₀ [GroupWithZero M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by obtain rfl | ha0 := eq_or_ne a 0 · rw [inv_zero] exact zero_mem_center M · lift a to Mˣ using IsUnit.mk0 _ ha0 simpa only [Units.val_inv_eq_inv_val] using units_inv_mem_center ha #align set.inv_mem_center₀ Set.inv_mem_center₀ @[to_additive (attr := simp) sub_mem_addCenter] theorem div_mem_center [Group M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a / b ∈ Set.center M := by rw [div_eq_mul_inv] exact mul_mem_center ha (inv_mem_center hb) #align set.div_mem_center Set.div_mem_center #align set.sub_mem_add_center Set.sub_mem_addCenter @[simp] theorem div_mem_center₀ [GroupWithZero M] {a b : M} (ha : a ∈ Set.center M) (hb : b ∈ Set.center M) : a / b ∈ Set.center M := by rw [div_eq_mul_inv] exact mul_mem_center ha (inv_mem_center₀ hb) #align set.div_mem_center₀ Set.div_mem_center₀ end Set /-! ### `Set.center` as a `Subsemigroup`. -/ namespace Subsemigroup section Mul variable (M) [Mul M] /-- The center of a semigroup `M` is the set of elements that commute with everything in `M` -/ @[to_additive "The center of a semigroup `M` is the set of elements that commute with everything in `M`"] def center : Subsemigroup M where carrier := Set.center M mul_mem' := Set.mul_mem_center #align subsemigroup.center Subsemigroup.center #align add_subsemigroup.center AddSubsemigroup.center -- porting note: `coe_center` is now redundant #noalign subsemigroup.coe_center #noalign add_subsemigroup.coe_center variable {M} /-- The center of a magma is commutative and associative. -/ @[to_additive "The center of an additive magma is commutative and associative."] instance center.commSemigroup : CommSemigroup (center M) where mul_assoc _ b _ := Subtype.ext <| b.2.mid_assoc _ _ mul_comm a _ := Subtype.ext <| a.2.comm _ #align subsemigroup.center.comm_semigroup Subsemigroup.center.commSemigroup #align add_subsemigroup.center.add_comm_semigroup AddSubsemigroup.center.addCommSemigroup end Mul section Semigroup variable [Semigroup M] @[to_additive] theorem mem_center_iff {z : M} : z ∈ center M ↔ ∀ g, g * z = z * g := by rw [← Semigroup.mem_center_iff]
exact Iff.rfl
@[to_additive] theorem mem_center_iff {z : M} : z ∈ center M ↔ ∀ g, g * z = z * g := by rw [← Semigroup.mem_center_iff]
Mathlib.GroupTheory.Subsemigroup.Center.347_0.vKbtzx3rREtft3E
@[to_additive] theorem mem_center_iff {z : M} : z ∈ center M ↔ ∀ g, g * z = z * g
Mathlib_GroupTheory_Subsemigroup_Center
J : Type v inst✝ : SmallCategory J F : J ⥤ SemiRingCatMax j : J ⊢ Semiring ((F ⋙ forget SemiRingCat).obj j)
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by
change Semiring (F.obj j)
instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by
Mathlib.Algebra.Category.Ring.Limits.42_0.VxjNIkMLPSqe2rX
instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j)
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ SemiRingCatMax j : J ⊢ Semiring ↑(F.obj j)
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j)
infer_instance
instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j)
Mathlib.Algebra.Category.Ring.Limits.42_0.VxjNIkMLPSqe2rX
instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j)
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ SemiRingCatMax ⊢ IsLimit (limitCone F)
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align SemiRing.semiring_obj SemiRingCat.semiringObj /-- The flat sections of a functor into `SemiRingCat` form a subsemiring of all sections. -/ def sectionsSubsemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Subsemiring.{max v u} (∀ j, F.obj j) := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat letI g : J ⥤ MonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} MonCat.{max v u} { (MonCat.sectionsSubmonoid.{v, u} (J := J) g), (AddMonCat.sectionsAddSubmonoid.{v, u} (J := J) f) with carrier := (F ⋙ forget SemiRingCat).sections } set_option linter.uppercaseLean3 false in #align SemiRing.sections_subsemiring SemiRingCat.sectionsSubsemiring instance limitSemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Semiring (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat.{max v u})).pt := (sectionsSubsemiring F).toSemiring set_option linter.uppercaseLean3 false in #align SemiRing.limit_semiring SemiRingCat.limitSemiring /-- `limit.π (F ⋙ forget SemiRingCat) j` as a `RingHom`. -/ def limitπRingHom (F : J ⥤ SemiRingCatMax.{v, u}) (j) : (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat)).pt →+* (F ⋙ forget SemiRingCat).obj j := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat { AddMonCat.limitπAddMonoidHom f j, MonCat.limitπMonoidHom (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) j with toFun := (Types.limitCone (F ⋙ forget SemiRingCat)).π.app j } set_option linter.uppercaseLean3 false in #align SemiRing.limit_π_ring_hom SemiRingCat.limitπRingHom namespace HasLimits -- The next two definitions are used in the construction of `HasLimits SemiRingCat`. -- After that, the limits should be constructed using the generic limits API, -- e.g. `limit F`, `limit.cone F`, and `limit.isLimit F`. /-- Construction of a limit cone in `SemiRingCat`. (Internal use only; use the limits API.) -/ def limitCone (F : J ⥤ SemiRingCatMax.{v, u}) : Cone F where pt := SemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := limitπRingHom.{v, u} F naturality := fun {_ _} f => RingHom.coe_inj ((Types.limitCone (F ⋙ forget _)).π.naturality f) } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone SemiRingCat.HasLimits.limitCone /-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by
refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl
/-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by
Mathlib.Algebra.Category.Ring.Limits.97_0.VxjNIkMLPSqe2rX
/-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F)
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ SemiRingCatMax s : Cone F j : J ⊢ ↑{ val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone s).π.app j' 1) } j = ↑1 j
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align SemiRing.semiring_obj SemiRingCat.semiringObj /-- The flat sections of a functor into `SemiRingCat` form a subsemiring of all sections. -/ def sectionsSubsemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Subsemiring.{max v u} (∀ j, F.obj j) := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat letI g : J ⥤ MonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} MonCat.{max v u} { (MonCat.sectionsSubmonoid.{v, u} (J := J) g), (AddMonCat.sectionsAddSubmonoid.{v, u} (J := J) f) with carrier := (F ⋙ forget SemiRingCat).sections } set_option linter.uppercaseLean3 false in #align SemiRing.sections_subsemiring SemiRingCat.sectionsSubsemiring instance limitSemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Semiring (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat.{max v u})).pt := (sectionsSubsemiring F).toSemiring set_option linter.uppercaseLean3 false in #align SemiRing.limit_semiring SemiRingCat.limitSemiring /-- `limit.π (F ⋙ forget SemiRingCat) j` as a `RingHom`. -/ def limitπRingHom (F : J ⥤ SemiRingCatMax.{v, u}) (j) : (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat)).pt →+* (F ⋙ forget SemiRingCat).obj j := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat { AddMonCat.limitπAddMonoidHom f j, MonCat.limitπMonoidHom (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) j with toFun := (Types.limitCone (F ⋙ forget SemiRingCat)).π.app j } set_option linter.uppercaseLean3 false in #align SemiRing.limit_π_ring_hom SemiRingCat.limitπRingHom namespace HasLimits -- The next two definitions are used in the construction of `HasLimits SemiRingCat`. -- After that, the limits should be constructed using the generic limits API, -- e.g. `limit F`, `limit.cone F`, and `limit.isLimit F`. /-- Construction of a limit cone in `SemiRingCat`. (Internal use only; use the limits API.) -/ def limitCone (F : J ⥤ SemiRingCatMax.{v, u}) : Cone F where pt := SemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := limitπRingHom.{v, u} F naturality := fun {_ _} f => RingHom.coe_inj ((Types.limitCone (F ⋙ forget _)).π.naturality f) } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone SemiRingCat.HasLimits.limitCone /-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by
exact (s.π.app j).map_one
/-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by
Mathlib.Algebra.Category.Ring.Limits.97_0.VxjNIkMLPSqe2rX
/-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F)
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ SemiRingCatMax s : Cone F x y : ↑s.1 j : J ⊢ ↑(OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone s).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone s).π.app j' 1) } = 1) } (x * y)) j = ↑(OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone s).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone s).π.app j' 1) } = 1) } x * OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone s).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone s).π.app j' 1) } = 1) } y) j
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align SemiRing.semiring_obj SemiRingCat.semiringObj /-- The flat sections of a functor into `SemiRingCat` form a subsemiring of all sections. -/ def sectionsSubsemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Subsemiring.{max v u} (∀ j, F.obj j) := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat letI g : J ⥤ MonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} MonCat.{max v u} { (MonCat.sectionsSubmonoid.{v, u} (J := J) g), (AddMonCat.sectionsAddSubmonoid.{v, u} (J := J) f) with carrier := (F ⋙ forget SemiRingCat).sections } set_option linter.uppercaseLean3 false in #align SemiRing.sections_subsemiring SemiRingCat.sectionsSubsemiring instance limitSemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Semiring (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat.{max v u})).pt := (sectionsSubsemiring F).toSemiring set_option linter.uppercaseLean3 false in #align SemiRing.limit_semiring SemiRingCat.limitSemiring /-- `limit.π (F ⋙ forget SemiRingCat) j` as a `RingHom`. -/ def limitπRingHom (F : J ⥤ SemiRingCatMax.{v, u}) (j) : (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat)).pt →+* (F ⋙ forget SemiRingCat).obj j := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat { AddMonCat.limitπAddMonoidHom f j, MonCat.limitπMonoidHom (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) j with toFun := (Types.limitCone (F ⋙ forget SemiRingCat)).π.app j } set_option linter.uppercaseLean3 false in #align SemiRing.limit_π_ring_hom SemiRingCat.limitπRingHom namespace HasLimits -- The next two definitions are used in the construction of `HasLimits SemiRingCat`. -- After that, the limits should be constructed using the generic limits API, -- e.g. `limit F`, `limit.cone F`, and `limit.isLimit F`. /-- Construction of a limit cone in `SemiRingCat`. (Internal use only; use the limits API.) -/ def limitCone (F : J ⥤ SemiRingCatMax.{v, u}) : Cone F where pt := SemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := limitπRingHom.{v, u} F naturality := fun {_ _} f => RingHom.coe_inj ((Types.limitCone (F ⋙ forget _)).π.naturality f) } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone SemiRingCat.HasLimits.limitCone /-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by
exact (s.π.app j).map_mul x y
/-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by
Mathlib.Algebra.Category.Ring.Limits.97_0.VxjNIkMLPSqe2rX
/-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F)
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ SemiRingCatMax s : Cone F j : J ⊢ ↑(OneHom.toFun (↑{ toOneHom := { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone s).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone s).π.app j' 1) } = 1) }, map_mul' := (_ : ∀ (x y : ↑s.1), OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone s).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone s).π.app j' 1) } = 1) } (x * y) = OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone s).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone s).π.app j' 1) } = 1) } x * OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone s).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone s).π.app j' 1) } = 1) } y) }) 0) j = ↑0 j
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align SemiRing.semiring_obj SemiRingCat.semiringObj /-- The flat sections of a functor into `SemiRingCat` form a subsemiring of all sections. -/ def sectionsSubsemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Subsemiring.{max v u} (∀ j, F.obj j) := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat letI g : J ⥤ MonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} MonCat.{max v u} { (MonCat.sectionsSubmonoid.{v, u} (J := J) g), (AddMonCat.sectionsAddSubmonoid.{v, u} (J := J) f) with carrier := (F ⋙ forget SemiRingCat).sections } set_option linter.uppercaseLean3 false in #align SemiRing.sections_subsemiring SemiRingCat.sectionsSubsemiring instance limitSemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Semiring (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat.{max v u})).pt := (sectionsSubsemiring F).toSemiring set_option linter.uppercaseLean3 false in #align SemiRing.limit_semiring SemiRingCat.limitSemiring /-- `limit.π (F ⋙ forget SemiRingCat) j` as a `RingHom`. -/ def limitπRingHom (F : J ⥤ SemiRingCatMax.{v, u}) (j) : (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat)).pt →+* (F ⋙ forget SemiRingCat).obj j := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat { AddMonCat.limitπAddMonoidHom f j, MonCat.limitπMonoidHom (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) j with toFun := (Types.limitCone (F ⋙ forget SemiRingCat)).π.app j } set_option linter.uppercaseLean3 false in #align SemiRing.limit_π_ring_hom SemiRingCat.limitπRingHom namespace HasLimits -- The next two definitions are used in the construction of `HasLimits SemiRingCat`. -- After that, the limits should be constructed using the generic limits API, -- e.g. `limit F`, `limit.cone F`, and `limit.isLimit F`. /-- Construction of a limit cone in `SemiRingCat`. (Internal use only; use the limits API.) -/ def limitCone (F : J ⥤ SemiRingCatMax.{v, u}) : Cone F where pt := SemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := limitπRingHom.{v, u} F naturality := fun {_ _} f => RingHom.coe_inj ((Types.limitCone (F ⋙ forget _)).π.naturality f) } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone SemiRingCat.HasLimits.limitCone /-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by
exact (s.π.app j).map_zero
/-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by
Mathlib.Algebra.Category.Ring.Limits.97_0.VxjNIkMLPSqe2rX
/-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F)
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ SemiRingCatMax s : Cone F x y : ↑s.1 j : J ⊢ ↑(OneHom.toFun (↑{ toOneHom := { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone s).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone s).π.app j' 1) } = 1) }, map_mul' := (_ : ∀ (x y : ↑s.1), OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone s).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone s).π.app j' 1) } = 1) } (x * y) = OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone s).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone s).π.app j' 1) } = 1) } x * OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone s).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone s).π.app j' 1) } = 1) } y) }) (x + y)) j = ↑(OneHom.toFun (↑{ toOneHom := { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone s).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone s).π.app j' 1) } = 1) }, map_mul' := (_ : ∀ (x y : ↑s.1), OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone s).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone s).π.app j' 1) } = 1) } (x * y) = OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone s).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone s).π.app j' 1) } = 1) } x * OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone s).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone s).π.app j' 1) } = 1) } y) }) x + OneHom.toFun (↑{ toOneHom := { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone s).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone s).π.app j' 1) } = 1) }, map_mul' := (_ : ∀ (x y : ↑s.1), OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone s).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone s).π.app j' 1) } = 1) } (x * y) = OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone s).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone s).π.app j' 1) } = 1) } x * OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone s).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone s).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone s).π.app j ≫ (F ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone s).π.app j' 1) } = 1) } y) }) y) j
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align SemiRing.semiring_obj SemiRingCat.semiringObj /-- The flat sections of a functor into `SemiRingCat` form a subsemiring of all sections. -/ def sectionsSubsemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Subsemiring.{max v u} (∀ j, F.obj j) := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat letI g : J ⥤ MonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} MonCat.{max v u} { (MonCat.sectionsSubmonoid.{v, u} (J := J) g), (AddMonCat.sectionsAddSubmonoid.{v, u} (J := J) f) with carrier := (F ⋙ forget SemiRingCat).sections } set_option linter.uppercaseLean3 false in #align SemiRing.sections_subsemiring SemiRingCat.sectionsSubsemiring instance limitSemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Semiring (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat.{max v u})).pt := (sectionsSubsemiring F).toSemiring set_option linter.uppercaseLean3 false in #align SemiRing.limit_semiring SemiRingCat.limitSemiring /-- `limit.π (F ⋙ forget SemiRingCat) j` as a `RingHom`. -/ def limitπRingHom (F : J ⥤ SemiRingCatMax.{v, u}) (j) : (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat)).pt →+* (F ⋙ forget SemiRingCat).obj j := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat { AddMonCat.limitπAddMonoidHom f j, MonCat.limitπMonoidHom (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) j with toFun := (Types.limitCone (F ⋙ forget SemiRingCat)).π.app j } set_option linter.uppercaseLean3 false in #align SemiRing.limit_π_ring_hom SemiRingCat.limitπRingHom namespace HasLimits -- The next two definitions are used in the construction of `HasLimits SemiRingCat`. -- After that, the limits should be constructed using the generic limits API, -- e.g. `limit F`, `limit.cone F`, and `limit.isLimit F`. /-- Construction of a limit cone in `SemiRingCat`. (Internal use only; use the limits API.) -/ def limitCone (F : J ⥤ SemiRingCatMax.{v, u}) : Cone F where pt := SemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := limitπRingHom.{v, u} F naturality := fun {_ _} f => RingHom.coe_inj ((Types.limitCone (F ⋙ forget _)).π.naturality f) } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone SemiRingCat.HasLimits.limitCone /-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by
exact (s.π.app j).map_add x y
/-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by
Mathlib.Algebra.Category.Ring.Limits.97_0.VxjNIkMLPSqe2rX
/-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F)
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ SemiRingCatMax ⊢ IsLimit ((forget₂ SemiRingCat AddCommMonCat).mapCone (limitCone F))
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align SemiRing.semiring_obj SemiRingCat.semiringObj /-- The flat sections of a functor into `SemiRingCat` form a subsemiring of all sections. -/ def sectionsSubsemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Subsemiring.{max v u} (∀ j, F.obj j) := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat letI g : J ⥤ MonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} MonCat.{max v u} { (MonCat.sectionsSubmonoid.{v, u} (J := J) g), (AddMonCat.sectionsAddSubmonoid.{v, u} (J := J) f) with carrier := (F ⋙ forget SemiRingCat).sections } set_option linter.uppercaseLean3 false in #align SemiRing.sections_subsemiring SemiRingCat.sectionsSubsemiring instance limitSemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Semiring (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat.{max v u})).pt := (sectionsSubsemiring F).toSemiring set_option linter.uppercaseLean3 false in #align SemiRing.limit_semiring SemiRingCat.limitSemiring /-- `limit.π (F ⋙ forget SemiRingCat) j` as a `RingHom`. -/ def limitπRingHom (F : J ⥤ SemiRingCatMax.{v, u}) (j) : (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat)).pt →+* (F ⋙ forget SemiRingCat).obj j := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat { AddMonCat.limitπAddMonoidHom f j, MonCat.limitπMonoidHom (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) j with toFun := (Types.limitCone (F ⋙ forget SemiRingCat)).π.app j } set_option linter.uppercaseLean3 false in #align SemiRing.limit_π_ring_hom SemiRingCat.limitπRingHom namespace HasLimits -- The next two definitions are used in the construction of `HasLimits SemiRingCat`. -- After that, the limits should be constructed using the generic limits API, -- e.g. `limit F`, `limit.cone F`, and `limit.isLimit F`. /-- Construction of a limit cone in `SemiRingCat`. (Internal use only; use the limits API.) -/ def limitCone (F : J ⥤ SemiRingCatMax.{v, u}) : Cone F where pt := SemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := limitπRingHom.{v, u} F naturality := fun {_ _} f => RingHom.coe_inj ((Types.limitCone (F ⋙ forget _)).π.naturality f) } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone SemiRingCat.HasLimits.limitCone /-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone_is_limit SemiRingCat.HasLimits.limitConeIsLimit end HasLimits open HasLimits /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v} SemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => ⟨limitCone.{v, u} F, limitConeIsLimit.{v, u} F⟩ } } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits_of_size SemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits SemiRingCat.{u} := SemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.has_limits SemiRingCat.hasLimits /-- Auxiliary lemma to prove the cone induced by `limitCone` is a limit cone. -/ def forget₂AddCommMonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat AddCommMonCat).mapCone (limitCone F)) := by
apply AddCommMonCat.limitConeIsLimit.{v, u}
/-- Auxiliary lemma to prove the cone induced by `limitCone` is a limit cone. -/ def forget₂AddCommMonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat AddCommMonCat).mapCone (limitCone F)) := by
Mathlib.Algebra.Category.Ring.Limits.129_0.VxjNIkMLPSqe2rX
/-- Auxiliary lemma to prove the cone induced by `limitCone` is a limit cone. -/ def forget₂AddCommMonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat AddCommMonCat).mapCone (limitCone F))
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ SemiRingCatMax ⊢ IsLimit ((forget₂ SemiRingCat MonCat).mapCone (limitCone F))
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align SemiRing.semiring_obj SemiRingCat.semiringObj /-- The flat sections of a functor into `SemiRingCat` form a subsemiring of all sections. -/ def sectionsSubsemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Subsemiring.{max v u} (∀ j, F.obj j) := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat letI g : J ⥤ MonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} MonCat.{max v u} { (MonCat.sectionsSubmonoid.{v, u} (J := J) g), (AddMonCat.sectionsAddSubmonoid.{v, u} (J := J) f) with carrier := (F ⋙ forget SemiRingCat).sections } set_option linter.uppercaseLean3 false in #align SemiRing.sections_subsemiring SemiRingCat.sectionsSubsemiring instance limitSemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Semiring (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat.{max v u})).pt := (sectionsSubsemiring F).toSemiring set_option linter.uppercaseLean3 false in #align SemiRing.limit_semiring SemiRingCat.limitSemiring /-- `limit.π (F ⋙ forget SemiRingCat) j` as a `RingHom`. -/ def limitπRingHom (F : J ⥤ SemiRingCatMax.{v, u}) (j) : (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat)).pt →+* (F ⋙ forget SemiRingCat).obj j := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat { AddMonCat.limitπAddMonoidHom f j, MonCat.limitπMonoidHom (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) j with toFun := (Types.limitCone (F ⋙ forget SemiRingCat)).π.app j } set_option linter.uppercaseLean3 false in #align SemiRing.limit_π_ring_hom SemiRingCat.limitπRingHom namespace HasLimits -- The next two definitions are used in the construction of `HasLimits SemiRingCat`. -- After that, the limits should be constructed using the generic limits API, -- e.g. `limit F`, `limit.cone F`, and `limit.isLimit F`. /-- Construction of a limit cone in `SemiRingCat`. (Internal use only; use the limits API.) -/ def limitCone (F : J ⥤ SemiRingCatMax.{v, u}) : Cone F where pt := SemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := limitπRingHom.{v, u} F naturality := fun {_ _} f => RingHom.coe_inj ((Types.limitCone (F ⋙ forget _)).π.naturality f) } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone SemiRingCat.HasLimits.limitCone /-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone_is_limit SemiRingCat.HasLimits.limitConeIsLimit end HasLimits open HasLimits /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v} SemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => ⟨limitCone.{v, u} F, limitConeIsLimit.{v, u} F⟩ } } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits_of_size SemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits SemiRingCat.{u} := SemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.has_limits SemiRingCat.hasLimits /-- Auxiliary lemma to prove the cone induced by `limitCone` is a limit cone. -/ def forget₂AddCommMonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat AddCommMonCat).mapCone (limitCone F)) := by apply AddCommMonCat.limitConeIsLimit.{v, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_aux SemiRingCat.forget₂AddCommMonPreservesLimitsAux /-- The forgetful functor from semirings to additive commutative monoids preserves all limits. -/ instance forget₂AddCommMonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat AddCommMonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (forget₂AddCommMonPreservesLimitsAux F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_of_size SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize instance forget₂AddCommMonPreservesLimits : PreservesLimits (forget₂ SemiRingCat AddCommMonCat.{u}) := SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits SemiRingCat.forget₂AddCommMonPreservesLimits /-- An auxiliary declaration to speed up typechecking. -/ def forget₂MonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat MonCat).mapCone (limitCone F)) := by
apply MonCat.HasLimits.limitConeIsLimit (F ⋙ forget₂ SemiRingCat MonCat.{max v u})
/-- An auxiliary declaration to speed up typechecking. -/ def forget₂MonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat MonCat).mapCone (limitCone F)) := by
Mathlib.Algebra.Category.Ring.Limits.155_0.VxjNIkMLPSqe2rX
/-- An auxiliary declaration to speed up typechecking. -/ def forget₂MonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat MonCat).mapCone (limitCone F))
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ CommSemiRingCatMax j : J ⊢ CommSemiring ((F ⋙ forget CommSemiRingCat).obj j)
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align SemiRing.semiring_obj SemiRingCat.semiringObj /-- The flat sections of a functor into `SemiRingCat` form a subsemiring of all sections. -/ def sectionsSubsemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Subsemiring.{max v u} (∀ j, F.obj j) := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat letI g : J ⥤ MonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} MonCat.{max v u} { (MonCat.sectionsSubmonoid.{v, u} (J := J) g), (AddMonCat.sectionsAddSubmonoid.{v, u} (J := J) f) with carrier := (F ⋙ forget SemiRingCat).sections } set_option linter.uppercaseLean3 false in #align SemiRing.sections_subsemiring SemiRingCat.sectionsSubsemiring instance limitSemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Semiring (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat.{max v u})).pt := (sectionsSubsemiring F).toSemiring set_option linter.uppercaseLean3 false in #align SemiRing.limit_semiring SemiRingCat.limitSemiring /-- `limit.π (F ⋙ forget SemiRingCat) j` as a `RingHom`. -/ def limitπRingHom (F : J ⥤ SemiRingCatMax.{v, u}) (j) : (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat)).pt →+* (F ⋙ forget SemiRingCat).obj j := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat { AddMonCat.limitπAddMonoidHom f j, MonCat.limitπMonoidHom (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) j with toFun := (Types.limitCone (F ⋙ forget SemiRingCat)).π.app j } set_option linter.uppercaseLean3 false in #align SemiRing.limit_π_ring_hom SemiRingCat.limitπRingHom namespace HasLimits -- The next two definitions are used in the construction of `HasLimits SemiRingCat`. -- After that, the limits should be constructed using the generic limits API, -- e.g. `limit F`, `limit.cone F`, and `limit.isLimit F`. /-- Construction of a limit cone in `SemiRingCat`. (Internal use only; use the limits API.) -/ def limitCone (F : J ⥤ SemiRingCatMax.{v, u}) : Cone F where pt := SemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := limitπRingHom.{v, u} F naturality := fun {_ _} f => RingHom.coe_inj ((Types.limitCone (F ⋙ forget _)).π.naturality f) } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone SemiRingCat.HasLimits.limitCone /-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone_is_limit SemiRingCat.HasLimits.limitConeIsLimit end HasLimits open HasLimits /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v} SemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => ⟨limitCone.{v, u} F, limitConeIsLimit.{v, u} F⟩ } } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits_of_size SemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits SemiRingCat.{u} := SemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.has_limits SemiRingCat.hasLimits /-- Auxiliary lemma to prove the cone induced by `limitCone` is a limit cone. -/ def forget₂AddCommMonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat AddCommMonCat).mapCone (limitCone F)) := by apply AddCommMonCat.limitConeIsLimit.{v, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_aux SemiRingCat.forget₂AddCommMonPreservesLimitsAux /-- The forgetful functor from semirings to additive commutative monoids preserves all limits. -/ instance forget₂AddCommMonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat AddCommMonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (forget₂AddCommMonPreservesLimitsAux F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_of_size SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize instance forget₂AddCommMonPreservesLimits : PreservesLimits (forget₂ SemiRingCat AddCommMonCat.{u}) := SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits SemiRingCat.forget₂AddCommMonPreservesLimits /-- An auxiliary declaration to speed up typechecking. -/ def forget₂MonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat MonCat).mapCone (limitCone F)) := by apply MonCat.HasLimits.limitConeIsLimit (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_aux SemiRingCat.forget₂MonPreservesLimitsAux /-- The forgetful functor from semirings to monoids preserves all limits. -/ instance forget₂MonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat MonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (forget₂MonPreservesLimitsAux.{v, u} F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_of_size SemiRingCat.forget₂MonPreservesLimitsOfSize instance forget₂MonPreservesLimits : PreservesLimits (forget₂ SemiRingCat MonCat.{u}) := SemiRingCat.forget₂MonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits SemiRingCat.forget₂MonPreservesLimits /-- The forgetful functor from semirings to types preserves all limits. -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (Types.limitConeIsLimit.{v, u} (F ⋙ forget _)) } set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits_of_size SemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget SemiRingCat.{u}) := SemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits SemiRingCat.forgetPreservesLimits end SemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `CommSemiring.{max u v}`, to deal with unification issues. -/ @[nolint checkUnivs] abbrev CommSemiRingCatMax.{u1, u2} := CommSemiRingCat.{max u1 u2} namespace CommSemiRingCat variable {J : Type v} [SmallCategory J] instance commSemiringObj (F : J ⥤ CommSemiRingCatMax.{v, u}) (j) : CommSemiring ((F ⋙ forget CommSemiRingCat).obj j) := by
change CommSemiring (F.obj j)
instance commSemiringObj (F : J ⥤ CommSemiRingCatMax.{v, u}) (j) : CommSemiring ((F ⋙ forget CommSemiRingCat).obj j) := by
Mathlib.Algebra.Category.Ring.Limits.206_0.VxjNIkMLPSqe2rX
instance commSemiringObj (F : J ⥤ CommSemiRingCatMax.{v, u}) (j) : CommSemiring ((F ⋙ forget CommSemiRingCat).obj j)
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ CommSemiRingCatMax j : J ⊢ CommSemiring ↑(F.obj j)
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align SemiRing.semiring_obj SemiRingCat.semiringObj /-- The flat sections of a functor into `SemiRingCat` form a subsemiring of all sections. -/ def sectionsSubsemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Subsemiring.{max v u} (∀ j, F.obj j) := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat letI g : J ⥤ MonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} MonCat.{max v u} { (MonCat.sectionsSubmonoid.{v, u} (J := J) g), (AddMonCat.sectionsAddSubmonoid.{v, u} (J := J) f) with carrier := (F ⋙ forget SemiRingCat).sections } set_option linter.uppercaseLean3 false in #align SemiRing.sections_subsemiring SemiRingCat.sectionsSubsemiring instance limitSemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Semiring (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat.{max v u})).pt := (sectionsSubsemiring F).toSemiring set_option linter.uppercaseLean3 false in #align SemiRing.limit_semiring SemiRingCat.limitSemiring /-- `limit.π (F ⋙ forget SemiRingCat) j` as a `RingHom`. -/ def limitπRingHom (F : J ⥤ SemiRingCatMax.{v, u}) (j) : (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat)).pt →+* (F ⋙ forget SemiRingCat).obj j := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat { AddMonCat.limitπAddMonoidHom f j, MonCat.limitπMonoidHom (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) j with toFun := (Types.limitCone (F ⋙ forget SemiRingCat)).π.app j } set_option linter.uppercaseLean3 false in #align SemiRing.limit_π_ring_hom SemiRingCat.limitπRingHom namespace HasLimits -- The next two definitions are used in the construction of `HasLimits SemiRingCat`. -- After that, the limits should be constructed using the generic limits API, -- e.g. `limit F`, `limit.cone F`, and `limit.isLimit F`. /-- Construction of a limit cone in `SemiRingCat`. (Internal use only; use the limits API.) -/ def limitCone (F : J ⥤ SemiRingCatMax.{v, u}) : Cone F where pt := SemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := limitπRingHom.{v, u} F naturality := fun {_ _} f => RingHom.coe_inj ((Types.limitCone (F ⋙ forget _)).π.naturality f) } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone SemiRingCat.HasLimits.limitCone /-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone_is_limit SemiRingCat.HasLimits.limitConeIsLimit end HasLimits open HasLimits /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v} SemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => ⟨limitCone.{v, u} F, limitConeIsLimit.{v, u} F⟩ } } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits_of_size SemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits SemiRingCat.{u} := SemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.has_limits SemiRingCat.hasLimits /-- Auxiliary lemma to prove the cone induced by `limitCone` is a limit cone. -/ def forget₂AddCommMonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat AddCommMonCat).mapCone (limitCone F)) := by apply AddCommMonCat.limitConeIsLimit.{v, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_aux SemiRingCat.forget₂AddCommMonPreservesLimitsAux /-- The forgetful functor from semirings to additive commutative monoids preserves all limits. -/ instance forget₂AddCommMonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat AddCommMonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (forget₂AddCommMonPreservesLimitsAux F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_of_size SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize instance forget₂AddCommMonPreservesLimits : PreservesLimits (forget₂ SemiRingCat AddCommMonCat.{u}) := SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits SemiRingCat.forget₂AddCommMonPreservesLimits /-- An auxiliary declaration to speed up typechecking. -/ def forget₂MonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat MonCat).mapCone (limitCone F)) := by apply MonCat.HasLimits.limitConeIsLimit (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_aux SemiRingCat.forget₂MonPreservesLimitsAux /-- The forgetful functor from semirings to monoids preserves all limits. -/ instance forget₂MonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat MonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (forget₂MonPreservesLimitsAux.{v, u} F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_of_size SemiRingCat.forget₂MonPreservesLimitsOfSize instance forget₂MonPreservesLimits : PreservesLimits (forget₂ SemiRingCat MonCat.{u}) := SemiRingCat.forget₂MonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits SemiRingCat.forget₂MonPreservesLimits /-- The forgetful functor from semirings to types preserves all limits. -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (Types.limitConeIsLimit.{v, u} (F ⋙ forget _)) } set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits_of_size SemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget SemiRingCat.{u}) := SemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits SemiRingCat.forgetPreservesLimits end SemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `CommSemiring.{max u v}`, to deal with unification issues. -/ @[nolint checkUnivs] abbrev CommSemiRingCatMax.{u1, u2} := CommSemiRingCat.{max u1 u2} namespace CommSemiRingCat variable {J : Type v} [SmallCategory J] instance commSemiringObj (F : J ⥤ CommSemiRingCatMax.{v, u}) (j) : CommSemiring ((F ⋙ forget CommSemiRingCat).obj j) := by change CommSemiring (F.obj j)
infer_instance
instance commSemiringObj (F : J ⥤ CommSemiRingCatMax.{v, u}) (j) : CommSemiring ((F ⋙ forget CommSemiRingCat).obj j) := by change CommSemiring (F.obj j)
Mathlib.Algebra.Category.Ring.Limits.206_0.VxjNIkMLPSqe2rX
instance commSemiringObj (F : J ⥤ CommSemiRingCatMax.{v, u}) (j) : CommSemiring ((F ⋙ forget CommSemiRingCat).obj j)
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ CommSemiRingCatMax this✝ : ReflectsIsomorphisms (forget CommSemiRingCatMax) := forgetReflectIsos this : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax SemiRingCatMax) := reflectsIsomorphisms_forget₂ CommSemiRingCatMax SemiRingCatMax c : Cone F := { pt := of (Types.limitCone (F ⋙ forget CommSemiRingCatMax)).pt, π := NatTrans.mk fun j => ofHom (SemiRingCat.limitπRingHom (F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) j) } c' : Cone (F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) t : IsLimit c' ⊢ IsLimit { liftedCone := c, validLift := IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit (F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax)) t }.liftedCone
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align SemiRing.semiring_obj SemiRingCat.semiringObj /-- The flat sections of a functor into `SemiRingCat` form a subsemiring of all sections. -/ def sectionsSubsemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Subsemiring.{max v u} (∀ j, F.obj j) := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat letI g : J ⥤ MonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} MonCat.{max v u} { (MonCat.sectionsSubmonoid.{v, u} (J := J) g), (AddMonCat.sectionsAddSubmonoid.{v, u} (J := J) f) with carrier := (F ⋙ forget SemiRingCat).sections } set_option linter.uppercaseLean3 false in #align SemiRing.sections_subsemiring SemiRingCat.sectionsSubsemiring instance limitSemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Semiring (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat.{max v u})).pt := (sectionsSubsemiring F).toSemiring set_option linter.uppercaseLean3 false in #align SemiRing.limit_semiring SemiRingCat.limitSemiring /-- `limit.π (F ⋙ forget SemiRingCat) j` as a `RingHom`. -/ def limitπRingHom (F : J ⥤ SemiRingCatMax.{v, u}) (j) : (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat)).pt →+* (F ⋙ forget SemiRingCat).obj j := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat { AddMonCat.limitπAddMonoidHom f j, MonCat.limitπMonoidHom (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) j with toFun := (Types.limitCone (F ⋙ forget SemiRingCat)).π.app j } set_option linter.uppercaseLean3 false in #align SemiRing.limit_π_ring_hom SemiRingCat.limitπRingHom namespace HasLimits -- The next two definitions are used in the construction of `HasLimits SemiRingCat`. -- After that, the limits should be constructed using the generic limits API, -- e.g. `limit F`, `limit.cone F`, and `limit.isLimit F`. /-- Construction of a limit cone in `SemiRingCat`. (Internal use only; use the limits API.) -/ def limitCone (F : J ⥤ SemiRingCatMax.{v, u}) : Cone F where pt := SemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := limitπRingHom.{v, u} F naturality := fun {_ _} f => RingHom.coe_inj ((Types.limitCone (F ⋙ forget _)).π.naturality f) } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone SemiRingCat.HasLimits.limitCone /-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone_is_limit SemiRingCat.HasLimits.limitConeIsLimit end HasLimits open HasLimits /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v} SemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => ⟨limitCone.{v, u} F, limitConeIsLimit.{v, u} F⟩ } } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits_of_size SemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits SemiRingCat.{u} := SemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.has_limits SemiRingCat.hasLimits /-- Auxiliary lemma to prove the cone induced by `limitCone` is a limit cone. -/ def forget₂AddCommMonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat AddCommMonCat).mapCone (limitCone F)) := by apply AddCommMonCat.limitConeIsLimit.{v, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_aux SemiRingCat.forget₂AddCommMonPreservesLimitsAux /-- The forgetful functor from semirings to additive commutative monoids preserves all limits. -/ instance forget₂AddCommMonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat AddCommMonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (forget₂AddCommMonPreservesLimitsAux F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_of_size SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize instance forget₂AddCommMonPreservesLimits : PreservesLimits (forget₂ SemiRingCat AddCommMonCat.{u}) := SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits SemiRingCat.forget₂AddCommMonPreservesLimits /-- An auxiliary declaration to speed up typechecking. -/ def forget₂MonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat MonCat).mapCone (limitCone F)) := by apply MonCat.HasLimits.limitConeIsLimit (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_aux SemiRingCat.forget₂MonPreservesLimitsAux /-- The forgetful functor from semirings to monoids preserves all limits. -/ instance forget₂MonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat MonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (forget₂MonPreservesLimitsAux.{v, u} F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_of_size SemiRingCat.forget₂MonPreservesLimitsOfSize instance forget₂MonPreservesLimits : PreservesLimits (forget₂ SemiRingCat MonCat.{u}) := SemiRingCat.forget₂MonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits SemiRingCat.forget₂MonPreservesLimits /-- The forgetful functor from semirings to types preserves all limits. -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (Types.limitConeIsLimit.{v, u} (F ⋙ forget _)) } set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits_of_size SemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget SemiRingCat.{u}) := SemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits SemiRingCat.forgetPreservesLimits end SemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `CommSemiring.{max u v}`, to deal with unification issues. -/ @[nolint checkUnivs] abbrev CommSemiRingCatMax.{u1, u2} := CommSemiRingCat.{max u1 u2} namespace CommSemiRingCat variable {J : Type v} [SmallCategory J] instance commSemiringObj (F : J ⥤ CommSemiRingCatMax.{v, u}) (j) : CommSemiring ((F ⋙ forget CommSemiRingCat).obj j) := by change CommSemiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align CommSemiRing.comm_semiring_obj CommSemiRingCat.commSemiringObj instance limitCommSemiring (F : J ⥤ CommSemiRingCatMax.{v, u}) : CommSemiring (Types.limitCone.{v, u} (F ⋙ forget CommSemiRingCat.{max v u})).pt := @Subsemiring.toCommSemiring (∀ j, F.obj j) _ (SemiRingCat.sectionsSubsemiring.{v, u} (F ⋙ forget₂ CommSemiRingCat SemiRingCat.{max v u})) set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_comm_semiring CommSemiRingCat.limitCommSemiring /-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := -- Porting note : `CommSemiRingCat ⥤ Type` reflecting isomorphism is needed to make Lean see that -- `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism. `CommSemiRingCat ⥤ Type` reflecting -- isomorphism is added manually since Lean can't see it, but even with this addition Lean can not -- see `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism, so this instance is also added. letI : ReflectsIsomorphisms (forget CommSemiRingCatMax.{v, u}) := CommSemiRingCat.forgetReflectIsos.{max v u} letI : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := CategoryTheory.reflectsIsomorphisms_forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u} let c : Cone F := { pt := CommSemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun j => CommSemiRingCat.ofHom <| SemiRingCat.limitπRingHom.{v, u} (J := J) (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) j naturality := (SemiRingCat.HasLimits.limitCone.{v, u} (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) t makesLimit := by
refine IsLimit.ofFaithful (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) (fun s : Cone F => CommSemiRingCat.ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl
/-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := -- Porting note : `CommSemiRingCat ⥤ Type` reflecting isomorphism is needed to make Lean see that -- `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism. `CommSemiRingCat ⥤ Type` reflecting -- isomorphism is added manually since Lean can't see it, but even with this addition Lean can not -- see `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism, so this instance is also added. letI : ReflectsIsomorphisms (forget CommSemiRingCatMax.{v, u}) := CommSemiRingCat.forgetReflectIsos.{max v u} letI : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := CategoryTheory.reflectsIsomorphisms_forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u} let c : Cone F := { pt := CommSemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun j => CommSemiRingCat.ofHom <| SemiRingCat.limitπRingHom.{v, u} (J := J) (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) j naturality := (SemiRingCat.HasLimits.limitCone.{v, u} (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) t makesLimit := by
Mathlib.Algebra.Category.Ring.Limits.220_0.VxjNIkMLPSqe2rX
/-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ CommSemiRingCatMax this✝ : ReflectsIsomorphisms (forget CommSemiRingCatMax) := forgetReflectIsos this : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax SemiRingCatMax) := reflectsIsomorphisms_forget₂ CommSemiRingCatMax SemiRingCatMax c : Cone F := { pt := of (Types.limitCone (F ⋙ forget CommSemiRingCatMax)).pt, π := NatTrans.mk fun j => ofHom (SemiRingCat.limitπRingHom (F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) j) } c' : Cone (F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) t : IsLimit c' s : Cone F j : J ⊢ ↑{ val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' 1) } j = ↑1 j
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align SemiRing.semiring_obj SemiRingCat.semiringObj /-- The flat sections of a functor into `SemiRingCat` form a subsemiring of all sections. -/ def sectionsSubsemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Subsemiring.{max v u} (∀ j, F.obj j) := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat letI g : J ⥤ MonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} MonCat.{max v u} { (MonCat.sectionsSubmonoid.{v, u} (J := J) g), (AddMonCat.sectionsAddSubmonoid.{v, u} (J := J) f) with carrier := (F ⋙ forget SemiRingCat).sections } set_option linter.uppercaseLean3 false in #align SemiRing.sections_subsemiring SemiRingCat.sectionsSubsemiring instance limitSemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Semiring (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat.{max v u})).pt := (sectionsSubsemiring F).toSemiring set_option linter.uppercaseLean3 false in #align SemiRing.limit_semiring SemiRingCat.limitSemiring /-- `limit.π (F ⋙ forget SemiRingCat) j` as a `RingHom`. -/ def limitπRingHom (F : J ⥤ SemiRingCatMax.{v, u}) (j) : (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat)).pt →+* (F ⋙ forget SemiRingCat).obj j := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat { AddMonCat.limitπAddMonoidHom f j, MonCat.limitπMonoidHom (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) j with toFun := (Types.limitCone (F ⋙ forget SemiRingCat)).π.app j } set_option linter.uppercaseLean3 false in #align SemiRing.limit_π_ring_hom SemiRingCat.limitπRingHom namespace HasLimits -- The next two definitions are used in the construction of `HasLimits SemiRingCat`. -- After that, the limits should be constructed using the generic limits API, -- e.g. `limit F`, `limit.cone F`, and `limit.isLimit F`. /-- Construction of a limit cone in `SemiRingCat`. (Internal use only; use the limits API.) -/ def limitCone (F : J ⥤ SemiRingCatMax.{v, u}) : Cone F where pt := SemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := limitπRingHom.{v, u} F naturality := fun {_ _} f => RingHom.coe_inj ((Types.limitCone (F ⋙ forget _)).π.naturality f) } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone SemiRingCat.HasLimits.limitCone /-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone_is_limit SemiRingCat.HasLimits.limitConeIsLimit end HasLimits open HasLimits /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v} SemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => ⟨limitCone.{v, u} F, limitConeIsLimit.{v, u} F⟩ } } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits_of_size SemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits SemiRingCat.{u} := SemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.has_limits SemiRingCat.hasLimits /-- Auxiliary lemma to prove the cone induced by `limitCone` is a limit cone. -/ def forget₂AddCommMonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat AddCommMonCat).mapCone (limitCone F)) := by apply AddCommMonCat.limitConeIsLimit.{v, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_aux SemiRingCat.forget₂AddCommMonPreservesLimitsAux /-- The forgetful functor from semirings to additive commutative monoids preserves all limits. -/ instance forget₂AddCommMonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat AddCommMonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (forget₂AddCommMonPreservesLimitsAux F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_of_size SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize instance forget₂AddCommMonPreservesLimits : PreservesLimits (forget₂ SemiRingCat AddCommMonCat.{u}) := SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits SemiRingCat.forget₂AddCommMonPreservesLimits /-- An auxiliary declaration to speed up typechecking. -/ def forget₂MonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat MonCat).mapCone (limitCone F)) := by apply MonCat.HasLimits.limitConeIsLimit (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_aux SemiRingCat.forget₂MonPreservesLimitsAux /-- The forgetful functor from semirings to monoids preserves all limits. -/ instance forget₂MonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat MonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (forget₂MonPreservesLimitsAux.{v, u} F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_of_size SemiRingCat.forget₂MonPreservesLimitsOfSize instance forget₂MonPreservesLimits : PreservesLimits (forget₂ SemiRingCat MonCat.{u}) := SemiRingCat.forget₂MonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits SemiRingCat.forget₂MonPreservesLimits /-- The forgetful functor from semirings to types preserves all limits. -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (Types.limitConeIsLimit.{v, u} (F ⋙ forget _)) } set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits_of_size SemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget SemiRingCat.{u}) := SemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits SemiRingCat.forgetPreservesLimits end SemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `CommSemiring.{max u v}`, to deal with unification issues. -/ @[nolint checkUnivs] abbrev CommSemiRingCatMax.{u1, u2} := CommSemiRingCat.{max u1 u2} namespace CommSemiRingCat variable {J : Type v} [SmallCategory J] instance commSemiringObj (F : J ⥤ CommSemiRingCatMax.{v, u}) (j) : CommSemiring ((F ⋙ forget CommSemiRingCat).obj j) := by change CommSemiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align CommSemiRing.comm_semiring_obj CommSemiRingCat.commSemiringObj instance limitCommSemiring (F : J ⥤ CommSemiRingCatMax.{v, u}) : CommSemiring (Types.limitCone.{v, u} (F ⋙ forget CommSemiRingCat.{max v u})).pt := @Subsemiring.toCommSemiring (∀ j, F.obj j) _ (SemiRingCat.sectionsSubsemiring.{v, u} (F ⋙ forget₂ CommSemiRingCat SemiRingCat.{max v u})) set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_comm_semiring CommSemiRingCat.limitCommSemiring /-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := -- Porting note : `CommSemiRingCat ⥤ Type` reflecting isomorphism is needed to make Lean see that -- `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism. `CommSemiRingCat ⥤ Type` reflecting -- isomorphism is added manually since Lean can't see it, but even with this addition Lean can not -- see `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism, so this instance is also added. letI : ReflectsIsomorphisms (forget CommSemiRingCatMax.{v, u}) := CommSemiRingCat.forgetReflectIsos.{max v u} letI : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := CategoryTheory.reflectsIsomorphisms_forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u} let c : Cone F := { pt := CommSemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun j => CommSemiRingCat.ofHom <| SemiRingCat.limitπRingHom.{v, u} (J := J) (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) j naturality := (SemiRingCat.HasLimits.limitCone.{v, u} (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) t makesLimit := by refine IsLimit.ofFaithful (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) (fun s : Cone F => CommSemiRingCat.ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by
exact (s.π.app j).map_one
/-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := -- Porting note : `CommSemiRingCat ⥤ Type` reflecting isomorphism is needed to make Lean see that -- `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism. `CommSemiRingCat ⥤ Type` reflecting -- isomorphism is added manually since Lean can't see it, but even with this addition Lean can not -- see `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism, so this instance is also added. letI : ReflectsIsomorphisms (forget CommSemiRingCatMax.{v, u}) := CommSemiRingCat.forgetReflectIsos.{max v u} letI : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := CategoryTheory.reflectsIsomorphisms_forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u} let c : Cone F := { pt := CommSemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun j => CommSemiRingCat.ofHom <| SemiRingCat.limitπRingHom.{v, u} (J := J) (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) j naturality := (SemiRingCat.HasLimits.limitCone.{v, u} (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) t makesLimit := by refine IsLimit.ofFaithful (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) (fun s : Cone F => CommSemiRingCat.ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by
Mathlib.Algebra.Category.Ring.Limits.220_0.VxjNIkMLPSqe2rX
/-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ CommSemiRingCatMax this✝ : ReflectsIsomorphisms (forget CommSemiRingCatMax) := forgetReflectIsos this : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax SemiRingCatMax) := reflectsIsomorphisms_forget₂ CommSemiRingCatMax SemiRingCatMax c : Cone F := { pt := of (Types.limitCone (F ⋙ forget CommSemiRingCatMax)).pt, π := NatTrans.mk fun j => ofHom (SemiRingCat.limitπRingHom (F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) j) } c' : Cone (F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) t : IsLimit c' s : Cone F x y : ↑s.1 j : J ⊢ ↑(OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' 1) } = 1) } (x * y)) j = ↑(OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' 1) } = 1) } x * OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' 1) } = 1) } y) j
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align SemiRing.semiring_obj SemiRingCat.semiringObj /-- The flat sections of a functor into `SemiRingCat` form a subsemiring of all sections. -/ def sectionsSubsemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Subsemiring.{max v u} (∀ j, F.obj j) := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat letI g : J ⥤ MonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} MonCat.{max v u} { (MonCat.sectionsSubmonoid.{v, u} (J := J) g), (AddMonCat.sectionsAddSubmonoid.{v, u} (J := J) f) with carrier := (F ⋙ forget SemiRingCat).sections } set_option linter.uppercaseLean3 false in #align SemiRing.sections_subsemiring SemiRingCat.sectionsSubsemiring instance limitSemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Semiring (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat.{max v u})).pt := (sectionsSubsemiring F).toSemiring set_option linter.uppercaseLean3 false in #align SemiRing.limit_semiring SemiRingCat.limitSemiring /-- `limit.π (F ⋙ forget SemiRingCat) j` as a `RingHom`. -/ def limitπRingHom (F : J ⥤ SemiRingCatMax.{v, u}) (j) : (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat)).pt →+* (F ⋙ forget SemiRingCat).obj j := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat { AddMonCat.limitπAddMonoidHom f j, MonCat.limitπMonoidHom (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) j with toFun := (Types.limitCone (F ⋙ forget SemiRingCat)).π.app j } set_option linter.uppercaseLean3 false in #align SemiRing.limit_π_ring_hom SemiRingCat.limitπRingHom namespace HasLimits -- The next two definitions are used in the construction of `HasLimits SemiRingCat`. -- After that, the limits should be constructed using the generic limits API, -- e.g. `limit F`, `limit.cone F`, and `limit.isLimit F`. /-- Construction of a limit cone in `SemiRingCat`. (Internal use only; use the limits API.) -/ def limitCone (F : J ⥤ SemiRingCatMax.{v, u}) : Cone F where pt := SemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := limitπRingHom.{v, u} F naturality := fun {_ _} f => RingHom.coe_inj ((Types.limitCone (F ⋙ forget _)).π.naturality f) } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone SemiRingCat.HasLimits.limitCone /-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone_is_limit SemiRingCat.HasLimits.limitConeIsLimit end HasLimits open HasLimits /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v} SemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => ⟨limitCone.{v, u} F, limitConeIsLimit.{v, u} F⟩ } } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits_of_size SemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits SemiRingCat.{u} := SemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.has_limits SemiRingCat.hasLimits /-- Auxiliary lemma to prove the cone induced by `limitCone` is a limit cone. -/ def forget₂AddCommMonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat AddCommMonCat).mapCone (limitCone F)) := by apply AddCommMonCat.limitConeIsLimit.{v, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_aux SemiRingCat.forget₂AddCommMonPreservesLimitsAux /-- The forgetful functor from semirings to additive commutative monoids preserves all limits. -/ instance forget₂AddCommMonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat AddCommMonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (forget₂AddCommMonPreservesLimitsAux F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_of_size SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize instance forget₂AddCommMonPreservesLimits : PreservesLimits (forget₂ SemiRingCat AddCommMonCat.{u}) := SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits SemiRingCat.forget₂AddCommMonPreservesLimits /-- An auxiliary declaration to speed up typechecking. -/ def forget₂MonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat MonCat).mapCone (limitCone F)) := by apply MonCat.HasLimits.limitConeIsLimit (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_aux SemiRingCat.forget₂MonPreservesLimitsAux /-- The forgetful functor from semirings to monoids preserves all limits. -/ instance forget₂MonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat MonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (forget₂MonPreservesLimitsAux.{v, u} F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_of_size SemiRingCat.forget₂MonPreservesLimitsOfSize instance forget₂MonPreservesLimits : PreservesLimits (forget₂ SemiRingCat MonCat.{u}) := SemiRingCat.forget₂MonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits SemiRingCat.forget₂MonPreservesLimits /-- The forgetful functor from semirings to types preserves all limits. -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (Types.limitConeIsLimit.{v, u} (F ⋙ forget _)) } set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits_of_size SemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget SemiRingCat.{u}) := SemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits SemiRingCat.forgetPreservesLimits end SemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `CommSemiring.{max u v}`, to deal with unification issues. -/ @[nolint checkUnivs] abbrev CommSemiRingCatMax.{u1, u2} := CommSemiRingCat.{max u1 u2} namespace CommSemiRingCat variable {J : Type v} [SmallCategory J] instance commSemiringObj (F : J ⥤ CommSemiRingCatMax.{v, u}) (j) : CommSemiring ((F ⋙ forget CommSemiRingCat).obj j) := by change CommSemiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align CommSemiRing.comm_semiring_obj CommSemiRingCat.commSemiringObj instance limitCommSemiring (F : J ⥤ CommSemiRingCatMax.{v, u}) : CommSemiring (Types.limitCone.{v, u} (F ⋙ forget CommSemiRingCat.{max v u})).pt := @Subsemiring.toCommSemiring (∀ j, F.obj j) _ (SemiRingCat.sectionsSubsemiring.{v, u} (F ⋙ forget₂ CommSemiRingCat SemiRingCat.{max v u})) set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_comm_semiring CommSemiRingCat.limitCommSemiring /-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := -- Porting note : `CommSemiRingCat ⥤ Type` reflecting isomorphism is needed to make Lean see that -- `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism. `CommSemiRingCat ⥤ Type` reflecting -- isomorphism is added manually since Lean can't see it, but even with this addition Lean can not -- see `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism, so this instance is also added. letI : ReflectsIsomorphisms (forget CommSemiRingCatMax.{v, u}) := CommSemiRingCat.forgetReflectIsos.{max v u} letI : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := CategoryTheory.reflectsIsomorphisms_forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u} let c : Cone F := { pt := CommSemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun j => CommSemiRingCat.ofHom <| SemiRingCat.limitπRingHom.{v, u} (J := J) (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) j naturality := (SemiRingCat.HasLimits.limitCone.{v, u} (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) t makesLimit := by refine IsLimit.ofFaithful (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) (fun s : Cone F => CommSemiRingCat.ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by
exact (s.π.app j).map_mul x y
/-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := -- Porting note : `CommSemiRingCat ⥤ Type` reflecting isomorphism is needed to make Lean see that -- `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism. `CommSemiRingCat ⥤ Type` reflecting -- isomorphism is added manually since Lean can't see it, but even with this addition Lean can not -- see `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism, so this instance is also added. letI : ReflectsIsomorphisms (forget CommSemiRingCatMax.{v, u}) := CommSemiRingCat.forgetReflectIsos.{max v u} letI : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := CategoryTheory.reflectsIsomorphisms_forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u} let c : Cone F := { pt := CommSemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun j => CommSemiRingCat.ofHom <| SemiRingCat.limitπRingHom.{v, u} (J := J) (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) j naturality := (SemiRingCat.HasLimits.limitCone.{v, u} (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) t makesLimit := by refine IsLimit.ofFaithful (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) (fun s : Cone F => CommSemiRingCat.ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by
Mathlib.Algebra.Category.Ring.Limits.220_0.VxjNIkMLPSqe2rX
/-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ CommSemiRingCatMax this✝ : ReflectsIsomorphisms (forget CommSemiRingCatMax) := forgetReflectIsos this : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax SemiRingCatMax) := reflectsIsomorphisms_forget₂ CommSemiRingCatMax SemiRingCatMax c : Cone F := { pt := of (Types.limitCone (F ⋙ forget CommSemiRingCatMax)).pt, π := NatTrans.mk fun j => ofHom (SemiRingCat.limitπRingHom (F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) j) } c' : Cone (F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) t : IsLimit c' s : Cone F j : J ⊢ ↑(OneHom.toFun (↑{ toOneHom := { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' 1) } = 1) }, map_mul' := (_ : ∀ (x y : ↑s.1), OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' 1) } = 1) } (x * y) = OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' 1) } = 1) } x * OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' 1) } = 1) } y) }) 0) j = ↑0 j
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align SemiRing.semiring_obj SemiRingCat.semiringObj /-- The flat sections of a functor into `SemiRingCat` form a subsemiring of all sections. -/ def sectionsSubsemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Subsemiring.{max v u} (∀ j, F.obj j) := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat letI g : J ⥤ MonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} MonCat.{max v u} { (MonCat.sectionsSubmonoid.{v, u} (J := J) g), (AddMonCat.sectionsAddSubmonoid.{v, u} (J := J) f) with carrier := (F ⋙ forget SemiRingCat).sections } set_option linter.uppercaseLean3 false in #align SemiRing.sections_subsemiring SemiRingCat.sectionsSubsemiring instance limitSemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Semiring (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat.{max v u})).pt := (sectionsSubsemiring F).toSemiring set_option linter.uppercaseLean3 false in #align SemiRing.limit_semiring SemiRingCat.limitSemiring /-- `limit.π (F ⋙ forget SemiRingCat) j` as a `RingHom`. -/ def limitπRingHom (F : J ⥤ SemiRingCatMax.{v, u}) (j) : (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat)).pt →+* (F ⋙ forget SemiRingCat).obj j := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat { AddMonCat.limitπAddMonoidHom f j, MonCat.limitπMonoidHom (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) j with toFun := (Types.limitCone (F ⋙ forget SemiRingCat)).π.app j } set_option linter.uppercaseLean3 false in #align SemiRing.limit_π_ring_hom SemiRingCat.limitπRingHom namespace HasLimits -- The next two definitions are used in the construction of `HasLimits SemiRingCat`. -- After that, the limits should be constructed using the generic limits API, -- e.g. `limit F`, `limit.cone F`, and `limit.isLimit F`. /-- Construction of a limit cone in `SemiRingCat`. (Internal use only; use the limits API.) -/ def limitCone (F : J ⥤ SemiRingCatMax.{v, u}) : Cone F where pt := SemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := limitπRingHom.{v, u} F naturality := fun {_ _} f => RingHom.coe_inj ((Types.limitCone (F ⋙ forget _)).π.naturality f) } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone SemiRingCat.HasLimits.limitCone /-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone_is_limit SemiRingCat.HasLimits.limitConeIsLimit end HasLimits open HasLimits /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v} SemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => ⟨limitCone.{v, u} F, limitConeIsLimit.{v, u} F⟩ } } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits_of_size SemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits SemiRingCat.{u} := SemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.has_limits SemiRingCat.hasLimits /-- Auxiliary lemma to prove the cone induced by `limitCone` is a limit cone. -/ def forget₂AddCommMonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat AddCommMonCat).mapCone (limitCone F)) := by apply AddCommMonCat.limitConeIsLimit.{v, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_aux SemiRingCat.forget₂AddCommMonPreservesLimitsAux /-- The forgetful functor from semirings to additive commutative monoids preserves all limits. -/ instance forget₂AddCommMonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat AddCommMonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (forget₂AddCommMonPreservesLimitsAux F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_of_size SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize instance forget₂AddCommMonPreservesLimits : PreservesLimits (forget₂ SemiRingCat AddCommMonCat.{u}) := SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits SemiRingCat.forget₂AddCommMonPreservesLimits /-- An auxiliary declaration to speed up typechecking. -/ def forget₂MonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat MonCat).mapCone (limitCone F)) := by apply MonCat.HasLimits.limitConeIsLimit (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_aux SemiRingCat.forget₂MonPreservesLimitsAux /-- The forgetful functor from semirings to monoids preserves all limits. -/ instance forget₂MonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat MonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (forget₂MonPreservesLimitsAux.{v, u} F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_of_size SemiRingCat.forget₂MonPreservesLimitsOfSize instance forget₂MonPreservesLimits : PreservesLimits (forget₂ SemiRingCat MonCat.{u}) := SemiRingCat.forget₂MonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits SemiRingCat.forget₂MonPreservesLimits /-- The forgetful functor from semirings to types preserves all limits. -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (Types.limitConeIsLimit.{v, u} (F ⋙ forget _)) } set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits_of_size SemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget SemiRingCat.{u}) := SemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits SemiRingCat.forgetPreservesLimits end SemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `CommSemiring.{max u v}`, to deal with unification issues. -/ @[nolint checkUnivs] abbrev CommSemiRingCatMax.{u1, u2} := CommSemiRingCat.{max u1 u2} namespace CommSemiRingCat variable {J : Type v} [SmallCategory J] instance commSemiringObj (F : J ⥤ CommSemiRingCatMax.{v, u}) (j) : CommSemiring ((F ⋙ forget CommSemiRingCat).obj j) := by change CommSemiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align CommSemiRing.comm_semiring_obj CommSemiRingCat.commSemiringObj instance limitCommSemiring (F : J ⥤ CommSemiRingCatMax.{v, u}) : CommSemiring (Types.limitCone.{v, u} (F ⋙ forget CommSemiRingCat.{max v u})).pt := @Subsemiring.toCommSemiring (∀ j, F.obj j) _ (SemiRingCat.sectionsSubsemiring.{v, u} (F ⋙ forget₂ CommSemiRingCat SemiRingCat.{max v u})) set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_comm_semiring CommSemiRingCat.limitCommSemiring /-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := -- Porting note : `CommSemiRingCat ⥤ Type` reflecting isomorphism is needed to make Lean see that -- `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism. `CommSemiRingCat ⥤ Type` reflecting -- isomorphism is added manually since Lean can't see it, but even with this addition Lean can not -- see `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism, so this instance is also added. letI : ReflectsIsomorphisms (forget CommSemiRingCatMax.{v, u}) := CommSemiRingCat.forgetReflectIsos.{max v u} letI : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := CategoryTheory.reflectsIsomorphisms_forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u} let c : Cone F := { pt := CommSemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun j => CommSemiRingCat.ofHom <| SemiRingCat.limitπRingHom.{v, u} (J := J) (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) j naturality := (SemiRingCat.HasLimits.limitCone.{v, u} (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) t makesLimit := by refine IsLimit.ofFaithful (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) (fun s : Cone F => CommSemiRingCat.ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by
exact (s.π.app j).map_zero
/-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := -- Porting note : `CommSemiRingCat ⥤ Type` reflecting isomorphism is needed to make Lean see that -- `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism. `CommSemiRingCat ⥤ Type` reflecting -- isomorphism is added manually since Lean can't see it, but even with this addition Lean can not -- see `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism, so this instance is also added. letI : ReflectsIsomorphisms (forget CommSemiRingCatMax.{v, u}) := CommSemiRingCat.forgetReflectIsos.{max v u} letI : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := CategoryTheory.reflectsIsomorphisms_forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u} let c : Cone F := { pt := CommSemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun j => CommSemiRingCat.ofHom <| SemiRingCat.limitπRingHom.{v, u} (J := J) (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) j naturality := (SemiRingCat.HasLimits.limitCone.{v, u} (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) t makesLimit := by refine IsLimit.ofFaithful (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) (fun s : Cone F => CommSemiRingCat.ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by
Mathlib.Algebra.Category.Ring.Limits.220_0.VxjNIkMLPSqe2rX
/-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ CommSemiRingCatMax this✝ : ReflectsIsomorphisms (forget CommSemiRingCatMax) := forgetReflectIsos this : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax SemiRingCatMax) := reflectsIsomorphisms_forget₂ CommSemiRingCatMax SemiRingCatMax c : Cone F := { pt := of (Types.limitCone (F ⋙ forget CommSemiRingCatMax)).pt, π := NatTrans.mk fun j => ofHom (SemiRingCat.limitπRingHom (F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) j) } c' : Cone (F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) t : IsLimit c' s : Cone F x y : ↑s.1 j : J ⊢ ↑(OneHom.toFun (↑{ toOneHom := { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' 1) } = 1) }, map_mul' := (_ : ∀ (x y : ↑s.1), OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' 1) } = 1) } (x * y) = OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' 1) } = 1) } x * OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' 1) } = 1) } y) }) (x + y)) j = ↑(OneHom.toFun (↑{ toOneHom := { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' 1) } = 1) }, map_mul' := (_ : ∀ (x y : ↑s.1), OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' 1) } = 1) } (x * y) = OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' 1) } = 1) } x * OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' 1) } = 1) } y) }) x + OneHom.toFun (↑{ toOneHom := { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' 1) } = 1) }, map_mul' := (_ : ∀ (x y : ↑s.1), OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' 1) } = 1) } (x * y) = OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' 1) } = 1) } x * OneHom.toFun { toFun := fun v => { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j v, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) v = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' v) }, map_one' := (_ : { val := fun j => ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j 1, property := (_ : ∀ {j j' : J} (f : j ⟶ j'), (((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j ≫ ((F ⋙ forget₂ CommSemiRingCatMax SemiRingCatMax) ⋙ forget SemiRingCatMax).map f) 1 = ((forget SemiRingCatMax).mapCone ((forget₂ CommSemiRingCatMax SemiRingCatMax).mapCone s)).π.app j' 1) } = 1) } y) }) y) j
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align SemiRing.semiring_obj SemiRingCat.semiringObj /-- The flat sections of a functor into `SemiRingCat` form a subsemiring of all sections. -/ def sectionsSubsemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Subsemiring.{max v u} (∀ j, F.obj j) := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat letI g : J ⥤ MonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} MonCat.{max v u} { (MonCat.sectionsSubmonoid.{v, u} (J := J) g), (AddMonCat.sectionsAddSubmonoid.{v, u} (J := J) f) with carrier := (F ⋙ forget SemiRingCat).sections } set_option linter.uppercaseLean3 false in #align SemiRing.sections_subsemiring SemiRingCat.sectionsSubsemiring instance limitSemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Semiring (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat.{max v u})).pt := (sectionsSubsemiring F).toSemiring set_option linter.uppercaseLean3 false in #align SemiRing.limit_semiring SemiRingCat.limitSemiring /-- `limit.π (F ⋙ forget SemiRingCat) j` as a `RingHom`. -/ def limitπRingHom (F : J ⥤ SemiRingCatMax.{v, u}) (j) : (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat)).pt →+* (F ⋙ forget SemiRingCat).obj j := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat { AddMonCat.limitπAddMonoidHom f j, MonCat.limitπMonoidHom (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) j with toFun := (Types.limitCone (F ⋙ forget SemiRingCat)).π.app j } set_option linter.uppercaseLean3 false in #align SemiRing.limit_π_ring_hom SemiRingCat.limitπRingHom namespace HasLimits -- The next two definitions are used in the construction of `HasLimits SemiRingCat`. -- After that, the limits should be constructed using the generic limits API, -- e.g. `limit F`, `limit.cone F`, and `limit.isLimit F`. /-- Construction of a limit cone in `SemiRingCat`. (Internal use only; use the limits API.) -/ def limitCone (F : J ⥤ SemiRingCatMax.{v, u}) : Cone F where pt := SemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := limitπRingHom.{v, u} F naturality := fun {_ _} f => RingHom.coe_inj ((Types.limitCone (F ⋙ forget _)).π.naturality f) } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone SemiRingCat.HasLimits.limitCone /-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone_is_limit SemiRingCat.HasLimits.limitConeIsLimit end HasLimits open HasLimits /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v} SemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => ⟨limitCone.{v, u} F, limitConeIsLimit.{v, u} F⟩ } } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits_of_size SemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits SemiRingCat.{u} := SemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.has_limits SemiRingCat.hasLimits /-- Auxiliary lemma to prove the cone induced by `limitCone` is a limit cone. -/ def forget₂AddCommMonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat AddCommMonCat).mapCone (limitCone F)) := by apply AddCommMonCat.limitConeIsLimit.{v, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_aux SemiRingCat.forget₂AddCommMonPreservesLimitsAux /-- The forgetful functor from semirings to additive commutative monoids preserves all limits. -/ instance forget₂AddCommMonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat AddCommMonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (forget₂AddCommMonPreservesLimitsAux F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_of_size SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize instance forget₂AddCommMonPreservesLimits : PreservesLimits (forget₂ SemiRingCat AddCommMonCat.{u}) := SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits SemiRingCat.forget₂AddCommMonPreservesLimits /-- An auxiliary declaration to speed up typechecking. -/ def forget₂MonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat MonCat).mapCone (limitCone F)) := by apply MonCat.HasLimits.limitConeIsLimit (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_aux SemiRingCat.forget₂MonPreservesLimitsAux /-- The forgetful functor from semirings to monoids preserves all limits. -/ instance forget₂MonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat MonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (forget₂MonPreservesLimitsAux.{v, u} F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_of_size SemiRingCat.forget₂MonPreservesLimitsOfSize instance forget₂MonPreservesLimits : PreservesLimits (forget₂ SemiRingCat MonCat.{u}) := SemiRingCat.forget₂MonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits SemiRingCat.forget₂MonPreservesLimits /-- The forgetful functor from semirings to types preserves all limits. -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (Types.limitConeIsLimit.{v, u} (F ⋙ forget _)) } set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits_of_size SemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget SemiRingCat.{u}) := SemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits SemiRingCat.forgetPreservesLimits end SemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `CommSemiring.{max u v}`, to deal with unification issues. -/ @[nolint checkUnivs] abbrev CommSemiRingCatMax.{u1, u2} := CommSemiRingCat.{max u1 u2} namespace CommSemiRingCat variable {J : Type v} [SmallCategory J] instance commSemiringObj (F : J ⥤ CommSemiRingCatMax.{v, u}) (j) : CommSemiring ((F ⋙ forget CommSemiRingCat).obj j) := by change CommSemiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align CommSemiRing.comm_semiring_obj CommSemiRingCat.commSemiringObj instance limitCommSemiring (F : J ⥤ CommSemiRingCatMax.{v, u}) : CommSemiring (Types.limitCone.{v, u} (F ⋙ forget CommSemiRingCat.{max v u})).pt := @Subsemiring.toCommSemiring (∀ j, F.obj j) _ (SemiRingCat.sectionsSubsemiring.{v, u} (F ⋙ forget₂ CommSemiRingCat SemiRingCat.{max v u})) set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_comm_semiring CommSemiRingCat.limitCommSemiring /-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := -- Porting note : `CommSemiRingCat ⥤ Type` reflecting isomorphism is needed to make Lean see that -- `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism. `CommSemiRingCat ⥤ Type` reflecting -- isomorphism is added manually since Lean can't see it, but even with this addition Lean can not -- see `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism, so this instance is also added. letI : ReflectsIsomorphisms (forget CommSemiRingCatMax.{v, u}) := CommSemiRingCat.forgetReflectIsos.{max v u} letI : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := CategoryTheory.reflectsIsomorphisms_forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u} let c : Cone F := { pt := CommSemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun j => CommSemiRingCat.ofHom <| SemiRingCat.limitπRingHom.{v, u} (J := J) (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) j naturality := (SemiRingCat.HasLimits.limitCone.{v, u} (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) t makesLimit := by refine IsLimit.ofFaithful (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) (fun s : Cone F => CommSemiRingCat.ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by
exact (s.π.app j).map_add x y
/-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := -- Porting note : `CommSemiRingCat ⥤ Type` reflecting isomorphism is needed to make Lean see that -- `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism. `CommSemiRingCat ⥤ Type` reflecting -- isomorphism is added manually since Lean can't see it, but even with this addition Lean can not -- see `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism, so this instance is also added. letI : ReflectsIsomorphisms (forget CommSemiRingCatMax.{v, u}) := CommSemiRingCat.forgetReflectIsos.{max v u} letI : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := CategoryTheory.reflectsIsomorphisms_forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u} let c : Cone F := { pt := CommSemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun j => CommSemiRingCat.ofHom <| SemiRingCat.limitπRingHom.{v, u} (J := J) (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) j naturality := (SemiRingCat.HasLimits.limitCone.{v, u} (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) t makesLimit := by refine IsLimit.ofFaithful (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) (fun s : Cone F => CommSemiRingCat.ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by
Mathlib.Algebra.Category.Ring.Limits.220_0.VxjNIkMLPSqe2rX
/-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ RingCatMax j : J ⊢ Ring ((F ⋙ forget RingCat).obj j)
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align SemiRing.semiring_obj SemiRingCat.semiringObj /-- The flat sections of a functor into `SemiRingCat` form a subsemiring of all sections. -/ def sectionsSubsemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Subsemiring.{max v u} (∀ j, F.obj j) := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat letI g : J ⥤ MonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} MonCat.{max v u} { (MonCat.sectionsSubmonoid.{v, u} (J := J) g), (AddMonCat.sectionsAddSubmonoid.{v, u} (J := J) f) with carrier := (F ⋙ forget SemiRingCat).sections } set_option linter.uppercaseLean3 false in #align SemiRing.sections_subsemiring SemiRingCat.sectionsSubsemiring instance limitSemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Semiring (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat.{max v u})).pt := (sectionsSubsemiring F).toSemiring set_option linter.uppercaseLean3 false in #align SemiRing.limit_semiring SemiRingCat.limitSemiring /-- `limit.π (F ⋙ forget SemiRingCat) j` as a `RingHom`. -/ def limitπRingHom (F : J ⥤ SemiRingCatMax.{v, u}) (j) : (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat)).pt →+* (F ⋙ forget SemiRingCat).obj j := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat { AddMonCat.limitπAddMonoidHom f j, MonCat.limitπMonoidHom (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) j with toFun := (Types.limitCone (F ⋙ forget SemiRingCat)).π.app j } set_option linter.uppercaseLean3 false in #align SemiRing.limit_π_ring_hom SemiRingCat.limitπRingHom namespace HasLimits -- The next two definitions are used in the construction of `HasLimits SemiRingCat`. -- After that, the limits should be constructed using the generic limits API, -- e.g. `limit F`, `limit.cone F`, and `limit.isLimit F`. /-- Construction of a limit cone in `SemiRingCat`. (Internal use only; use the limits API.) -/ def limitCone (F : J ⥤ SemiRingCatMax.{v, u}) : Cone F where pt := SemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := limitπRingHom.{v, u} F naturality := fun {_ _} f => RingHom.coe_inj ((Types.limitCone (F ⋙ forget _)).π.naturality f) } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone SemiRingCat.HasLimits.limitCone /-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone_is_limit SemiRingCat.HasLimits.limitConeIsLimit end HasLimits open HasLimits /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v} SemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => ⟨limitCone.{v, u} F, limitConeIsLimit.{v, u} F⟩ } } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits_of_size SemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits SemiRingCat.{u} := SemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.has_limits SemiRingCat.hasLimits /-- Auxiliary lemma to prove the cone induced by `limitCone` is a limit cone. -/ def forget₂AddCommMonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat AddCommMonCat).mapCone (limitCone F)) := by apply AddCommMonCat.limitConeIsLimit.{v, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_aux SemiRingCat.forget₂AddCommMonPreservesLimitsAux /-- The forgetful functor from semirings to additive commutative monoids preserves all limits. -/ instance forget₂AddCommMonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat AddCommMonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (forget₂AddCommMonPreservesLimitsAux F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_of_size SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize instance forget₂AddCommMonPreservesLimits : PreservesLimits (forget₂ SemiRingCat AddCommMonCat.{u}) := SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits SemiRingCat.forget₂AddCommMonPreservesLimits /-- An auxiliary declaration to speed up typechecking. -/ def forget₂MonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat MonCat).mapCone (limitCone F)) := by apply MonCat.HasLimits.limitConeIsLimit (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_aux SemiRingCat.forget₂MonPreservesLimitsAux /-- The forgetful functor from semirings to monoids preserves all limits. -/ instance forget₂MonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat MonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (forget₂MonPreservesLimitsAux.{v, u} F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_of_size SemiRingCat.forget₂MonPreservesLimitsOfSize instance forget₂MonPreservesLimits : PreservesLimits (forget₂ SemiRingCat MonCat.{u}) := SemiRingCat.forget₂MonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits SemiRingCat.forget₂MonPreservesLimits /-- The forgetful functor from semirings to types preserves all limits. -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (Types.limitConeIsLimit.{v, u} (F ⋙ forget _)) } set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits_of_size SemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget SemiRingCat.{u}) := SemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits SemiRingCat.forgetPreservesLimits end SemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `CommSemiring.{max u v}`, to deal with unification issues. -/ @[nolint checkUnivs] abbrev CommSemiRingCatMax.{u1, u2} := CommSemiRingCat.{max u1 u2} namespace CommSemiRingCat variable {J : Type v} [SmallCategory J] instance commSemiringObj (F : J ⥤ CommSemiRingCatMax.{v, u}) (j) : CommSemiring ((F ⋙ forget CommSemiRingCat).obj j) := by change CommSemiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align CommSemiRing.comm_semiring_obj CommSemiRingCat.commSemiringObj instance limitCommSemiring (F : J ⥤ CommSemiRingCatMax.{v, u}) : CommSemiring (Types.limitCone.{v, u} (F ⋙ forget CommSemiRingCat.{max v u})).pt := @Subsemiring.toCommSemiring (∀ j, F.obj j) _ (SemiRingCat.sectionsSubsemiring.{v, u} (F ⋙ forget₂ CommSemiRingCat SemiRingCat.{max v u})) set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_comm_semiring CommSemiRingCat.limitCommSemiring /-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := -- Porting note : `CommSemiRingCat ⥤ Type` reflecting isomorphism is needed to make Lean see that -- `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism. `CommSemiRingCat ⥤ Type` reflecting -- isomorphism is added manually since Lean can't see it, but even with this addition Lean can not -- see `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism, so this instance is also added. letI : ReflectsIsomorphisms (forget CommSemiRingCatMax.{v, u}) := CommSemiRingCat.forgetReflectIsos.{max v u} letI : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := CategoryTheory.reflectsIsomorphisms_forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u} let c : Cone F := { pt := CommSemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun j => CommSemiRingCat.ofHom <| SemiRingCat.limitπRingHom.{v, u} (J := J) (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) j naturality := (SemiRingCat.HasLimits.limitCone.{v, u} (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) t makesLimit := by refine IsLimit.ofFaithful (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) (fun s : Cone F => CommSemiRingCat.ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl } /-- A choice of limit cone for a functor into `CommSemiRingCat`. (Generally, you'll just want to use `limit F`.) -/ def limitCone (F : J ⥤ CommSemiRingCatMax.{v, u}) : Cone F := liftLimit (limit.isLimit (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})) set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_cone CommSemiRingCat.limitCone /-- The chosen cone is a limit cone. (Generally, you'll just want to use `limit.cone F`.) -/ def limitConeIsLimit (F : J ⥤ CommSemiRingCatMax.{v, u}) : IsLimit (limitCone F) := liftedLimitIsLimit _ set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_cone_is_limit CommSemiRingCat.limitConeIsLimit /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v, v} CommSemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => hasLimit_of_created F (forget₂ CommSemiRingCat SemiRingCatMax.{v, u}) } } set_option linter.uppercaseLean3 false in #align CommSemiRing.has_limits_of_size CommSemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits CommSemiRingCat.{u} := CommSemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.has_limits CommSemiRingCat.hasLimits /-- The forgetful functor from rings to semirings preserves all limits. -/ instance forget₂SemiRingPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ CommSemiRingCat SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (SemiRingCat.HasLimits.limitConeIsLimit _) } set_option linter.uppercaseLean3 false in #align CommSemiRing.forget₂_SemiRing_preserves_limits_of_size CommSemiRingCat.forget₂SemiRingPreservesLimitsOfSize instance forget₂SemiRingPreservesLimits : PreservesLimits (forget₂ CommSemiRingCat SemiRingCat.{u}) := CommSemiRingCat.forget₂SemiRingPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.forget₂_SemiRing_preserves_limits CommSemiRingCat.forget₂SemiRingPreservesLimits /-- The forgetful functor from rings to types preserves all limits. (That is, the underlying types could have been computed instead as limits in the category of types.) -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget CommSemiRingCatMax.{v, u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (Types.limitConeIsLimit.{v, u} _) } set_option linter.uppercaseLean3 false in #align CommSemiRing.forget_preserves_limits_of_size CommSemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget CommSemiRingCat.{u}) := CommSemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.forget_preserves_limits CommSemiRingCat.forgetPreservesLimits end CommSemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `RingCat.{max u v}`, to deal around unification issues. -/ @[nolint checkUnivs] abbrev RingCatMax.{u1, u2} := RingCat.{max u1 u2} namespace RingCat variable {J : Type v} [SmallCategory J] instance ringObj (F : J ⥤ RingCatMax.{v, u}) (j) : Ring ((F ⋙ forget RingCat).obj j) := by
change Ring (F.obj j)
instance ringObj (F : J ⥤ RingCatMax.{v, u}) (j) : Ring ((F ⋙ forget RingCat).obj j) := by
Mathlib.Algebra.Category.Ring.Limits.333_0.VxjNIkMLPSqe2rX
instance ringObj (F : J ⥤ RingCatMax.{v, u}) (j) : Ring ((F ⋙ forget RingCat).obj j)
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ RingCatMax j : J ⊢ Ring ↑(F.obj j)
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align SemiRing.semiring_obj SemiRingCat.semiringObj /-- The flat sections of a functor into `SemiRingCat` form a subsemiring of all sections. -/ def sectionsSubsemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Subsemiring.{max v u} (∀ j, F.obj j) := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat letI g : J ⥤ MonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} MonCat.{max v u} { (MonCat.sectionsSubmonoid.{v, u} (J := J) g), (AddMonCat.sectionsAddSubmonoid.{v, u} (J := J) f) with carrier := (F ⋙ forget SemiRingCat).sections } set_option linter.uppercaseLean3 false in #align SemiRing.sections_subsemiring SemiRingCat.sectionsSubsemiring instance limitSemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Semiring (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat.{max v u})).pt := (sectionsSubsemiring F).toSemiring set_option linter.uppercaseLean3 false in #align SemiRing.limit_semiring SemiRingCat.limitSemiring /-- `limit.π (F ⋙ forget SemiRingCat) j` as a `RingHom`. -/ def limitπRingHom (F : J ⥤ SemiRingCatMax.{v, u}) (j) : (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat)).pt →+* (F ⋙ forget SemiRingCat).obj j := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat { AddMonCat.limitπAddMonoidHom f j, MonCat.limitπMonoidHom (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) j with toFun := (Types.limitCone (F ⋙ forget SemiRingCat)).π.app j } set_option linter.uppercaseLean3 false in #align SemiRing.limit_π_ring_hom SemiRingCat.limitπRingHom namespace HasLimits -- The next two definitions are used in the construction of `HasLimits SemiRingCat`. -- After that, the limits should be constructed using the generic limits API, -- e.g. `limit F`, `limit.cone F`, and `limit.isLimit F`. /-- Construction of a limit cone in `SemiRingCat`. (Internal use only; use the limits API.) -/ def limitCone (F : J ⥤ SemiRingCatMax.{v, u}) : Cone F where pt := SemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := limitπRingHom.{v, u} F naturality := fun {_ _} f => RingHom.coe_inj ((Types.limitCone (F ⋙ forget _)).π.naturality f) } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone SemiRingCat.HasLimits.limitCone /-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone_is_limit SemiRingCat.HasLimits.limitConeIsLimit end HasLimits open HasLimits /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v} SemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => ⟨limitCone.{v, u} F, limitConeIsLimit.{v, u} F⟩ } } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits_of_size SemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits SemiRingCat.{u} := SemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.has_limits SemiRingCat.hasLimits /-- Auxiliary lemma to prove the cone induced by `limitCone` is a limit cone. -/ def forget₂AddCommMonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat AddCommMonCat).mapCone (limitCone F)) := by apply AddCommMonCat.limitConeIsLimit.{v, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_aux SemiRingCat.forget₂AddCommMonPreservesLimitsAux /-- The forgetful functor from semirings to additive commutative monoids preserves all limits. -/ instance forget₂AddCommMonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat AddCommMonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (forget₂AddCommMonPreservesLimitsAux F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_of_size SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize instance forget₂AddCommMonPreservesLimits : PreservesLimits (forget₂ SemiRingCat AddCommMonCat.{u}) := SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits SemiRingCat.forget₂AddCommMonPreservesLimits /-- An auxiliary declaration to speed up typechecking. -/ def forget₂MonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat MonCat).mapCone (limitCone F)) := by apply MonCat.HasLimits.limitConeIsLimit (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_aux SemiRingCat.forget₂MonPreservesLimitsAux /-- The forgetful functor from semirings to monoids preserves all limits. -/ instance forget₂MonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat MonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (forget₂MonPreservesLimitsAux.{v, u} F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_of_size SemiRingCat.forget₂MonPreservesLimitsOfSize instance forget₂MonPreservesLimits : PreservesLimits (forget₂ SemiRingCat MonCat.{u}) := SemiRingCat.forget₂MonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits SemiRingCat.forget₂MonPreservesLimits /-- The forgetful functor from semirings to types preserves all limits. -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (Types.limitConeIsLimit.{v, u} (F ⋙ forget _)) } set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits_of_size SemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget SemiRingCat.{u}) := SemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits SemiRingCat.forgetPreservesLimits end SemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `CommSemiring.{max u v}`, to deal with unification issues. -/ @[nolint checkUnivs] abbrev CommSemiRingCatMax.{u1, u2} := CommSemiRingCat.{max u1 u2} namespace CommSemiRingCat variable {J : Type v} [SmallCategory J] instance commSemiringObj (F : J ⥤ CommSemiRingCatMax.{v, u}) (j) : CommSemiring ((F ⋙ forget CommSemiRingCat).obj j) := by change CommSemiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align CommSemiRing.comm_semiring_obj CommSemiRingCat.commSemiringObj instance limitCommSemiring (F : J ⥤ CommSemiRingCatMax.{v, u}) : CommSemiring (Types.limitCone.{v, u} (F ⋙ forget CommSemiRingCat.{max v u})).pt := @Subsemiring.toCommSemiring (∀ j, F.obj j) _ (SemiRingCat.sectionsSubsemiring.{v, u} (F ⋙ forget₂ CommSemiRingCat SemiRingCat.{max v u})) set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_comm_semiring CommSemiRingCat.limitCommSemiring /-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := -- Porting note : `CommSemiRingCat ⥤ Type` reflecting isomorphism is needed to make Lean see that -- `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism. `CommSemiRingCat ⥤ Type` reflecting -- isomorphism is added manually since Lean can't see it, but even with this addition Lean can not -- see `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism, so this instance is also added. letI : ReflectsIsomorphisms (forget CommSemiRingCatMax.{v, u}) := CommSemiRingCat.forgetReflectIsos.{max v u} letI : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := CategoryTheory.reflectsIsomorphisms_forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u} let c : Cone F := { pt := CommSemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun j => CommSemiRingCat.ofHom <| SemiRingCat.limitπRingHom.{v, u} (J := J) (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) j naturality := (SemiRingCat.HasLimits.limitCone.{v, u} (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) t makesLimit := by refine IsLimit.ofFaithful (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) (fun s : Cone F => CommSemiRingCat.ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl } /-- A choice of limit cone for a functor into `CommSemiRingCat`. (Generally, you'll just want to use `limit F`.) -/ def limitCone (F : J ⥤ CommSemiRingCatMax.{v, u}) : Cone F := liftLimit (limit.isLimit (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})) set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_cone CommSemiRingCat.limitCone /-- The chosen cone is a limit cone. (Generally, you'll just want to use `limit.cone F`.) -/ def limitConeIsLimit (F : J ⥤ CommSemiRingCatMax.{v, u}) : IsLimit (limitCone F) := liftedLimitIsLimit _ set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_cone_is_limit CommSemiRingCat.limitConeIsLimit /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v, v} CommSemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => hasLimit_of_created F (forget₂ CommSemiRingCat SemiRingCatMax.{v, u}) } } set_option linter.uppercaseLean3 false in #align CommSemiRing.has_limits_of_size CommSemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits CommSemiRingCat.{u} := CommSemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.has_limits CommSemiRingCat.hasLimits /-- The forgetful functor from rings to semirings preserves all limits. -/ instance forget₂SemiRingPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ CommSemiRingCat SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (SemiRingCat.HasLimits.limitConeIsLimit _) } set_option linter.uppercaseLean3 false in #align CommSemiRing.forget₂_SemiRing_preserves_limits_of_size CommSemiRingCat.forget₂SemiRingPreservesLimitsOfSize instance forget₂SemiRingPreservesLimits : PreservesLimits (forget₂ CommSemiRingCat SemiRingCat.{u}) := CommSemiRingCat.forget₂SemiRingPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.forget₂_SemiRing_preserves_limits CommSemiRingCat.forget₂SemiRingPreservesLimits /-- The forgetful functor from rings to types preserves all limits. (That is, the underlying types could have been computed instead as limits in the category of types.) -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget CommSemiRingCatMax.{v, u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (Types.limitConeIsLimit.{v, u} _) } set_option linter.uppercaseLean3 false in #align CommSemiRing.forget_preserves_limits_of_size CommSemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget CommSemiRingCat.{u}) := CommSemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.forget_preserves_limits CommSemiRingCat.forgetPreservesLimits end CommSemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `RingCat.{max u v}`, to deal around unification issues. -/ @[nolint checkUnivs] abbrev RingCatMax.{u1, u2} := RingCat.{max u1 u2} namespace RingCat variable {J : Type v} [SmallCategory J] instance ringObj (F : J ⥤ RingCatMax.{v, u}) (j) : Ring ((F ⋙ forget RingCat).obj j) := by change Ring (F.obj j)
infer_instance
instance ringObj (F : J ⥤ RingCatMax.{v, u}) (j) : Ring ((F ⋙ forget RingCat).obj j) := by change Ring (F.obj j)
Mathlib.Algebra.Category.Ring.Limits.333_0.VxjNIkMLPSqe2rX
instance ringObj (F : J ⥤ RingCatMax.{v, u}) (j) : Ring ((F ⋙ forget RingCat).obj j)
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ RingCatMax this : ReflectsIsomorphisms (forget₂ RingCatMax SemiRingCatMax) := reflectsIsomorphisms_forget₂ RingCatMax SemiRingCatMax c : Cone F := { pt := of (Types.limitCone (F ⋙ forget RingCatMax)).pt, π := NatTrans.mk fun x => SemiRingCat.ofHom ((SemiRingCat.HasLimits.limitCone (F ⋙ forget₂ RingCat SemiRingCat)).π.app x) } c' : Cone (F ⋙ forget₂ RingCatMax SemiRingCatMax) t : IsLimit c' ⊢ (forget₂ RingCatMax SemiRingCatMax).mapCone c ≅ c'
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align SemiRing.semiring_obj SemiRingCat.semiringObj /-- The flat sections of a functor into `SemiRingCat` form a subsemiring of all sections. -/ def sectionsSubsemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Subsemiring.{max v u} (∀ j, F.obj j) := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat letI g : J ⥤ MonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} MonCat.{max v u} { (MonCat.sectionsSubmonoid.{v, u} (J := J) g), (AddMonCat.sectionsAddSubmonoid.{v, u} (J := J) f) with carrier := (F ⋙ forget SemiRingCat).sections } set_option linter.uppercaseLean3 false in #align SemiRing.sections_subsemiring SemiRingCat.sectionsSubsemiring instance limitSemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Semiring (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat.{max v u})).pt := (sectionsSubsemiring F).toSemiring set_option linter.uppercaseLean3 false in #align SemiRing.limit_semiring SemiRingCat.limitSemiring /-- `limit.π (F ⋙ forget SemiRingCat) j` as a `RingHom`. -/ def limitπRingHom (F : J ⥤ SemiRingCatMax.{v, u}) (j) : (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat)).pt →+* (F ⋙ forget SemiRingCat).obj j := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat { AddMonCat.limitπAddMonoidHom f j, MonCat.limitπMonoidHom (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) j with toFun := (Types.limitCone (F ⋙ forget SemiRingCat)).π.app j } set_option linter.uppercaseLean3 false in #align SemiRing.limit_π_ring_hom SemiRingCat.limitπRingHom namespace HasLimits -- The next two definitions are used in the construction of `HasLimits SemiRingCat`. -- After that, the limits should be constructed using the generic limits API, -- e.g. `limit F`, `limit.cone F`, and `limit.isLimit F`. /-- Construction of a limit cone in `SemiRingCat`. (Internal use only; use the limits API.) -/ def limitCone (F : J ⥤ SemiRingCatMax.{v, u}) : Cone F where pt := SemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := limitπRingHom.{v, u} F naturality := fun {_ _} f => RingHom.coe_inj ((Types.limitCone (F ⋙ forget _)).π.naturality f) } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone SemiRingCat.HasLimits.limitCone /-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone_is_limit SemiRingCat.HasLimits.limitConeIsLimit end HasLimits open HasLimits /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v} SemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => ⟨limitCone.{v, u} F, limitConeIsLimit.{v, u} F⟩ } } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits_of_size SemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits SemiRingCat.{u} := SemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.has_limits SemiRingCat.hasLimits /-- Auxiliary lemma to prove the cone induced by `limitCone` is a limit cone. -/ def forget₂AddCommMonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat AddCommMonCat).mapCone (limitCone F)) := by apply AddCommMonCat.limitConeIsLimit.{v, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_aux SemiRingCat.forget₂AddCommMonPreservesLimitsAux /-- The forgetful functor from semirings to additive commutative monoids preserves all limits. -/ instance forget₂AddCommMonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat AddCommMonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (forget₂AddCommMonPreservesLimitsAux F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_of_size SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize instance forget₂AddCommMonPreservesLimits : PreservesLimits (forget₂ SemiRingCat AddCommMonCat.{u}) := SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits SemiRingCat.forget₂AddCommMonPreservesLimits /-- An auxiliary declaration to speed up typechecking. -/ def forget₂MonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat MonCat).mapCone (limitCone F)) := by apply MonCat.HasLimits.limitConeIsLimit (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_aux SemiRingCat.forget₂MonPreservesLimitsAux /-- The forgetful functor from semirings to monoids preserves all limits. -/ instance forget₂MonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat MonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (forget₂MonPreservesLimitsAux.{v, u} F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_of_size SemiRingCat.forget₂MonPreservesLimitsOfSize instance forget₂MonPreservesLimits : PreservesLimits (forget₂ SemiRingCat MonCat.{u}) := SemiRingCat.forget₂MonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits SemiRingCat.forget₂MonPreservesLimits /-- The forgetful functor from semirings to types preserves all limits. -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (Types.limitConeIsLimit.{v, u} (F ⋙ forget _)) } set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits_of_size SemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget SemiRingCat.{u}) := SemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits SemiRingCat.forgetPreservesLimits end SemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `CommSemiring.{max u v}`, to deal with unification issues. -/ @[nolint checkUnivs] abbrev CommSemiRingCatMax.{u1, u2} := CommSemiRingCat.{max u1 u2} namespace CommSemiRingCat variable {J : Type v} [SmallCategory J] instance commSemiringObj (F : J ⥤ CommSemiRingCatMax.{v, u}) (j) : CommSemiring ((F ⋙ forget CommSemiRingCat).obj j) := by change CommSemiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align CommSemiRing.comm_semiring_obj CommSemiRingCat.commSemiringObj instance limitCommSemiring (F : J ⥤ CommSemiRingCatMax.{v, u}) : CommSemiring (Types.limitCone.{v, u} (F ⋙ forget CommSemiRingCat.{max v u})).pt := @Subsemiring.toCommSemiring (∀ j, F.obj j) _ (SemiRingCat.sectionsSubsemiring.{v, u} (F ⋙ forget₂ CommSemiRingCat SemiRingCat.{max v u})) set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_comm_semiring CommSemiRingCat.limitCommSemiring /-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := -- Porting note : `CommSemiRingCat ⥤ Type` reflecting isomorphism is needed to make Lean see that -- `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism. `CommSemiRingCat ⥤ Type` reflecting -- isomorphism is added manually since Lean can't see it, but even with this addition Lean can not -- see `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism, so this instance is also added. letI : ReflectsIsomorphisms (forget CommSemiRingCatMax.{v, u}) := CommSemiRingCat.forgetReflectIsos.{max v u} letI : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := CategoryTheory.reflectsIsomorphisms_forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u} let c : Cone F := { pt := CommSemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun j => CommSemiRingCat.ofHom <| SemiRingCat.limitπRingHom.{v, u} (J := J) (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) j naturality := (SemiRingCat.HasLimits.limitCone.{v, u} (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) t makesLimit := by refine IsLimit.ofFaithful (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) (fun s : Cone F => CommSemiRingCat.ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl } /-- A choice of limit cone for a functor into `CommSemiRingCat`. (Generally, you'll just want to use `limit F`.) -/ def limitCone (F : J ⥤ CommSemiRingCatMax.{v, u}) : Cone F := liftLimit (limit.isLimit (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})) set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_cone CommSemiRingCat.limitCone /-- The chosen cone is a limit cone. (Generally, you'll just want to use `limit.cone F`.) -/ def limitConeIsLimit (F : J ⥤ CommSemiRingCatMax.{v, u}) : IsLimit (limitCone F) := liftedLimitIsLimit _ set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_cone_is_limit CommSemiRingCat.limitConeIsLimit /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v, v} CommSemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => hasLimit_of_created F (forget₂ CommSemiRingCat SemiRingCatMax.{v, u}) } } set_option linter.uppercaseLean3 false in #align CommSemiRing.has_limits_of_size CommSemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits CommSemiRingCat.{u} := CommSemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.has_limits CommSemiRingCat.hasLimits /-- The forgetful functor from rings to semirings preserves all limits. -/ instance forget₂SemiRingPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ CommSemiRingCat SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (SemiRingCat.HasLimits.limitConeIsLimit _) } set_option linter.uppercaseLean3 false in #align CommSemiRing.forget₂_SemiRing_preserves_limits_of_size CommSemiRingCat.forget₂SemiRingPreservesLimitsOfSize instance forget₂SemiRingPreservesLimits : PreservesLimits (forget₂ CommSemiRingCat SemiRingCat.{u}) := CommSemiRingCat.forget₂SemiRingPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.forget₂_SemiRing_preserves_limits CommSemiRingCat.forget₂SemiRingPreservesLimits /-- The forgetful functor from rings to types preserves all limits. (That is, the underlying types could have been computed instead as limits in the category of types.) -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget CommSemiRingCatMax.{v, u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (Types.limitConeIsLimit.{v, u} _) } set_option linter.uppercaseLean3 false in #align CommSemiRing.forget_preserves_limits_of_size CommSemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget CommSemiRingCat.{u}) := CommSemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.forget_preserves_limits CommSemiRingCat.forgetPreservesLimits end CommSemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `RingCat.{max u v}`, to deal around unification issues. -/ @[nolint checkUnivs] abbrev RingCatMax.{u1, u2} := RingCat.{max u1 u2} namespace RingCat variable {J : Type v} [SmallCategory J] instance ringObj (F : J ⥤ RingCatMax.{v, u}) (j) : Ring ((F ⋙ forget RingCat).obj j) := by change Ring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align Ring.ring_obj RingCat.ringObj /-- The flat sections of a functor into `RingCat` form a subring of all sections. -/ def sectionsSubring (F : J ⥤ RingCatMax.{v, u}) : Subring.{max v u} (∀ j, F.obj j) := letI f : J ⥤ AddGroupCat.{max v u} := F ⋙ forget₂ RingCatMax.{v, u} AddCommGroupCat.{max v u} ⋙ forget₂ AddCommGroupCat.{max v u} AddGroupCat.{max v u} letI g : J ⥤ SemiRingCatMax.{v, u} := F ⋙ forget₂ RingCatMax.{v, u} SemiRingCat.{max v u} { AddGroupCat.sectionsAddSubgroup.{v, u} (J := J) f, SemiRingCat.sectionsSubsemiring.{v, u} (J := J) g with carrier := (F ⋙ forget RingCatMax.{v, u}).sections } set_option linter.uppercaseLean3 false in #align Ring.sections_subring RingCat.sectionsSubring instance limitRing (F : J ⥤ RingCatMax.{v, u}) : Ring.{max v u} (Types.limitCone.{v, u} (F ⋙ forget RingCatMax.{v, u})).pt := (sectionsSubring F).toRing set_option linter.uppercaseLean3 false in #align Ring.limit_ring RingCat.limitRing /-- We show that the forgetful functor `CommRingCat ⥤ RingCat` creates limits. All we need to do is notice that the limit point has a `Ring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ RingCatMax.{v, u}) : CreatesLimit F (forget₂ RingCatMax.{v, u} SemiRingCatMax.{v, u}) := letI : ReflectsIsomorphisms (forget₂ RingCatMax SemiRingCatMax) := CategoryTheory.reflectsIsomorphisms_forget₂ _ _ letI c : Cone F := { pt := RingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun x => SemiRingCat.ofHom _ naturality := (SemiRingCat.HasLimits.limitCone (F ⋙ forget₂ RingCat SemiRingCat.{max v u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := by
apply IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit _) t
/-- We show that the forgetful functor `CommRingCat ⥤ RingCat` creates limits. All we need to do is notice that the limit point has a `Ring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ RingCatMax.{v, u}) : CreatesLimit F (forget₂ RingCatMax.{v, u} SemiRingCatMax.{v, u}) := letI : ReflectsIsomorphisms (forget₂ RingCatMax SemiRingCatMax) := CategoryTheory.reflectsIsomorphisms_forget₂ _ _ letI c : Cone F := { pt := RingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun x => SemiRingCat.ofHom _ naturality := (SemiRingCat.HasLimits.limitCone (F ⋙ forget₂ RingCat SemiRingCat.{max v u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := by
Mathlib.Algebra.Category.Ring.Limits.358_0.VxjNIkMLPSqe2rX
/-- We show that the forgetful functor `CommRingCat ⥤ RingCat` creates limits. All we need to do is notice that the limit point has a `Ring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ RingCatMax.{v, u}) : CreatesLimit F (forget₂ RingCatMax.{v, u} SemiRingCatMax.{v, u})
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ RingCatMax this : ReflectsIsomorphisms (forget₂ RingCatMax SemiRingCatMax) := reflectsIsomorphisms_forget₂ RingCatMax SemiRingCatMax c : Cone F := { pt := of (Types.limitCone (F ⋙ forget RingCatMax)).pt, π := NatTrans.mk fun x => SemiRingCat.ofHom ((SemiRingCat.HasLimits.limitCone (F ⋙ forget₂ RingCat SemiRingCat)).π.app x) } c' : Cone (F ⋙ forget₂ RingCatMax SemiRingCatMax) t : IsLimit c' ⊢ IsLimit ((forget₂ RingCat SemiRingCat).mapCone { liftedCone := c, validLift := IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit (F ⋙ forget₂ RingCatMax SemiRingCatMax)) t }.liftedCone)
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align SemiRing.semiring_obj SemiRingCat.semiringObj /-- The flat sections of a functor into `SemiRingCat` form a subsemiring of all sections. -/ def sectionsSubsemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Subsemiring.{max v u} (∀ j, F.obj j) := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat letI g : J ⥤ MonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} MonCat.{max v u} { (MonCat.sectionsSubmonoid.{v, u} (J := J) g), (AddMonCat.sectionsAddSubmonoid.{v, u} (J := J) f) with carrier := (F ⋙ forget SemiRingCat).sections } set_option linter.uppercaseLean3 false in #align SemiRing.sections_subsemiring SemiRingCat.sectionsSubsemiring instance limitSemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Semiring (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat.{max v u})).pt := (sectionsSubsemiring F).toSemiring set_option linter.uppercaseLean3 false in #align SemiRing.limit_semiring SemiRingCat.limitSemiring /-- `limit.π (F ⋙ forget SemiRingCat) j` as a `RingHom`. -/ def limitπRingHom (F : J ⥤ SemiRingCatMax.{v, u}) (j) : (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat)).pt →+* (F ⋙ forget SemiRingCat).obj j := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat { AddMonCat.limitπAddMonoidHom f j, MonCat.limitπMonoidHom (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) j with toFun := (Types.limitCone (F ⋙ forget SemiRingCat)).π.app j } set_option linter.uppercaseLean3 false in #align SemiRing.limit_π_ring_hom SemiRingCat.limitπRingHom namespace HasLimits -- The next two definitions are used in the construction of `HasLimits SemiRingCat`. -- After that, the limits should be constructed using the generic limits API, -- e.g. `limit F`, `limit.cone F`, and `limit.isLimit F`. /-- Construction of a limit cone in `SemiRingCat`. (Internal use only; use the limits API.) -/ def limitCone (F : J ⥤ SemiRingCatMax.{v, u}) : Cone F where pt := SemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := limitπRingHom.{v, u} F naturality := fun {_ _} f => RingHom.coe_inj ((Types.limitCone (F ⋙ forget _)).π.naturality f) } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone SemiRingCat.HasLimits.limitCone /-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone_is_limit SemiRingCat.HasLimits.limitConeIsLimit end HasLimits open HasLimits /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v} SemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => ⟨limitCone.{v, u} F, limitConeIsLimit.{v, u} F⟩ } } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits_of_size SemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits SemiRingCat.{u} := SemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.has_limits SemiRingCat.hasLimits /-- Auxiliary lemma to prove the cone induced by `limitCone` is a limit cone. -/ def forget₂AddCommMonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat AddCommMonCat).mapCone (limitCone F)) := by apply AddCommMonCat.limitConeIsLimit.{v, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_aux SemiRingCat.forget₂AddCommMonPreservesLimitsAux /-- The forgetful functor from semirings to additive commutative monoids preserves all limits. -/ instance forget₂AddCommMonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat AddCommMonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (forget₂AddCommMonPreservesLimitsAux F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_of_size SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize instance forget₂AddCommMonPreservesLimits : PreservesLimits (forget₂ SemiRingCat AddCommMonCat.{u}) := SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits SemiRingCat.forget₂AddCommMonPreservesLimits /-- An auxiliary declaration to speed up typechecking. -/ def forget₂MonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat MonCat).mapCone (limitCone F)) := by apply MonCat.HasLimits.limitConeIsLimit (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_aux SemiRingCat.forget₂MonPreservesLimitsAux /-- The forgetful functor from semirings to monoids preserves all limits. -/ instance forget₂MonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat MonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (forget₂MonPreservesLimitsAux.{v, u} F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_of_size SemiRingCat.forget₂MonPreservesLimitsOfSize instance forget₂MonPreservesLimits : PreservesLimits (forget₂ SemiRingCat MonCat.{u}) := SemiRingCat.forget₂MonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits SemiRingCat.forget₂MonPreservesLimits /-- The forgetful functor from semirings to types preserves all limits. -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (Types.limitConeIsLimit.{v, u} (F ⋙ forget _)) } set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits_of_size SemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget SemiRingCat.{u}) := SemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits SemiRingCat.forgetPreservesLimits end SemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `CommSemiring.{max u v}`, to deal with unification issues. -/ @[nolint checkUnivs] abbrev CommSemiRingCatMax.{u1, u2} := CommSemiRingCat.{max u1 u2} namespace CommSemiRingCat variable {J : Type v} [SmallCategory J] instance commSemiringObj (F : J ⥤ CommSemiRingCatMax.{v, u}) (j) : CommSemiring ((F ⋙ forget CommSemiRingCat).obj j) := by change CommSemiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align CommSemiRing.comm_semiring_obj CommSemiRingCat.commSemiringObj instance limitCommSemiring (F : J ⥤ CommSemiRingCatMax.{v, u}) : CommSemiring (Types.limitCone.{v, u} (F ⋙ forget CommSemiRingCat.{max v u})).pt := @Subsemiring.toCommSemiring (∀ j, F.obj j) _ (SemiRingCat.sectionsSubsemiring.{v, u} (F ⋙ forget₂ CommSemiRingCat SemiRingCat.{max v u})) set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_comm_semiring CommSemiRingCat.limitCommSemiring /-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := -- Porting note : `CommSemiRingCat ⥤ Type` reflecting isomorphism is needed to make Lean see that -- `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism. `CommSemiRingCat ⥤ Type` reflecting -- isomorphism is added manually since Lean can't see it, but even with this addition Lean can not -- see `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism, so this instance is also added. letI : ReflectsIsomorphisms (forget CommSemiRingCatMax.{v, u}) := CommSemiRingCat.forgetReflectIsos.{max v u} letI : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := CategoryTheory.reflectsIsomorphisms_forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u} let c : Cone F := { pt := CommSemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun j => CommSemiRingCat.ofHom <| SemiRingCat.limitπRingHom.{v, u} (J := J) (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) j naturality := (SemiRingCat.HasLimits.limitCone.{v, u} (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) t makesLimit := by refine IsLimit.ofFaithful (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) (fun s : Cone F => CommSemiRingCat.ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl } /-- A choice of limit cone for a functor into `CommSemiRingCat`. (Generally, you'll just want to use `limit F`.) -/ def limitCone (F : J ⥤ CommSemiRingCatMax.{v, u}) : Cone F := liftLimit (limit.isLimit (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})) set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_cone CommSemiRingCat.limitCone /-- The chosen cone is a limit cone. (Generally, you'll just want to use `limit.cone F`.) -/ def limitConeIsLimit (F : J ⥤ CommSemiRingCatMax.{v, u}) : IsLimit (limitCone F) := liftedLimitIsLimit _ set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_cone_is_limit CommSemiRingCat.limitConeIsLimit /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v, v} CommSemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => hasLimit_of_created F (forget₂ CommSemiRingCat SemiRingCatMax.{v, u}) } } set_option linter.uppercaseLean3 false in #align CommSemiRing.has_limits_of_size CommSemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits CommSemiRingCat.{u} := CommSemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.has_limits CommSemiRingCat.hasLimits /-- The forgetful functor from rings to semirings preserves all limits. -/ instance forget₂SemiRingPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ CommSemiRingCat SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (SemiRingCat.HasLimits.limitConeIsLimit _) } set_option linter.uppercaseLean3 false in #align CommSemiRing.forget₂_SemiRing_preserves_limits_of_size CommSemiRingCat.forget₂SemiRingPreservesLimitsOfSize instance forget₂SemiRingPreservesLimits : PreservesLimits (forget₂ CommSemiRingCat SemiRingCat.{u}) := CommSemiRingCat.forget₂SemiRingPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.forget₂_SemiRing_preserves_limits CommSemiRingCat.forget₂SemiRingPreservesLimits /-- The forgetful functor from rings to types preserves all limits. (That is, the underlying types could have been computed instead as limits in the category of types.) -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget CommSemiRingCatMax.{v, u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (Types.limitConeIsLimit.{v, u} _) } set_option linter.uppercaseLean3 false in #align CommSemiRing.forget_preserves_limits_of_size CommSemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget CommSemiRingCat.{u}) := CommSemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.forget_preserves_limits CommSemiRingCat.forgetPreservesLimits end CommSemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `RingCat.{max u v}`, to deal around unification issues. -/ @[nolint checkUnivs] abbrev RingCatMax.{u1, u2} := RingCat.{max u1 u2} namespace RingCat variable {J : Type v} [SmallCategory J] instance ringObj (F : J ⥤ RingCatMax.{v, u}) (j) : Ring ((F ⋙ forget RingCat).obj j) := by change Ring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align Ring.ring_obj RingCat.ringObj /-- The flat sections of a functor into `RingCat` form a subring of all sections. -/ def sectionsSubring (F : J ⥤ RingCatMax.{v, u}) : Subring.{max v u} (∀ j, F.obj j) := letI f : J ⥤ AddGroupCat.{max v u} := F ⋙ forget₂ RingCatMax.{v, u} AddCommGroupCat.{max v u} ⋙ forget₂ AddCommGroupCat.{max v u} AddGroupCat.{max v u} letI g : J ⥤ SemiRingCatMax.{v, u} := F ⋙ forget₂ RingCatMax.{v, u} SemiRingCat.{max v u} { AddGroupCat.sectionsAddSubgroup.{v, u} (J := J) f, SemiRingCat.sectionsSubsemiring.{v, u} (J := J) g with carrier := (F ⋙ forget RingCatMax.{v, u}).sections } set_option linter.uppercaseLean3 false in #align Ring.sections_subring RingCat.sectionsSubring instance limitRing (F : J ⥤ RingCatMax.{v, u}) : Ring.{max v u} (Types.limitCone.{v, u} (F ⋙ forget RingCatMax.{v, u})).pt := (sectionsSubring F).toRing set_option linter.uppercaseLean3 false in #align Ring.limit_ring RingCat.limitRing /-- We show that the forgetful functor `CommRingCat ⥤ RingCat` creates limits. All we need to do is notice that the limit point has a `Ring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ RingCatMax.{v, u}) : CreatesLimit F (forget₂ RingCatMax.{v, u} SemiRingCatMax.{v, u}) := letI : ReflectsIsomorphisms (forget₂ RingCatMax SemiRingCatMax) := CategoryTheory.reflectsIsomorphisms_forget₂ _ _ letI c : Cone F := { pt := RingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun x => SemiRingCat.ofHom _ naturality := (SemiRingCat.HasLimits.limitCone (F ⋙ forget₂ RingCat SemiRingCat.{max v u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := by apply IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit _) t makesLimit := IsLimit.ofFaithful (forget₂ RingCat SemiRingCat.{max v u}) (by
apply SemiRingCat.HasLimits.limitConeIsLimit _
/-- We show that the forgetful functor `CommRingCat ⥤ RingCat` creates limits. All we need to do is notice that the limit point has a `Ring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ RingCatMax.{v, u}) : CreatesLimit F (forget₂ RingCatMax.{v, u} SemiRingCatMax.{v, u}) := letI : ReflectsIsomorphisms (forget₂ RingCatMax SemiRingCatMax) := CategoryTheory.reflectsIsomorphisms_forget₂ _ _ letI c : Cone F := { pt := RingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun x => SemiRingCat.ofHom _ naturality := (SemiRingCat.HasLimits.limitCone (F ⋙ forget₂ RingCat SemiRingCat.{max v u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := by apply IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit _) t makesLimit := IsLimit.ofFaithful (forget₂ RingCat SemiRingCat.{max v u}) (by
Mathlib.Algebra.Category.Ring.Limits.358_0.VxjNIkMLPSqe2rX
/-- We show that the forgetful functor `CommRingCat ⥤ RingCat` creates limits. All we need to do is notice that the limit point has a `Ring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ RingCatMax.{v, u}) : CreatesLimit F (forget₂ RingCatMax.{v, u} SemiRingCatMax.{v, u})
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ RingCatMax ⊢ IsLimit ((forget₂ RingCatMax AddCommGroupCat).mapCone (limitCone F))
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align SemiRing.semiring_obj SemiRingCat.semiringObj /-- The flat sections of a functor into `SemiRingCat` form a subsemiring of all sections. -/ def sectionsSubsemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Subsemiring.{max v u} (∀ j, F.obj j) := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat letI g : J ⥤ MonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} MonCat.{max v u} { (MonCat.sectionsSubmonoid.{v, u} (J := J) g), (AddMonCat.sectionsAddSubmonoid.{v, u} (J := J) f) with carrier := (F ⋙ forget SemiRingCat).sections } set_option linter.uppercaseLean3 false in #align SemiRing.sections_subsemiring SemiRingCat.sectionsSubsemiring instance limitSemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Semiring (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat.{max v u})).pt := (sectionsSubsemiring F).toSemiring set_option linter.uppercaseLean3 false in #align SemiRing.limit_semiring SemiRingCat.limitSemiring /-- `limit.π (F ⋙ forget SemiRingCat) j` as a `RingHom`. -/ def limitπRingHom (F : J ⥤ SemiRingCatMax.{v, u}) (j) : (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat)).pt →+* (F ⋙ forget SemiRingCat).obj j := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat { AddMonCat.limitπAddMonoidHom f j, MonCat.limitπMonoidHom (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) j with toFun := (Types.limitCone (F ⋙ forget SemiRingCat)).π.app j } set_option linter.uppercaseLean3 false in #align SemiRing.limit_π_ring_hom SemiRingCat.limitπRingHom namespace HasLimits -- The next two definitions are used in the construction of `HasLimits SemiRingCat`. -- After that, the limits should be constructed using the generic limits API, -- e.g. `limit F`, `limit.cone F`, and `limit.isLimit F`. /-- Construction of a limit cone in `SemiRingCat`. (Internal use only; use the limits API.) -/ def limitCone (F : J ⥤ SemiRingCatMax.{v, u}) : Cone F where pt := SemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := limitπRingHom.{v, u} F naturality := fun {_ _} f => RingHom.coe_inj ((Types.limitCone (F ⋙ forget _)).π.naturality f) } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone SemiRingCat.HasLimits.limitCone /-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone_is_limit SemiRingCat.HasLimits.limitConeIsLimit end HasLimits open HasLimits /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v} SemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => ⟨limitCone.{v, u} F, limitConeIsLimit.{v, u} F⟩ } } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits_of_size SemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits SemiRingCat.{u} := SemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.has_limits SemiRingCat.hasLimits /-- Auxiliary lemma to prove the cone induced by `limitCone` is a limit cone. -/ def forget₂AddCommMonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat AddCommMonCat).mapCone (limitCone F)) := by apply AddCommMonCat.limitConeIsLimit.{v, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_aux SemiRingCat.forget₂AddCommMonPreservesLimitsAux /-- The forgetful functor from semirings to additive commutative monoids preserves all limits. -/ instance forget₂AddCommMonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat AddCommMonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (forget₂AddCommMonPreservesLimitsAux F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_of_size SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize instance forget₂AddCommMonPreservesLimits : PreservesLimits (forget₂ SemiRingCat AddCommMonCat.{u}) := SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits SemiRingCat.forget₂AddCommMonPreservesLimits /-- An auxiliary declaration to speed up typechecking. -/ def forget₂MonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat MonCat).mapCone (limitCone F)) := by apply MonCat.HasLimits.limitConeIsLimit (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_aux SemiRingCat.forget₂MonPreservesLimitsAux /-- The forgetful functor from semirings to monoids preserves all limits. -/ instance forget₂MonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat MonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (forget₂MonPreservesLimitsAux.{v, u} F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_of_size SemiRingCat.forget₂MonPreservesLimitsOfSize instance forget₂MonPreservesLimits : PreservesLimits (forget₂ SemiRingCat MonCat.{u}) := SemiRingCat.forget₂MonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits SemiRingCat.forget₂MonPreservesLimits /-- The forgetful functor from semirings to types preserves all limits. -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (Types.limitConeIsLimit.{v, u} (F ⋙ forget _)) } set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits_of_size SemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget SemiRingCat.{u}) := SemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits SemiRingCat.forgetPreservesLimits end SemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `CommSemiring.{max u v}`, to deal with unification issues. -/ @[nolint checkUnivs] abbrev CommSemiRingCatMax.{u1, u2} := CommSemiRingCat.{max u1 u2} namespace CommSemiRingCat variable {J : Type v} [SmallCategory J] instance commSemiringObj (F : J ⥤ CommSemiRingCatMax.{v, u}) (j) : CommSemiring ((F ⋙ forget CommSemiRingCat).obj j) := by change CommSemiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align CommSemiRing.comm_semiring_obj CommSemiRingCat.commSemiringObj instance limitCommSemiring (F : J ⥤ CommSemiRingCatMax.{v, u}) : CommSemiring (Types.limitCone.{v, u} (F ⋙ forget CommSemiRingCat.{max v u})).pt := @Subsemiring.toCommSemiring (∀ j, F.obj j) _ (SemiRingCat.sectionsSubsemiring.{v, u} (F ⋙ forget₂ CommSemiRingCat SemiRingCat.{max v u})) set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_comm_semiring CommSemiRingCat.limitCommSemiring /-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := -- Porting note : `CommSemiRingCat ⥤ Type` reflecting isomorphism is needed to make Lean see that -- `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism. `CommSemiRingCat ⥤ Type` reflecting -- isomorphism is added manually since Lean can't see it, but even with this addition Lean can not -- see `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism, so this instance is also added. letI : ReflectsIsomorphisms (forget CommSemiRingCatMax.{v, u}) := CommSemiRingCat.forgetReflectIsos.{max v u} letI : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := CategoryTheory.reflectsIsomorphisms_forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u} let c : Cone F := { pt := CommSemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun j => CommSemiRingCat.ofHom <| SemiRingCat.limitπRingHom.{v, u} (J := J) (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) j naturality := (SemiRingCat.HasLimits.limitCone.{v, u} (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) t makesLimit := by refine IsLimit.ofFaithful (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) (fun s : Cone F => CommSemiRingCat.ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl } /-- A choice of limit cone for a functor into `CommSemiRingCat`. (Generally, you'll just want to use `limit F`.) -/ def limitCone (F : J ⥤ CommSemiRingCatMax.{v, u}) : Cone F := liftLimit (limit.isLimit (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})) set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_cone CommSemiRingCat.limitCone /-- The chosen cone is a limit cone. (Generally, you'll just want to use `limit.cone F`.) -/ def limitConeIsLimit (F : J ⥤ CommSemiRingCatMax.{v, u}) : IsLimit (limitCone F) := liftedLimitIsLimit _ set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_cone_is_limit CommSemiRingCat.limitConeIsLimit /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v, v} CommSemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => hasLimit_of_created F (forget₂ CommSemiRingCat SemiRingCatMax.{v, u}) } } set_option linter.uppercaseLean3 false in #align CommSemiRing.has_limits_of_size CommSemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits CommSemiRingCat.{u} := CommSemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.has_limits CommSemiRingCat.hasLimits /-- The forgetful functor from rings to semirings preserves all limits. -/ instance forget₂SemiRingPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ CommSemiRingCat SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (SemiRingCat.HasLimits.limitConeIsLimit _) } set_option linter.uppercaseLean3 false in #align CommSemiRing.forget₂_SemiRing_preserves_limits_of_size CommSemiRingCat.forget₂SemiRingPreservesLimitsOfSize instance forget₂SemiRingPreservesLimits : PreservesLimits (forget₂ CommSemiRingCat SemiRingCat.{u}) := CommSemiRingCat.forget₂SemiRingPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.forget₂_SemiRing_preserves_limits CommSemiRingCat.forget₂SemiRingPreservesLimits /-- The forgetful functor from rings to types preserves all limits. (That is, the underlying types could have been computed instead as limits in the category of types.) -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget CommSemiRingCatMax.{v, u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (Types.limitConeIsLimit.{v, u} _) } set_option linter.uppercaseLean3 false in #align CommSemiRing.forget_preserves_limits_of_size CommSemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget CommSemiRingCat.{u}) := CommSemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.forget_preserves_limits CommSemiRingCat.forgetPreservesLimits end CommSemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `RingCat.{max u v}`, to deal around unification issues. -/ @[nolint checkUnivs] abbrev RingCatMax.{u1, u2} := RingCat.{max u1 u2} namespace RingCat variable {J : Type v} [SmallCategory J] instance ringObj (F : J ⥤ RingCatMax.{v, u}) (j) : Ring ((F ⋙ forget RingCat).obj j) := by change Ring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align Ring.ring_obj RingCat.ringObj /-- The flat sections of a functor into `RingCat` form a subring of all sections. -/ def sectionsSubring (F : J ⥤ RingCatMax.{v, u}) : Subring.{max v u} (∀ j, F.obj j) := letI f : J ⥤ AddGroupCat.{max v u} := F ⋙ forget₂ RingCatMax.{v, u} AddCommGroupCat.{max v u} ⋙ forget₂ AddCommGroupCat.{max v u} AddGroupCat.{max v u} letI g : J ⥤ SemiRingCatMax.{v, u} := F ⋙ forget₂ RingCatMax.{v, u} SemiRingCat.{max v u} { AddGroupCat.sectionsAddSubgroup.{v, u} (J := J) f, SemiRingCat.sectionsSubsemiring.{v, u} (J := J) g with carrier := (F ⋙ forget RingCatMax.{v, u}).sections } set_option linter.uppercaseLean3 false in #align Ring.sections_subring RingCat.sectionsSubring instance limitRing (F : J ⥤ RingCatMax.{v, u}) : Ring.{max v u} (Types.limitCone.{v, u} (F ⋙ forget RingCatMax.{v, u})).pt := (sectionsSubring F).toRing set_option linter.uppercaseLean3 false in #align Ring.limit_ring RingCat.limitRing /-- We show that the forgetful functor `CommRingCat ⥤ RingCat` creates limits. All we need to do is notice that the limit point has a `Ring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ RingCatMax.{v, u}) : CreatesLimit F (forget₂ RingCatMax.{v, u} SemiRingCatMax.{v, u}) := letI : ReflectsIsomorphisms (forget₂ RingCatMax SemiRingCatMax) := CategoryTheory.reflectsIsomorphisms_forget₂ _ _ letI c : Cone F := { pt := RingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun x => SemiRingCat.ofHom _ naturality := (SemiRingCat.HasLimits.limitCone (F ⋙ forget₂ RingCat SemiRingCat.{max v u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := by apply IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit _) t makesLimit := IsLimit.ofFaithful (forget₂ RingCat SemiRingCat.{max v u}) (by apply SemiRingCat.HasLimits.limitConeIsLimit _) (fun s => _) fun s => rfl } /-- A choice of limit cone for a functor into `RingCat`. (Generally, you'll just want to use `limit F`.) -/ def limitCone (F : J ⥤ RingCatMax.{v, u}) : Cone F := liftLimit (limit.isLimit (F ⋙ forget₂ RingCatMax.{v, u} SemiRingCatMax.{v, u})) set_option linter.uppercaseLean3 false in #align Ring.limit_cone RingCat.limitCone /-- The chosen cone is a limit cone. (Generally, you'll just want to use `limit.cone F`.) -/ def limitConeIsLimit (F : J ⥤ RingCatMax.{v, u}) : IsLimit (limitCone F) := liftedLimitIsLimit _ set_option linter.uppercaseLean3 false in #align Ring.limit_cone_is_limit RingCat.limitConeIsLimit /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v, v} RingCat.{max v u} := { has_limits_of_shape := fun {_ _} => { has_limit := fun {F} => hasLimit_of_created F (forget₂ RingCatMax.{v, u} SemiRingCatMax.{v, u}) } } set_option linter.uppercaseLean3 false in #align Ring.has_limits_of_size RingCat.hasLimitsOfSize instance hasLimits : HasLimits RingCat.{u} := RingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align Ring.has_limits RingCat.hasLimits /-- The forgetful functor from rings to semirings preserves all limits. -/ instance forget₂SemiRingPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ RingCat SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) } set_option linter.uppercaseLean3 false in #align Ring.forget₂_SemiRing_preserves_limits_of_size RingCat.forget₂SemiRingPreservesLimitsOfSize instance forget₂SemiRingPreservesLimits : PreservesLimits (forget₂ RingCat SemiRingCat.{u}) := RingCat.forget₂SemiRingPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align Ring.forget₂_SemiRing_preserves_limits RingCat.forget₂SemiRingPreservesLimits /-- An auxiliary declaration to speed up typechecking. -/ def forget₂AddCommGroupPreservesLimitsAux (F : J ⥤ RingCatMax.{v, u}) : IsLimit ((forget₂ RingCatMax.{v, u} AddCommGroupCat).mapCone (limitCone.{v, u} F)) := by -- Porting note : inline `f` would not compile
letI f := (F ⋙ forget₂ RingCatMax.{v, u} AddCommGroupCat.{max v u})
/-- An auxiliary declaration to speed up typechecking. -/ def forget₂AddCommGroupPreservesLimitsAux (F : J ⥤ RingCatMax.{v, u}) : IsLimit ((forget₂ RingCatMax.{v, u} AddCommGroupCat).mapCone (limitCone.{v, u} F)) := by -- Porting note : inline `f` would not compile
Mathlib.Algebra.Category.Ring.Limits.426_0.VxjNIkMLPSqe2rX
/-- An auxiliary declaration to speed up typechecking. -/ def forget₂AddCommGroupPreservesLimitsAux (F : J ⥤ RingCatMax.{v, u}) : IsLimit ((forget₂ RingCatMax.{v, u} AddCommGroupCat).mapCone (limitCone.{v, u} F))
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ RingCatMax f : J ⥤ AddCommGroupCat := F ⋙ forget₂ RingCatMax AddCommGroupCat ⊢ IsLimit ((forget₂ RingCatMax AddCommGroupCat).mapCone (limitCone F))
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align SemiRing.semiring_obj SemiRingCat.semiringObj /-- The flat sections of a functor into `SemiRingCat` form a subsemiring of all sections. -/ def sectionsSubsemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Subsemiring.{max v u} (∀ j, F.obj j) := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat letI g : J ⥤ MonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} MonCat.{max v u} { (MonCat.sectionsSubmonoid.{v, u} (J := J) g), (AddMonCat.sectionsAddSubmonoid.{v, u} (J := J) f) with carrier := (F ⋙ forget SemiRingCat).sections } set_option linter.uppercaseLean3 false in #align SemiRing.sections_subsemiring SemiRingCat.sectionsSubsemiring instance limitSemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Semiring (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat.{max v u})).pt := (sectionsSubsemiring F).toSemiring set_option linter.uppercaseLean3 false in #align SemiRing.limit_semiring SemiRingCat.limitSemiring /-- `limit.π (F ⋙ forget SemiRingCat) j` as a `RingHom`. -/ def limitπRingHom (F : J ⥤ SemiRingCatMax.{v, u}) (j) : (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat)).pt →+* (F ⋙ forget SemiRingCat).obj j := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat { AddMonCat.limitπAddMonoidHom f j, MonCat.limitπMonoidHom (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) j with toFun := (Types.limitCone (F ⋙ forget SemiRingCat)).π.app j } set_option linter.uppercaseLean3 false in #align SemiRing.limit_π_ring_hom SemiRingCat.limitπRingHom namespace HasLimits -- The next two definitions are used in the construction of `HasLimits SemiRingCat`. -- After that, the limits should be constructed using the generic limits API, -- e.g. `limit F`, `limit.cone F`, and `limit.isLimit F`. /-- Construction of a limit cone in `SemiRingCat`. (Internal use only; use the limits API.) -/ def limitCone (F : J ⥤ SemiRingCatMax.{v, u}) : Cone F where pt := SemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := limitπRingHom.{v, u} F naturality := fun {_ _} f => RingHom.coe_inj ((Types.limitCone (F ⋙ forget _)).π.naturality f) } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone SemiRingCat.HasLimits.limitCone /-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone_is_limit SemiRingCat.HasLimits.limitConeIsLimit end HasLimits open HasLimits /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v} SemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => ⟨limitCone.{v, u} F, limitConeIsLimit.{v, u} F⟩ } } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits_of_size SemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits SemiRingCat.{u} := SemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.has_limits SemiRingCat.hasLimits /-- Auxiliary lemma to prove the cone induced by `limitCone` is a limit cone. -/ def forget₂AddCommMonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat AddCommMonCat).mapCone (limitCone F)) := by apply AddCommMonCat.limitConeIsLimit.{v, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_aux SemiRingCat.forget₂AddCommMonPreservesLimitsAux /-- The forgetful functor from semirings to additive commutative monoids preserves all limits. -/ instance forget₂AddCommMonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat AddCommMonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (forget₂AddCommMonPreservesLimitsAux F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_of_size SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize instance forget₂AddCommMonPreservesLimits : PreservesLimits (forget₂ SemiRingCat AddCommMonCat.{u}) := SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits SemiRingCat.forget₂AddCommMonPreservesLimits /-- An auxiliary declaration to speed up typechecking. -/ def forget₂MonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat MonCat).mapCone (limitCone F)) := by apply MonCat.HasLimits.limitConeIsLimit (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_aux SemiRingCat.forget₂MonPreservesLimitsAux /-- The forgetful functor from semirings to monoids preserves all limits. -/ instance forget₂MonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat MonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (forget₂MonPreservesLimitsAux.{v, u} F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_of_size SemiRingCat.forget₂MonPreservesLimitsOfSize instance forget₂MonPreservesLimits : PreservesLimits (forget₂ SemiRingCat MonCat.{u}) := SemiRingCat.forget₂MonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits SemiRingCat.forget₂MonPreservesLimits /-- The forgetful functor from semirings to types preserves all limits. -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (Types.limitConeIsLimit.{v, u} (F ⋙ forget _)) } set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits_of_size SemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget SemiRingCat.{u}) := SemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits SemiRingCat.forgetPreservesLimits end SemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `CommSemiring.{max u v}`, to deal with unification issues. -/ @[nolint checkUnivs] abbrev CommSemiRingCatMax.{u1, u2} := CommSemiRingCat.{max u1 u2} namespace CommSemiRingCat variable {J : Type v} [SmallCategory J] instance commSemiringObj (F : J ⥤ CommSemiRingCatMax.{v, u}) (j) : CommSemiring ((F ⋙ forget CommSemiRingCat).obj j) := by change CommSemiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align CommSemiRing.comm_semiring_obj CommSemiRingCat.commSemiringObj instance limitCommSemiring (F : J ⥤ CommSemiRingCatMax.{v, u}) : CommSemiring (Types.limitCone.{v, u} (F ⋙ forget CommSemiRingCat.{max v u})).pt := @Subsemiring.toCommSemiring (∀ j, F.obj j) _ (SemiRingCat.sectionsSubsemiring.{v, u} (F ⋙ forget₂ CommSemiRingCat SemiRingCat.{max v u})) set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_comm_semiring CommSemiRingCat.limitCommSemiring /-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := -- Porting note : `CommSemiRingCat ⥤ Type` reflecting isomorphism is needed to make Lean see that -- `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism. `CommSemiRingCat ⥤ Type` reflecting -- isomorphism is added manually since Lean can't see it, but even with this addition Lean can not -- see `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism, so this instance is also added. letI : ReflectsIsomorphisms (forget CommSemiRingCatMax.{v, u}) := CommSemiRingCat.forgetReflectIsos.{max v u} letI : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := CategoryTheory.reflectsIsomorphisms_forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u} let c : Cone F := { pt := CommSemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun j => CommSemiRingCat.ofHom <| SemiRingCat.limitπRingHom.{v, u} (J := J) (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) j naturality := (SemiRingCat.HasLimits.limitCone.{v, u} (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) t makesLimit := by refine IsLimit.ofFaithful (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) (fun s : Cone F => CommSemiRingCat.ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl } /-- A choice of limit cone for a functor into `CommSemiRingCat`. (Generally, you'll just want to use `limit F`.) -/ def limitCone (F : J ⥤ CommSemiRingCatMax.{v, u}) : Cone F := liftLimit (limit.isLimit (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})) set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_cone CommSemiRingCat.limitCone /-- The chosen cone is a limit cone. (Generally, you'll just want to use `limit.cone F`.) -/ def limitConeIsLimit (F : J ⥤ CommSemiRingCatMax.{v, u}) : IsLimit (limitCone F) := liftedLimitIsLimit _ set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_cone_is_limit CommSemiRingCat.limitConeIsLimit /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v, v} CommSemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => hasLimit_of_created F (forget₂ CommSemiRingCat SemiRingCatMax.{v, u}) } } set_option linter.uppercaseLean3 false in #align CommSemiRing.has_limits_of_size CommSemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits CommSemiRingCat.{u} := CommSemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.has_limits CommSemiRingCat.hasLimits /-- The forgetful functor from rings to semirings preserves all limits. -/ instance forget₂SemiRingPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ CommSemiRingCat SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (SemiRingCat.HasLimits.limitConeIsLimit _) } set_option linter.uppercaseLean3 false in #align CommSemiRing.forget₂_SemiRing_preserves_limits_of_size CommSemiRingCat.forget₂SemiRingPreservesLimitsOfSize instance forget₂SemiRingPreservesLimits : PreservesLimits (forget₂ CommSemiRingCat SemiRingCat.{u}) := CommSemiRingCat.forget₂SemiRingPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.forget₂_SemiRing_preserves_limits CommSemiRingCat.forget₂SemiRingPreservesLimits /-- The forgetful functor from rings to types preserves all limits. (That is, the underlying types could have been computed instead as limits in the category of types.) -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget CommSemiRingCatMax.{v, u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (Types.limitConeIsLimit.{v, u} _) } set_option linter.uppercaseLean3 false in #align CommSemiRing.forget_preserves_limits_of_size CommSemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget CommSemiRingCat.{u}) := CommSemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.forget_preserves_limits CommSemiRingCat.forgetPreservesLimits end CommSemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `RingCat.{max u v}`, to deal around unification issues. -/ @[nolint checkUnivs] abbrev RingCatMax.{u1, u2} := RingCat.{max u1 u2} namespace RingCat variable {J : Type v} [SmallCategory J] instance ringObj (F : J ⥤ RingCatMax.{v, u}) (j) : Ring ((F ⋙ forget RingCat).obj j) := by change Ring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align Ring.ring_obj RingCat.ringObj /-- The flat sections of a functor into `RingCat` form a subring of all sections. -/ def sectionsSubring (F : J ⥤ RingCatMax.{v, u}) : Subring.{max v u} (∀ j, F.obj j) := letI f : J ⥤ AddGroupCat.{max v u} := F ⋙ forget₂ RingCatMax.{v, u} AddCommGroupCat.{max v u} ⋙ forget₂ AddCommGroupCat.{max v u} AddGroupCat.{max v u} letI g : J ⥤ SemiRingCatMax.{v, u} := F ⋙ forget₂ RingCatMax.{v, u} SemiRingCat.{max v u} { AddGroupCat.sectionsAddSubgroup.{v, u} (J := J) f, SemiRingCat.sectionsSubsemiring.{v, u} (J := J) g with carrier := (F ⋙ forget RingCatMax.{v, u}).sections } set_option linter.uppercaseLean3 false in #align Ring.sections_subring RingCat.sectionsSubring instance limitRing (F : J ⥤ RingCatMax.{v, u}) : Ring.{max v u} (Types.limitCone.{v, u} (F ⋙ forget RingCatMax.{v, u})).pt := (sectionsSubring F).toRing set_option linter.uppercaseLean3 false in #align Ring.limit_ring RingCat.limitRing /-- We show that the forgetful functor `CommRingCat ⥤ RingCat` creates limits. All we need to do is notice that the limit point has a `Ring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ RingCatMax.{v, u}) : CreatesLimit F (forget₂ RingCatMax.{v, u} SemiRingCatMax.{v, u}) := letI : ReflectsIsomorphisms (forget₂ RingCatMax SemiRingCatMax) := CategoryTheory.reflectsIsomorphisms_forget₂ _ _ letI c : Cone F := { pt := RingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun x => SemiRingCat.ofHom _ naturality := (SemiRingCat.HasLimits.limitCone (F ⋙ forget₂ RingCat SemiRingCat.{max v u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := by apply IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit _) t makesLimit := IsLimit.ofFaithful (forget₂ RingCat SemiRingCat.{max v u}) (by apply SemiRingCat.HasLimits.limitConeIsLimit _) (fun s => _) fun s => rfl } /-- A choice of limit cone for a functor into `RingCat`. (Generally, you'll just want to use `limit F`.) -/ def limitCone (F : J ⥤ RingCatMax.{v, u}) : Cone F := liftLimit (limit.isLimit (F ⋙ forget₂ RingCatMax.{v, u} SemiRingCatMax.{v, u})) set_option linter.uppercaseLean3 false in #align Ring.limit_cone RingCat.limitCone /-- The chosen cone is a limit cone. (Generally, you'll just want to use `limit.cone F`.) -/ def limitConeIsLimit (F : J ⥤ RingCatMax.{v, u}) : IsLimit (limitCone F) := liftedLimitIsLimit _ set_option linter.uppercaseLean3 false in #align Ring.limit_cone_is_limit RingCat.limitConeIsLimit /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v, v} RingCat.{max v u} := { has_limits_of_shape := fun {_ _} => { has_limit := fun {F} => hasLimit_of_created F (forget₂ RingCatMax.{v, u} SemiRingCatMax.{v, u}) } } set_option linter.uppercaseLean3 false in #align Ring.has_limits_of_size RingCat.hasLimitsOfSize instance hasLimits : HasLimits RingCat.{u} := RingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align Ring.has_limits RingCat.hasLimits /-- The forgetful functor from rings to semirings preserves all limits. -/ instance forget₂SemiRingPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ RingCat SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) } set_option linter.uppercaseLean3 false in #align Ring.forget₂_SemiRing_preserves_limits_of_size RingCat.forget₂SemiRingPreservesLimitsOfSize instance forget₂SemiRingPreservesLimits : PreservesLimits (forget₂ RingCat SemiRingCat.{u}) := RingCat.forget₂SemiRingPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align Ring.forget₂_SemiRing_preserves_limits RingCat.forget₂SemiRingPreservesLimits /-- An auxiliary declaration to speed up typechecking. -/ def forget₂AddCommGroupPreservesLimitsAux (F : J ⥤ RingCatMax.{v, u}) : IsLimit ((forget₂ RingCatMax.{v, u} AddCommGroupCat).mapCone (limitCone.{v, u} F)) := by -- Porting note : inline `f` would not compile letI f := (F ⋙ forget₂ RingCatMax.{v, u} AddCommGroupCat.{max v u})
apply AddCommGroupCat.limitConeIsLimit.{v, u} f
/-- An auxiliary declaration to speed up typechecking. -/ def forget₂AddCommGroupPreservesLimitsAux (F : J ⥤ RingCatMax.{v, u}) : IsLimit ((forget₂ RingCatMax.{v, u} AddCommGroupCat).mapCone (limitCone.{v, u} F)) := by -- Porting note : inline `f` would not compile letI f := (F ⋙ forget₂ RingCatMax.{v, u} AddCommGroupCat.{max v u})
Mathlib.Algebra.Category.Ring.Limits.426_0.VxjNIkMLPSqe2rX
/-- An auxiliary declaration to speed up typechecking. -/ def forget₂AddCommGroupPreservesLimitsAux (F : J ⥤ RingCatMax.{v, u}) : IsLimit ((forget₂ RingCatMax.{v, u} AddCommGroupCat).mapCone (limitCone.{v, u} F))
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ CommRingCatMax j : J ⊢ CommRing ((F ⋙ forget CommRingCat).obj j)
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align SemiRing.semiring_obj SemiRingCat.semiringObj /-- The flat sections of a functor into `SemiRingCat` form a subsemiring of all sections. -/ def sectionsSubsemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Subsemiring.{max v u} (∀ j, F.obj j) := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat letI g : J ⥤ MonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} MonCat.{max v u} { (MonCat.sectionsSubmonoid.{v, u} (J := J) g), (AddMonCat.sectionsAddSubmonoid.{v, u} (J := J) f) with carrier := (F ⋙ forget SemiRingCat).sections } set_option linter.uppercaseLean3 false in #align SemiRing.sections_subsemiring SemiRingCat.sectionsSubsemiring instance limitSemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Semiring (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat.{max v u})).pt := (sectionsSubsemiring F).toSemiring set_option linter.uppercaseLean3 false in #align SemiRing.limit_semiring SemiRingCat.limitSemiring /-- `limit.π (F ⋙ forget SemiRingCat) j` as a `RingHom`. -/ def limitπRingHom (F : J ⥤ SemiRingCatMax.{v, u}) (j) : (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat)).pt →+* (F ⋙ forget SemiRingCat).obj j := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat { AddMonCat.limitπAddMonoidHom f j, MonCat.limitπMonoidHom (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) j with toFun := (Types.limitCone (F ⋙ forget SemiRingCat)).π.app j } set_option linter.uppercaseLean3 false in #align SemiRing.limit_π_ring_hom SemiRingCat.limitπRingHom namespace HasLimits -- The next two definitions are used in the construction of `HasLimits SemiRingCat`. -- After that, the limits should be constructed using the generic limits API, -- e.g. `limit F`, `limit.cone F`, and `limit.isLimit F`. /-- Construction of a limit cone in `SemiRingCat`. (Internal use only; use the limits API.) -/ def limitCone (F : J ⥤ SemiRingCatMax.{v, u}) : Cone F where pt := SemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := limitπRingHom.{v, u} F naturality := fun {_ _} f => RingHom.coe_inj ((Types.limitCone (F ⋙ forget _)).π.naturality f) } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone SemiRingCat.HasLimits.limitCone /-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone_is_limit SemiRingCat.HasLimits.limitConeIsLimit end HasLimits open HasLimits /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v} SemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => ⟨limitCone.{v, u} F, limitConeIsLimit.{v, u} F⟩ } } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits_of_size SemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits SemiRingCat.{u} := SemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.has_limits SemiRingCat.hasLimits /-- Auxiliary lemma to prove the cone induced by `limitCone` is a limit cone. -/ def forget₂AddCommMonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat AddCommMonCat).mapCone (limitCone F)) := by apply AddCommMonCat.limitConeIsLimit.{v, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_aux SemiRingCat.forget₂AddCommMonPreservesLimitsAux /-- The forgetful functor from semirings to additive commutative monoids preserves all limits. -/ instance forget₂AddCommMonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat AddCommMonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (forget₂AddCommMonPreservesLimitsAux F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_of_size SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize instance forget₂AddCommMonPreservesLimits : PreservesLimits (forget₂ SemiRingCat AddCommMonCat.{u}) := SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits SemiRingCat.forget₂AddCommMonPreservesLimits /-- An auxiliary declaration to speed up typechecking. -/ def forget₂MonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat MonCat).mapCone (limitCone F)) := by apply MonCat.HasLimits.limitConeIsLimit (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_aux SemiRingCat.forget₂MonPreservesLimitsAux /-- The forgetful functor from semirings to monoids preserves all limits. -/ instance forget₂MonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat MonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (forget₂MonPreservesLimitsAux.{v, u} F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_of_size SemiRingCat.forget₂MonPreservesLimitsOfSize instance forget₂MonPreservesLimits : PreservesLimits (forget₂ SemiRingCat MonCat.{u}) := SemiRingCat.forget₂MonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits SemiRingCat.forget₂MonPreservesLimits /-- The forgetful functor from semirings to types preserves all limits. -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (Types.limitConeIsLimit.{v, u} (F ⋙ forget _)) } set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits_of_size SemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget SemiRingCat.{u}) := SemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits SemiRingCat.forgetPreservesLimits end SemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `CommSemiring.{max u v}`, to deal with unification issues. -/ @[nolint checkUnivs] abbrev CommSemiRingCatMax.{u1, u2} := CommSemiRingCat.{max u1 u2} namespace CommSemiRingCat variable {J : Type v} [SmallCategory J] instance commSemiringObj (F : J ⥤ CommSemiRingCatMax.{v, u}) (j) : CommSemiring ((F ⋙ forget CommSemiRingCat).obj j) := by change CommSemiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align CommSemiRing.comm_semiring_obj CommSemiRingCat.commSemiringObj instance limitCommSemiring (F : J ⥤ CommSemiRingCatMax.{v, u}) : CommSemiring (Types.limitCone.{v, u} (F ⋙ forget CommSemiRingCat.{max v u})).pt := @Subsemiring.toCommSemiring (∀ j, F.obj j) _ (SemiRingCat.sectionsSubsemiring.{v, u} (F ⋙ forget₂ CommSemiRingCat SemiRingCat.{max v u})) set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_comm_semiring CommSemiRingCat.limitCommSemiring /-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := -- Porting note : `CommSemiRingCat ⥤ Type` reflecting isomorphism is needed to make Lean see that -- `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism. `CommSemiRingCat ⥤ Type` reflecting -- isomorphism is added manually since Lean can't see it, but even with this addition Lean can not -- see `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism, so this instance is also added. letI : ReflectsIsomorphisms (forget CommSemiRingCatMax.{v, u}) := CommSemiRingCat.forgetReflectIsos.{max v u} letI : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := CategoryTheory.reflectsIsomorphisms_forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u} let c : Cone F := { pt := CommSemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun j => CommSemiRingCat.ofHom <| SemiRingCat.limitπRingHom.{v, u} (J := J) (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) j naturality := (SemiRingCat.HasLimits.limitCone.{v, u} (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) t makesLimit := by refine IsLimit.ofFaithful (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) (fun s : Cone F => CommSemiRingCat.ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl } /-- A choice of limit cone for a functor into `CommSemiRingCat`. (Generally, you'll just want to use `limit F`.) -/ def limitCone (F : J ⥤ CommSemiRingCatMax.{v, u}) : Cone F := liftLimit (limit.isLimit (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})) set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_cone CommSemiRingCat.limitCone /-- The chosen cone is a limit cone. (Generally, you'll just want to use `limit.cone F`.) -/ def limitConeIsLimit (F : J ⥤ CommSemiRingCatMax.{v, u}) : IsLimit (limitCone F) := liftedLimitIsLimit _ set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_cone_is_limit CommSemiRingCat.limitConeIsLimit /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v, v} CommSemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => hasLimit_of_created F (forget₂ CommSemiRingCat SemiRingCatMax.{v, u}) } } set_option linter.uppercaseLean3 false in #align CommSemiRing.has_limits_of_size CommSemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits CommSemiRingCat.{u} := CommSemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.has_limits CommSemiRingCat.hasLimits /-- The forgetful functor from rings to semirings preserves all limits. -/ instance forget₂SemiRingPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ CommSemiRingCat SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (SemiRingCat.HasLimits.limitConeIsLimit _) } set_option linter.uppercaseLean3 false in #align CommSemiRing.forget₂_SemiRing_preserves_limits_of_size CommSemiRingCat.forget₂SemiRingPreservesLimitsOfSize instance forget₂SemiRingPreservesLimits : PreservesLimits (forget₂ CommSemiRingCat SemiRingCat.{u}) := CommSemiRingCat.forget₂SemiRingPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.forget₂_SemiRing_preserves_limits CommSemiRingCat.forget₂SemiRingPreservesLimits /-- The forgetful functor from rings to types preserves all limits. (That is, the underlying types could have been computed instead as limits in the category of types.) -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget CommSemiRingCatMax.{v, u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (Types.limitConeIsLimit.{v, u} _) } set_option linter.uppercaseLean3 false in #align CommSemiRing.forget_preserves_limits_of_size CommSemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget CommSemiRingCat.{u}) := CommSemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.forget_preserves_limits CommSemiRingCat.forgetPreservesLimits end CommSemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `RingCat.{max u v}`, to deal around unification issues. -/ @[nolint checkUnivs] abbrev RingCatMax.{u1, u2} := RingCat.{max u1 u2} namespace RingCat variable {J : Type v} [SmallCategory J] instance ringObj (F : J ⥤ RingCatMax.{v, u}) (j) : Ring ((F ⋙ forget RingCat).obj j) := by change Ring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align Ring.ring_obj RingCat.ringObj /-- The flat sections of a functor into `RingCat` form a subring of all sections. -/ def sectionsSubring (F : J ⥤ RingCatMax.{v, u}) : Subring.{max v u} (∀ j, F.obj j) := letI f : J ⥤ AddGroupCat.{max v u} := F ⋙ forget₂ RingCatMax.{v, u} AddCommGroupCat.{max v u} ⋙ forget₂ AddCommGroupCat.{max v u} AddGroupCat.{max v u} letI g : J ⥤ SemiRingCatMax.{v, u} := F ⋙ forget₂ RingCatMax.{v, u} SemiRingCat.{max v u} { AddGroupCat.sectionsAddSubgroup.{v, u} (J := J) f, SemiRingCat.sectionsSubsemiring.{v, u} (J := J) g with carrier := (F ⋙ forget RingCatMax.{v, u}).sections } set_option linter.uppercaseLean3 false in #align Ring.sections_subring RingCat.sectionsSubring instance limitRing (F : J ⥤ RingCatMax.{v, u}) : Ring.{max v u} (Types.limitCone.{v, u} (F ⋙ forget RingCatMax.{v, u})).pt := (sectionsSubring F).toRing set_option linter.uppercaseLean3 false in #align Ring.limit_ring RingCat.limitRing /-- We show that the forgetful functor `CommRingCat ⥤ RingCat` creates limits. All we need to do is notice that the limit point has a `Ring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ RingCatMax.{v, u}) : CreatesLimit F (forget₂ RingCatMax.{v, u} SemiRingCatMax.{v, u}) := letI : ReflectsIsomorphisms (forget₂ RingCatMax SemiRingCatMax) := CategoryTheory.reflectsIsomorphisms_forget₂ _ _ letI c : Cone F := { pt := RingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun x => SemiRingCat.ofHom _ naturality := (SemiRingCat.HasLimits.limitCone (F ⋙ forget₂ RingCat SemiRingCat.{max v u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := by apply IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit _) t makesLimit := IsLimit.ofFaithful (forget₂ RingCat SemiRingCat.{max v u}) (by apply SemiRingCat.HasLimits.limitConeIsLimit _) (fun s => _) fun s => rfl } /-- A choice of limit cone for a functor into `RingCat`. (Generally, you'll just want to use `limit F`.) -/ def limitCone (F : J ⥤ RingCatMax.{v, u}) : Cone F := liftLimit (limit.isLimit (F ⋙ forget₂ RingCatMax.{v, u} SemiRingCatMax.{v, u})) set_option linter.uppercaseLean3 false in #align Ring.limit_cone RingCat.limitCone /-- The chosen cone is a limit cone. (Generally, you'll just want to use `limit.cone F`.) -/ def limitConeIsLimit (F : J ⥤ RingCatMax.{v, u}) : IsLimit (limitCone F) := liftedLimitIsLimit _ set_option linter.uppercaseLean3 false in #align Ring.limit_cone_is_limit RingCat.limitConeIsLimit /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v, v} RingCat.{max v u} := { has_limits_of_shape := fun {_ _} => { has_limit := fun {F} => hasLimit_of_created F (forget₂ RingCatMax.{v, u} SemiRingCatMax.{v, u}) } } set_option linter.uppercaseLean3 false in #align Ring.has_limits_of_size RingCat.hasLimitsOfSize instance hasLimits : HasLimits RingCat.{u} := RingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align Ring.has_limits RingCat.hasLimits /-- The forgetful functor from rings to semirings preserves all limits. -/ instance forget₂SemiRingPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ RingCat SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) } set_option linter.uppercaseLean3 false in #align Ring.forget₂_SemiRing_preserves_limits_of_size RingCat.forget₂SemiRingPreservesLimitsOfSize instance forget₂SemiRingPreservesLimits : PreservesLimits (forget₂ RingCat SemiRingCat.{u}) := RingCat.forget₂SemiRingPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align Ring.forget₂_SemiRing_preserves_limits RingCat.forget₂SemiRingPreservesLimits /-- An auxiliary declaration to speed up typechecking. -/ def forget₂AddCommGroupPreservesLimitsAux (F : J ⥤ RingCatMax.{v, u}) : IsLimit ((forget₂ RingCatMax.{v, u} AddCommGroupCat).mapCone (limitCone.{v, u} F)) := by -- Porting note : inline `f` would not compile letI f := (F ⋙ forget₂ RingCatMax.{v, u} AddCommGroupCat.{max v u}) apply AddCommGroupCat.limitConeIsLimit.{v, u} f set_option linter.uppercaseLean3 false in #align Ring.forget₂_AddCommGroup_preserves_limits_aux RingCat.forget₂AddCommGroupPreservesLimitsAux /-- The forgetful functor from rings to additive commutative groups preserves all limits. -/ instance forget₂AddCommGroupPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ RingCatMax.{v, u} AddCommGroupCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (forget₂AddCommGroupPreservesLimitsAux F) } set_option linter.uppercaseLean3 false in #align Ring.forget₂_AddCommGroup_preserves_limits_of_size RingCat.forget₂AddCommGroupPreservesLimitsOfSize instance forget₂AddCommGroupPreservesLimits : PreservesLimits (forget₂ RingCat AddCommGroupCat.{u}) := RingCat.forget₂AddCommGroupPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align Ring.forget₂_AddCommGroup_preserves_limits RingCat.forget₂AddCommGroupPreservesLimits /-- The forgetful functor from rings to types preserves all limits. (That is, the underlying types could have been computed instead as limits in the category of types.) -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget RingCatMax.{v, u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (Types.limitConeIsLimit.{v, u} _) } set_option linter.uppercaseLean3 false in #align Ring.forget_preserves_limits_of_size RingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget RingCat.{u}) := RingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align Ring.forget_preserves_limits RingCat.forgetPreservesLimits end RingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `CommRingCat.{max u v}`, to deal around unification issues. -/ @[nolint checkUnivs] abbrev CommRingCatMax.{u1, u2} := CommRingCat.{max u1 u2} namespace CommRingCat variable {J : Type v} [SmallCategory J] instance commRingObj (F : J ⥤ CommRingCatMax.{v, u}) (j) : CommRing ((F ⋙ forget CommRingCat).obj j) := by
change CommRing (F.obj j)
instance commRingObj (F : J ⥤ CommRingCatMax.{v, u}) (j) : CommRing ((F ⋙ forget CommRingCat).obj j) := by
Mathlib.Algebra.Category.Ring.Limits.480_0.VxjNIkMLPSqe2rX
instance commRingObj (F : J ⥤ CommRingCatMax.{v, u}) (j) : CommRing ((F ⋙ forget CommRingCat).obj j)
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ CommRingCatMax j : J ⊢ CommRing ↑(F.obj j)
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align SemiRing.semiring_obj SemiRingCat.semiringObj /-- The flat sections of a functor into `SemiRingCat` form a subsemiring of all sections. -/ def sectionsSubsemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Subsemiring.{max v u} (∀ j, F.obj j) := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat letI g : J ⥤ MonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} MonCat.{max v u} { (MonCat.sectionsSubmonoid.{v, u} (J := J) g), (AddMonCat.sectionsAddSubmonoid.{v, u} (J := J) f) with carrier := (F ⋙ forget SemiRingCat).sections } set_option linter.uppercaseLean3 false in #align SemiRing.sections_subsemiring SemiRingCat.sectionsSubsemiring instance limitSemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Semiring (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat.{max v u})).pt := (sectionsSubsemiring F).toSemiring set_option linter.uppercaseLean3 false in #align SemiRing.limit_semiring SemiRingCat.limitSemiring /-- `limit.π (F ⋙ forget SemiRingCat) j` as a `RingHom`. -/ def limitπRingHom (F : J ⥤ SemiRingCatMax.{v, u}) (j) : (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat)).pt →+* (F ⋙ forget SemiRingCat).obj j := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat { AddMonCat.limitπAddMonoidHom f j, MonCat.limitπMonoidHom (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) j with toFun := (Types.limitCone (F ⋙ forget SemiRingCat)).π.app j } set_option linter.uppercaseLean3 false in #align SemiRing.limit_π_ring_hom SemiRingCat.limitπRingHom namespace HasLimits -- The next two definitions are used in the construction of `HasLimits SemiRingCat`. -- After that, the limits should be constructed using the generic limits API, -- e.g. `limit F`, `limit.cone F`, and `limit.isLimit F`. /-- Construction of a limit cone in `SemiRingCat`. (Internal use only; use the limits API.) -/ def limitCone (F : J ⥤ SemiRingCatMax.{v, u}) : Cone F where pt := SemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := limitπRingHom.{v, u} F naturality := fun {_ _} f => RingHom.coe_inj ((Types.limitCone (F ⋙ forget _)).π.naturality f) } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone SemiRingCat.HasLimits.limitCone /-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone_is_limit SemiRingCat.HasLimits.limitConeIsLimit end HasLimits open HasLimits /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v} SemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => ⟨limitCone.{v, u} F, limitConeIsLimit.{v, u} F⟩ } } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits_of_size SemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits SemiRingCat.{u} := SemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.has_limits SemiRingCat.hasLimits /-- Auxiliary lemma to prove the cone induced by `limitCone` is a limit cone. -/ def forget₂AddCommMonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat AddCommMonCat).mapCone (limitCone F)) := by apply AddCommMonCat.limitConeIsLimit.{v, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_aux SemiRingCat.forget₂AddCommMonPreservesLimitsAux /-- The forgetful functor from semirings to additive commutative monoids preserves all limits. -/ instance forget₂AddCommMonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat AddCommMonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (forget₂AddCommMonPreservesLimitsAux F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_of_size SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize instance forget₂AddCommMonPreservesLimits : PreservesLimits (forget₂ SemiRingCat AddCommMonCat.{u}) := SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits SemiRingCat.forget₂AddCommMonPreservesLimits /-- An auxiliary declaration to speed up typechecking. -/ def forget₂MonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat MonCat).mapCone (limitCone F)) := by apply MonCat.HasLimits.limitConeIsLimit (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_aux SemiRingCat.forget₂MonPreservesLimitsAux /-- The forgetful functor from semirings to monoids preserves all limits. -/ instance forget₂MonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat MonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (forget₂MonPreservesLimitsAux.{v, u} F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_of_size SemiRingCat.forget₂MonPreservesLimitsOfSize instance forget₂MonPreservesLimits : PreservesLimits (forget₂ SemiRingCat MonCat.{u}) := SemiRingCat.forget₂MonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits SemiRingCat.forget₂MonPreservesLimits /-- The forgetful functor from semirings to types preserves all limits. -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (Types.limitConeIsLimit.{v, u} (F ⋙ forget _)) } set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits_of_size SemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget SemiRingCat.{u}) := SemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits SemiRingCat.forgetPreservesLimits end SemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `CommSemiring.{max u v}`, to deal with unification issues. -/ @[nolint checkUnivs] abbrev CommSemiRingCatMax.{u1, u2} := CommSemiRingCat.{max u1 u2} namespace CommSemiRingCat variable {J : Type v} [SmallCategory J] instance commSemiringObj (F : J ⥤ CommSemiRingCatMax.{v, u}) (j) : CommSemiring ((F ⋙ forget CommSemiRingCat).obj j) := by change CommSemiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align CommSemiRing.comm_semiring_obj CommSemiRingCat.commSemiringObj instance limitCommSemiring (F : J ⥤ CommSemiRingCatMax.{v, u}) : CommSemiring (Types.limitCone.{v, u} (F ⋙ forget CommSemiRingCat.{max v u})).pt := @Subsemiring.toCommSemiring (∀ j, F.obj j) _ (SemiRingCat.sectionsSubsemiring.{v, u} (F ⋙ forget₂ CommSemiRingCat SemiRingCat.{max v u})) set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_comm_semiring CommSemiRingCat.limitCommSemiring /-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := -- Porting note : `CommSemiRingCat ⥤ Type` reflecting isomorphism is needed to make Lean see that -- `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism. `CommSemiRingCat ⥤ Type` reflecting -- isomorphism is added manually since Lean can't see it, but even with this addition Lean can not -- see `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism, so this instance is also added. letI : ReflectsIsomorphisms (forget CommSemiRingCatMax.{v, u}) := CommSemiRingCat.forgetReflectIsos.{max v u} letI : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := CategoryTheory.reflectsIsomorphisms_forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u} let c : Cone F := { pt := CommSemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun j => CommSemiRingCat.ofHom <| SemiRingCat.limitπRingHom.{v, u} (J := J) (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) j naturality := (SemiRingCat.HasLimits.limitCone.{v, u} (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) t makesLimit := by refine IsLimit.ofFaithful (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) (fun s : Cone F => CommSemiRingCat.ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl } /-- A choice of limit cone for a functor into `CommSemiRingCat`. (Generally, you'll just want to use `limit F`.) -/ def limitCone (F : J ⥤ CommSemiRingCatMax.{v, u}) : Cone F := liftLimit (limit.isLimit (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})) set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_cone CommSemiRingCat.limitCone /-- The chosen cone is a limit cone. (Generally, you'll just want to use `limit.cone F`.) -/ def limitConeIsLimit (F : J ⥤ CommSemiRingCatMax.{v, u}) : IsLimit (limitCone F) := liftedLimitIsLimit _ set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_cone_is_limit CommSemiRingCat.limitConeIsLimit /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v, v} CommSemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => hasLimit_of_created F (forget₂ CommSemiRingCat SemiRingCatMax.{v, u}) } } set_option linter.uppercaseLean3 false in #align CommSemiRing.has_limits_of_size CommSemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits CommSemiRingCat.{u} := CommSemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.has_limits CommSemiRingCat.hasLimits /-- The forgetful functor from rings to semirings preserves all limits. -/ instance forget₂SemiRingPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ CommSemiRingCat SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (SemiRingCat.HasLimits.limitConeIsLimit _) } set_option linter.uppercaseLean3 false in #align CommSemiRing.forget₂_SemiRing_preserves_limits_of_size CommSemiRingCat.forget₂SemiRingPreservesLimitsOfSize instance forget₂SemiRingPreservesLimits : PreservesLimits (forget₂ CommSemiRingCat SemiRingCat.{u}) := CommSemiRingCat.forget₂SemiRingPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.forget₂_SemiRing_preserves_limits CommSemiRingCat.forget₂SemiRingPreservesLimits /-- The forgetful functor from rings to types preserves all limits. (That is, the underlying types could have been computed instead as limits in the category of types.) -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget CommSemiRingCatMax.{v, u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (Types.limitConeIsLimit.{v, u} _) } set_option linter.uppercaseLean3 false in #align CommSemiRing.forget_preserves_limits_of_size CommSemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget CommSemiRingCat.{u}) := CommSemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.forget_preserves_limits CommSemiRingCat.forgetPreservesLimits end CommSemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `RingCat.{max u v}`, to deal around unification issues. -/ @[nolint checkUnivs] abbrev RingCatMax.{u1, u2} := RingCat.{max u1 u2} namespace RingCat variable {J : Type v} [SmallCategory J] instance ringObj (F : J ⥤ RingCatMax.{v, u}) (j) : Ring ((F ⋙ forget RingCat).obj j) := by change Ring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align Ring.ring_obj RingCat.ringObj /-- The flat sections of a functor into `RingCat` form a subring of all sections. -/ def sectionsSubring (F : J ⥤ RingCatMax.{v, u}) : Subring.{max v u} (∀ j, F.obj j) := letI f : J ⥤ AddGroupCat.{max v u} := F ⋙ forget₂ RingCatMax.{v, u} AddCommGroupCat.{max v u} ⋙ forget₂ AddCommGroupCat.{max v u} AddGroupCat.{max v u} letI g : J ⥤ SemiRingCatMax.{v, u} := F ⋙ forget₂ RingCatMax.{v, u} SemiRingCat.{max v u} { AddGroupCat.sectionsAddSubgroup.{v, u} (J := J) f, SemiRingCat.sectionsSubsemiring.{v, u} (J := J) g with carrier := (F ⋙ forget RingCatMax.{v, u}).sections } set_option linter.uppercaseLean3 false in #align Ring.sections_subring RingCat.sectionsSubring instance limitRing (F : J ⥤ RingCatMax.{v, u}) : Ring.{max v u} (Types.limitCone.{v, u} (F ⋙ forget RingCatMax.{v, u})).pt := (sectionsSubring F).toRing set_option linter.uppercaseLean3 false in #align Ring.limit_ring RingCat.limitRing /-- We show that the forgetful functor `CommRingCat ⥤ RingCat` creates limits. All we need to do is notice that the limit point has a `Ring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ RingCatMax.{v, u}) : CreatesLimit F (forget₂ RingCatMax.{v, u} SemiRingCatMax.{v, u}) := letI : ReflectsIsomorphisms (forget₂ RingCatMax SemiRingCatMax) := CategoryTheory.reflectsIsomorphisms_forget₂ _ _ letI c : Cone F := { pt := RingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun x => SemiRingCat.ofHom _ naturality := (SemiRingCat.HasLimits.limitCone (F ⋙ forget₂ RingCat SemiRingCat.{max v u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := by apply IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit _) t makesLimit := IsLimit.ofFaithful (forget₂ RingCat SemiRingCat.{max v u}) (by apply SemiRingCat.HasLimits.limitConeIsLimit _) (fun s => _) fun s => rfl } /-- A choice of limit cone for a functor into `RingCat`. (Generally, you'll just want to use `limit F`.) -/ def limitCone (F : J ⥤ RingCatMax.{v, u}) : Cone F := liftLimit (limit.isLimit (F ⋙ forget₂ RingCatMax.{v, u} SemiRingCatMax.{v, u})) set_option linter.uppercaseLean3 false in #align Ring.limit_cone RingCat.limitCone /-- The chosen cone is a limit cone. (Generally, you'll just want to use `limit.cone F`.) -/ def limitConeIsLimit (F : J ⥤ RingCatMax.{v, u}) : IsLimit (limitCone F) := liftedLimitIsLimit _ set_option linter.uppercaseLean3 false in #align Ring.limit_cone_is_limit RingCat.limitConeIsLimit /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v, v} RingCat.{max v u} := { has_limits_of_shape := fun {_ _} => { has_limit := fun {F} => hasLimit_of_created F (forget₂ RingCatMax.{v, u} SemiRingCatMax.{v, u}) } } set_option linter.uppercaseLean3 false in #align Ring.has_limits_of_size RingCat.hasLimitsOfSize instance hasLimits : HasLimits RingCat.{u} := RingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align Ring.has_limits RingCat.hasLimits /-- The forgetful functor from rings to semirings preserves all limits. -/ instance forget₂SemiRingPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ RingCat SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) } set_option linter.uppercaseLean3 false in #align Ring.forget₂_SemiRing_preserves_limits_of_size RingCat.forget₂SemiRingPreservesLimitsOfSize instance forget₂SemiRingPreservesLimits : PreservesLimits (forget₂ RingCat SemiRingCat.{u}) := RingCat.forget₂SemiRingPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align Ring.forget₂_SemiRing_preserves_limits RingCat.forget₂SemiRingPreservesLimits /-- An auxiliary declaration to speed up typechecking. -/ def forget₂AddCommGroupPreservesLimitsAux (F : J ⥤ RingCatMax.{v, u}) : IsLimit ((forget₂ RingCatMax.{v, u} AddCommGroupCat).mapCone (limitCone.{v, u} F)) := by -- Porting note : inline `f` would not compile letI f := (F ⋙ forget₂ RingCatMax.{v, u} AddCommGroupCat.{max v u}) apply AddCommGroupCat.limitConeIsLimit.{v, u} f set_option linter.uppercaseLean3 false in #align Ring.forget₂_AddCommGroup_preserves_limits_aux RingCat.forget₂AddCommGroupPreservesLimitsAux /-- The forgetful functor from rings to additive commutative groups preserves all limits. -/ instance forget₂AddCommGroupPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ RingCatMax.{v, u} AddCommGroupCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (forget₂AddCommGroupPreservesLimitsAux F) } set_option linter.uppercaseLean3 false in #align Ring.forget₂_AddCommGroup_preserves_limits_of_size RingCat.forget₂AddCommGroupPreservesLimitsOfSize instance forget₂AddCommGroupPreservesLimits : PreservesLimits (forget₂ RingCat AddCommGroupCat.{u}) := RingCat.forget₂AddCommGroupPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align Ring.forget₂_AddCommGroup_preserves_limits RingCat.forget₂AddCommGroupPreservesLimits /-- The forgetful functor from rings to types preserves all limits. (That is, the underlying types could have been computed instead as limits in the category of types.) -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget RingCatMax.{v, u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (Types.limitConeIsLimit.{v, u} _) } set_option linter.uppercaseLean3 false in #align Ring.forget_preserves_limits_of_size RingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget RingCat.{u}) := RingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align Ring.forget_preserves_limits RingCat.forgetPreservesLimits end RingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `CommRingCat.{max u v}`, to deal around unification issues. -/ @[nolint checkUnivs] abbrev CommRingCatMax.{u1, u2} := CommRingCat.{max u1 u2} namespace CommRingCat variable {J : Type v} [SmallCategory J] instance commRingObj (F : J ⥤ CommRingCatMax.{v, u}) (j) : CommRing ((F ⋙ forget CommRingCat).obj j) := by change CommRing (F.obj j)
infer_instance
instance commRingObj (F : J ⥤ CommRingCatMax.{v, u}) (j) : CommRing ((F ⋙ forget CommRingCat).obj j) := by change CommRing (F.obj j)
Mathlib.Algebra.Category.Ring.Limits.480_0.VxjNIkMLPSqe2rX
instance commRingObj (F : J ⥤ CommRingCatMax.{v, u}) (j) : CommRing ((F ⋙ forget CommRingCat).obj j)
Mathlib_Algebra_Category_Ring_Limits
J : Type v inst✝ : SmallCategory J F : J ⥤ CommRingCatMax ⊢ IsLimit ((forget₂ CommRingCat CommSemiRingCat).mapCone (limitCone F))
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Category.Ring.Basic import Mathlib.Algebra.Category.GroupCat.Limits import Mathlib.RingTheory.Subring.Basic #align_import algebra.category.Ring.limits from "leanprover-community/mathlib"@"c43486ecf2a5a17479a32ce09e4818924145e90e" /-! # The category of (commutative) rings has all limits Further, these limits are preserved by the forgetful functor --- that is, the underlying types are just the limits in the category of types. -/ -- We use the following trick a lot of times in this file. library_note "change elaboration strategy with `by apply`"/-- Some definitions may be extremely slow to elaborate, when the target type to be constructed is complicated and when the type of the term given in the definition is also complicated and does not obviously match the target type. In this case, instead of just giving the term, prefixing it with `by apply` may speed up things considerably as the types are not elaborated in the same order. -/ open CategoryTheory open CategoryTheory.Limits universe v u noncomputable section namespace SemiRingCat variable {J : Type v} [SmallCategory J] instance semiringObj (F : J ⥤ SemiRingCatMax.{v, u}) (j) : Semiring ((F ⋙ forget SemiRingCat).obj j) := by change Semiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align SemiRing.semiring_obj SemiRingCat.semiringObj /-- The flat sections of a functor into `SemiRingCat` form a subsemiring of all sections. -/ def sectionsSubsemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Subsemiring.{max v u} (∀ j, F.obj j) := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat letI g : J ⥤ MonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} MonCat.{max v u} { (MonCat.sectionsSubmonoid.{v, u} (J := J) g), (AddMonCat.sectionsAddSubmonoid.{v, u} (J := J) f) with carrier := (F ⋙ forget SemiRingCat).sections } set_option linter.uppercaseLean3 false in #align SemiRing.sections_subsemiring SemiRingCat.sectionsSubsemiring instance limitSemiring (F : J ⥤ SemiRingCatMax.{v, u}) : Semiring (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat.{max v u})).pt := (sectionsSubsemiring F).toSemiring set_option linter.uppercaseLean3 false in #align SemiRing.limit_semiring SemiRingCat.limitSemiring /-- `limit.π (F ⋙ forget SemiRingCat) j` as a `RingHom`. -/ def limitπRingHom (F : J ⥤ SemiRingCatMax.{v, u}) (j) : (Types.limitCone.{v, u} (F ⋙ forget SemiRingCat)).pt →+* (F ⋙ forget SemiRingCat).obj j := -- Porting note : if `f` and `g` were inlined, it does not compile letI f : J ⥤ AddMonCat.{max v u} := F ⋙ forget₂ SemiRingCatMax.{v, u} AddCommMonCat.{max v u} ⋙ forget₂ AddCommMonCat AddMonCat { AddMonCat.limitπAddMonoidHom f j, MonCat.limitπMonoidHom (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) j with toFun := (Types.limitCone (F ⋙ forget SemiRingCat)).π.app j } set_option linter.uppercaseLean3 false in #align SemiRing.limit_π_ring_hom SemiRingCat.limitπRingHom namespace HasLimits -- The next two definitions are used in the construction of `HasLimits SemiRingCat`. -- After that, the limits should be constructed using the generic limits API, -- e.g. `limit F`, `limit.cone F`, and `limit.isLimit F`. /-- Construction of a limit cone in `SemiRingCat`. (Internal use only; use the limits API.) -/ def limitCone (F : J ⥤ SemiRingCatMax.{v, u}) : Cone F where pt := SemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := limitπRingHom.{v, u} F naturality := fun {_ _} f => RingHom.coe_inj ((Types.limitCone (F ⋙ forget _)).π.naturality f) } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone SemiRingCat.HasLimits.limitCone /-- Witness that the limit cone in `SemiRingCat` is a limit cone. (Internal use only; use the limits API.) -/ def limitConeIsLimit (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit (limitCone F) := by refine IsLimit.ofFaithful (forget SemiRingCatMax.{v, u}) (Types.limitConeIsLimit.{v, u} _) (fun s : Cone F => ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl set_option linter.uppercaseLean3 false in #align SemiRing.has_limits.limit_cone_is_limit SemiRingCat.HasLimits.limitConeIsLimit end HasLimits open HasLimits /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v} SemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => ⟨limitCone.{v, u} F, limitConeIsLimit.{v, u} F⟩ } } set_option linter.uppercaseLean3 false in #align SemiRing.has_limits_of_size SemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits SemiRingCat.{u} := SemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.has_limits SemiRingCat.hasLimits /-- Auxiliary lemma to prove the cone induced by `limitCone` is a limit cone. -/ def forget₂AddCommMonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat AddCommMonCat).mapCone (limitCone F)) := by apply AddCommMonCat.limitConeIsLimit.{v, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_aux SemiRingCat.forget₂AddCommMonPreservesLimitsAux /-- The forgetful functor from semirings to additive commutative monoids preserves all limits. -/ instance forget₂AddCommMonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat AddCommMonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (forget₂AddCommMonPreservesLimitsAux F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits_of_size SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize instance forget₂AddCommMonPreservesLimits : PreservesLimits (forget₂ SemiRingCat AddCommMonCat.{u}) := SemiRingCat.forget₂AddCommMonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_AddCommMon_preserves_limits SemiRingCat.forget₂AddCommMonPreservesLimits /-- An auxiliary declaration to speed up typechecking. -/ def forget₂MonPreservesLimitsAux (F : J ⥤ SemiRingCatMax.{v, u}) : IsLimit ((forget₂ SemiRingCat MonCat).mapCone (limitCone F)) := by apply MonCat.HasLimits.limitConeIsLimit (F ⋙ forget₂ SemiRingCat MonCat.{max v u}) set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_aux SemiRingCat.forget₂MonPreservesLimitsAux /-- The forgetful functor from semirings to monoids preserves all limits. -/ instance forget₂MonPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ SemiRingCat MonCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (forget₂MonPreservesLimitsAux.{v, u} F) } set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits_of_size SemiRingCat.forget₂MonPreservesLimitsOfSize instance forget₂MonPreservesLimits : PreservesLimits (forget₂ SemiRingCat MonCat.{u}) := SemiRingCat.forget₂MonPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget₂_Mon_preserves_limits SemiRingCat.forget₂MonPreservesLimits /-- The forgetful functor from semirings to types preserves all limits. -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit F) (Types.limitConeIsLimit.{v, u} (F ⋙ forget _)) } set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits_of_size SemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget SemiRingCat.{u}) := SemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align SemiRing.forget_preserves_limits SemiRingCat.forgetPreservesLimits end SemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `CommSemiring.{max u v}`, to deal with unification issues. -/ @[nolint checkUnivs] abbrev CommSemiRingCatMax.{u1, u2} := CommSemiRingCat.{max u1 u2} namespace CommSemiRingCat variable {J : Type v} [SmallCategory J] instance commSemiringObj (F : J ⥤ CommSemiRingCatMax.{v, u}) (j) : CommSemiring ((F ⋙ forget CommSemiRingCat).obj j) := by change CommSemiring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align CommSemiRing.comm_semiring_obj CommSemiRingCat.commSemiringObj instance limitCommSemiring (F : J ⥤ CommSemiRingCatMax.{v, u}) : CommSemiring (Types.limitCone.{v, u} (F ⋙ forget CommSemiRingCat.{max v u})).pt := @Subsemiring.toCommSemiring (∀ j, F.obj j) _ (SemiRingCat.sectionsSubsemiring.{v, u} (F ⋙ forget₂ CommSemiRingCat SemiRingCat.{max v u})) set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_comm_semiring CommSemiRingCat.limitCommSemiring /-- We show that the forgetful functor `CommSemiRingCat ⥤ SemiRingCat` creates limits. All we need to do is notice that the limit point has a `CommSemiring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommSemiRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := -- Porting note : `CommSemiRingCat ⥤ Type` reflecting isomorphism is needed to make Lean see that -- `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism. `CommSemiRingCat ⥤ Type` reflecting -- isomorphism is added manually since Lean can't see it, but even with this addition Lean can not -- see `CommSemiRingCat ⥤ SemiRingCat` reflects isomorphism, so this instance is also added. letI : ReflectsIsomorphisms (forget CommSemiRingCatMax.{v, u}) := CommSemiRingCat.forgetReflectIsos.{max v u} letI : ReflectsIsomorphisms (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) := CategoryTheory.reflectsIsomorphisms_forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u} let c : Cone F := { pt := CommSemiRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun j => CommSemiRingCat.ofHom <| SemiRingCat.limitπRingHom.{v, u} (J := J) (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) j naturality := (SemiRingCat.HasLimits.limitCone.{v, u} (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) t makesLimit := by refine IsLimit.ofFaithful (forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u}) (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) (fun s : Cone F => CommSemiRingCat.ofHom { toFun := _ map_one' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_one map_mul' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_mul x y map_zero' := Subtype.ext <| funext fun j => by exact (s.π.app j).map_zero map_add' := fun x y => Subtype.ext <| funext fun j => by exact (s.π.app j).map_add x y }) fun s => rfl } /-- A choice of limit cone for a functor into `CommSemiRingCat`. (Generally, you'll just want to use `limit F`.) -/ def limitCone (F : J ⥤ CommSemiRingCatMax.{v, u}) : Cone F := liftLimit (limit.isLimit (F ⋙ forget₂ CommSemiRingCatMax.{v, u} SemiRingCatMax.{v, u})) set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_cone CommSemiRingCat.limitCone /-- The chosen cone is a limit cone. (Generally, you'll just want to use `limit.cone F`.) -/ def limitConeIsLimit (F : J ⥤ CommSemiRingCatMax.{v, u}) : IsLimit (limitCone F) := liftedLimitIsLimit _ set_option linter.uppercaseLean3 false in #align CommSemiRing.limit_cone_is_limit CommSemiRingCat.limitConeIsLimit /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v, v} CommSemiRingCatMax.{v, u} := { has_limits_of_shape := fun _ _ => { has_limit := fun F => hasLimit_of_created F (forget₂ CommSemiRingCat SemiRingCatMax.{v, u}) } } set_option linter.uppercaseLean3 false in #align CommSemiRing.has_limits_of_size CommSemiRingCat.hasLimitsOfSize instance hasLimits : HasLimits CommSemiRingCat.{u} := CommSemiRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.has_limits CommSemiRingCat.hasLimits /-- The forgetful functor from rings to semirings preserves all limits. -/ instance forget₂SemiRingPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ CommSemiRingCat SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (SemiRingCat.HasLimits.limitConeIsLimit _) } set_option linter.uppercaseLean3 false in #align CommSemiRing.forget₂_SemiRing_preserves_limits_of_size CommSemiRingCat.forget₂SemiRingPreservesLimitsOfSize instance forget₂SemiRingPreservesLimits : PreservesLimits (forget₂ CommSemiRingCat SemiRingCat.{u}) := CommSemiRingCat.forget₂SemiRingPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.forget₂_SemiRing_preserves_limits CommSemiRingCat.forget₂SemiRingPreservesLimits /-- The forgetful functor from rings to types preserves all limits. (That is, the underlying types could have been computed instead as limits in the category of types.) -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget CommSemiRingCatMax.{v, u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (Types.limitConeIsLimit.{v, u} _) } set_option linter.uppercaseLean3 false in #align CommSemiRing.forget_preserves_limits_of_size CommSemiRingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget CommSemiRingCat.{u}) := CommSemiRingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommSemiRing.forget_preserves_limits CommSemiRingCat.forgetPreservesLimits end CommSemiRingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `RingCat.{max u v}`, to deal around unification issues. -/ @[nolint checkUnivs] abbrev RingCatMax.{u1, u2} := RingCat.{max u1 u2} namespace RingCat variable {J : Type v} [SmallCategory J] instance ringObj (F : J ⥤ RingCatMax.{v, u}) (j) : Ring ((F ⋙ forget RingCat).obj j) := by change Ring (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align Ring.ring_obj RingCat.ringObj /-- The flat sections of a functor into `RingCat` form a subring of all sections. -/ def sectionsSubring (F : J ⥤ RingCatMax.{v, u}) : Subring.{max v u} (∀ j, F.obj j) := letI f : J ⥤ AddGroupCat.{max v u} := F ⋙ forget₂ RingCatMax.{v, u} AddCommGroupCat.{max v u} ⋙ forget₂ AddCommGroupCat.{max v u} AddGroupCat.{max v u} letI g : J ⥤ SemiRingCatMax.{v, u} := F ⋙ forget₂ RingCatMax.{v, u} SemiRingCat.{max v u} { AddGroupCat.sectionsAddSubgroup.{v, u} (J := J) f, SemiRingCat.sectionsSubsemiring.{v, u} (J := J) g with carrier := (F ⋙ forget RingCatMax.{v, u}).sections } set_option linter.uppercaseLean3 false in #align Ring.sections_subring RingCat.sectionsSubring instance limitRing (F : J ⥤ RingCatMax.{v, u}) : Ring.{max v u} (Types.limitCone.{v, u} (F ⋙ forget RingCatMax.{v, u})).pt := (sectionsSubring F).toRing set_option linter.uppercaseLean3 false in #align Ring.limit_ring RingCat.limitRing /-- We show that the forgetful functor `CommRingCat ⥤ RingCat` creates limits. All we need to do is notice that the limit point has a `Ring` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ RingCatMax.{v, u}) : CreatesLimit F (forget₂ RingCatMax.{v, u} SemiRingCatMax.{v, u}) := letI : ReflectsIsomorphisms (forget₂ RingCatMax SemiRingCatMax) := CategoryTheory.reflectsIsomorphisms_forget₂ _ _ letI c : Cone F := { pt := RingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun x => SemiRingCat.ofHom _ naturality := (SemiRingCat.HasLimits.limitCone (F ⋙ forget₂ RingCat SemiRingCat.{max v u})).π.naturality } } createsLimitOfReflectsIso fun c' t => { liftedCone := c validLift := by apply IsLimit.uniqueUpToIso (SemiRingCat.HasLimits.limitConeIsLimit _) t makesLimit := IsLimit.ofFaithful (forget₂ RingCat SemiRingCat.{max v u}) (by apply SemiRingCat.HasLimits.limitConeIsLimit _) (fun s => _) fun s => rfl } /-- A choice of limit cone for a functor into `RingCat`. (Generally, you'll just want to use `limit F`.) -/ def limitCone (F : J ⥤ RingCatMax.{v, u}) : Cone F := liftLimit (limit.isLimit (F ⋙ forget₂ RingCatMax.{v, u} SemiRingCatMax.{v, u})) set_option linter.uppercaseLean3 false in #align Ring.limit_cone RingCat.limitCone /-- The chosen cone is a limit cone. (Generally, you'll just want to use `limit.cone F`.) -/ def limitConeIsLimit (F : J ⥤ RingCatMax.{v, u}) : IsLimit (limitCone F) := liftedLimitIsLimit _ set_option linter.uppercaseLean3 false in #align Ring.limit_cone_is_limit RingCat.limitConeIsLimit /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v, v} RingCat.{max v u} := { has_limits_of_shape := fun {_ _} => { has_limit := fun {F} => hasLimit_of_created F (forget₂ RingCatMax.{v, u} SemiRingCatMax.{v, u}) } } set_option linter.uppercaseLean3 false in #align Ring.has_limits_of_size RingCat.hasLimitsOfSize instance hasLimits : HasLimits RingCat.{u} := RingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align Ring.has_limits RingCat.hasLimits /-- The forgetful functor from rings to semirings preserves all limits. -/ instance forget₂SemiRingPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ RingCat SemiRingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (SemiRingCat.HasLimits.limitConeIsLimit.{v, u} _) } set_option linter.uppercaseLean3 false in #align Ring.forget₂_SemiRing_preserves_limits_of_size RingCat.forget₂SemiRingPreservesLimitsOfSize instance forget₂SemiRingPreservesLimits : PreservesLimits (forget₂ RingCat SemiRingCat.{u}) := RingCat.forget₂SemiRingPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align Ring.forget₂_SemiRing_preserves_limits RingCat.forget₂SemiRingPreservesLimits /-- An auxiliary declaration to speed up typechecking. -/ def forget₂AddCommGroupPreservesLimitsAux (F : J ⥤ RingCatMax.{v, u}) : IsLimit ((forget₂ RingCatMax.{v, u} AddCommGroupCat).mapCone (limitCone.{v, u} F)) := by -- Porting note : inline `f` would not compile letI f := (F ⋙ forget₂ RingCatMax.{v, u} AddCommGroupCat.{max v u}) apply AddCommGroupCat.limitConeIsLimit.{v, u} f set_option linter.uppercaseLean3 false in #align Ring.forget₂_AddCommGroup_preserves_limits_aux RingCat.forget₂AddCommGroupPreservesLimitsAux /-- The forgetful functor from rings to additive commutative groups preserves all limits. -/ instance forget₂AddCommGroupPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ RingCatMax.{v, u} AddCommGroupCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (forget₂AddCommGroupPreservesLimitsAux F) } set_option linter.uppercaseLean3 false in #align Ring.forget₂_AddCommGroup_preserves_limits_of_size RingCat.forget₂AddCommGroupPreservesLimitsOfSize instance forget₂AddCommGroupPreservesLimits : PreservesLimits (forget₂ RingCat AddCommGroupCat.{u}) := RingCat.forget₂AddCommGroupPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align Ring.forget₂_AddCommGroup_preserves_limits RingCat.forget₂AddCommGroupPreservesLimits /-- The forgetful functor from rings to types preserves all limits. (That is, the underlying types could have been computed instead as limits in the category of types.) -/ instance forgetPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget RingCatMax.{v, u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone (limitConeIsLimit.{v, u} F) (Types.limitConeIsLimit.{v, u} _) } set_option linter.uppercaseLean3 false in #align Ring.forget_preserves_limits_of_size RingCat.forgetPreservesLimitsOfSize instance forgetPreservesLimits : PreservesLimits (forget RingCat.{u}) := RingCat.forgetPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align Ring.forget_preserves_limits RingCat.forgetPreservesLimits end RingCat -- Porting note: typemax hack to fix universe complaints /-- An alias for `CommRingCat.{max u v}`, to deal around unification issues. -/ @[nolint checkUnivs] abbrev CommRingCatMax.{u1, u2} := CommRingCat.{max u1 u2} namespace CommRingCat variable {J : Type v} [SmallCategory J] instance commRingObj (F : J ⥤ CommRingCatMax.{v, u}) (j) : CommRing ((F ⋙ forget CommRingCat).obj j) := by change CommRing (F.obj j) infer_instance set_option linter.uppercaseLean3 false in #align CommRing.comm_ring_obj CommRingCat.commRingObj instance limitCommRing (F : J ⥤ CommRingCatMax.{v, u}) : CommRing.{max v u} (Types.limitCone.{v, u} (F ⋙ forget CommRingCatMax.{v, u})).pt := @Subring.toCommRing (∀ j, F.obj j) _ (RingCat.sectionsSubring.{v, u} (F ⋙ forget₂ CommRingCat RingCat.{max v u})) set_option linter.uppercaseLean3 false in #align CommRing.limit_comm_ring CommRingCat.limitCommRing /-- We show that the forgetful functor `CommRingCat ⥤ RingCat` creates limits. All we need to do is notice that the limit point has a `CommRing` instance available, and then reuse the existing limit. -/ instance (F : J ⥤ CommRingCatMax.{v, u}) : CreatesLimit F (forget₂ CommRingCatMax.{v, u} RingCatMax.{v, u}) := /- A terse solution here would be ``` createsLimitOfFullyFaithfulOfIso (CommRingCat.of (limit (F ⋙ forget _))) (Iso.refl _) ``` but it seems this would introduce additional identity morphisms in `limit.π`. -/ -- Porting note : need to add these instances manually letI : ReflectsIsomorphisms (forget₂ CommRingCatMax.{v, u} RingCatMax.{v, u}) := CategoryTheory.reflectsIsomorphisms_forget₂ _ _ letI c : Cone F := { pt := CommRingCat.of (Types.limitCone (F ⋙ forget _)).pt π := { app := fun x => ofHom <| SemiRingCat.limitπRingHom.{v, u} (F ⋙ forget₂ CommRingCatMax.{v, u} RingCatMax.{v, u} ⋙ forget₂ RingCatMax.{v, u} SemiRingCatMax.{v, u}) x naturality := (SemiRingCat.HasLimits.limitCone.{v, u} (F ⋙ forget₂ _ RingCat.{max v u} ⋙ forget₂ _ SemiRingCat.{max v u})).π.naturality } } createsLimitOfReflectsIso fun _ t => { liftedCone := c validLift := IsLimit.uniqueUpToIso (RingCat.limitConeIsLimit.{v, u} _) t makesLimit := IsLimit.ofFaithful (forget₂ _ RingCatMax.{v, u}) (RingCat.limitConeIsLimit.{v, u} (F ⋙ forget₂ CommRingCatMax.{v, u} RingCatMax.{v, u})) (fun s : Cone F => ofHom <| (RingCat.limitConeIsLimit.{v, u} (F ⋙ forget₂ CommRingCatMax.{v, u} RingCatMax.{v, u})).lift ((forget₂ _ RingCatMax.{v, u}).mapCone s)) fun _ => rfl } /-- A choice of limit cone for a functor into `CommRingCat`. (Generally, you'll just want to use `limit F`.) -/ def limitCone (F : J ⥤ CommRingCatMax.{v, u}) : Cone F := -- Porting note : add this manually to get `liftLimit` letI : HasLimitsOfSize RingCatMax.{v, u} := RingCat.hasLimitsOfSize.{v, u} liftLimit (limit.isLimit (F ⋙ forget₂ CommRingCatMax.{v, u} RingCatMax.{v, u})) set_option linter.uppercaseLean3 false in #align CommRing.limit_cone CommRingCat.limitCone /-- The chosen cone is a limit cone. (Generally, you'll just want to use `limit.cone F`.) -/ def limitConeIsLimit (F : J ⥤ CommRingCatMax.{v, u}) : IsLimit (limitCone.{v, u} F) := liftedLimitIsLimit _ set_option linter.uppercaseLean3 false in #align CommRing.limit_cone_is_limit CommRingCat.limitConeIsLimit /- ./././Mathport/Syntax/Translate/Command.lean:322:38: unsupported irreducible non-definition -/ /-- The category of commutative rings has all limits. -/ instance hasLimitsOfSize : HasLimitsOfSize.{v, v} CommRingCatMax.{v, u} := -- Porting note : add this manually to get `liftLimit` letI : HasLimitsOfSize RingCatMax.{v, u} := RingCat.hasLimitsOfSize.{v, u} { has_limits_of_shape := fun {_ _} => { has_limit := fun F => hasLimit_of_created F (forget₂ CommRingCatMax.{v, u} RingCatMax.{v, u}) } } set_option linter.uppercaseLean3 false in #align CommRing.has_limits_of_size CommRingCat.hasLimitsOfSize instance hasLimits : HasLimits CommRingCat.{u} := CommRingCat.hasLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommRing.has_limits CommRingCat.hasLimits /-- The forgetful functor from commutative rings to rings preserves all limits. (That is, the underlying rings could have been computed instead as limits in the category of rings.) -/ instance forget₂RingPreservesLimitsOfSize : PreservesLimitsOfSize.{v, v} (forget₂ CommRingCat RingCat.{max v u}) where preservesLimitsOfShape {_ _} := { preservesLimit := fun {F} => preservesLimitOfPreservesLimitCone.{v, v} (limitConeIsLimit.{v, u} F) (RingCat.limitConeIsLimit.{v, u} _) } set_option linter.uppercaseLean3 false in #align CommRing.forget₂_Ring_preserves_limits_of_size CommRingCat.forget₂RingPreservesLimitsOfSize instance forget₂RingPreservesLimits : PreservesLimits (forget₂ CommRingCat RingCat.{u}) := CommRingCat.forget₂RingPreservesLimitsOfSize.{u, u} set_option linter.uppercaseLean3 false in #align CommRing.forget₂_Ring_preserves_limits CommRingCat.forget₂RingPreservesLimits /-- An auxiliary declaration to speed up typechecking. -/ def forget₂CommSemiRingPreservesLimitsAux (F : J ⥤ CommRingCatMax.{v, u}) : IsLimit ((forget₂ CommRingCat CommSemiRingCat).mapCone (limitCone F)) := by
apply CommSemiRingCat.limitConeIsLimit (F ⋙ forget₂ CommRingCat CommSemiRingCat.{max v u})
/-- An auxiliary declaration to speed up typechecking. -/ def forget₂CommSemiRingPreservesLimitsAux (F : J ⥤ CommRingCatMax.{v, u}) : IsLimit ((forget₂ CommRingCat CommSemiRingCat).mapCone (limitCone F)) := by
Mathlib.Algebra.Category.Ring.Limits.586_0.VxjNIkMLPSqe2rX
/-- An auxiliary declaration to speed up typechecking. -/ def forget₂CommSemiRingPreservesLimitsAux (F : J ⥤ CommRingCatMax.{v, u}) : IsLimit ((forget₂ CommRingCat CommSemiRingCat).mapCone (limitCone F))
Mathlib_Algebra_Category_Ring_Limits
R : Type u_1 inst✝ : Semiring R p q : R[X] ⊢ mirror 0 = 0
/- Copyright (c) 2020 Thomas Browning. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Thomas Browning -/ import Mathlib.Algebra.BigOperators.NatAntidiagonal import Mathlib.Data.Polynomial.RingDivision #align_import data.polynomial.mirror from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" /-! # "Mirror" of a univariate polynomial In this file we define `Polynomial.mirror`, a variant of `Polynomial.reverse`. The difference between `reverse` and `mirror` is that `reverse` will decrease the degree if the polynomial is divisible by `X`. ## Main definitions - `Polynomial.mirror` ## Main results - `Polynomial.mirror_mul_of_domain`: `mirror` preserves multiplication. - `Polynomial.irreducible_of_mirror`: an irreducibility criterion involving `mirror` -/ namespace Polynomial open Polynomial section Semiring variable {R : Type*} [Semiring R] (p q : R[X]) /-- mirror of a polynomial: reverses the coefficients while preserving `Polynomial.natDegree` -/ noncomputable def mirror := p.reverse * X ^ p.natTrailingDegree #align polynomial.mirror Polynomial.mirror @[simp] theorem mirror_zero : (0 : R[X]).mirror = 0 := by
simp [mirror]
@[simp] theorem mirror_zero : (0 : R[X]).mirror = 0 := by
Mathlib.Data.Polynomial.Mirror.43_0.jRYkh9xLrkM32QX
@[simp] theorem mirror_zero : (0 : R[X]).mirror = 0
Mathlib_Data_Polynomial_Mirror
R : Type u_1 inst✝ : Semiring R p q : R[X] n : ℕ a : R ⊢ mirror ((monomial n) a) = (monomial n) a
/- Copyright (c) 2020 Thomas Browning. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Thomas Browning -/ import Mathlib.Algebra.BigOperators.NatAntidiagonal import Mathlib.Data.Polynomial.RingDivision #align_import data.polynomial.mirror from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" /-! # "Mirror" of a univariate polynomial In this file we define `Polynomial.mirror`, a variant of `Polynomial.reverse`. The difference between `reverse` and `mirror` is that `reverse` will decrease the degree if the polynomial is divisible by `X`. ## Main definitions - `Polynomial.mirror` ## Main results - `Polynomial.mirror_mul_of_domain`: `mirror` preserves multiplication. - `Polynomial.irreducible_of_mirror`: an irreducibility criterion involving `mirror` -/ namespace Polynomial open Polynomial section Semiring variable {R : Type*} [Semiring R] (p q : R[X]) /-- mirror of a polynomial: reverses the coefficients while preserving `Polynomial.natDegree` -/ noncomputable def mirror := p.reverse * X ^ p.natTrailingDegree #align polynomial.mirror Polynomial.mirror @[simp] theorem mirror_zero : (0 : R[X]).mirror = 0 := by simp [mirror] #align polynomial.mirror_zero Polynomial.mirror_zero theorem mirror_monomial (n : ℕ) (a : R) : (monomial n a).mirror = monomial n a := by
classical by_cases ha : a = 0 · rw [ha, monomial_zero_right, mirror_zero] · rw [mirror, reverse, natDegree_monomial n a, if_neg ha, natTrailingDegree_monomial ha, ← C_mul_X_pow_eq_monomial, reflect_C_mul_X_pow, revAt_le (le_refl n), tsub_self, pow_zero, mul_one]
theorem mirror_monomial (n : ℕ) (a : R) : (monomial n a).mirror = monomial n a := by
Mathlib.Data.Polynomial.Mirror.47_0.jRYkh9xLrkM32QX
theorem mirror_monomial (n : ℕ) (a : R) : (monomial n a).mirror = monomial n a
Mathlib_Data_Polynomial_Mirror
R : Type u_1 inst✝ : Semiring R p q : R[X] n : ℕ a : R ⊢ mirror ((monomial n) a) = (monomial n) a
/- Copyright (c) 2020 Thomas Browning. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Thomas Browning -/ import Mathlib.Algebra.BigOperators.NatAntidiagonal import Mathlib.Data.Polynomial.RingDivision #align_import data.polynomial.mirror from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" /-! # "Mirror" of a univariate polynomial In this file we define `Polynomial.mirror`, a variant of `Polynomial.reverse`. The difference between `reverse` and `mirror` is that `reverse` will decrease the degree if the polynomial is divisible by `X`. ## Main definitions - `Polynomial.mirror` ## Main results - `Polynomial.mirror_mul_of_domain`: `mirror` preserves multiplication. - `Polynomial.irreducible_of_mirror`: an irreducibility criterion involving `mirror` -/ namespace Polynomial open Polynomial section Semiring variable {R : Type*} [Semiring R] (p q : R[X]) /-- mirror of a polynomial: reverses the coefficients while preserving `Polynomial.natDegree` -/ noncomputable def mirror := p.reverse * X ^ p.natTrailingDegree #align polynomial.mirror Polynomial.mirror @[simp] theorem mirror_zero : (0 : R[X]).mirror = 0 := by simp [mirror] #align polynomial.mirror_zero Polynomial.mirror_zero theorem mirror_monomial (n : ℕ) (a : R) : (monomial n a).mirror = monomial n a := by classical
by_cases ha : a = 0
theorem mirror_monomial (n : ℕ) (a : R) : (monomial n a).mirror = monomial n a := by classical
Mathlib.Data.Polynomial.Mirror.47_0.jRYkh9xLrkM32QX
theorem mirror_monomial (n : ℕ) (a : R) : (monomial n a).mirror = monomial n a
Mathlib_Data_Polynomial_Mirror