Skip to content

Commit

Permalink
chore: move def MonoidHom.inverse to earlier defs file (#19348)
Browse files Browse the repository at this point in the history
No import effect, just moving defs to be with other defs.
  • Loading branch information
kim-em committed Nov 22, 2024
1 parent 8e3e89e commit 944e357
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 40 deletions.
31 changes: 0 additions & 31 deletions Mathlib/Algebra/Group/Equiv/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -45,37 +45,6 @@ theorem map_ne_one_iff {f : F} {x : M} :

end EmbeddingLike

/-- Makes a `OneHom` inverse from the bijective inverse of a `OneHom` -/
@[to_additive (attr := simps)
"Make a `ZeroHom` inverse from the bijective inverse of a `ZeroHom`"]
def OneHom.inverse [One M] [One N]
(f : OneHom M N) (g : N → M)
(h₁ : Function.LeftInverse g f) :
OneHom N M :=
{ toFun := g,
map_one' := by rw [← f.map_one, h₁] }

/-- Makes a multiplicative inverse from a bijection which preserves multiplication. -/
@[to_additive (attr := simps)
"Makes an additive inverse from a bijection which preserves addition."]
def MulHom.inverse [Mul M] [Mul N] (f : M →ₙ* N) (g : N → M)
(h₁ : Function.LeftInverse g f)
(h₂ : Function.RightInverse g f) : N →ₙ* M where
toFun := g
map_mul' x y :=
calc
g (x * y) = g (f (g x) * f (g y)) := by rw [h₂ x, h₂ y]
_ = g (f (g x * g y)) := by rw [f.map_mul]
_ = g x * g y := h₁ _

/-- The inverse of a bijective `MonoidHom` is a `MonoidHom`. -/
@[to_additive (attr := simps)
"The inverse of a bijective `AddMonoidHom` is an `AddMonoidHom`."]
def MonoidHom.inverse {A B : Type*} [Monoid A] [Monoid B] (f : A →* B) (g : B → A)
(h₁ : Function.LeftInverse g f) (h₂ : Function.RightInverse g f) : B →* A :=
{ (f : OneHom A B).inverse g h₁,
(f : A →ₙ* B).inverse g h₁ h₂ with toFun := g }

/-- `AddEquiv α β` is the type of an equiv `α ≃ β` which preserves addition. -/
structure AddEquiv (A B : Type*) [Add A] [Add B] extends A ≃ B, AddHom A B

Expand Down
31 changes: 31 additions & 0 deletions Mathlib/Algebra/Group/Hom/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,37 @@ protected theorem MonoidHom.map_zpow' [DivInvMonoid M] [DivInvMonoid N] (f : M
(hf : ∀ x, f x⁻¹ = (f x)⁻¹) (a : M) (n : ℤ) :
f (a ^ n) = f a ^ n := map_zpow' f hf a n

/-- Makes a `OneHom` inverse from the bijective inverse of a `OneHom` -/
@[to_additive (attr := simps)
"Make a `ZeroHom` inverse from the bijective inverse of a `ZeroHom`"]
def OneHom.inverse [One M] [One N]
(f : OneHom M N) (g : N → M)
(h₁ : Function.LeftInverse g f) :
OneHom N M :=
{ toFun := g,
map_one' := by rw [← f.map_one, h₁] }

/-- Makes a multiplicative inverse from a bijection which preserves multiplication. -/
@[to_additive (attr := simps)
"Makes an additive inverse from a bijection which preserves addition."]
def MulHom.inverse [Mul M] [Mul N] (f : M →ₙ* N) (g : N → M)
(h₁ : Function.LeftInverse g f)
(h₂ : Function.RightInverse g f) : N →ₙ* M where
toFun := g
map_mul' x y :=
calc
g (x * y) = g (f (g x) * f (g y)) := by rw [h₂ x, h₂ y]
_ = g (f (g x * g y)) := by rw [f.map_mul]
_ = g x * g y := h₁ _

/-- The inverse of a bijective `MonoidHom` is a `MonoidHom`. -/
@[to_additive (attr := simps)
"The inverse of a bijective `AddMonoidHom` is an `AddMonoidHom`."]
def MonoidHom.inverse {A B : Type*} [Monoid A] [Monoid B] (f : A →* B) (g : B → A)
(h₁ : Function.LeftInverse g f) (h₂ : Function.RightInverse g f) : B →* A :=
{ (f : OneHom A B).inverse g h₁,
(f : A →ₙ* B).inverse g h₁ h₂ with toFun := g }

section End

namespace Monoid
Expand Down
9 changes: 0 additions & 9 deletions MathlibTest/symm.lean
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ example (a b c : Nat) (ab : a = b) (bc : b = c) : c = a := by
symm_saturate
apply Eq.trans <;> assumption

def MulHom.inverse [Mul M] [Mul N] (f : M →ₙ* N) (g : N → M) (h₁ : Function.LeftInverse g f)
(h₂ : Function.RightInverse g f) : N →ₙ* M where
toFun := g
map_mul' x y :=
calc
g (x * y) = g (f (g x) * f (g y)) := by rw [h₂ x, h₂ y]
_ = g (f (g x * g y)) := by rw [f.map_mul]
_ = g x * g y := h₁ _

structure MulEquiv (M N : Type u) [Mul M] [Mul N] extends M ≃ N, M →ₙ* N

/--
Expand Down

0 comments on commit 944e357

Please sign in to comment.