Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - chore: refactor of Algebra/Group/Defs to reduce imports #9606

Closed
wants to merge 16 commits into from
4 changes: 4 additions & 0 deletions Mathlib.lean
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ import Mathlib.Algebra.GradedMonoid
import Mathlib.Algebra.GradedMulAction
import Mathlib.Algebra.Group.Aut
import Mathlib.Algebra.Group.Basic
import Mathlib.Algebra.Group.Cancel
import Mathlib.Algebra.Group.Classes
import Mathlib.Algebra.Group.Commutator
import Mathlib.Algebra.Group.Commute.Basic
import Mathlib.Algebra.Group.Commute.Defs
Expand Down Expand Up @@ -3346,6 +3348,7 @@ import Mathlib.Tactic.InferParam
import Mathlib.Tactic.Inhabit
import Mathlib.Tactic.IntervalCases
import Mathlib.Tactic.IrreducibleDef
import Mathlib.Tactic.Lemma
import Mathlib.Tactic.LibrarySearch
import Mathlib.Tactic.Lift
import Mathlib.Tactic.LiftLets
Expand Down Expand Up @@ -3447,6 +3450,7 @@ import Mathlib.Tactic.ToLevel
import Mathlib.Tactic.Trace
import Mathlib.Tactic.TryThis
import Mathlib.Tactic.TypeCheck
import Mathlib.Tactic.TypeStar
import Mathlib.Tactic.UnsetOption
import Mathlib.Tactic.Use
import Mathlib.Tactic.Variable
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Algebra/Abs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Christopher Hoskin
-/
import Mathlib.Mathport.Rename
import Mathlib.Tactic.Basic
import Mathlib.Tactic.TypeStar

#align_import algebra.abs from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
Expand Down
1 change: 1 addition & 0 deletions Mathlib/Algebra/CharZero/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Mathlib.Init.Data.Nat.Lemmas
import Mathlib.Data.Int.Cast.Defs
import Mathlib.Tactic.Cases
import Mathlib.Algebra.NeZero
import Mathlib.Logic.Function.Basic

#align_import algebra.char_zero.defs from "leanprover-community/mathlib"@"d6aae1bcbd04b8de2022b9b83a5b5b10e10c777d"

Expand Down
3 changes: 2 additions & 1 deletion Mathlib/Algebra/CovariantAndContravariant.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Algebra.Group.Cancel
import Mathlib.Algebra.Group.Classes
import Mathlib.Order.Basic
import Mathlib.Order.Monotone.Basic

Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Algebra/Group/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Copyright (c) 2014 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Leonardo de Moura, Simon Hudon, Mario Carneiro
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Algebra.Group.Cancel
import Mathlib.Tactic.Cases
import Mathlib.Tactic.SimpRw
import Mathlib.Tactic.SplitIfs
Expand Down
65 changes: 65 additions & 0 deletions Mathlib/Algebra/Group/Cancel.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/-
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Leonardo de Moura, Simon Hudon, Mario Carneiro
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Function.Basic

/-!
# Facts about injectivity of cancellative multiplication.
-/

#align_import algebra.group.defs from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4"

universe u v w

open Function

variable {G : Type*} [Mul G]

section IsLeftCancelMul

variable [IsLeftCancelMul G] {a b c : G}

@[to_additive]
theorem mul_right_injective (a : G) : Injective (a * ·) := fun _ _ ↦ mul_left_cancel
#align mul_right_injective mul_right_injective
#align add_right_injective add_right_injective

@[to_additive (attr := simp)]
theorem mul_right_inj (a : G) {b c : G} : a * b = a * c ↔ b = c :=
(mul_right_injective a).eq_iff
#align mul_right_inj mul_right_inj
#align add_right_inj add_right_inj

@[to_additive]
theorem mul_ne_mul_right (a : G) {b c : G} : a * b ≠ a * c ↔ b ≠ c :=
(mul_right_injective a).ne_iff
#align mul_ne_mul_right mul_ne_mul_right
#align add_ne_add_right add_ne_add_right

end IsLeftCancelMul

section IsRightCancelMul

variable [IsRightCancelMul G] {a b c : G}

@[to_additive]
theorem mul_left_injective (a : G) : Function.Injective (· * a) := fun _ _ ↦ mul_right_cancel
#align mul_left_injective mul_left_injective
#align add_left_injective add_left_injective

@[to_additive (attr := simp)]
theorem mul_left_inj (a : G) {b c : G} : b * a = c * a ↔ b = c :=
(mul_left_injective a).eq_iff
#align mul_left_inj mul_left_inj
#align add_left_inj add_left_inj

