Skip to content

Commit c62c2f2

Browse files
authored
chore: bump to v4.8.0-rc1 and fix proofs (#33)
* chore: bump to v4.8.0-rc1 * chore: update lake manifest * fix: `OfScientific` instances * wip: fixing `Lib` errors due to new `mathlib` * fix: deprecated `SchedulerM` * wip: fixing more errors in proofs * fix: all update-related errors fixed, mainly atoms * fix: syntax issues because of domain binding * fix: instance name was making `pre_dcp` fail! * test: fix expected output * fix: `Solution` is a type * fix: all case studies * fix: proofs in truss design * style: make style chack pass
1 parent 25b66f2 commit c62c2f2

36 files changed

+143
-148
lines changed

CvxLean/Command/Solve/Conic.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ unsafe def solutionDataFromProblemData (minExpr : MinimizationExpr) (data : Prob
7979

8080
match Sol.Parser.parse output with
8181
| Except.ok res =>
82-
return Except.ok <| Sol.Result.toSolutionData res
82+
return Except.ok <| Sol.Result.toSolutionData res
8383
| Except.error err =>
84-
return Except.error ("MOSEK output parsing failed. " ++ err)
84+
return Except.error ("MOSEK output parsing failed. " ++ err)
8585

86-
match res with
87-
| Except.ok res => return res
88-
| Except.error err => throwSolveError err
86+
match res with
87+
| Except.ok res => return res
88+
| Except.error err => throwSolveError err
8989

9090
/-- -/
9191
unsafe def exprFromSolutionData (minExpr : MinimizationExpr) (solData : SolutionData) :

CvxLean/Command/Solve/Float/FloatToReal.lean

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,23 @@ open Lean
1212

1313
/-- Convert a `Float` to an `Expr` of type `Real`. -/
1414
def floatToReal (f : Float) : Expr :=
15-
let divisionRingToOfScientific :=
16-
mkApp2 (mkConst ``DivisionRing.toOfScientific ([levelZero] : List Level))
17-
(mkConst ``Real)
18-
(mkConst ``Real.instDivisionRingReal)
15+
let nnRatCastToOfScientific :=
16+
mkApp2 (mkConst ``NNRatCast.toOfScientific ([levelZero] : List Level))
17+
(mkConst ``Real) (mkConst ``Real.instNNRatCast)
1918
let realOfScientific :=
2019
mkApp2 (mkConst ``OfScientific.ofScientific ([levelZero] : List Level))
21-
(mkConst ``Real)
22-
divisionRingToOfScientific
20+
(mkConst ``Real) nnRatCastToOfScientific
2321
match Json.Parser.num f.toString.mkIterator with
2422
| Parsec.ParseResult.success _ res =>
2523
let num := mkApp3 realOfScientific
2624
(mkNatLit res.mantissa.natAbs) (toExpr true) (mkNatLit res.exponent)
2725
if res.mantissa < 0 then
2826
mkApp3 (mkConst ``Neg.neg ([levelZero] : List Level))
29-
(mkConst ``Real) (mkConst ``Real.instNegReal) num
27+
(mkConst ``Real) (mkConst ``Real.instNeg) num
3028
else num
3129
-- On parser error return zero.
3230
| Parsec.ParseResult.error _ _ =>
3331
mkApp3 realOfScientific
34-
(mkConst ``Int.zero) (toExpr true) (mkNatLit 1)
32+
(mkNatLit 0) (toExpr true) (mkNatLit 1)
3533

3634
end CvxLean

CvxLean/Command/Solve/Float/RealToFloatLibrary.lean

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,25 @@ section Basic
1717
add_real_to_float : Real :=
1818
Float
1919

20-
add_real_to_float : Real.instInhabitedReal :=
20+
add_real_to_float : Real.instInhabited :=
2121
instInhabitedFloat
2222

23-
add_real_to_float : Real.instZeroReal :=
23+
add_real_to_float : Real.instZero :=
2424
Zero.mk (0 : Float)
2525

26-
add_real_to_float : Real.instOneReal :=
26+
add_real_to_float : Real.instOne :=
2727
One.mk (1 : Float)
2828

29-
add_real_to_float : Real.instLEReal :=
29+
add_real_to_float : Real.instLE :=
3030
instLEFloat
3131

32-
add_real_to_float : Real.instLTReal :=
32+
add_real_to_float : Real.instLT :=
3333
instLTFloat
3434

3535
add_real_to_float : Real.instDivReal :=
3636
instDivFloat
3737

38-
add_real_to_float : Real.instPowReal :=
38+
add_real_to_float : Real.instPow :=
3939
Pow.mk Float.pow
4040

4141
add_real_to_float (n : Nat) (i) : @OfNat.ofNat Real n i :=
@@ -54,25 +54,25 @@ add_real_to_float (k : Nat) :
5454
add_real_to_float (i) : @Ring.toNeg Real i :=
5555
Neg.mk Float.neg
5656

57-
add_real_to_float : Real.instNegReal := instNegFloat
57+
add_real_to_float : Real.instNeg := instNegFloat
5858

59-
add_real_to_float : Real.instAddReal := instAddFloat
59+
add_real_to_float : Real.instAdd := instAddFloat
6060

6161
add_real_to_float (i) : @HAdd.hAdd Real Real Real i :=
6262
Float.add
6363

6464
add_real_to_float (i) : @instHAdd Real i :=
6565
@HAdd.mk Float Float Float Float.add
6666

67-
add_real_to_float : Real.instSubReal := instSubFloat
67+
add_real_to_float : Real.instSub := instSubFloat
6868

6969
add_real_to_float (i) : @HSub.hSub Real Real Real i :=
7070
Float.sub
7171

7272
add_real_to_float (i) : @instHSub Real i :=
7373
@HSub.mk Float Float Float Float.sub
7474

75-
add_real_to_float : Real.instMulReal := instMulFloat
75+
add_real_to_float : Real.instMul := instMulFloat
7676

7777
add_real_to_float (i) : @HMul.hMul Real Real Real i :=
7878
Float.mul
@@ -128,7 +128,7 @@ add_real_to_float (n) (i) : @Norm.norm.{0} (Fin n → ℝ) i :=
128128
add_real_to_float (i) : @OfScientific.ofScientific Real i :=
129129
Float.ofScientific
130130

131-
add_real_to_float : Real.natCast :=
131+
add_real_to_float : Real.instNatCast :=
132132
NatCast.mk Float.ofNat
133133

134134
end Basic

CvxLean/Examples/FittingSphere.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ equivalence* eqv/fittingSphereT (n m : ℕ) (x : Fin m → Fin n → ℝ) : fitt
127127
apply ChangeOfVariablesBij.toEquivalence
128128
(fun (ct : (Fin n → ℝ) × ℝ) => (ct.1, sqrt (ct.2 + ‖ct.1‖ ^ 2))) covBij
129129
· rintro cr h; exact h
130-
. rintro ct _; simp [covBij, sq_nonneg]
130+
· rintro ct _; simp [covBij, sq_nonneg]
131131
rename_vars [c, t]
132132
rename_constrs [h₁, h₂]
133133
conv_constr h₁ => dsimp
@@ -171,14 +171,14 @@ lemma optimal_convex_implies_optimal_t (hm : 0 < m) (c : Fin n → ℝ) (t : ℝ
171171
have h_t_eq := leastSquaresVec_optimal_eq_mean hm a t h_ls
172172
have h_c2_eq : ‖c‖ ^ 2 = (1 / m) * ∑ i : Fin m, ‖c‖ ^ 2 := by
173173
simp [sum_const]
174-
field_simp; ring
174+
field_simp
175175
have h_t_add_c2_eq : t + ‖c‖ ^ 2 = (1 / m) * ∑ i, ‖(x i) - c‖ ^ 2 := by
176176
rw [h_t_eq]; dsimp [mean]
177177
rw [h_c2_eq, mul_sum, mul_sum, mul_sum, ← sum_add_distrib]
178178
congr; funext i; rw [← mul_add]
179179
congr; simp [Vec.norm]
180180
rw [norm_sub_sq (𝕜 := ℝ) (E := Fin n → ℝ)]
181-
congr
181+
simp [a]; congr
182182
-- We use the result to establish that `t + ‖c‖ ^ 2` is non-negative.
183183
rw [← rpow_two, h_t_add_c2_eq]
184184
apply mul_nonneg (by norm_num)

CvxLean/Examples/TrussDesign.lean

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@ equivalence* eqv₁/trussDesignGP (hmin hmax wmin wmax Rmax σ F₁ F₂ : ℝ)
8484
-- Simplify objective function.
8585
rw_obj into (2 * A * sqrt (w ^ 2 + h ^ 2)) =>
8686
rw [rpow_two, sq_sqrt (h_A_div_2π_add_r2_nonneg r A c_r c_R_lb)]
87-
ring_nf; field_simp; ring
87+
ring_nf; field_simp
8888
-- Simplify constraint `c_F₁`.
8989
rw_constr c_F₁ into (F₁ * sqrt (w ^ 2 + h ^ 2) / (2 * h) ≤ σ * A) =>
9090
rw [rpow_two (sqrt (_ + r ^ 2)), sq_sqrt (h_A_div_2π_add_r2_nonneg r A c_r c_R_lb)]
91-
rw [iff_eq_eq]; congr; ring_nf; field_simp; ring
91+
rw [iff_eq_eq]; congr; ring_nf; field_simp
9292
-- Simplify constraint `c_F₂`.
9393
rw_constr c_F₂ into (F₂ * sqrt (w ^ 2 + h ^ 2) / (2 * w) ≤ σ * A) =>
9494
rw [rpow_two (sqrt (_ + r ^ 2)), sq_sqrt (h_A_div_2π_add_r2_nonneg r A c_r c_R_lb)]
95-
rw [iff_eq_eq]; congr; ring_nf; field_simp; ring
95+
rw [iff_eq_eq]; congr; ring_nf; field_simp
9696

9797
#print trussDesignGP
9898
-- minimize 2 * A * sqrt (w ^ 2 + h ^ 2)
@@ -246,6 +246,7 @@ def wₚ_opt := sol.2.1
246246
def rₚ_opt := sol.2.2.1
247247
def Rₚ_opt := sol.2.2.2
248248

249+
-- NOTE: These numbers may differ slighlty depending on the rewrites found by `pre_dcp`.
249250
#eval hₚ_opt -- 1.000000
250251
#eval wₚ_opt -- 1.000517
251252
#eval rₚ_opt -- 0.010162

CvxLean/Examples/VehicleSpeedScheduling.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def dₚ : Fin nₚ → ℝ :=
152152
![1.9501, 1.2311, 1.6068, 1.4860, 1.8913, 1.7621, 1.4565, 1.0185, 1.8214, 1.4447]
153153

154154
lemma dₚ_pos : StrongLT 0 dₚ := by
155-
intro i; fin_cases i <;> (simp [dₚ]; norm_num)
155+
intro i; fin_cases i <;> (dsimp [dₚ]; norm_num)
156156

157157
@[optimization_param, reducible]
158158
def τminₚ : Fin nₚ → ℝ :=
@@ -177,7 +177,7 @@ lemma sminₚ_pos : StrongLT 0 sminₚ := by
177177
lemma sminₚ_nonneg : 0 ≤ sminₚ := le_of_strongLT sminₚ_pos
178178

179179
lemma sminₚ_le_smaxₚ : sminₚ ≤ smaxₚ := by
180-
intro i; fin_cases i <;> (simp [sminₚ, smaxₚ]; norm_num)
180+
intro i; fin_cases i <;> (dsimp [sminₚ, smaxₚ]; norm_num)
181181

182182
@[simp]
183183
lemma smaxₚ_nonneg : 0 ≤ smaxₚ := le_trans sminₚ_nonneg sminₚ_le_smaxₚ
@@ -190,7 +190,7 @@ lemma aₚ_nonneg : 0 ≤ aₚ := by unfold aₚ; norm_num
190190

191191
@[simp]
192192
lemma aₚdₚ2_nonneg : 0 ≤ aₚ • (dₚ ^ (2 : ℝ)) := by
193-
intros i; fin_cases i <;> (simp [aₚ, dₚ]; norm_num)
193+
intros i; fin_cases i <;> (dsimp [aₚ, dₚ]; norm_num)
194194

195195
@[optimization_param]
196196
def bₚ : ℝ := 6

CvxLean/Lib/Math/Analysis/InnerProductSpace/GramSchmidtOrtho.lean

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The Gram-Schmidt algorithm respects basis vectors.
66

77
section GramSchmidt
88

9-
variable (𝕜 : Type _) {E : Type _} [IsROrC 𝕜]
9+
variable (𝕜 : Type _) {E : Type _} [RCLike 𝕜]
1010
variable [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
1111
variable {ι : Type _} [LinearOrder ι] [LocallyFiniteOrderBot ι]
1212
variable [IsWellOrder ι (· < · : ι → ι → Prop)]
@@ -17,9 +17,8 @@ local notation "⟪" x "," y "⟫" => @inner 𝕜 _ _ x y
1717

1818
lemma repr_gramSchmidt_diagonal {i : ι} (b : Basis ι 𝕜 E) :
1919
b.repr (gramSchmidt 𝕜 b i) i = 1 := by
20-
rw [gramSchmidt_def, LinearEquiv.map_sub, Finsupp.sub_apply, Basis.repr_self,
21-
Finsupp.single_eq_same, sub_eq_self, map_sum, Finsupp.coe_finset_sum,
22-
Finset.sum_apply, Finset.sum_eq_zero]
20+
rw [gramSchmidt_def, map_sub, Finsupp.sub_apply, Basis.repr_self, Finsupp.single_eq_same,
21+
sub_eq_self, map_sum, Finsupp.coe_finset_sum, Finset.sum_apply, Finset.sum_eq_zero]
2322
intros j hj
2423
rw [Finset.mem_Iio] at hj
2524
simp [orthogonalProjection_singleton, gramSchmidt_triangular hj]

CvxLean/Lib/Math/Analysis/InnerProductSpace/Spectrum.lean

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Version of the spectral theorem.
66

77
namespace LinearMap
88

9-
variable {𝕜 : Type _} [IsROrC 𝕜] [DecidableEq 𝕜]
9+
variable {𝕜 : Type _} [RCLike 𝕜] [DecidableEq 𝕜]
1010
variable {E : Type _} [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
1111
variable [FiniteDimensional 𝕜 E]
1212
variable {n : ℕ} (hn : FiniteDimensional.finrank 𝕜 E = n)
@@ -19,14 +19,13 @@ lemma spectral_theorem' (v : E) (i : Fin n)
1919
(xs : OrthonormalBasis (Fin n) 𝕜 E) (as : Fin n → ℝ)
2020
(hxs : ∀ j, Module.End.HasEigenvector T (as j) (xs j)) :
2121
xs.repr (T v) i = as i * xs.repr v i := by
22-
suffices : ∀ w : EuclideanSpace 𝕜 (Fin n),
23-
T (xs.repr.symm w) = xs.repr.symm (fun i => as i * w i)
24-
{ simpa only [LinearIsometryEquiv.symm_apply_apply,
25-
LinearIsometryEquiv.apply_symm_apply]
26-
using congr_arg (fun (v : E) => (xs.repr) v i) (this ((xs.repr) v)) }
22+
suffices hsuff : ∀ (w : EuclideanSpace 𝕜 (Fin n)),
23+
T (xs.repr.symm w) = xs.repr.symm (fun i => as i * w i) by
24+
simpa only [LinearIsometryEquiv.symm_apply_apply,
25+
LinearIsometryEquiv.apply_symm_apply]
26+
using congr_arg (fun (v : E) => (xs.repr) v i) (hsuff ((xs.repr) v))
2727
intros w
28-
simp_rw [← OrthonormalBasis.sum_repr_symm, map_sum,
29-
LinearMap.map_smul, fun j => Module.End.mem_eigenspace_iff.mp (hxs j).1,
30-
smul_smul, mul_comm]
28+
simp_rw [← OrthonormalBasis.sum_repr_symm, map_sum, LinearMap.map_smul,
29+
fun j => Module.End.mem_eigenspace_iff.mp (hxs j).1, smul_smul, mul_comm]
3130

3231
end LinearMap

CvxLean/Lib/Math/CovarianceEstimation.lean

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,13 @@ lemma sum_quadForm {n : ℕ} (R : Matrix (Fin n) (Fin n) ℝ) {m : ℕ} (y : Fin
5858
{ subst h; simp }
5959
simp only [Matrix.quadForm, Matrix.trace, covarianceMatrix, diag, mul_apply, Finset.sum_mul,
6060
Finset.sum_div]
61-
simp_rw [@Finset.sum_comm _ (Fin m), Finset.mul_sum]
62-
apply congr_arg
63-
ext i
64-
unfold dotProduct
65-
have : (m : ℝ) ≠ 0 := by simp [h]
66-
simp_rw [← mul_assoc, mul_div_cancel' _ this]
67-
apply congr_arg
68-
ext j
61+
erw [Finset.sum_comm (γ := Fin m)]
62+
simp_rw [Finset.mul_sum]
63+
congr; ext i
64+
have hmnz : (m : ℝ) ≠ 0 := by simp [h]
65+
simp_rw [← mul_assoc, mul_div_cancel₀ _ hmnz]
66+
erw [Finset.sum_comm (α := Fin m)]
67+
congr; ext j
6968
simp_rw [mul_assoc, ← Finset.mul_sum]
7069
apply congr_arg
7170
unfold Matrix.mulVec

CvxLean/Lib/Math/LinearAlgebra/Matrix/Block.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ lemma toBlock_inverse_mul_toBlock_eq_one_of_BlockTriangular [LinearOrder α]
5757
have h_sum : M⁻¹.toBlock p p * M.toBlock p p +
5858
M⁻¹.toBlock p (fun i => ¬ p i) * M.toBlock (fun i => ¬ p i) p = 1 := by
5959
rw [← toBlock_mul_eq_add, inv_mul_of_invertible M, toBlock_one_self]
60-
have h_zero : M.toBlock (fun i => ¬ p i) p = 0
60+
have h_zero : M.toBlock (fun i => ¬ p i) p = 0 := by
6161
{ ext i j
6262
simpa using hM (lt_of_lt_of_le j.2 (le_of_not_lt i.2)) }
6363
simpa [h_zero] using h_sum
@@ -87,7 +87,7 @@ lemma toSquareBlock_inv_mul_toSquareBlock_eq_one [LinearOrder α]
8787
M⁻¹.toBlock p (λ i => ¬ p i) * M.toBlock (λ i => ¬ p i) p = 1 := by
8888
rw [← toBlock_mul_eq_add, inv_mul_of_invertible M, toBlock_one_self]
8989
have h_zero : ∀ i j l,
90-
M⁻¹.toBlock p (fun i => ¬p i) i j * M.toBlock (fun i => ¬p i) p j l = 0
90+
M⁻¹.toBlock p (fun i => ¬p i) i j * M.toBlock (fun i => ¬p i) p j l = 0 := by
9191
{ intro i j l
9292
by_cases hj : b j.1 ≤ k
9393
{ have hj := lt_of_le_of_ne hj j.2
@@ -98,7 +98,7 @@ lemma toSquareBlock_inv_mul_toSquareBlock_eq_one [LinearOrder α]
9898
apply mul_eq_zero_of_right
9999
simpa using hM (lt_of_eq_of_lt l.2 hj) }}
100100
have h_zero' :
101-
M⁻¹.toBlock p (λ (i : m) => ¬p i) * M.toBlock (λ (i : m) => ¬p i) p = 0
101+
M⁻¹.toBlock p (λ (i : m) => ¬p i) * M.toBlock (λ (i : m) => ¬p i) p = 0 := by
102102
{ ext i l
103103
apply sum_eq_zero (λ j _ => h_zero i j l) }
104104
simpa [h_zero'] using h_sum

CvxLean/Lib/Math/LinearAlgebra/Matrix/LDL.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import CvxLean.Lib.Math.LinearAlgebra.Matrix.Triangular
88
More results about LDL factorization (see `Mathlib.LinearAlgebra.Matrix.LDL`).
99
-/
1010

11-
variable {𝕜 : Type _} [IsROrC 𝕜]
11+
variable {𝕜 : Type _} [RCLike 𝕜]
1212
variable {n : Type _} [LinearOrder n] [IsWellOrder n (· < · : n → n → Prop)]
1313
variable [LocallyFiniteOrderBot n]
1414

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ namespace Matrix
1010

1111
variable {m n : Type _} [Fintype m] [Fintype n]
1212
variable {𝕜 : Type _}
13-
variable [NormedField 𝕜] [PartialOrder 𝕜] [StarOrderedRing 𝕜]
14-
variable [IsROrC 𝕜]
13+
variable [NormedField 𝕜] [PartialOrder 𝕜] [StarRing 𝕜] [StarOrderedRing 𝕜]
14+
variable [RCLike 𝕜]
1515

1616
lemma PosSemidef.det_nonneg {M : Matrix n n ℝ} (hM : M.PosSemidef) [DecidableEq n] : 0 ≤ det M := by
1717
rw [hM.1.det_eq_prod_eigenvalues]
@@ -39,7 +39,7 @@ lemma PosSemidef_diagonal [DecidableEq n] {f : n → ℝ} (hf : ∀ i, 0 ≤ f i
3939
(diagonal f).PosSemidef := by
4040
refine' ⟨isHermitian_diagonal _, _⟩
4141
intro x
42-
simp only [star, id.def, IsROrC.re_to_real]
42+
simp only [star, id_def, RCLike.re_to_real]
4343
apply Finset.sum_nonneg'
4444
intro i
4545
rw [mulVec_diagonal f x i, mul_comm, mul_assoc]
@@ -48,7 +48,7 @@ lemma PosSemidef_diagonal [DecidableEq n] {f : n → ℝ} (hf : ∀ i, 0 ≤ f i
4848
lemma PosDef_diagonal [DecidableEq n] {f : n → ℝ} (hf : ∀ i, 0 < f i) : (diagonal f).PosDef := by
4949
refine' ⟨isHermitian_diagonal _, _⟩
5050
intros x hx
51-
simp only [star, id.def, IsROrC.re_to_real]
51+
simp only [star, id_def, RCLike.re_to_real]
5252
apply Finset.sum_pos'
5353
{ intros i _
5454
rw [mulVec_diagonal f x i, mul_comm, mul_assoc]

CvxLean/Lib/Math/LinearAlgebra/Matrix/Spectrum.lean

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Version of the spectral theorem for matrices.
77

88
namespace Matrix
99

10-
variable {𝕜 : Type _} [IsROrC 𝕜] [DecidableEq 𝕜]
10+
variable {𝕜 : Type _} [RCLike 𝕜] [DecidableEq 𝕜]
1111
variable {n : Type _} [Fintype n] [DecidableEq n]
1212
variable {A : Matrix n n 𝕜}
1313

@@ -25,7 +25,7 @@ noncomputable def frobeniusNormedAddCommGroup' [NormedAddCommGroup 𝕜] :
2525
attribute [-instance] Pi.normedAddCommGroup
2626

2727
noncomputable instance : InnerProductSpace 𝕜 (n → 𝕜) :=
28-
EuclideanSpace.instInnerProductSpace
28+
PiLp.innerProductSpace (fun _ : n => 𝕜)
2929

3030
lemma IsHermitian.hasEigenvector_eigenvectorBasis (hA : A.IsHermitian) (i : n) :
3131
Module.End.HasEigenvector (Matrix.toLin' A) (hA.eigenvalues i) (hA.eigenvectorBasis i) := by
@@ -37,15 +37,14 @@ diagonalized by a change of basis using a matrix consisting of eigenvectors. -/
3737
theorem spectral_theorem (xs : OrthonormalBasis n 𝕜 (EuclideanSpace 𝕜 n)) (as : n → ℝ)
3838
(hxs : ∀ j, Module.End.HasEigenvector (Matrix.toLin' A) (as j) (xs j)) :
3939
xs.toBasis.toMatrix (Pi.basisFun 𝕜 n) * A =
40-
diagonal (IsROrC.ofReal ∘ as) * xs.toBasis.toMatrix (Pi.basisFun 𝕜 n) := by
40+
diagonal (RCLike.ofReal ∘ as) * xs.toBasis.toMatrix (Pi.basisFun 𝕜 n) := by
4141
rw [basis_toMatrix_basisFun_mul]
4242
ext i j
4343
let xs' := xs.reindex (Fintype.equivOfCardEq (Fintype.card_fin _)).symm
4444
let as' : Fin (Fintype.card n) → ℝ :=
4545
fun i => as <| (Fintype.equivOfCardEq (Fintype.card_fin _)) i
46-
have hxs' :
47-
∀ j, Module.End.HasEigenvector (Matrix.toLin' A) (as' j) (xs' j) := by
48-
simp only [OrthonormalBasis.coe_reindex, Equiv.symm_symm]
46+
have hxs' : ∀ j, Module.End.HasEigenvector (Matrix.toLin' A) (as' j) (xs' j) := by
47+
simp only [xs', OrthonormalBasis.coe_reindex, Equiv.symm_symm]
4948
intros j
5049
exact (hxs ((Fintype.equivOfCardEq (Fintype.card_fin _)) j))
5150
convert @LinearMap.spectral_theorem' 𝕜 _
@@ -54,18 +53,17 @@ theorem spectral_theorem (xs : OrthonormalBasis n 𝕜 (EuclideanSpace 𝕜 n))
5453
((Fintype.equivOfCardEq (Fintype.card_fin _)).symm i)
5554
xs' as' hxs'
5655
{ erw [toLin'_apply]
57-
simp only [OrthonormalBasis.coe_toBasis_repr_apply, of_apply,
56+
simp only [xs', OrthonormalBasis.coe_toBasis_repr_apply, of_apply,
5857
OrthonormalBasis.repr_reindex]
59-
erw [Equiv.symm_apply_apply, EuclideanSpace.single,
60-
WithLp.equiv_symm_pi_apply 2, mulVec_single]
58+
erw [Equiv.symm_apply_apply, EuclideanSpace.single, WithLp.equiv_symm_pi_apply 2, mulVec_single]
6159
simp_rw [mul_one]
6260
rfl }
6361
{ simp only [diagonal_mul, Function.comp]
6462
erw [Basis.toMatrix_apply, OrthonormalBasis.coe_toBasis_repr_apply,
6563
OrthonormalBasis.repr_reindex, Pi.basisFun_apply, LinearMap.coe_stdBasis,
6664
EuclideanSpace.single, WithLp.equiv_symm_pi_apply 2,
6765
Equiv.symm_apply_apply, Equiv.apply_symm_apply]
68-
rfl }
66+
congr; simp }
6967

7068
lemma det_eq_prod_eigenvalues (xs : OrthonormalBasis n 𝕜 (EuclideanSpace 𝕜 n)) (as : n → ℝ)
7169
(hxs : ∀ j, Module.End.HasEigenvector (Matrix.toLin' A) (as j) (xs j)) : det A = ∏ i, as i := by

0 commit comments

Comments
 (0)