Download data/lean/OAI/LinearAlgebra/Moore/Concavity.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 13.6 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/Moore/Concavity.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/LinearAlgebra/Moore/Concavity.lean
-
curl -L -o Concavity.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/Moore/Concavity.lean
13.6 kB
| import OAI.LinearAlgebra.Moore.Square | |
| /-! Inverse variation and concavity of the logarithmic Moore determinant. -/ | |
| noncomputable section | |
| namespace OAI.LinearAlgebra.Moore | |
| open Matrix Filter | |
| open scoped MatrixOrder ComplexOrder Matrix.Norms.Operator Topology | |
| theorem hasDerivAt_complexMatrix_of_entries {I : Type*} [Fintype I] [DecidableEq I] | |
| (M : β β Matrix I I β) (N : Matrix I I β) (t : β) | |
| (h : β i j, HasDerivAt (fun s β¦ M s i j) (N i j) t) : HasDerivAt M N t := by | |
| have hd := HasDerivAt.fun_sum (u := Finset.univ) (fun i _ β¦ | |
| HasDerivAt.fun_sum (u := Finset.univ) (fun j _ β¦ | |
| (h i j).smul_const (Matrix.single i j (1 : β)))) | |
| convert! hd using 1 | |
| Β· funext s | |
| ext i j | |
| simp [Matrix.sum_apply, Matrix.single, ite_and] | |
| Β· ext i j | |
| simp [Matrix.sum_apply, Matrix.single, ite_and] | |
| theorem hasDerivAt_complexMatrix_inverse {I : Type*} [Fintype I] [DecidableEq I] | |
| (M : β β Matrix I I β) (N : Matrix I I β) (t : β) | |
| (hdet : (M t).det β 0) (hM : HasDerivAt M N t) : | |
| HasDerivAt (fun s β¦ (M s)β»ΒΉ) (-((M t)β»ΒΉ * N * (M t)β»ΒΉ)) t := by | |
| have hu : IsUnit (M t) := (Matrix.isUnit_iff_isUnit_det _).mpr (isUnit_iff_ne_zero.mpr hdet) | |
| obtain β¨u, huβ© := hu | |
| have hui : (β(uβ»ΒΉ) : Matrix I I β) = (M t)β»ΒΉ := by | |
| rw [Matrix.nonsing_inv_eq_ringInverse, β hu, Ring.inverse_unit] | |
| have hd := (hasFDerivAt_ringInverse (π := β) u) | |
| rw [hu] at hd | |
| have hh := hd.comp_hasDerivAt t hM | |
| change HasDerivAt (fun s β¦ Ring.inverse (M s)) | |
| (-((β(uβ»ΒΉ) : Matrix I I β) * N * (β(uβ»ΒΉ) : Matrix I I β))) t at hh | |
| rw [hui] at hh | |
| simpa only [β Matrix.nonsing_inv_eq_ringInverse] using hh | |
| def complexMatrixTraceRealLinear (I : Type*) [Fintype I] : Matrix I I β ββ[β] β where | |
| toFun A := A.trace.re | |
| map_add' A B := by simp | |
| map_smul' r A := by simp | |
| def complexMatrixTraceRealCLM (I : Type*) [Fintype I] [DecidableEq I] : | |
| Matrix I I β βL[β] β := (complexMatrixTraceRealLinear I).toContinuousLinearMap | |
| theorem hasDerivAt_complexInverseTrace {I : Type*} [Fintype I] [DecidableEq I] | |
| (M D : β β Matrix I I β) (N E : Matrix I I β) (t : β) | |
| (hdet : (M t).det β 0) (hM : HasDerivAt M N t) (hD : HasDerivAt D E t) : | |
| HasDerivAt (fun s β¦ ((M s)β»ΒΉ * D s).trace.re / 2) | |
| (((M t)β»ΒΉ * E).trace.re / 2 - | |
| ((M t)β»ΒΉ * N * (M t)β»ΒΉ * D t).trace.re / 2) t := by | |
| have hd := (hasDerivAt_complexMatrix_inverse M N t hdet hM).mul hD | |
| have ht := (complexMatrixTraceRealCLM I).hasFDerivAt.comp_hasDerivAt t hd | |
| have hh := ht.div_const 2 | |
| convert! hh using 1 | |
| change ((M t)β»ΒΉ * E).trace.re / 2 - | |
| ((M t)β»ΒΉ * N * (M t)β»ΒΉ * D t).trace.re / 2 = | |
| (-((M t)β»ΒΉ * N * (M t)β»ΒΉ) * D t + (M t)β»ΒΉ * E).trace.re / 2 | |
| simp only [Matrix.neg_mul, Matrix.trace_add, Matrix.trace_neg, Complex.add_re, Complex.neg_re] | |
| ring | |
| theorem complex_inverse_trace_square_nonneg {I : Type*} [Fintype I] [DecidableEq I] | |
| (A D : Matrix I I β) (hA : A.PosDef) (hD : D.IsHermitian) : | |
| 0 β€ (Aβ»ΒΉ * D * Aβ»ΒΉ * D).trace.re := by | |
| have hp : (D * Aβ»ΒΉ * D).PosSemidef := by | |
| have hDe : Dα΄΄ = D := hD | |
| simpa only [hDe] using hA.inv.posSemidef.mul_mul_conjTranspose_same D | |
| simpa only [Matrix.mul_assoc] using complex_trace_mul_nonneg hA.inv.posSemidef hp | |
| def quaternionMatrixEntryLinear (a b : Fin 2) : Quaternion β ββ[β] β where | |
| toFun q := quaternionMatrix q a b | |
| map_add' p q := by rw [quaternionMatrix_add]; rfl | |
| map_smul' s q := by | |
| have h := congrArg (fun M : Matrix (Fin 2) (Fin 2) β β¦ M a b) (quaternionMatrix_real_smul s q) | |
| simpa only [Matrix.smul_apply, Complex.real_smul, smul_eq_mul, RingHom.id_apply] using h | |
| def quaternionMatrixEntryCLM (a b : Fin 2) : Quaternion β βL[β] β := | |
| (quaternionMatrixEntryLinear a b).toContinuousLinearMap | |
| theorem hasDerivAt_complexify_of_entries {n : β} | |
| (A : β β Matrix (Fin n) (Fin n) (Quaternion β)) | |
| (D : Matrix (Fin n) (Fin n) (Quaternion β)) (t : β) | |
| (h : β i j, HasDerivAt (fun s β¦ A s i j) (D i j) t) : | |
| HasDerivAt (fun s β¦ complexify (A s)) (complexify D) t := by | |
| apply hasDerivAt_complexMatrix_of_entries | |
| rintro β¨i, aβ© β¨j, bβ© | |
| exact (quaternionMatrixEntryCLM a b).hasFDerivAt.comp_hasDerivAt t (h i j) | |
| theorem hasDerivAt_log_mooreDet_complexTrace {n : β} | |
| (A : β β Matrix (Fin n) (Fin n) (Quaternion β)) | |
| (D : Matrix (Fin n) (Fin n) (Quaternion β)) (t : β) | |
| (hA : (complexify (A t)).PosDef) (hD : D.IsHermitian) | |
| (h : β i j, HasDerivAt (fun s β¦ A s i j) (D i j) t) : | |
| HasDerivAt (fun s β¦ Real.log (mooreDet n (A s))) | |
| (((complexify (A t))β»ΒΉ * complexify D).trace.re / 2) t := by | |
| have hm := mooreDet_pos_of_complexify_posDef (A t) hA | |
| convert! (hasDerivAt_mooreDet_path n A D t h).log hm.ne' using 1 | |
| rw [mooreDifferential_eq_complex_inverse (A t) D hA hD] | |
| field_simp | |
| theorem hasDerivAt_mooreLogSlope {n : β} | |
| (A D : β β Matrix (Fin n) (Fin n) (Quaternion β)) | |
| (E : Matrix (Fin n) (Fin n) (Quaternion β)) (t : β) | |
| (hpos : (complexify (A t)).PosDef) | |
| (hA : β i j, HasDerivAt (fun s β¦ A s i j) (D t i j) t) | |
| (hD : β i j, HasDerivAt (fun s β¦ D s i j) (E i j) t) : | |
| HasDerivAt (fun s β¦ ((complexify (A s))β»ΒΉ * complexify (D s)).trace.re / 2) | |
| (((complexify (A t))β»ΒΉ * complexify E).trace.re / 2 - | |
| ((complexify (A t))β»ΒΉ * complexify (D t) * | |
| (complexify (A t))β»ΒΉ * complexify (D t)).trace.re / 2) t := by | |
| exact hasDerivAt_complexInverseTrace (fun s β¦ complexify (A s)) | |
| (fun s β¦ complexify (D s)) (complexify (D t)) (complexify E) t hpos.det_pos.ne' | |
| (hasDerivAt_complexify_of_entries A (D t) t hA) | |
| (hasDerivAt_complexify_of_entries D E t hD) | |
| /-- The genuine second derivative along a smooth positive Hermitian path. | |
| The last term is the nonnegative quadratic correction responsible for concavity. -/ | |
| theorem hasDerivAt_deriv_log_mooreDet_path {n : β} | |
| (A D : β β Matrix (Fin n) (Fin n) (Quaternion β)) | |
| (E : Matrix (Fin n) (Fin n) (Quaternion β)) (t : β) | |
| (hpos : (complexify (A t)).PosDef) | |
| (hA : β i j, HasDerivAt (fun s β¦ A s i j) (D t i j) t) | |
| (hD : β i j, HasDerivAt (fun s β¦ D s i j) (E i j) t) | |
| (hlocal : βαΆ s in π t, (complexify (A s)).PosDef β§ (D s).IsHermitian β§ | |
| β i j, HasDerivAt (fun u β¦ A u i j) (D s i j) s) : | |
| HasDerivAt (deriv (fun s β¦ Real.log (mooreDet n (A s)))) | |
| (((complexify (A t))β»ΒΉ * complexify E).trace.re / 2 - | |
| ((complexify (A t))β»ΒΉ * complexify (D t) * | |
| (complexify (A t))β»ΒΉ * complexify (D t)).trace.re / 2) t := by | |
| apply (hasDerivAt_mooreLogSlope A D E t hpos hA hD).congr_of_eventuallyEq | |
| filter_upwards [hlocal] with s hs | |
| exact (hasDerivAt_log_mooreDet_complexTrace A (D s) s hs.1 hs.2.1 hs.2.2).deriv | |
| theorem deriv_deriv_log_mooreDet_le {n : β} | |
| (A D : β β Matrix (Fin n) (Fin n) (Quaternion β)) | |
| (E : Matrix (Fin n) (Fin n) (Quaternion β)) (t : β) | |
| (hpos : (complexify (A t)).PosDef) (hHerm : (D t).IsHermitian) | |
| (hA : β i j, HasDerivAt (fun s β¦ A s i j) (D t i j) t) | |
| (hD : β i j, HasDerivAt (fun s β¦ D s i j) (E i j) t) | |
| (hlocal : βαΆ s in π t, (complexify (A s)).PosDef β§ (D s).IsHermitian β§ | |
| β i j, HasDerivAt (fun u β¦ A u i j) (D s i j) s) : | |
| deriv (deriv (fun s β¦ Real.log (mooreDet n (A s)))) t β€ | |
| ((complexify (A t))β»ΒΉ * complexify E).trace.re / 2 := by | |
| rw [(hasDerivAt_deriv_log_mooreDet_path A D E t hpos hA hD hlocal).deriv] | |
| exact sub_le_self _ (div_nonneg | |
| (complex_inverse_trace_square_nonneg _ _ hpos (complexify_isHermitian hHerm)) | |
| (by norm_num)) | |
| /-- The unnormalized form used when differentiating the nonlinear equation. -/ | |
| theorem mooreDifferential_second_derivative_bound {n : β} | |
| (A D : β β Matrix (Fin n) (Fin n) (Quaternion β)) | |
| (E : Matrix (Fin n) (Fin n) (Quaternion β)) (t : β) | |
| (hpos : (complexify (A t)).PosDef) (hHerm : (D t).IsHermitian) (hE : E.IsHermitian) | |
| (hA : β i j, HasDerivAt (fun s β¦ A s i j) (D t i j) t) | |
| (hD : β i j, HasDerivAt (fun s β¦ D s i j) (E i j) t) | |
| (hlocal : βαΆ s in π t, (complexify (A s)).PosDef β§ (D s).IsHermitian β§ | |
| β i j, HasDerivAt (fun u β¦ A u i j) (D s i j) s) : | |
| mooreDet n (A t) * deriv (deriv (fun s β¦ Real.log (mooreDet n (A s)))) t β€ | |
| mooreDifferential n (A t) E := by | |
| rw [mooreDifferential_eq_complex_inverse (A t) E hpos hE] | |
| exact mul_le_mul_of_nonneg_left | |
| (deriv_deriv_log_mooreDet_le A D E t hpos hHerm hA hD hlocal) | |
| (mooreDet_pos_of_complexify_posDef (A t) hpos).le | |
| theorem hasDerivAt_deriv_log_mooreDet_affine {n : β} | |
| (A D : Matrix (Fin n) (Fin n) (Quaternion β)) (t : β) (hD : D.IsHermitian) | |
| (hpos : (complexify (A + t β’ D)).PosDef) | |
| (hlocal : βαΆ s in π t, (complexify (A + s β’ D)).PosDef) : | |
| HasDerivAt (deriv (fun s β¦ Real.log (mooreDet n (A + s β’ D)))) | |
| (-((complexify (A + t β’ D))β»ΒΉ * complexify D * | |
| (complexify (A + t β’ D))β»ΒΉ * complexify D).trace.re / 2) t := by | |
| have hentry (s : β) (i j : Fin n) : | |
| HasDerivAt (fun u β¦ (A + u β’ D) i j) (D i j) s := by | |
| convert! (hasDerivAt_const s (A i j)).add ((hasDerivAt_id s).smul_const (D i j)) using 1 | |
| simp | |
| have hevent : βαΆ s in π t, (complexify (A + s β’ D)).PosDef β§ D.IsHermitian β§ | |
| β i j, HasDerivAt (fun u β¦ (A + u β’ D) i j) (D i j) s := by | |
| filter_upwards [hlocal] with s hs | |
| exact β¨hs, hD, hentry sβ© | |
| simpa only [complexify_zero, Matrix.mul_zero, Matrix.trace_zero, Complex.zero_re, | |
| zero_div, zero_sub, neg_div] using | |
| hasDerivAt_deriv_log_mooreDet_path (fun s β¦ A + s β’ D) (fun _ β¦ D) 0 t | |
| hpos (hentry t) (fun i j β¦ hasDerivAt_const t (D i j)) hevent | |
| /-- Concavity on every scalar interval contained in the positive cone. -/ | |
| theorem concaveOn_log_mooreDet_affine {n : β} | |
| (A D : Matrix (Fin n) (Fin n) (Quaternion β)) (a b : β) | |
| (hD : D.IsHermitian) | |
| (hpos : β t β Set.Icc a b, (complexify (A + t β’ D)).PosDef) : | |
| ConcaveOn β (Set.Icc a b) (fun t β¦ Real.log (mooreDet n (A + t β’ D))) := by | |
| have hfirst (t : β) (ht : t β Set.Icc a b) : | |
| HasDerivAt (fun s β¦ Real.log (mooreDet n (A + s β’ D))) | |
| (((complexify (A + t β’ D))β»ΒΉ * complexify D).trace.re / 2) t := by | |
| apply hasDerivAt_log_mooreDet_complexTrace (fun s β¦ A + s β’ D) D t (hpos t ht) hD | |
| intro i j | |
| convert! (hasDerivAt_const t (A i j)).add ((hasDerivAt_id t).smul_const (D i j)) using 1 | |
| simp | |
| have hsecond (t : β) (ht : t β interior (Set.Icc a b)) : | |
| HasDerivAt (deriv (fun s β¦ Real.log (mooreDet n (A + s β’ D)))) | |
| (-((complexify (A + t β’ D))β»ΒΉ * complexify D * | |
| (complexify (A + t β’ D))β»ΒΉ * complexify D).trace.re / 2) t := by | |
| apply hasDerivAt_deriv_log_mooreDet_affine A D t hD (hpos t (interior_subset ht)) | |
| filter_upwards [isOpen_interior.mem_nhds ht] with s hs | |
| exact hpos s (interior_subset hs) | |
| apply concaveOn_of_deriv2_nonpos (convex_Icc a b) | |
| (fun t ht β¦ (hfirst t ht).continuousAt.continuousWithinAt) | |
| (fun t ht β¦ (hfirst t (interior_subset ht)).differentiableAt.differentiableWithinAt) | |
| (fun t ht β¦ (hsecond t ht).differentiableAt.differentiableWithinAt) | |
| intro t ht | |
| change deriv (deriv (fun s β¦ Real.log (mooreDet n (A + s β’ D)))) t β€ 0 | |
| rw [(hsecond t ht).deriv] | |
| exact div_nonpos_of_nonpos_of_nonneg | |
| (neg_nonpos.mpr (complex_inverse_trace_square_nonneg _ _ | |
| (hpos t (interior_subset ht)) (complexify_isHermitian hD))) (by norm_num) | |
| theorem convex_complexify_posDef (n : β) : | |
| Convex β {A : Matrix (Fin n) (Fin n) (Quaternion β) | (complexify A).PosDef} := by | |
| intro A hA B hB a b ha hb hab | |
| change (complexify A).PosDef at hA | |
| change (complexify B).PosDef at hB | |
| change (complexify (a β’ A + b β’ B)).PosDef | |
| rw [complexify_add, complexify_real_smul, complexify_real_smul] | |
| by_cases ha0 : a = 0 | |
| Β· have hb1 : b = 1 := by linarith | |
| simpa only [ha0, hb1, zero_smul, one_smul, zero_add] using hB | |
| Β· exact (hA.smul (lt_of_le_of_ne ha (Ne.symm ha0))).add_posSemidef (hB.posSemidef.smul hb) | |
| /-- The logarithm of the signed Pfaffian-defined Moore determinant is concave | |
| on the entire positive quaternionic Hermitian cone. -/ | |
| theorem concaveOn_log_mooreDet (n : β) : | |
| ConcaveOn β {A : Matrix (Fin n) (Fin n) (Quaternion β) | (complexify A).PosDef} | |
| (fun A β¦ Real.log (mooreDet n A)) := by | |
| refine β¨convex_complexify_posDef n, ?_β© | |
| intro A hA B hB a b ha hb hab | |
| have hD : (B - A).IsHermitian := | |
| (isHermitian_of_complexify hB.isHermitian).sub (isHermitian_of_complexify hA.isHermitian) | |
| have hpos (t : β) (ht : t β Set.Icc (0 : β) 1) : | |
| (complexify (A + t β’ (B - A))).PosDef := by | |
| have hh := convex_complexify_posDef n hA hB (sub_nonneg.mpr ht.2) ht.1 | |
| (show (1 - t) + t = 1 by ring) | |
| have he : (1 - t) β’ A + t β’ B = A + t β’ (B - A) := by | |
| rw [sub_smul, one_smul, smul_sub] | |
| abel | |
| rwa [he] at hh | |
| have hc := concaveOn_log_mooreDet_affine A (B - A) 0 1 hD hpos | |
| have hh := hc.2 (show (0 : β) β Set.Icc 0 1 by simp) | |
| (show (1 : β) β Set.Icc 0 1 by simp) ha hb hab | |
| have he : A + b β’ (B - A) = a β’ A + b β’ B := by | |
| have ha' : a = 1 - b := by linarith | |
| rw [ha', sub_smul, one_smul, smul_sub] | |
| abel | |
| have hAB : A + (B - A) = B := by abel | |
| simpa only [zero_smul, add_zero, one_smul, hAB, | |
| smul_eq_mul, mul_zero, mul_one, zero_add, he] using hh | |
| end OAI.LinearAlgebra.Moore | |