Zulip Chat Archive

Stream: Is there code for X?

Topic: inv_of_inj


Damiano Testa (May 07 2022 at 05:24):

Dear All,

Lean gave me a hard time proving the result below, but I would imagine that it should already be available in some form or other.

Does anyone know of a simpler proof?

Thanks!

import algebra.invertible

lemma inv_of_inj {R : Type*} [monoid R] {a b : R} [invertible a] [invertible b] :
   a =  b  a = b :=
begin
  refine λ h, _, λ h, invertible_unique a b h⟩,
  unfreezingI
  { rcases is_unit_of_invertible a with au, rfl⟩,
    rcases is_unit_of_invertible b with bu, rfl },
  rw [inv_of_units, inv_of_units] at h,
  rw [ inv_inv au,  inv_inv bu],
  exact congr_arg _ (inv_inj.mpr (units.ext h))
end

Floris van Doorn (May 07 2022 at 08:09):

import algebra.invertible

lemma inv_of_inj {R : Type*} [monoid R] {a b : R} [invertible a] [invertible b] :
   a =  b  a = b :=
begin
  refine λ h, _, λ h, invertible_unique a b h⟩,
  rw [ (inv_of_inv_of : _ = a),  (inv_of_inv_of : _ = b)],
  exact invertible_unique _ _ h
end

Damiano Testa (May 07 2022 at 08:16):

Thanks for the golfing! Should I PR it?

Floris van Doorn (May 07 2022 at 09:57):

Yes, please do! It should go right after invertible_unique (and can be simp).

Damiano Testa (May 07 2022 at 09:58):

Ok, I'll do that once I'm back at a computer!

Damiano Testa (May 07 2022 at 13:48):

#14011

Damiano Testa (May 07 2022 at 16:44):

It turns out that

λ h, invertible_unique _ _ h, λ h, invertible_unique _ _ h

is also a proof. :upside_down:
Yet another fine example of proof by obfuscation.

(In case anyone is wondering, I tried removing the λ h, ... h but even Lean thinks that this is too obscure.)

Yaël Dillies (May 07 2022 at 16:50):

That's because the a = b argument comes before the [invertible a] [invertible b] arguments in docs#invertible_unique

Yaël Dillies (May 07 2022 at 16:51):

They should probably be swapped around.

Damiano Testa (May 07 2022 at 16:58):

If this is desirable, I can do it in this PR: I already made an argument in a different lemma explicit...

Damiano Testa (May 07 2022 at 17:00):

It seems that invertible_unique is uniquely used in mathlib. And with @!

Damiano Testa (May 07 2022 at 17:15):

Yaël, I went ahead, swapped the arguments and golfed the proof further.


Last updated: Dec 20 2023 at 11:08 UTC