@[to_additive]
theorem mul_ne_mul_left (a : G) {b c : G} : b * a ≠ c * a ↔ b ≠ c :=
(mul_left_injective a).ne_iff
#align mul_ne_mul_left mul_ne_mul_left
#align add_ne_add_left add_ne_add_left

end IsRightCancelMul
29 changes: 29 additions & 0 deletions Mathlib/Algebra/Group/Classes.lean
YaelDillies marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/-
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Leonardo de Moura, Simon Hudon, Mario Carneiro
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Init.Algebra.Classes

/-!
# Instances for operations in algebraic structures.

As the unbundle algebraic structures typeclasses are of somewhat dubious use at present,
semorrison marked this conversation as resolved.
Show resolved Hide resolved
we separate out the file providing instances from the main `Mathlib.Algebra.Group.Defs` file.
-/

#align_import algebra.group.defs from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4"

variable {G : Type*}

@[to_additive]
instance Semigroup.to_isAssociative [Semigroup G] : IsAssociative G (· * ·) :=
⟨mul_assoc⟩
#align semigroup.to_is_associative Semigroup.to_isAssociative
#align add_semigroup.to_is_associative AddSemigroup.to_isAssociative

@[to_additive]
instance CommMagma.to_isCommutative [CommMagma G] : IsCommutative G (· * ·) := ⟨mul_comm⟩
#align comm_semigroup.to_is_commutative CommMagma.to_isCommutative
#align add_comm_semigroup.to_is_commutative AddCommMagma.to_isCommutative
1 change: 1 addition & 0 deletions Mathlib/Algebra/Group/Commute/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Copyright (c) 2019 Neil Strickland. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Neil Strickland, Yury Kudryashov
-/
import Mathlib.Init.Algebra.Classes
import Mathlib.Algebra.Group.Semiconj.Defs

#align_import algebra.group.commute from "leanprover-community/mathlib"@"05101c3df9d9cfe9430edc205860c79b6d660102"
Expand Down
68 changes: 5 additions & 63 deletions Mathlib/Algebra/Group/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ Copyright (c) 2014 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Leonardo de Moura, Simon Hudon, Mario Carneiro
-/
import Mathlib.Init.ZeroOne
import Mathlib.Init.Data.Int.Basic
import Mathlib.Logic.Function.Basic
import Mathlib.Tactic.Basic
import Mathlib.Tactic.Lemma
import Mathlib.Tactic.TypeStar

Parcly-Taxel marked this conversation as resolved.
Show resolved Hide resolved
#align_import algebra.group.defs from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4"

Expand Down Expand Up @@ -220,27 +219,10 @@ theorem mul_left_cancel : a * b = a * c → b = c :=

@[to_additive]
theorem mul_left_cancel_iff : a * b = a * c ↔ b = c :=
⟨mul_left_cancel, congr_arg _⟩
⟨mul_left_cancel, congrArg _⟩
#align mul_left_cancel_iff mul_left_cancel_iff
#align add_left_cancel_iff add_left_cancel_iff

@[to_additive]
theorem mul_right_injective (a : G) : Injective (a * ·) := fun _ _ ↦ mul_left_cancel
#align mul_right_injective mul_right_injective
#align add_right_injective add_right_injective

@[to_additive (attr := simp)]
theorem mul_right_inj (a : G) {b c : G} : a * b = a * c ↔ b = c :=
(mul_right_injective a).eq_iff
#align mul_right_inj mul_right_inj
#align add_right_inj add_right_inj

@[to_additive]
theorem mul_ne_mul_right (a : G) {b c : G} : a * b ≠ a * c ↔ b ≠ c :=
(mul_right_injective a).ne_iff
#align mul_ne_mul_right mul_ne_mul_right
#align add_ne_add_right add_ne_add_right

end IsLeftCancelMul

section IsRightCancelMul
Expand All @@ -255,27 +237,10 @@ theorem mul_right_cancel : a * b = c * b → a = c :=

@[to_additive]
theorem mul_right_cancel_iff : b * a = c * a ↔ b = c :=
⟨mul_right_cancel, congr_arg (· * a)⟩
⟨mul_right_cancel, congrArg (· * a)⟩
#align mul_right_cancel_iff mul_right_cancel_iff
#align add_right_cancel_iff add_right_cancel_iff

@[to_additive]
theorem mul_left_injective (a : G) : Function.Injective (· * a) := fun _ _ ↦ mul_right_cancel
#align mul_left_injective mul_left_injective
#align add_left_injective add_left_injective

@[to_additive (attr := simp)]
theorem mul_left_inj (a : G) {b c : G} : b * a = c * a ↔ b = c :=
(mul_left_injective a).eq_iff
#align mul_left_inj mul_left_inj
#align add_left_inj add_left_inj

