l3lab/ntp-mathlib huggingface dataset:
/-- The categorical subobjects of a module `M` are in one-to-one correspondence with its
    submodules.-/
noncomputable def subobjectModule : Subobject M ≃o Submodule R M :=
  OrderIso.symm
    { invFun := fun S => LinearMap.range S.arrow
      toFun := fun N => Subobject.mk (↾N.subtype)
      right_inv := fun S => Eq.symm (by
        fapply eq_mk_of_comm
        · apply LinearEquiv.toModuleIso'Left
          apply LinearEquiv.ofBijective (LinearMap.codRestrict (LinearMap.range S.arrow) S.arrow _)
          constructor
          · simp [← LinearMap.ker_eq_bot, LinearMap.ker_codRestrict]
            rw [ker_eq_bot_of_mono]
          · rw [← LinearMap.range_eq_top, LinearMap.range_codRestrict, Submodule.comap_subtype_self]
            exact LinearMap.mem_range_self _
        · apply LinearMap.ext
          intro x
          rfl)
      left_inv := fun N => by
        -- Porting note: The type of `↾N.subtype` was ambiguous. Not entirely sure, I made the right
        -- choice here
        convert congr_arg LinearMap.range
            (underlyingIso_arrow (↾N.subtype : of R { x // x ∈ N } ⟶ M)) using 1
        · 

Proof state:
case h.e'_2
R : Type u
inst✝ : Ring R
M : ModuleCat R
N : Submodule R ↑M
⊢ (fun S => LinearMap.range (arrow S)) ((fun N => Subobject.mk (↾(Submodule.subtype N))) N) =
    LinearMap.range ((underlyingIso (↾(Submodule.subtype N))).inv ≫ arrow (Subobject.mk (↾(Submodule.subtype N))))

Next tactic:
have :
            -- Porting note: added the `.toLinearEquiv.toLinearMap`
            (underlyingIso (↾N.subtype : of R _ ⟶ M)).inv =
              (underlyingIso (↾N.subtype : of R _ ⟶ M)).symm.toLinearEquiv.toLinearMap := by
              apply LinearMap.ext
              intro x
              rfl
/-- The categorical subobjects of a module `M` are in one-to-one correspondence with its
    submodules.-/
noncomputable def subobjectModule : Subobject M ≃o Submodule R M :=
  OrderIso.symm
    { invFun := fun S => LinearMap.range S.arrow
      toFun := fun N => Subobject.mk (↾N.subtype)
      right_inv := fun S => Eq.symm (by
        fapply eq_mk_of_comm
        · apply LinearEquiv.toModuleIso'Left
          apply LinearEquiv.ofBijective (LinearMap.codRestrict (LinearMap.range S.arrow) S.arrow _)
          constructor
          · simp [← LinearMap.ker_eq_bot, LinearMap.ker_codRestrict]
            rw [ker_eq_bot_of_mono]
          · rw [← LinearMap.range_eq_top, LinearMap.range_codRestrict, Submodule.comap_subtype_self]
            exact LinearMap.mem_range_self _
        · apply LinearMap.ext
          intro x
          rfl)
      left_inv := fun N => by
        -- Porting note: The type of `↾N.subtype` was ambiguous. Not entirely sure, I made the right
        -- choice here
        convert congr_arg LinearMap.range
            (underlyingIso_arrow (↾N.subtype : of R { x // x ∈ N } ⟶ M)) using 1
        · have :
            -- Porting note: added the `.toLinearEquiv.toLinearMap`
            (underlyingIso (↾N.subtype : of R _ ⟶ M)).inv =
              (underlyingIso (↾N.subtype : of R _ ⟶ M)).symm.toLinearEquiv.toLinearMap := by
              

Proof state:
R : Type u
inst✝ : Ring R
M : ModuleCat R
N : Submodule R ↑M
⊢ (underlyingIso (↾(Submodule.subtype N))).inv = ↑(Iso.toLinearEquiv (underlyingIso (↾(Submodule.subtype N))).symm)

Next tactic:
apply LinearMap.ext
/-- The categorical subobjects of a module `M` are in one-to-one correspondence with its
    submodules.-/
noncomputable def subobjectModule : Subobject M ≃o Submodule R M :=
  OrderIso.symm
    { invFun := fun S => LinearMap.range S.arrow
      toFun := fun N => Subobject.mk (↾N.subtype)
      right_inv := fun S => Eq.symm (by
        fapply eq_mk_of_comm
        · apply LinearEquiv.toModuleIso'Left
          apply LinearEquiv.ofBijective (LinearMap.codRestrict (LinearMap.range S.arrow) S.arrow _)
          constructor
          · simp [← LinearMap.ker_eq_bot, LinearMap.ker_codRestrict]
            rw [ker_eq_bot_of_mono]
          · rw [← LinearMap.range_eq_top, LinearMap.range_codRestrict, Submodule.comap_subtype_self]
            exact LinearMap.mem_range_self _
        · apply LinearMap.ext
          intro x
          rfl)
      left_inv := fun N => by
        -- Porting note: The type of `↾N.subtype` was ambiguous. Not entirely sure, I made the right
        -- choice here
        convert congr_arg LinearMap.range
            (underlyingIso_arrow (↾N.subtype : of R { x // x ∈ N } ⟶ M)) using 1
        · have :
            -- Porting note: added the `.toLinearEquiv.toLinearMap`
            (underlyingIso (↾N.subtype : of R _ ⟶ M)).inv =
              (underlyingIso (↾N.subtype : of R _ ⟶ M)).symm.toLinearEquiv.toLinearMap := by
              apply LinearMap.ext
              

Proof state:
case h
R : Type u
inst✝ : Ring R
M : ModuleCat R
N : Submodule R ↑M
⊢ ∀ (x : ↑(of R ↥N)),
    (underlyingIso (↾(Submodule.subtype N))).inv x =
      ↑(Iso.toLinearEquiv (underlyingIso (↾(Submodule.subtype N))).symm) x

Next tactic:
intro x
/-- The categorical subobjects of a module `M` are in one-to-one correspondence with its
    submodules.-/
noncomputable def subobjectModule : Subobject M ≃o Submodule R M :=
  OrderIso.symm
    { invFun := fun S => LinearMap.range S.arrow
      toFun := fun N => Subobject.mk (↾N.subtype)
      right_inv := fun S => Eq.symm (by
        fapply eq_mk_of_comm
        · apply LinearEquiv.toModuleIso'Left
          apply LinearEquiv.ofBijective (LinearMap.codRestrict (LinearMap.range S.arrow) S.arrow _)
          constructor
          · simp [← LinearMap.ker_eq_bot, LinearMap.ker_codRestrict]
            rw [ker_eq_bot_of_mono]
          · rw [← LinearMap.range_eq_top, LinearMap.range_codRestrict, Submodule.comap_subtype_self]
            exact LinearMap.mem_range_self _
        · apply LinearMap.ext
          intro x
          rfl)
      left_inv := fun N => by
        -- Porting note: The type of `↾N.subtype` was ambiguous. Not entirely sure, I made the right
        -- choice here
        convert congr_arg LinearMap.range
            (underlyingIso_arrow (↾N.subtype : of R { x // x ∈ N } ⟶ M)) using 1
        · have :
            -- Porting note: added the `.toLinearEquiv.toLinearMap`
            (underlyingIso (↾N.subtype : of R _ ⟶ M)).inv =
              (underlyingIso (↾N.subtype : of R _ ⟶ M)).symm.toLinearEquiv.toLinearMap := by
              apply LinearMap.ext
              intro x
              

Proof state:
case h
R : Type u
inst✝ : Ring R
M : ModuleCat R
N : Submodule R ↑M
x : ↑(of R ↥N)
⊢ (underlyingIso (↾(Submodule.subtype N))).inv x = ↑(Iso.toLinearEquiv (underlyingIso (↾(Submodule.subtype N))).symm) x

Next tactic:
rfl
/-- The categorical subobjects of a module `M` are in one-to-one correspondence with its
    submodules.-/
noncomputable def subobjectModule : Subobject M ≃o Submodule R M :=
  OrderIso.symm
    { invFun := fun S => LinearMap.range S.arrow
      toFun := fun N => Subobject.mk (↾N.subtype)
      right_inv := fun S => Eq.symm (by
        fapply eq_mk_of_comm
        · apply LinearEquiv.toModuleIso'Left
          apply LinearEquiv.ofBijective (LinearMap.codRestrict (LinearMap.range S.arrow) S.arrow _)
          constructor
          · simp [← LinearMap.ker_eq_bot, LinearMap.ker_codRestrict]
            rw [ker_eq_bot_of_mono]
          · rw [← LinearMap.range_eq_top, LinearMap.range_codRestrict, Submodule.comap_subtype_self]
            exact LinearMap.mem_range_self _
        · apply LinearMap.ext
          intro x
          rfl)
      left_inv := fun N => by
        -- Porting note: The type of `↾N.subtype` was ambiguous. Not entirely sure, I made the right
        -- choice here
        convert congr_arg LinearMap.range
            (underlyingIso_arrow (↾N.subtype : of R { x // x ∈ N } ⟶ M)) using 1
        · have :
            -- Porting note: added the `.toLinearEquiv.toLinearMap`
            (underlyingIso (↾N.subtype : of R _ ⟶ M)).inv =
              (underlyingIso (↾N.subtype : of R _ ⟶ M)).symm.toLinearEquiv.toLinearMap := by
              apply LinearMap.ext
              intro x
              rfl
          

Proof state:
case h.e'_2
R : Type u
inst✝ : Ring R
M : ModuleCat R
N : Submodule R ↑M
this : (underlyingIso (↾(Submodule.subtype N))).inv = ↑(Iso.toLinearEquiv (underlyingIso (↾(Submodule.subtype N))).symm)
⊢ (fun S => LinearMap.range (arrow S)) ((fun N => Subobject.mk (↾(Submodule.subtype N))) N) =
    LinearMap.range ((underlyingIso (↾(Submodule.subtype N))).inv ≫ arrow (Subobject.mk (↾(Submodule.subtype N))))

Next tactic:
rw [this, comp_def, LinearEquiv.range_comp]
/-- The categorical subobjects of a module `M` are in one-to-one correspondence with its
    submodules.-/
noncomputable def subobjectModule : Subobject M ≃o Submodule R M :=
  OrderIso.symm
    { invFun := fun S => LinearMap.range S.arrow
      toFun := fun N => Subobject.mk (↾N.subtype)
      right_inv := fun S => Eq.symm (by
        fapply eq_mk_of_comm
        · apply LinearEquiv.toModuleIso'Left
          apply LinearEquiv.ofBijective (LinearMap.codRestrict (LinearMap.range S.arrow) S.arrow _)
          constructor
          · simp [← LinearMap.ker_eq_bot, LinearMap.ker_codRestrict]
            rw [ker_eq_bot_of_mono]
          · rw [← LinearMap.range_eq_top, LinearMap.range_codRestrict, Submodule.comap_subtype_self]
            exact LinearMap.mem_range_self _
        · apply LinearMap.ext
          intro x
          rfl)
      left_inv := fun N => by
        -- Porting note: The type of `↾N.subtype` was ambiguous. Not entirely sure, I made the right
        -- choice here
        convert congr_arg LinearMap.range
            (underlyingIso_arrow (↾N.subtype : of R { x // x ∈ N } ⟶ M)) using 1
        · have :
            -- Porting note: added the `.toLinearEquiv.toLinearMap`
            (underlyingIso (↾N.subtype : of R _ ⟶ M)).inv =
              (underlyingIso (↾N.subtype : of R _ ⟶ M)).symm.toLinearEquiv.toLinearMap := by
              apply LinearMap.ext
              intro x
              rfl
          rw [this, comp_def, LinearEquiv.range_comp]
        · 

Proof state:
case h.e'_3
R : Type u
inst✝ : Ring R
M : ModuleCat R
N : Submodule R ↑M
⊢ N = LinearMap.range (↾(Submodule.subtype N))

Next tactic:
exact (Submodule.range_subtype _).symm
/-- The categorical subobjects of a module `M` are in one-to-one correspondence with its
    submodules.-/
noncomputable def subobjectModule : Subobject M ≃o Submodule R M :=
  OrderIso.symm
    { invFun := fun S => LinearMap.range S.arrow
      toFun := fun N => Subobject.mk (↾N.subtype)
      right_inv := fun S => Eq.symm (by
        

Proof state:
R : Type u
inst✝ : Ring R
M : ModuleCat R
S : Subobject M
⊢ S = (fun N => Subobject.mk (↾(Submodule.subtype N))) ((fun S => LinearMap.range (arrow S)) S)

Next tactic:
fapply eq_mk_of_comm
/-- The categorical subobjects of a module `M` are in one-to-one correspondence with its
    submodules.-/
noncomputable def subobjectModule : Subobject M ≃o Submodule R M :=
  OrderIso.symm
    { invFun := fun S => LinearMap.range S.arrow
      toFun := fun N => Subobject.mk (↾N.subtype)
      right_inv := fun S => Eq.symm (by
        fapply eq_mk_of_comm
        · 

Proof state:
case i
R : Type u
inst✝ : Ring R
M : ModuleCat R
S : Subobject M
⊢ underlying.obj S ≅ of R ↥((fun S => LinearMap.range (arrow S)) S)

Next tactic:
apply LinearEquiv.toModuleIso'Left
/-- The categorical subobjects of a module `M` are in one-to-one correspondence with its
    submodules.-/
noncomputable def subobjectModule : Subobject M ≃o Submodule R M :=
  OrderIso.symm
    { invFun := fun S => LinearMap.range S.arrow
      toFun := fun N => Subobject.mk (↾N.subtype)
      right_inv := fun S => Eq.symm (by
        fapply eq_mk_of_comm
        · apply LinearEquiv.toModuleIso'Left
          

Proof state:
case i.e
R : Type u
inst✝ : Ring R
M : ModuleCat R
S : Subobject M
⊢ ↑(underlying.obj S) ≃ₗ[R] ↥((fun S => LinearMap.range (arrow S)) S)

Next tactic:
apply LinearEquiv.ofBijective (LinearMap.codRestrict (LinearMap.range S.arrow) S.arrow _)
/-- The categorical subobjects of a module `M` are in one-to-one correspondence with its
    submodules.-/
noncomputable def subobjectModule : Subobject M ≃o Submodule R M :=
  OrderIso.symm
    { invFun := fun S => LinearMap.range S.arrow
      toFun := fun N => Subobject.mk (↾N.subtype)
      right_inv := fun S => Eq.symm (by
        fapply eq_mk_of_comm
        · apply LinearEquiv.toModuleIso'Left
          apply LinearEquiv.ofBijective (LinearMap.codRestrict (LinearMap.range S.arrow) S.arrow _)
          

Proof state:
case i.e
R : Type u
inst✝ : Ring R
M : ModuleCat R
S : Subobject M
⊢ Function.Bijective ⇑(LinearMap.codRestrict (LinearMap.range (arrow S)) (arrow S) ?m.83059)
R : Type u
inst✝ : Ring R
M : ModuleCat R
S : Subobject M
⊢ ∀ (c : ↑(underlying.obj S)), (arrow S) c ∈ LinearMap.range (arrow S)

Next tactic:
constructor
/-- The categorical subobjects of a module `M` are in one-to-one correspondence with its
    submodules.-/
noncomputable def subobjectModule : Subobject M ≃o Submodule R M :=
  OrderIso.symm
    { invFun := fun S => LinearMap.range S.arrow
      toFun := fun N => Subobject.mk (↾N.subtype)
      right_inv := fun S => Eq.symm (by
        fapply eq_mk_of_comm
        · apply LinearEquiv.toModuleIso'Left
          apply LinearEquiv.ofBijective (LinearMap.codRestrict (LinearMap.range S.arrow) S.arrow _)
          constructor
          · 

Proof state:
case i.e.left
R : Type u
inst✝ : Ring R
M : ModuleCat R
S : Subobject M
⊢ Function.Injective ⇑(LinearMap.codRestrict (LinearMap.range (arrow S)) (arrow S) ?m.83059)

Next tactic:
simp [← LinearMap.ker_eq_bot, LinearMap.ker_codRestrict]
/-- The categorical subobjects of a module `M` are in one-to-one correspondence with its
    submodules.-/
noncomputable def subobjectModule : Subobject M ≃o Submodule R M :=
  OrderIso.symm
    { invFun := fun S => LinearMap.range S.arrow
      toFun := fun N => Subobject.mk (↾N.subtype)
      right_inv := fun S => Eq.symm (by
        fapply eq_mk_of_comm
        · apply LinearEquiv.toModuleIso'Left
          apply LinearEquiv.ofBijective (LinearMap.codRestrict (LinearMap.range S.arrow) S.arrow _)
          constructor
          · simp [← LinearMap.ker_eq_bot, LinearMap.ker_codRestrict]
            

Proof state:
case i.e.left
R : Type u
inst✝ : Ring R
M : ModuleCat R
S : Subobject M
⊢ LinearMap.ker (arrow S) = ⊥

Next tactic:
rw [ker_eq_bot_of_mono]
/-- The categorical subobjects of a module `M` are in one-to-one correspondence with its
    submodules.-/
noncomputable def subobjectModule : Subobject M ≃o Submodule R M :=
  OrderIso.symm
    { invFun := fun S => LinearMap.range S.arrow
      toFun := fun N => Subobject.mk (↾N.subtype)
      right_inv := fun S => Eq.symm (by
        fapply eq_mk_of_comm
        · apply LinearEquiv.toModuleIso'Left
          apply LinearEquiv.ofBijective (LinearMap.codRestrict (LinearMap.range S.arrow) S.arrow _)
          constructor
          · simp [← LinearMap.ker_eq_bot, LinearMap.ker_codRestrict]
            rw [ker_eq_bot_of_mono]
          · 

Proof state:
case i.e.right
R : Type u
inst✝ : Ring R
M : ModuleCat R
S : Subobject M
⊢ Function.Surjective ⇑(LinearMap.codRestrict (LinearMap.range (arrow S)) (arrow S) ?m.83059)

Next tactic:
rw [← LinearMap.range_eq_top, LinearMap.range_codRestrict, Submodule.comap_subtype_self]
/-- The categorical subobjects of a module `M` are in one-to-one correspondence with its
    submodules.-/
noncomputable def subobjectModule : Subobject M ≃o Submodule R M :=
  OrderIso.symm
    { invFun := fun S => LinearMap.range S.arrow
      toFun := fun N => Subobject.mk (↾N.subtype)
      right_inv := fun S => Eq.symm (by
        fapply eq_mk_of_comm
        · apply LinearEquiv.toModuleIso'Left
          apply LinearEquiv.ofBijective (LinearMap.codRestrict (LinearMap.range S.arrow) S.arrow _)
          constructor
          · simp [← LinearMap.ker_eq_bot, LinearMap.ker_codRestrict]
            rw [ker_eq_bot_of_mono]
          · rw [← LinearMap.range_eq_top, LinearMap.range_codRestrict, Submodule.comap_subtype_self]
            

Proof state:
case i.e.right.hf
R : Type u
inst✝ : Ring R
M : ModuleCat R
S : Subobject M
⊢ ∀ (c : ↑(underlying.obj S)), (arrow S) c ∈ LinearMap.range (arrow S)

Next tactic:
exact LinearMap.mem_range_self _
/-- The categorical subobjects of a module `M` are in one-to-one correspondence with its
    submodules.-/
noncomputable def subobjectModule : Subobject M ≃o Submodule R M :=
  OrderIso.symm
    { invFun := fun S => LinearMap.range S.arrow
      toFun := fun N => Subobject.mk (↾N.subtype)
      right_inv := fun S => Eq.symm (by
        fapply eq_mk_of_comm
        · apply LinearEquiv.toModuleIso'Left
          apply LinearEquiv.ofBijective (LinearMap.codRestrict (LinearMap.range S.arrow) S.arrow _)
          constructor
          · simp [← LinearMap.ker_eq_bot, LinearMap.ker_codRestrict]
            rw [ker_eq_bot_of_mono]
          · rw [← LinearMap.range_eq_top, LinearMap.range_codRestrict, Submodule.comap_subtype_self]
            exact LinearMap.mem_range_self _
        · 

Proof state:
case w
R : Type u
inst✝ : Ring R
M : ModuleCat R
S : Subobject M
⊢ (LinearEquiv.toModuleIso'Left
          (LinearEquiv.ofBijective
            (LinearMap.codRestrict (LinearMap.range (arrow S)) (arrow S)
              (_ : ∀ (x : ↑(underlying.obj S)), (arrow S) x ∈ LinearMap.range (arrow S)))
            (_ :
              Function.Injective
                  ⇑(LinearMap.codRestrict (LinearMap.range (arrow S)) (arrow S)
                      (_ : ∀ (x : ↑(underlying.obj S)), (arrow S) x ∈ LinearMap.range (arrow S))) ∧
                Function.Surjective
                  ⇑(LinearMap.codRestrict (LinearMap.range (arrow S)) (arrow S)
                      (_ : ∀ (x : ↑(underlying.obj S)), (arrow S) x ∈ LinearMap.range (arrow S)))))).hom ≫
      ↾(Submodule.subtype ((fun S => LinearMap.range (arrow S)) S)) =
    arrow S

Next tactic:
apply LinearMap.ext
/-- The categorical subobjects of a module `M` are in one-to-one correspondence with its
    submodules.-/
noncomputable def subobjectModule : Subobject M ≃o Submodule R M :=
  OrderIso.symm
    { invFun := fun S => LinearMap.range S.arrow
      toFun := fun N => Subobject.mk (↾N.subtype)
      right_inv := fun S => Eq.symm (by
        fapply eq_mk_of_comm
        · apply LinearEquiv.toModuleIso'Left
          apply LinearEquiv.ofBijective (LinearMap.codRestrict (LinearMap.range S.arrow) S.arrow _)
          constructor
          · simp [← LinearMap.ker_eq_bot, LinearMap.ker_codRestrict]
            rw [ker_eq_bot_of_mono]
          · rw [← LinearMap.range_eq_top, LinearMap.range_codRestrict, Submodule.comap_subtype_self]
            exact LinearMap.mem_range_self _
        · apply LinearMap.ext
          

Proof state:
case w.h
R : Type u
inst✝ : Ring R
M : ModuleCat R
S : Subobject M
⊢ ∀ (x : ↑(underlying.obj S)),
    ((LinearEquiv.toModuleIso'Left
              (LinearEquiv.ofBijective
                (LinearMap.codRestrict (LinearMap.range (arrow S)) (arrow S)
                  (_ : ∀ (x : ↑(underlying.obj S)), (arrow S) x ∈ LinearMap.range (arrow S)))
                (_ :
                  Function.Injective
                      ⇑(LinearMap.codRestrict (LinearMap.range (arrow S)) (arrow S)
                          (_ : ∀ (x : ↑(underlying.obj S)), (arrow S) x ∈ LinearMap.range (arrow S))) ∧
                    Function.Surjective
                      ⇑(LinearMap.codRestrict (LinearMap.range (arrow S)) (arrow S)
                          (_ : ∀ (x : ↑(underlying.obj S)), (arrow S) x ∈ LinearMap.range (arrow S)))))).hom ≫
          ↾(Submodule.subtype ((fun S => LinearMap.range (arrow S)) S)))
        x =
      (arrow S) x

Next tactic:
intro x
/-- The categorical subobjects of a module `M` are in one-to-one correspondence with its
    submodules.-/
noncomputable def subobjectModule : Subobject M ≃o Submodule R M :=
  OrderIso.symm
    { invFun := fun S => LinearMap.range S.arrow
      toFun := fun N => Subobject.mk (↾N.subtype)
      right_inv := fun S => Eq.symm (by
        fapply eq_mk_of_comm
        · apply LinearEquiv.toModuleIso'Left
          apply LinearEquiv.ofBijective (LinearMap.codRestrict (LinearMap.range S.arrow) S.arrow _)
          constructor
          · simp [← LinearMap.ker_eq_bot, LinearMap.ker_codRestrict]
            rw [ker_eq_bot_of_mono]
          · rw [← LinearMap.range_eq_top, LinearMap.range_codRestrict, Submodule.comap_subtype_self]
            exact LinearMap.mem_range_self _
        · apply LinearMap.ext
          intro x
          

Proof state:
case w.h
R : Type u
inst✝ : Ring R
M : ModuleCat R
S : Subobject M
x : ↑(underlying.obj S)
⊢ ((LinearEquiv.toModuleIso'Left
            (LinearEquiv.ofBijective
              (LinearMap.codRestrict (LinearMap.range (arrow S)) (arrow S)
                (_ : ∀ (x : ↑(underlying.obj S)), (arrow S) x ∈ LinearMap.range (arrow S)))
              (_ :
                Function.Injective
                    ⇑(LinearMap.codRestrict (LinearMap.range (arrow S)) (arrow S)
                        (_ : ∀ (x : ↑(underlying.obj S)), (arrow S) x ∈ LinearMap.range (arrow S))) ∧
                  Function.Surjective
                    ⇑(LinearMap.codRestrict (LinearMap.range (arrow S)) (arrow S)
                        (_ : ∀ (x : ↑(underlying.obj S)), (arrow S) x ∈ LinearMap.range (arrow S)))))).hom ≫
        ↾(Submodule.subtype ((fun S => LinearMap.range (arrow S)) S)))
      x =
    (arrow S) x

Next tactic:
rfl
/-- The categorical subobjects of a module `M` are in one-to-one correspondence with its
    submodules.-/
noncomputable def subobjectModule : Subobject M ≃o Submodule R M :=
  OrderIso.symm
    { invFun := fun S => LinearMap.range S.arrow
      toFun := fun N => Subobject.mk (↾N.subtype)
      right_inv := fun S => Eq.symm (by
        fapply eq_mk_of_comm
        · apply LinearEquiv.toModuleIso'Left
          apply LinearEquiv.ofBijective (LinearMap.codRestrict (LinearMap.range S.arrow) S.arrow _)
          constructor
          · simp [← LinearMap.ker_eq_bot, LinearMap.ker_codRestrict]
            rw [ker_eq_bot_of_mono]
          · rw [← LinearMap.range_eq_top, LinearMap.range_codRestrict, Submodule.comap_subtype_self]
            exact LinearMap.mem_range_self _
        · apply LinearMap.ext
          intro x
          rfl)
      left_inv := fun N => by
        -- Porting note: The type of `↾N.subtype` was ambiguous. Not entirely sure, I made the right
        -- choice here
        convert congr_arg LinearMap.range
            (underlyingIso_arrow (↾N.subtype : of R { x // x ∈ N } ⟶ M)) using 1
        · have :
            -- Porting note: added the `.toLinearEquiv.toLinearMap`
            (underlyingIso (↾N.subtype : of R _ ⟶ M)).inv =
              (underlyingIso (↾N.subtype : of R _ ⟶ M)).symm.toLinearEquiv.toLinearMap := by
              apply LinearMap.ext
              intro x
              rfl
          rw [this, comp_def, LinearEquiv.range_comp]
        · exact (Submodule.range_subtype _).symm
      map_rel_iff' := fun {S T} => by
        

Proof state:
R : Type u
inst✝ : Ring R
M : ModuleCat R
S T : Submodule R ↑M
⊢ { toFun := fun N => Subobject.mk (↾(Submodule.subtype N)), invFun := fun S => LinearMap.range (arrow S),
          left_inv :=
            (_ :
              ∀ (N : Submodule R ↑M),
                (fun S => LinearMap.range (arrow S)) ((fun N => Subobject.mk (↾(Submodule.subtype N))) N) = N),
          right_inv :=
            (_ :
              ∀ (S : Subobject M),
                (fun N => Subobject.mk (↾(Submodule.subtype N))) ((fun S => LinearMap.range (arrow S)) S) = S) }
        S ≤
      { toFun := fun N => Subobject.mk (↾(Submodule.subtype N)), invFun := fun S => LinearMap.range (arrow S),
          left_inv :=
            (_ :
              ∀ (N : Submodule R ↑M),
                (fun S => LinearMap.range (arrow S)) ((fun N => Subobject.mk (↾(Submodule.subtype N))) N) = N),
          right_inv :=
            (_ :
              ∀ (S : Subobject M),
                (fun N => Subobject.mk (↾(Submodule.subtype N))) ((fun S => LinearMap.range (arrow S)) S) = S) }
        T ↔
    S ≤ T

Next tactic:
refine' ⟨fun h => _, fun h => mk_le_mk_of_comm (↟(Submodule.inclusion h)) rfl⟩