l3lab/ntp-mathlib huggingface dataset:
theorem norm_extendTo𝕜'_apply_sq (fr : F →ₗ[ℝ] ℝ) (x : F) :
    ‖(fr.extendTo𝕜' x : 𝕜)‖ ^ 2 = fr (conj (fr.extendTo𝕜' x : 𝕜) • x) :=
  calc
    ‖(fr.extendTo𝕜' x : 𝕜)‖ ^ 2 = re (conj (fr.extendTo𝕜' x) * fr.extendTo𝕜' x : 𝕜) := by
      

Proof state:
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
F : Type u_2
inst✝³ : SeminormedAddCommGroup F
inst✝² : NormedSpace 𝕜 F
inst✝¹ : Module ℝ F
inst✝ : IsScalarTower ℝ 𝕜 F
fr : F →ₗ[ℝ] ℝ
x : F
⊢ ‖(extendTo𝕜' fr) x‖ ^ 2 = re ((starRingEnd 𝕜) ((extendTo𝕜' fr) x) * (extendTo𝕜' fr) x)

Next tactic:
rw [IsROrC.conj_mul, normSq_eq_def', ofReal_re]
theorem norm_extendTo𝕜'_apply_sq (fr : F →ₗ[ℝ] ℝ) (x : F) :
    ‖(fr.extendTo𝕜' x : 𝕜)‖ ^ 2 = fr (conj (fr.extendTo𝕜' x : 𝕜) • x) :=
  calc
    ‖(fr.extendTo𝕜' x : 𝕜)‖ ^ 2 = re (conj (fr.extendTo𝕜' x) * fr.extendTo𝕜' x : 𝕜) := by
      rw [IsROrC.conj_mul, normSq_eq_def', ofReal_re]
    _ = fr (conj (fr.extendTo𝕜' x : 𝕜) • x) := by
      

Proof state:
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
F : Type u_2
inst✝³ : SeminormedAddCommGroup F
inst✝² : NormedSpace 𝕜 F
inst✝¹ : Module ℝ F
inst✝ : IsScalarTower ℝ 𝕜 F
fr : F →ₗ[ℝ] ℝ
x : F
⊢ re ((starRingEnd 𝕜) ((extendTo𝕜' fr) x) * (extendTo𝕜' fr) x) = fr ((starRingEnd 𝕜) ((extendTo𝕜' fr) x) • x)

Next tactic:
rw [← smul_eq_mul, ← map_smul, extendTo𝕜'_apply_re]
/-- The norm of the extension is bounded by `‖fr‖`. -/
theorem norm_extendTo𝕜'_bound (fr : F →L[ℝ] ℝ) (x : F) :
    ‖(fr.toLinearMap.extendTo𝕜' x : 𝕜)‖ ≤ ‖fr‖ * ‖x‖ := by
  

Proof state:
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
F : Type u_2
inst✝³ : SeminormedAddCommGroup F
inst✝² : NormedSpace 𝕜 F
inst✝¹ : NormedSpace ℝ F
inst✝ : IsScalarTower ℝ 𝕜 F
fr : F →L[ℝ] ℝ
x : F
⊢ ‖(LinearMap.extendTo𝕜' ↑fr) x‖ ≤ ‖fr‖ * ‖x‖

Next tactic:
set lm : F →ₗ[𝕜] 𝕜 := fr.toLinearMap.extendTo𝕜'
/-- The norm of the extension is bounded by `‖fr‖`. -/
theorem norm_extendTo𝕜'_bound (fr : F →L[ℝ] ℝ) (x : F) :
    ‖(fr.toLinearMap.extendTo𝕜' x : 𝕜)‖ ≤ ‖fr‖ * ‖x‖ := by
  set lm : F →ₗ[𝕜] 𝕜 := fr.toLinearMap.extendTo𝕜'
  

Proof state:
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
F : Type u_2
inst✝³ : SeminormedAddCommGroup F
inst✝² : NormedSpace 𝕜 F
inst✝¹ : NormedSpace ℝ F
inst✝ : IsScalarTower ℝ 𝕜 F
fr : F →L[ℝ] ℝ
x : F
lm : F →ₗ[𝕜] 𝕜 := LinearMap.extendTo𝕜' ↑fr
⊢ ‖lm x‖ ≤ ‖fr‖ * ‖x‖

Next tactic:
by_cases h : lm x = 0
/-- The norm of the extension is bounded by `‖fr‖`. -/
theorem norm_extendTo𝕜'_bound (fr : F →L[ℝ] ℝ) (x : F) :
    ‖(fr.toLinearMap.extendTo𝕜' x : 𝕜)‖ ≤ ‖fr‖ * ‖x‖ := by
  set lm : F →ₗ[𝕜] 𝕜 := fr.toLinearMap.extendTo𝕜'
  by_cases h : lm x = 0
  · 

Proof state:
case pos
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
F : Type u_2
inst✝³ : SeminormedAddCommGroup F
inst✝² : NormedSpace 𝕜 F
inst✝¹ : NormedSpace ℝ F
inst✝ : IsScalarTower ℝ 𝕜 F
fr : F →L[ℝ] ℝ
x : F
lm : F →ₗ[𝕜] 𝕜 := LinearMap.extendTo𝕜' ↑fr
h : lm x = 0
⊢ ‖lm x‖ ≤ ‖fr‖ * ‖x‖

Next tactic:
rw [h, norm_zero]
/-- The norm of the extension is bounded by `‖fr‖`. -/
theorem norm_extendTo𝕜'_bound (fr : F →L[ℝ] ℝ) (x : F) :
    ‖(fr.toLinearMap.extendTo𝕜' x : 𝕜)‖ ≤ ‖fr‖ * ‖x‖ := by
  set lm : F →ₗ[𝕜] 𝕜 := fr.toLinearMap.extendTo𝕜'
  by_cases h : lm x = 0
  · rw [h, norm_zero]
    

Proof state:
case pos
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
F : Type u_2
inst✝³ : SeminormedAddCommGroup F
inst✝² : NormedSpace 𝕜 F
inst✝¹ : NormedSpace ℝ F
inst✝ : IsScalarTower ℝ 𝕜 F
fr : F →L[ℝ] ℝ
x : F
lm : F →ₗ[𝕜] 𝕜 := LinearMap.extendTo𝕜' ↑fr
h : lm x = 0
⊢ 0 ≤ ‖fr‖ * ‖x‖

Next tactic:
apply mul_nonneg
/-- The norm of the extension is bounded by `‖fr‖`. -/
theorem norm_extendTo𝕜'_bound (fr : F →L[ℝ] ℝ) (x : F) :
    ‖(fr.toLinearMap.extendTo𝕜' x : 𝕜)‖ ≤ ‖fr‖ * ‖x‖ := by
  set lm : F →ₗ[𝕜] 𝕜 := fr.toLinearMap.extendTo𝕜'
  by_cases h : lm x = 0
  · rw [h, norm_zero]
    apply mul_nonneg <;> 

Proof state:
case pos.ha
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
F : Type u_2
inst✝³ : SeminormedAddCommGroup F
inst✝² : NormedSpace 𝕜 F
inst✝¹ : NormedSpace ℝ F
inst✝ : IsScalarTower ℝ 𝕜 F
fr : F →L[ℝ] ℝ
x : F
lm : F →ₗ[𝕜] 𝕜 := LinearMap.extendTo𝕜' ↑fr
h : lm x = 0
⊢ 0 ≤ ‖fr‖

Next tactic:
exact norm_nonneg _
/-- The norm of the extension is bounded by `‖fr‖`. -/
theorem norm_extendTo𝕜'_bound (fr : F →L[ℝ] ℝ) (x : F) :
    ‖(fr.toLinearMap.extendTo𝕜' x : 𝕜)‖ ≤ ‖fr‖ * ‖x‖ := by
  set lm : F →ₗ[𝕜] 𝕜 := fr.toLinearMap.extendTo𝕜'
  by_cases h : lm x = 0
  · rw [h, norm_zero]
    apply mul_nonneg <;> 

Proof state:
case pos.hb
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
F : Type u_2
inst✝³ : SeminormedAddCommGroup F
inst✝² : NormedSpace 𝕜 F
inst✝¹ : NormedSpace ℝ F
inst✝ : IsScalarTower ℝ 𝕜 F
fr : F →L[ℝ] ℝ
x : F
lm : F →ₗ[𝕜] 𝕜 := LinearMap.extendTo𝕜' ↑fr
h : lm x = 0
⊢ 0 ≤ ‖x‖

Next tactic:
exact norm_nonneg _
/-- The norm of the extension is bounded by `‖fr‖`. -/
theorem norm_extendTo𝕜'_bound (fr : F →L[ℝ] ℝ) (x : F) :
    ‖(fr.toLinearMap.extendTo𝕜' x : 𝕜)‖ ≤ ‖fr‖ * ‖x‖ := by
  set lm : F →ₗ[𝕜] 𝕜 := fr.toLinearMap.extendTo𝕜'
  by_cases h : lm x = 0
  · rw [h, norm_zero]
    apply mul_nonneg <;> exact norm_nonneg _
  

Proof state:
case neg
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
F : Type u_2
inst✝³ : SeminormedAddCommGroup F
inst✝² : NormedSpace 𝕜 F
inst✝¹ : NormedSpace ℝ F
inst✝ : IsScalarTower ℝ 𝕜 F
fr : F →L[ℝ] ℝ
x : F
lm : F →ₗ[𝕜] 𝕜 := LinearMap.extendTo𝕜' ↑fr
h : ¬lm x = 0
⊢ ‖lm x‖ ≤ ‖fr‖ * ‖x‖

Next tactic:
rw [← mul_le_mul_left (norm_pos_iff.2 h), ← sq]
/-- The norm of the extension is bounded by `‖fr‖`. -/
theorem norm_extendTo𝕜'_bound (fr : F →L[ℝ] ℝ) (x : F) :
    ‖(fr.toLinearMap.extendTo𝕜' x : 𝕜)‖ ≤ ‖fr‖ * ‖x‖ := by
  set lm : F →ₗ[𝕜] 𝕜 := fr.toLinearMap.extendTo𝕜'
  by_cases h : lm x = 0
  · rw [h, norm_zero]
    apply mul_nonneg <;> exact norm_nonneg _
  rw [← mul_le_mul_left (norm_pos_iff.2 h), ← sq]
  

Proof state:
case neg
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
F : Type u_2
inst✝³ : SeminormedAddCommGroup F
inst✝² : NormedSpace 𝕜 F
inst✝¹ : NormedSpace ℝ F
inst✝ : IsScalarTower ℝ 𝕜 F
fr : F →L[ℝ] ℝ
x : F
lm : F →ₗ[𝕜] 𝕜 := LinearMap.extendTo𝕜' ↑fr
h : ¬lm x = 0
⊢ ‖lm x‖ ^ 2 ≤ ‖lm x‖ * (‖fr‖ * ‖x‖)

Next tactic:
calc
    ‖lm x‖ ^ 2 = fr (conj (lm x : 𝕜) • x) := fr.toLinearMap.norm_extendTo𝕜'_apply_sq x
    _ ≤ ‖fr (conj (lm x : 𝕜) • x)‖ := (le_abs_self _)
    _ ≤ ‖fr‖ * ‖conj (lm x : 𝕜) • x‖ := (le_op_norm _ _)
    _ = ‖(lm x : 𝕜)‖ * (‖fr‖ * ‖x‖) := by rw [norm_smul, norm_conj, mul_left_comm]
/-- The norm of the extension is bounded by `‖fr‖`. -/
theorem norm_extendTo𝕜'_bound (fr : F →L[ℝ] ℝ) (x : F) :
    ‖(fr.toLinearMap.extendTo𝕜' x : 𝕜)‖ ≤ ‖fr‖ * ‖x‖ := by
  set lm : F →ₗ[𝕜] 𝕜 := fr.toLinearMap.extendTo𝕜'
  by_cases h : lm x = 0
  · rw [h, norm_zero]
    apply mul_nonneg <;> exact norm_nonneg _
  rw [← mul_le_mul_left (norm_pos_iff.2 h), ← sq]
  calc
    ‖lm x‖ ^ 2 = fr (conj (lm x : 𝕜) • x) := fr.toLinearMap.norm_extendTo𝕜'_apply_sq x
    _ ≤ ‖fr (conj (lm x : 𝕜) • x)‖ := (le_abs_self _)
    _ ≤ ‖fr‖ * ‖conj (lm x : 𝕜) • x‖ := (le_op_norm _ _)
    _ = ‖(lm x : 𝕜)‖ * (‖fr‖ * ‖x‖) := by 

Proof state:
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
F : Type u_2
inst✝³ : SeminormedAddCommGroup F
inst✝² : NormedSpace 𝕜 F
inst✝¹ : NormedSpace ℝ F
inst✝ : IsScalarTower ℝ 𝕜 F
fr : F →L[ℝ] ℝ
x : F
lm : F →ₗ[𝕜] 𝕜 := LinearMap.extendTo𝕜' ↑fr
h : ¬lm x = 0
⊢ ‖fr‖ * ‖(starRingEnd 𝕜) (lm x) • x‖ = ‖lm x‖ * (‖fr‖ * ‖x‖)

Next tactic:
rw [norm_smul, norm_conj, mul_left_comm]
instance : NormedSpace 𝕜 (RestrictScalars ℝ 𝕜 F) := by
  

Proof state:
𝕜 : Type u_1
inst✝² : IsROrC 𝕜
F : Type u_2
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace 𝕜 F
⊢ NormedSpace 𝕜 (RestrictScalars ℝ 𝕜 F)

Next tactic:
unfold RestrictScalars
instance : NormedSpace 𝕜 (RestrictScalars ℝ 𝕜 F) := by
  unfold RestrictScalars
  

Proof state:
𝕜 : Type u_1
inst✝² : IsROrC 𝕜
F : Type u_2
inst✝¹ : SeminormedAddCommGroup F
inst✝ : NormedSpace 𝕜 F
⊢ NormedSpace 𝕜 F

Next tactic:
infer_instance
theorem LDL.lowerInv_eq_gramSchmidtBasis :
    LDL.lowerInv hS =
      ((Pi.basisFun 𝕜 n).toMatrix
          (@gramSchmidtBasis 𝕜 (n → 𝕜) _ (_ : _) (InnerProductSpace.ofMatrix hS.transpose) n _ _ _
            (Pi.basisFun 𝕜 n)))ᵀ := by
  

Proof state:
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
n : Type u_2
inst✝³ : LinearOrder n
inst✝² : IsWellOrder n fun x x_1 => x < x_1
inst✝¹ : LocallyFiniteOrderBot n
S : Matrix n n 𝕜
inst✝ : Fintype n
hS : PosDef S
⊢ lowerInv hS = (Basis.toMatrix (Pi.basisFun 𝕜 n) ⇑(gramSchmidtBasis (Pi.basisFun 𝕜 n)))ᵀ

Next tactic:
letI := NormedAddCommGroup.ofMatrix hS.transpose
theorem LDL.lowerInv_eq_gramSchmidtBasis :
    LDL.lowerInv hS =
      ((Pi.basisFun 𝕜 n).toMatrix
          (@gramSchmidtBasis 𝕜 (n → 𝕜) _ (_ : _) (InnerProductSpace.ofMatrix hS.transpose) n _ _ _
            (Pi.basisFun 𝕜 n)))ᵀ := by
  letI := NormedAddCommGroup.ofMatrix hS.transpose
  

Proof state:
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
n : Type u_2
inst✝³ : LinearOrder n
inst✝² : IsWellOrder n fun x x_1 => x < x_1
inst✝¹ : LocallyFiniteOrderBot n
S : Matrix n n 𝕜
inst✝ : Fintype n
hS : PosDef S
this : NormedAddCommGroup (n → 𝕜) := NormedAddCommGroup.ofMatrix (_ : PosDef Sᵀ)
⊢ lowerInv hS = (Basis.toMatrix (Pi.basisFun 𝕜 n) ⇑(gramSchmidtBasis (Pi.basisFun 𝕜 n)))ᵀ

Next tactic:
letI := InnerProductSpace.ofMatrix hS.transpose
theorem LDL.lowerInv_eq_gramSchmidtBasis :
    LDL.lowerInv hS =
      ((Pi.basisFun 𝕜 n).toMatrix
          (@gramSchmidtBasis 𝕜 (n → 𝕜) _ (_ : _) (InnerProductSpace.ofMatrix hS.transpose) n _ _ _
            (Pi.basisFun 𝕜 n)))ᵀ := by
  letI := NormedAddCommGroup.ofMatrix hS.transpose
  letI := InnerProductSpace.ofMatrix hS.transpose
  

Proof state:
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
n : Type u_2
inst✝³ : LinearOrder n
inst✝² : IsWellOrder n fun x x_1 => x < x_1
inst✝¹ : LocallyFiniteOrderBot n
S : Matrix n n 𝕜
inst✝ : Fintype n
hS : PosDef S
this✝ : NormedAddCommGroup (n → 𝕜) := NormedAddCommGroup.ofMatrix (_ : PosDef Sᵀ)
this : InnerProductSpace 𝕜 (n → 𝕜) := InnerProductSpace.ofMatrix (_ : PosDef Sᵀ)
⊢ lowerInv hS = (Basis.toMatrix (Pi.basisFun 𝕜 n) ⇑(gramSchmidtBasis (Pi.basisFun 𝕜 n)))ᵀ

Next tactic:
ext i j
theorem LDL.lowerInv_eq_gramSchmidtBasis :
    LDL.lowerInv hS =
      ((Pi.basisFun 𝕜 n).toMatrix
          (@gramSchmidtBasis 𝕜 (n → 𝕜) _ (_ : _) (InnerProductSpace.ofMatrix hS.transpose) n _ _ _
            (Pi.basisFun 𝕜 n)))ᵀ := by
  letI := NormedAddCommGroup.ofMatrix hS.transpose
  letI := InnerProductSpace.ofMatrix hS.transpose
  ext i j
  

Proof state:
case a.h
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
n : Type u_2
inst✝³ : LinearOrder n
inst✝² : IsWellOrder n fun x x_1 => x < x_1
inst✝¹ : LocallyFiniteOrderBot n
S : Matrix n n 𝕜
inst✝ : Fintype n
hS : PosDef S
this✝ : NormedAddCommGroup (n → 𝕜) := NormedAddCommGroup.ofMatrix (_ : PosDef Sᵀ)
this : InnerProductSpace 𝕜 (n → 𝕜) := InnerProductSpace.ofMatrix (_ : PosDef Sᵀ)
i j : n
⊢ lowerInv hS i j = (Basis.toMatrix (Pi.basisFun 𝕜 n) ⇑(gramSchmidtBasis (Pi.basisFun 𝕜 n)))ᵀ i j

Next tactic:
rw [LDL.lowerInv, Basis.coePiBasisFun.toMatrix_eq_transpose, coe_gramSchmidtBasis]
theorem LDL.lowerInv_eq_gramSchmidtBasis :
    LDL.lowerInv hS =
      ((Pi.basisFun 𝕜 n).toMatrix
          (@gramSchmidtBasis 𝕜 (n → 𝕜) _ (_ : _) (InnerProductSpace.ofMatrix hS.transpose) n _ _ _
            (Pi.basisFun 𝕜 n)))ᵀ := by
  letI := NormedAddCommGroup.ofMatrix hS.transpose
  letI := InnerProductSpace.ofMatrix hS.transpose
  ext i j
  rw [LDL.lowerInv, Basis.coePiBasisFun.toMatrix_eq_transpose, coe_gramSchmidtBasis]
  

Proof state:
case a.h
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
n : Type u_2
inst✝³ : LinearOrder n
inst✝² : IsWellOrder n fun x x_1 => x < x_1
inst✝¹ : LocallyFiniteOrderBot n
S : Matrix n n 𝕜
inst✝ : Fintype n
hS : PosDef S
this✝ : NormedAddCommGroup (n → 𝕜) := NormedAddCommGroup.ofMatrix (_ : PosDef Sᵀ)
this : InnerProductSpace 𝕜 (n → 𝕜) := InnerProductSpace.ofMatrix (_ : PosDef Sᵀ)
i j : n
⊢ gramSchmidt 𝕜 (⇑(Pi.basisFun 𝕜 n)) i j = (gramSchmidt 𝕜 ⇑(Pi.basisFun 𝕜 n))ᵀᵀ i j

Next tactic:
rfl
noncomputable instance LDL.invertibleLowerInv : Invertible (LDL.lowerInv hS) := by
  

Proof state:
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
n : Type u_2
inst✝³ : LinearOrder n
inst✝² : IsWellOrder n fun x x_1 => x < x_1
inst✝¹ : LocallyFiniteOrderBot n
S : Matrix n n 𝕜
inst✝ : Fintype n
hS : PosDef S
⊢ Invertible (lowerInv hS)

Next tactic:
rw [LDL.lowerInv_eq_gramSchmidtBasis]
noncomputable instance LDL.invertibleLowerInv : Invertible (LDL.lowerInv hS) := by
  rw [LDL.lowerInv_eq_gramSchmidtBasis]
  

Proof state:
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
n : Type u_2
inst✝³ : LinearOrder n
inst✝² : IsWellOrder n fun x x_1 => x < x_1
inst✝¹ : LocallyFiniteOrderBot n
S : Matrix n n 𝕜
inst✝ : Fintype n
hS : PosDef S
⊢ Invertible (Basis.toMatrix (Pi.basisFun 𝕜 n) ⇑(gramSchmidtBasis (Pi.basisFun 𝕜 n)))ᵀ

Next tactic:
haveI :=
    Basis.invertibleToMatrix (Pi.basisFun 𝕜 n)
      (@gramSchmidtBasis 𝕜 (n → 𝕜) _ (_ : _) (InnerProductSpace.ofMatrix hS.transpose) n _ _ _
        (Pi.basisFun 𝕜 n))
noncomputable instance LDL.invertibleLowerInv : Invertible (LDL.lowerInv hS) := by
  rw [LDL.lowerInv_eq_gramSchmidtBasis]
  haveI :=
    Basis.invertibleToMatrix (Pi.basisFun 𝕜 n)
      (@gramSchmidtBasis 𝕜 (n → 𝕜) _ (_ : _) (InnerProductSpace.ofMatrix hS.transpose) n _ _ _
        (Pi.basisFun 𝕜 n))
  

Proof state:
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
n : Type u_2
inst✝³ : LinearOrder n
inst✝² : IsWellOrder n fun x x_1 => x < x_1
inst✝¹ : LocallyFiniteOrderBot n
S : Matrix n n 𝕜
inst✝ : Fintype n
hS : PosDef S
this : Invertible (Basis.toMatrix (Pi.basisFun 𝕜 n) ⇑(gramSchmidtBasis (Pi.basisFun 𝕜 n)))
⊢ Invertible (Basis.toMatrix (Pi.basisFun 𝕜 n) ⇑(gramSchmidtBasis (Pi.basisFun 𝕜 n)))ᵀ

Next tactic:
infer_instance
theorem LDL.lowerInv_triangular {i j : n} (hij : i < j) : LDL.lowerInv hS i j = 0 := by
  

Proof state:
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
n : Type u_2
inst✝³ : LinearOrder n
inst✝² : IsWellOrder n fun x x_1 => x < x_1
inst✝¹ : LocallyFiniteOrderBot n
S : Matrix n n 𝕜
inst✝ : Fintype n
hS : PosDef S
i j : n
hij : i < j
⊢ lowerInv hS i j = 0

Next tactic:
rw [←
    @gramSchmidt_triangular 𝕜 (n → 𝕜) _ (_ : _) (InnerProductSpace.ofMatrix hS.transpose) n _ _ _
      i j hij (Pi.basisFun 𝕜 n),
    Pi.basisFun_repr, LDL.lowerInv]
/-- Inverse statement of **LDL decomposition**: we can conjugate a positive definite matrix
by some lower triangular matrix and get a diagonal matrix. -/
theorem LDL.diag_eq_lowerInv_conj : LDL.diag hS = LDL.lowerInv hS * S * (LDL.lowerInv hS)ᴴ := by
  

Proof state:
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
n : Type u_2
inst✝³ : LinearOrder n
inst✝² : IsWellOrder n fun x x_1 => x < x_1
inst✝¹ : LocallyFiniteOrderBot n
S : Matrix n n 𝕜
inst✝ : Fintype n
hS : PosDef S
⊢ diag hS = lowerInv hS * S * (lowerInv hS)ᴴ

Next tactic:
ext i j
/-- Inverse statement of **LDL decomposition**: we can conjugate a positive definite matrix
by some lower triangular matrix and get a diagonal matrix. -/
theorem LDL.diag_eq_lowerInv_conj : LDL.diag hS = LDL.lowerInv hS * S * (LDL.lowerInv hS)ᴴ := by
  ext i j
  

Proof state:
case a.h
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
n : Type u_2
inst✝³ : LinearOrder n
inst✝² : IsWellOrder n fun x x_1 => x < x_1
inst✝¹ : LocallyFiniteOrderBot n
S : Matrix n n 𝕜
inst✝ : Fintype n
hS : PosDef S
i j : n
⊢ diag hS i j = (lowerInv hS * S * (lowerInv hS)ᴴ) i j

Next tactic:
by_cases hij : i = j
/-- Inverse statement of **LDL decomposition**: we can conjugate a positive definite matrix
by some lower triangular matrix and get a diagonal matrix. -/
theorem LDL.diag_eq_lowerInv_conj : LDL.diag hS = LDL.lowerInv hS * S * (LDL.lowerInv hS)ᴴ := by
  ext i j
  by_cases hij : i = j
  · 

Proof state:
case pos
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
n : Type u_2
inst✝³ : LinearOrder n
inst✝² : IsWellOrder n fun x x_1 => x < x_1
inst✝¹ : LocallyFiniteOrderBot n
S : Matrix n n 𝕜
inst✝ : Fintype n
hS : PosDef S
i j : n
hij : i = j
⊢ diag hS i j = (lowerInv hS * S * (lowerInv hS)ᴴ) i j

Next tactic:
simp only [diag, diagEntries, EuclideanSpace.inner_piLp_equiv_symm, star_star, hij,
    diagonal_apply_eq, Matrix.mul_assoc]
/-- Inverse statement of **LDL decomposition**: we can conjugate a positive definite matrix
by some lower triangular matrix and get a diagonal matrix. -/
theorem LDL.diag_eq_lowerInv_conj : LDL.diag hS = LDL.lowerInv hS * S * (LDL.lowerInv hS)ᴴ := by
  ext i j
  by_cases hij : i = j
  · simp only [diag, diagEntries, EuclideanSpace.inner_piLp_equiv_symm, star_star, hij,
    diagonal_apply_eq, Matrix.mul_assoc]
    

Proof state:
case pos
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
n : Type u_2
inst✝³ : LinearOrder n
inst✝² : IsWellOrder n fun x x_1 => x < x_1
inst✝¹ : LocallyFiniteOrderBot n
S : Matrix n n 𝕜
inst✝ : Fintype n
hS : PosDef S
i j : n
hij : i = j
⊢ lowerInv hS j ⬝ᵥ mulVec S (star (lowerInv hS j)) = (lowerInv hS * (S * (lowerInv hS)ᴴ)) j j

Next tactic:
rfl
/-- Inverse statement of **LDL decomposition**: we can conjugate a positive definite matrix
by some lower triangular matrix and get a diagonal matrix. -/
theorem LDL.diag_eq_lowerInv_conj : LDL.diag hS = LDL.lowerInv hS * S * (LDL.lowerInv hS)ᴴ := by
  ext i j
  by_cases hij : i = j
  · simp only [diag, diagEntries, EuclideanSpace.inner_piLp_equiv_symm, star_star, hij,
    diagonal_apply_eq, Matrix.mul_assoc]
    rfl
  · 

Proof state:
case neg
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
n : Type u_2
inst✝³ : LinearOrder n
inst✝² : IsWellOrder n fun x x_1 => x < x_1
inst✝¹ : LocallyFiniteOrderBot n
S : Matrix n n 𝕜
inst✝ : Fintype n
hS : PosDef S
i j : n
hij : ¬i = j
⊢ diag hS i j = (lowerInv hS * S * (lowerInv hS)ᴴ) i j

Next tactic:
simp only [LDL.diag, hij, diagonal_apply_ne, Ne.def, not_false_iff, mul_mul_apply]
/-- Inverse statement of **LDL decomposition**: we can conjugate a positive definite matrix
by some lower triangular matrix and get a diagonal matrix. -/
theorem LDL.diag_eq_lowerInv_conj : LDL.diag hS = LDL.lowerInv hS * S * (LDL.lowerInv hS)ᴴ := by
  ext i j
  by_cases hij : i = j
  · simp only [diag, diagEntries, EuclideanSpace.inner_piLp_equiv_symm, star_star, hij,
    diagonal_apply_eq, Matrix.mul_assoc]
    rfl
  · simp only [LDL.diag, hij, diagonal_apply_ne, Ne.def, not_false_iff, mul_mul_apply]
    

Proof state:
case neg
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
n : Type u_2
inst✝³ : LinearOrder n
inst✝² : IsWellOrder n fun x x_1 => x < x_1
inst✝¹ : LocallyFiniteOrderBot n
S : Matrix n n 𝕜
inst✝ : Fintype n
hS : PosDef S
i j : n
hij : ¬i = j
⊢ 0 = lowerInv hS i ⬝ᵥ mulVec S ((lowerInv hS)ᴴᵀ j)

Next tactic:
rw [conjTranspose, transpose_map, transpose_transpose, dotProduct_mulVec,
      (LDL.lowerInv_orthogonal hS fun h : j = i => hij h.symm).symm, ← inner_conj_symm,
      mulVec_transpose, EuclideanSpace.inner_piLp_equiv_symm, ← IsROrC.star_def, ←
      star_dotProduct_star, dotProduct_comm, star_star]
/-- Inverse statement of **LDL decomposition**: we can conjugate a positive definite matrix
by some lower triangular matrix and get a diagonal matrix. -/
theorem LDL.diag_eq_lowerInv_conj : LDL.diag hS = LDL.lowerInv hS * S * (LDL.lowerInv hS)ᴴ := by
  ext i j
  by_cases hij : i = j
  · simp only [diag, diagEntries, EuclideanSpace.inner_piLp_equiv_symm, star_star, hij,
    diagonal_apply_eq, Matrix.mul_assoc]
    rfl
  · simp only [LDL.diag, hij, diagonal_apply_ne, Ne.def, not_false_iff, mul_mul_apply]
    rw [conjTranspose, transpose_map, transpose_transpose, dotProduct_mulVec,
      (LDL.lowerInv_orthogonal hS fun h : j = i => hij h.symm).symm, ← inner_conj_symm,
      mulVec_transpose, EuclideanSpace.inner_piLp_equiv_symm, ← IsROrC.star_def, ←
      star_dotProduct_star, dotProduct_comm, star_star]
    

Proof state:
case neg
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
n : Type u_2
inst✝³ : LinearOrder n
inst✝² : IsWellOrder n fun x x_1 => x < x_1
inst✝¹ : LocallyFiniteOrderBot n
S : Matrix n n 𝕜
inst✝ : Fintype n
hS : PosDef S
i j : n
hij : ¬i = j
⊢ vecMul (lowerInv hS i) S ⬝ᵥ star (lowerInv hS j) = vecMul (lowerInv hS i) S ⬝ᵥ map (lowerInv hS) star j

Next tactic:
rfl
/-- **LDL decomposition**: any positive definite matrix `S` can be
decomposed as `S = LDLᴴ` where `L` is a lower-triangular matrix and `D` is a diagonal matrix.  -/
theorem LDL.lower_conj_diag : LDL.lower hS * LDL.diag hS * (LDL.lower hS)ᴴ = S := by
  

Proof state:
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
n : Type u_2
inst✝³ : LinearOrder n
inst✝² : IsWellOrder n fun x x_1 => x < x_1
inst✝¹ : LocallyFiniteOrderBot n
S : Matrix n n 𝕜
inst✝ : Fintype n
hS : PosDef S
⊢ lower hS * diag hS * (lower hS)ᴴ = S

Next tactic:
rw [LDL.lower, conjTranspose_nonsing_inv, Matrix.mul_assoc,
    Matrix.inv_mul_eq_iff_eq_mul_of_invertible (LDL.lowerInv hS),
    Matrix.mul_inv_eq_iff_eq_mul_of_invertible]
/-- **LDL decomposition**: any positive definite matrix `S` can be
decomposed as `S = LDLᴴ` where `L` is a lower-triangular matrix and `D` is a diagonal matrix.  -/
theorem LDL.lower_conj_diag : LDL.lower hS * LDL.diag hS * (LDL.lower hS)ᴴ = S := by
  rw [LDL.lower, conjTranspose_nonsing_inv, Matrix.mul_assoc,
    Matrix.inv_mul_eq_iff_eq_mul_of_invertible (LDL.lowerInv hS),
    Matrix.mul_inv_eq_iff_eq_mul_of_invertible]
  

Proof state:
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
n : Type u_2
inst✝³ : LinearOrder n
inst✝² : IsWellOrder n fun x x_1 => x < x_1
inst✝¹ : LocallyFiniteOrderBot n
S : Matrix n n 𝕜
inst✝ : Fintype n
hS : PosDef S
⊢ diag hS = lowerInv hS * S * (lowerInv hS)ᴴ

Next tactic:
exact LDL.diag_eq_lowerInv_conj hS
instance : EstimatorData (Thunk.mk fun _ => (levenshtein C xs ys, ys.length))
    (LevenshteinEstimator' C xs ys) where
  bound e := e.bound
  improve e := match e.pre_rev, e.split with
    | [], _ => none
    | y :: ys, split => some
      { pre_rev := ys
        suff := y :: e.suff
        split := by 

Proof state:
α β δ : Type
inst✝ : CanonicallyLinearOrderedAddCommMonoid δ
C : Levenshtein.Cost α β δ
xs : List α
ys✝ : List β
e : LevenshteinEstimator' C xs ys✝
y : β
ys : List β
split : List.reverse (y :: ys) ++ e.suff = ys✝
⊢ List.reverse ys ++ y :: e.suff = ys✝

Next tactic:
simpa using split
instance estimator' :
    Estimator (Thunk.mk fun _ => (levenshtein C xs ys, ys.length))
      (LevenshteinEstimator' C xs ys) where
  bound_le e := match e.pre_rev, e.split, e.bound_eq with
  | [], split, eq => by
    

Proof state:
α β δ : Type
inst✝ : CanonicallyLinearOrderedAddCommMonoid δ
C : Levenshtein.Cost α β δ
xs : List α
ys : List β
e : LevenshteinEstimator' C xs ys
split : List.reverse [] ++ e.suff = ys
eq :
  e.bound =
    match [], split with
    | [], split => ((↑e.distances)[0], List.length ys)
    | x, split => (List.minimum_of_length_pos (_ : 0 < List.length ↑e.distances), List.length e.suff)
⊢ EstimatorData.bound { fn := fun x => (levenshtein C xs ys, List.length ys) } e ≤
    Thunk.get { fn := fun x => (levenshtein C xs ys, List.length ys) }

Next tactic:
simp only [List.reverse_nil, List.nil_append] at split
instance estimator' :
    Estimator (Thunk.mk fun _ => (levenshtein C xs ys, ys.length))
      (LevenshteinEstimator' C xs ys) where
  bound_le e := match e.pre_rev, e.split, e.bound_eq with
  | [], split, eq => by
    simp only [List.reverse_nil, List.nil_append] at split
    

Proof state:
α β δ : Type
inst✝ : CanonicallyLinearOrderedAddCommMonoid δ
C : Levenshtein.Cost α β δ
xs : List α
ys : List β
e : LevenshteinEstimator' C xs ys
split : e.suff = ys
eq :
  e.bound =
    match [], split with
    | [], split => ((↑e.distances)[0], List.length ys)
    | x, split => (List.minimum_of_length_pos (_ : 0 < List.length ↑e.distances), List.length e.suff)
⊢ EstimatorData.bound { fn := fun x => (levenshtein C xs ys, List.length ys) } e ≤
    Thunk.get { fn := fun x => (levenshtein C xs ys, List.length ys) }

Next tactic:
rw [e.distances_eq] at eq
instance estimator' :
    Estimator (Thunk.mk fun _ => (levenshtein C xs ys, ys.length))
      (LevenshteinEstimator' C xs ys) where
  bound_le e := match e.pre_rev, e.split, e.bound_eq with
  | [], split, eq => by
    simp only [List.reverse_nil, List.nil_append] at split
    rw [e.distances_eq] at eq
    

Proof state:
α β δ : Type
inst✝ : CanonicallyLinearOrderedAddCommMonoid δ
C : Levenshtein.Cost α β δ
xs : List α
ys : List β
e : LevenshteinEstimator' C xs ys
split : e.suff = ys
eq :
  e.bound =
    match [], split with
    | [], split => ((↑(suffixLevenshtein C xs e.suff))[0], List.length ys)
    | x, split =>
      (List.minimum_of_length_pos (_ : 0 < List.length ↑(suffixLevenshtein C xs e.suff)), List.length e.suff)
⊢ EstimatorData.bound { fn := fun x => (levenshtein C xs ys, List.length ys) } e ≤
    Thunk.get { fn := fun x => (levenshtein C xs ys, List.length ys) }

Next tactic:
simp only [List.getElem_eq_get] at eq