import Mathlib import OAI.Probability.SKGap.Model namespace OAI section noncomputable section open MeasureTheory ProbabilityTheory InformationTheory Real Set open scoped NNReal ENNReal open Filter open scoped Topology noncomputable section open Matrix Real open scoped BigOperators Matrix.Norms.Frobenius ENNReal NNReal noncomputable section open Matrix Real open scoped BigOperators Matrix.Norms.Frobenius NNReal noncomputable section open MeasureTheory ProbabilityTheory Real Set Filter open MeasureTheory.Measure open scoped ENNReal NNReal MeasureTheory Topology open MeasureTheory noncomputable section noncomputable section open MeasureTheory Set NormedSpace open scoped Topology noncomputable section open Matrix Real open scoped BigOperators Matrix.Norms.Frobenius noncomputable section open Set Real open scoped Topology noncomputable section open Matrix Set Filter open scoped Topology Matrix.Norms.Frobenius noncomputable section open Matrix NormedSpace ContinuousLinearMap open scoped Matrix.Norms.Frobenius noncomputable section open Matrix namespace SKGap.ResolventIdentity variable {ι : Type*} [Fintype ι] [DecidableEq ι] variable {𝕜 : Type*} [RCLike 𝕜] lemma inverse_one_sub_square_mul (D V : Matrix ι ι 𝕜) (hS : IsUnit (1-D*V*D)) : (1-D*D*V)⁻¹ = 1+D*(1-D*V*D)⁻¹*D*V := by apply Matrix.inv_eq_right_inv have hSS : (1-D*V*D)*(1-D*V*D)⁻¹ = 1 := Matrix.mul_nonsing_inv _ (((1-D*V*D).isUnit_iff_isUnit_det).mp hS) calc _ = (1-D*D*V)+D*((1-D*V*D)*(1-D*V*D)⁻¹)*D*V := by noncomm_ring _ = 1 := by rw [hSS]; noncomm_ring lemma inverse_one_sub_square_mul_unit (D V : Matrix ι ι 𝕜) (hS : IsUnit (1-D*V*D)) : IsUnit (1-D*D*V) := by have hSS : (1-D*V*D)*(1-D*V*D)⁻¹ = 1 := Matrix.mul_nonsing_inv _ (((1-D*V*D).isUnit_iff_isUnit_det).mp hS) apply ((1-D*D*V).isUnit_iff_isUnit_det).mpr have hh : (1-D*D*V)*(1+D*(1-D*V*D)⁻¹*D*V) = 1 := by calc _ = (1-D*D*V)+D*((1-D*V*D)*(1-D*V*D)⁻¹)*D*V := by noncomm_ring _ = 1 := by rw [hSS]; noncomm_ring exact Matrix.isUnit_det_of_right_inverse hh lemma inverse_one_sub_square_mul_square (D V : Matrix ι ι 𝕜) (hS : IsUnit (1-D*V*D)) : (1-D*D*V)⁻¹*(D*D) = D*(1-D*V*D)⁻¹*D := by rw [inverse_one_sub_square_mul D V hS] have hSS : (1-D*V*D)⁻¹*(1-D*V*D) = 1 := Matrix.nonsing_inv_mul _ (((1-D*V*D).isUnit_iff_isUnit_det).mp hS) calc _ = D*(1-D*V*D)⁻¹*D+D*(1-(1-D*V*D)⁻¹*(1-D*V*D))*D := by noncomm_ring _ = _ := by rw [hSS]; simp end SKGap.ResolventIdentity end end end end end end end end end end end end end OAI