@@ -281,12 +281,83 @@ theorem bijective_of_surjective [Module.Invertible R N] {f : M →ₗ[R] N}
281281 simpa [lTensor_bijective_iff] using bijective_self_of_surjective
282282 (f.lTensor _ ∘ₗ (linearEquiv R M).symm.toLinearMap) (by simpa [lTensor_surjective_iff] using hf)
283283
284+ section LinearEquiv
285+ variable {R M N} [Module.Invertible R N] {f : M →ₗ[R] N} {g : N →ₗ[R] M}
286+
287+ theorem rightInverse_of_leftInverse (hfg : Function.LeftInverse f g) :
288+ Function.RightInverse f g :=
289+ Function.rightInverse_of_injective_of_leftInverse
290+ (bijective_of_surjective hfg.surjective).injective hfg
291+
292+ theorem leftInverse_of_rightInverse (hfg : Function.RightInverse f g) :
293+ Function.LeftInverse f g :=
294+ rightInverse_of_leftInverse hfg
295+
296+ variable (f g) in
297+ theorem leftInverse_iff_rightInverse :
298+ Function.LeftInverse f g ↔ Function.RightInverse f g :=
299+ ⟨rightInverse_of_leftInverse, leftInverse_of_rightInverse⟩
300+
301+ /-- If `f : M →ₗ[R] N` and `g : N →ₗ[R] M` where `M` and `N` are invertible `R`-modules, and `f` is
302+ a left inverse of `g`, then in fact `f` is also the right inverse of `g`, and we promote this to
303+ an `R`-module isomorphism. -/
304+ def linearEquivOfLeftInverse (hfg : Function.LeftInverse f g) : M ≃ₗ[R] N :=
305+ .ofLinear f g (LinearMap.ext hfg) (LinearMap.ext <| rightInverse_of_leftInverse hfg)
306+
307+ @[simp] lemma linearEquivOfLeftInverse_apply (hfg : Function.LeftInverse f g) (x : M) :
308+ linearEquivOfLeftInverse hfg x = f x := rfl
309+
310+ @[simp] lemma linearEquivOfLeftInverse_symm_apply (hfg : Function.LeftInverse f g) (x : N) :
311+ (linearEquivOfLeftInverse hfg).symm x = g x := rfl
312+
313+ /-- If `f : M →ₗ[R] N` and `g : N →ₗ[R] M` where `M` and `N` are invertible `R`-modules, and `f` is
314+ a right inverse of `g`, then in fact `f` is also the left inverse of `g`, and we promote this to
315+ an `R`-module isomorphism. -/
316+ def linearEquivOfRightInverse (hfg : Function.RightInverse f g) : M ≃ₗ[R] N :=
317+ .ofLinear f g (LinearMap.ext <| leftInverse_of_rightInverse hfg) (LinearMap.ext hfg)
318+
319+ @[simp] lemma linearEquivOfRightInverse_apply (hfg : Function.RightInverse f g) (x : M) :
320+ linearEquivOfRightInverse hfg x = f x := rfl
321+
322+ @[simp] lemma linearEquivOfRightInverse_symm_apply (hfg : Function.RightInverse f g) (x : N) :
323+ (linearEquivOfRightInverse hfg).symm x = g x := rfl
324+
325+ end LinearEquiv
326+
284327section Algebra
285328
329+ section algEquivOfRing
330+ variable (A : Type *) [Semiring A] [Algebra R A] [Module.Invertible R A]
331+
332+ /-- If an `R`-algebra `A` is also an invertible `R`-module, then it is in fact isomorphic to the
333+ base ring `R`. The algebra structure gives us a map `A ⊗ A → A`, which after tensoring by `Aᵛ`
334+ becomes a map `A → R`, which is the inverse map we seek. -/
335+ noncomputable def algEquivOfRing : R ≃ₐ[R] A :=
336+ let inv : A →ₗ[R] R :=
337+ linearEquiv R A ∘ₗ
338+ (LinearMap.mul' R A).lTensor (Dual R A) ∘ₗ
339+ (leftCancelEquiv A (linearEquiv R A)).symm
340+ have right : inv ∘ₗ Algebra.linearMap R A = LinearMap.id :=
341+ let ⟨s, hs⟩ := exists_finset ((linearEquiv R A).symm 1 )
342+ LinearMap.ext_ring <| by simp [inv, hs, sum_tmul, map_sum, ← (LinearEquiv.symm_apply_eq _).1 hs]
343+ { linearEquivOfRightInverse (f := Algebra.linearMap R A) (g := inv) (LinearMap.ext_iff.1 right),
344+ Algebra.ofId R A with }
345+
346+ variable {A} in
347+ @[simp] lemma algEquivOfRing_apply (x : R) : algEquivOfRing R A x = algebraMap R A x := rfl
348+
349+ end algEquivOfRing
350+
286351instance : Module.Invertible A (A ⊗[R] M) :=
287352 .right (M := A ⊗[R] Dual R M) <| (AlgebraTensorModule.distribBaseChange ..).symm ≪≫ₗ
288353 AlgebraTensorModule.congr (.refl A A) (linearEquiv R M) ≪≫ₗ AlgebraTensorModule.rid ..
289354
355+ variable {R M N A} in
356+ theorem of_isLocalization (S : Submonoid R) [IsLocalization S A]
357+ (f : M →ₗ[R] N) [IsLocalizedModule S f] [Module A N] [IsScalarTower R A N] :
358+ Module.Invertible A N :=
359+ .congr (IsLocalizedModule.isBaseChange S A f).equiv
360+
290361instance (L) [AddCommMonoid L] [Module R L] [Module A L] [IsScalarTower R A L]
291362 [Module.Invertible A L] : Module.Invertible A (L ⊗[R] M) :=
292363 .congr (AlgebraTensorModule.cancelBaseChange R A A L M)
0 commit comments