-- CvxLean/Lib/Math/LinearAlgebra/Matrix/PosDef.lean

import Mathlib.LinearAlgebra.Matrix.PosDef

import Mathlib.Algebra.Star.Pi

namespace Matrix

variable {m n : Type _} [Fintype m] [Fintype n]

variable {𝕜 : Type _}

variable [NormedField 𝕜] [PartialOrder 𝕜] [StarRing 𝕜] [StarOrderedRing 𝕜]

variable [RCLike 𝕜]

noncomputable instance PosDef.Invertible [DecidableEq n] {M : Matrix n n 𝕜} (hM : M.PosDef) :
    Invertible M :=
  invertibleOfIsUnitDet M (isUnit_iff_ne_zero.2 hM.det_ne_zero)

-- Repository definitions used:
content: ...

-- Repository lemmas used:
content: theorem List.getElem_append_left{α : Type u_1} {l₁ l₂ : List α} {i : Nat} (hn : i < l₁.length) :\n(l₁ ++ l₂)[i] = l₁[i]

-- Local definitions used:
content: noncomputable instance PosDef.Invertible [DecidableEq n] {M : Matrix n n 𝕜} (hM : M.PosDef) :
    Invertible M :=
  invertibleOfIsUnitDet M (isUnit_iff_ne_zero.2 hM.det_ne_zero)

-- Local lemmas used:
content: lemma PosDef.det_ne_zero [DecidableEq n] {M : Matrix n n 𝕜} (hM : M.PosDef) : M.det ≠ 0

content: lemma PosDef.isUnit_det [DecidableEq n] {M : Matrix n n ℝ} (hM : M.PosDef) : IsUnit M.det

-- Target theorem and proof:
lemma isUnit_det_of_PosDef_inv [DecidableEq n] {M : Matrix n n ℝ} (h : M⁻¹.PosDef) :
    IsUnit M.det
:= by
  apply isUnit_iff_ne_zero.2
  have := h.isUnit_det
  rw [det_nonsing_inv, isUnit_ring_inverse] at this
  apply IsUnit.ne_zero this