@[to_additive]
theorem mul_ne_mul_left (a : G) {b c : G} : b * a ≠ c * a ↔ b ≠ c :=
(mul_left_injective a).ne_iff
#align mul_ne_mul_left mul_ne_mul_left
#align add_ne_add_left add_ne_add_left

end IsRightCancelMul

end Mul
Expand Down Expand Up @@ -310,12 +275,6 @@ theorem mul_assoc : ∀ a b c : G, a * b * c = a * (b * c) :=
#align mul_assoc mul_assoc
#align add_assoc add_assoc

@[to_additive]
instance Semigroup.to_isAssociative : IsAssociative G (· * ·) :=
⟨mul_assoc⟩
#align semigroup.to_is_associative Semigroup.to_isAssociative
#align add_semigroup.to_is_associative AddSemigroup.to_isAssociative

end Semigroup

/-- A commutative addition is a type with an addition which commutes-/
Expand Down Expand Up @@ -358,11 +317,6 @@ theorem mul_comm : ∀ a b : G, a * b = b * a := CommMagma.mul_comm
#align mul_comm mul_comm
#align add_comm add_comm

@[to_additive]
instance CommMagma.to_isCommutative : IsCommutative G (· * ·) := ⟨mul_comm⟩
#align comm_semigroup.to_is_commutative CommMagma.to_isCommutative
#align add_comm_semigroup.to_is_commutative AddCommMagma.to_isCommutative

