Skip to content

Commit

Permalink
feat(data/equiv/mul_add): define mul_hom.inverse (#6864)
Browse files Browse the repository at this point in the history
Co-authored-by: Yury G. Kudryashov <urkud@urkud.name>
  • Loading branch information
ocfnash and urkud committed Mar 25, 2021
1 parent e054705 commit 6e14e8f
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/data/equiv/mul_add.lean
Expand Up @@ -34,6 +34,16 @@ equiv, mul_equiv, add_equiv
variables {A : Type*} {B : Type*} {M : Type*} {N : Type*}
{P : Type*} {Q : Type*} {G : Type*} {H : Type*}

/-- Makes a multiplicative inverse from a bijection which preserves multiplication. -/
@[to_additive "Makes an additive inverse from a bijection which preserves addition."]
def mul_hom.inverse [has_mul M] [has_mul N] (f : mul_hom M N) (g : N → M)
(h₁ : function.left_inverse g f) (h₂ : function.right_inverse g f) : mul_hom N M :=
{ to_fun := 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₁ _, }

set_option old_structure_cmd true

/-- add_equiv α β is the type of an equiv α ≃ β which preserves addition. -/
Expand Down Expand Up @@ -102,11 +112,7 @@ instance : inhabited (M ≃* M) := ⟨refl M⟩
/-- The inverse of an isomorphism is an isomorphism. -/
@[symm, to_additive "The inverse of an isomorphism is an isomorphism."]
def symm (h : M ≃* N) : N ≃* M :=
{ map_mul' := λ n₁ n₂, h.injective $
begin
have : ∀ x, h (h.to_equiv.symm.to_fun x) = x := h.to_equiv.apply_symm_apply,
simp only [this, h.map_mul]
end,
{ map_mul' := (h.to_mul_hom.inverse h.to_equiv.symm h.left_inv h.right_inv).map_mul,
.. h.to_equiv.symm}

/-- See Note [custom simps projection] -/
Expand Down

0 comments on commit 6e14e8f

Please sign in to comment.