/-- Any `CommMagma G` that satisfies `IsRightCancelMul G` also satisfies `IsLeftCancelMul G`. -/
@[to_additive AddCommMagma.IsRightCancelAdd.toIsLeftCancelAdd "Any `AddCommMagma G` that satisfies
`IsRightCancelAdd G` also satisfies `IsLeftCancelAdd G`."]
Expand Down Expand Up @@ -992,7 +946,7 @@ theorem zpow_ofNat (a : G) : ∀ n : ℕ, a ^ (n : ℤ) = a ^ n
| 0 => (zpow_zero _).trans (pow_zero _).symm
| n + 1 => calc
a ^ (↑(n + 1) : ℤ) = a * a ^ (n : ℤ) := DivInvMonoid.zpow_succ' _ _
_ = a * a ^ n := congr_arg (a * ·) (zpow_ofNat a n)
_ = a * a ^ n := congrArg (a * ·) (zpow_ofNat a n)
_ = a ^ (n + 1) := (pow_succ _ _).symm
#align zpow_coe_nat zpow_ofNat
#align zpow_of_nat zpow_ofNat
Expand Down Expand Up @@ -1230,12 +1184,6 @@ instance (priority := 100) Group.toCancelMonoid : CancelMonoid G :=

end Group

@[to_additive]
theorem Group.toDivInvMonoid_injective {G : Type*} :
Function.Injective (@Group.toDivInvMonoid G) := by rintro ⟨⟩ ⟨⟩ ⟨⟩; rfl
#align group.to_div_inv_monoid_injective Group.toDivInvMonoid_injective
#align add_group.to_sub_neg_add_monoid_injective AddGroup.toSubNegAddMonoid_injective

/-- An additive commutative group is an additive group with commutative `(+)`. -/
class AddCommGroup (G : Type u) extends AddGroup G, AddCommMonoid G
#align add_comm_group AddCommGroup
Expand All @@ -1247,12 +1195,6 @@ class CommGroup (G : Type u) extends Group G, CommMonoid G

attribute [to_additive existing] CommGroup.toCommMonoid

@[to_additive]
theorem CommGroup.toGroup_injective {G : Type u} : Function.Injective (@CommGroup.toGroup G) := by
rintro ⟨⟩ ⟨⟩ ⟨⟩; rfl
#align comm_group.to_group_injective CommGroup.toGroup_injective
#align add_comm_group.to_add_group_injective AddCommGroup.toAddGroup_injective

section CommGroup

variable [CommGroup G]
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Algebra/Group/Embedding.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Algebra.Group.Cancel
import Mathlib.Logic.Embedding.Basic

#align_import algebra.hom.embedding from "leanprover-community/mathlib"@"70d50ecfd4900dd6d328da39ab7ebd516abe4025"
Expand Down
12 changes: 12 additions & 0 deletions Mathlib/Algebra/Group/Ext.lean
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ theorem DivInvMonoid.ext {M : Type*} ⦃m₁ m₂ : DivInvMonoid M⦄
#align div_inv_monoid.ext DivInvMonoid.ext
#align sub_neg_monoid.ext SubNegMonoid.ext

@[to_additive]
theorem Group.toDivInvMonoid_injective {G : Type*} :
Function.Injective (@Group.toDivInvMonoid G) := by rintro ⟨⟩ ⟨⟩ ⟨⟩; rfl
#align group.to_div_inv_monoid_injective Group.toDivInvMonoid_injective
#align add_group.to_sub_neg_add_monoid_injective AddGroup.toSubNegAddMonoid_injective

@[to_additive (attr := ext)]
theorem Group.ext {G : Type*} ⦃g₁ g₂ : Group G⦄ (h_mul : g₁.mul = g₂.mul) : g₁ = g₂ := by
have h₁ : g₁.one = g₂.one := congr_arg (·.one) (Monoid.ext h_mul)
Expand All @@ -165,6 +171,12 @@ theorem Group.ext {G : Type*} ⦃g₁ g₂ : Group G⦄ (h_mul : g₁.mul = g₂
#align group.ext Group.ext
#align add_group.ext AddGroup.ext

@[to_additive]
theorem CommGroup.toGroup_injective {G : Type u} : Function.Injective (@CommGroup.toGroup G) := by
rintro ⟨⟩ ⟨⟩ ⟨⟩; rfl
#align comm_group.to_group_injective CommGroup.toGroup_injective
#align add_comm_group.to_add_group_injective AddCommGroup.toAddGroup_injective

@[to_additive (attr := ext)]
theorem CommGroup.ext {G : Type*} ⦃g₁ g₂ : CommGroup G⦄ (h_mul : g₁.mul = g₂.mul) : g₁ = g₂ :=
CommGroup.toGroup_injective <| Group.ext h_mul
Expand Down
1 change: 1 addition & 0 deletions Mathlib/Algebra/Group/Semiconj/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Authors: Yury Kudryashov

Some proofs and docs came from `algebra/commute` (c) Neil Strickland
-/
import Mathlib.Init.Logic
import Mathlib.Algebra.Group.Defs
import Mathlib.Tactic.Cases
semorrison marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
1 change: 1 addition & 0 deletions Mathlib/Algebra/Group/WithOne/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Johan Commelin
-/
import Mathlib.Order.WithBot
import Mathlib.Algebra.Group.Classes
import Mathlib.Algebra.Ring.Defs

#align_import algebra.group.with_one.defs from "leanprover-community/mathlib"@"995b47e555f1b6297c7cf16855f1023e355219fb"
Expand Down
1 change: 1 addition & 0 deletions Mathlib/Algebra/GroupWithZero/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Authors: Johan Commelin
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Nontrivial.Defs
import Mathlib.Logic.Function.Basic
semorrison marked this conversation as resolved.
Show resolved Hide resolved

#align_import algebra.group_with_zero.defs from "leanprover-community/mathlib"@"2f3994e1b117b1e1da49bcfb67334f33460c3ce4"

Expand Down
1 change: 1 addition & 0 deletions Mathlib/Algebra/Invertible/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Basic

#align_import algebra.invertible from "leanprover-community/mathlib"@"722b3b152ddd5e0cf21c0a29787c76596cb6b422"

Expand Down
1 change: 1 addition & 0 deletions Mathlib/CategoryTheory/Shift/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Authors: Scott Morrison, Johan Commelin, Andrew Yang
import Mathlib.CategoryTheory.Limits.Preserves.Shapes.Zero
import Mathlib.CategoryTheory.Monoidal.End
import Mathlib.CategoryTheory.Monoidal.Discrete
import Mathlib.Algebra.Group.Cancel
semorrison marked this conversation as resolved.
Show resolved Hide resolved

#align_import category_theory.shift.basic from "leanprover-community/mathlib"@"6876fa15e3158ff3e4a4e2af1fb6e1945c6e8803"

Expand Down
1 change: 1 addition & 0 deletions Mathlib/Control/Functor.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Authors: Simon Hudon
import Mathlib.Control.Basic
import Mathlib.Init.Set
import Mathlib.Tactic.Basic
import Mathlib.Tactic.TypeStar
import Std.Tactic.Lint

#align_import control.functor from "leanprover-community/mathlib"@"70d50ecfd4900dd6d328da39ab7ebd516abe4025"
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Data/Bracket.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Patrick Lutz, Oliver Nash
-/
import Mathlib.Mathport.Rename
import Mathlib.Tactic.Basic
import Mathlib.Tactic.TypeStar

#align_import data.bracket from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"

Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Data/DList/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Simon Hudon
-/
import Mathlib.Data.DList.Defs
import Mathlib.Tactic.Basic
import Mathlib.Tactic.TypeStar

#align_import data.dlist.basic from "leanprover-community/mathlib"@"d6aae1bcbd04b8de2022b9b83a5b5b10e10c777d"

Expand Down