Download data/lean/OAI/LinearAlgebra/Moore/Cofactor.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 6.56 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/Moore/Cofactor.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/LinearAlgebra/Moore/Cofactor.lean
-
curl -L -o Cofactor.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/Moore/Cofactor.lean
6.56 kB
| import OAI.LinearAlgebra.Moore.Boundary | |
| /-! A genuine quaternionic Hermitian cofactor matrix representing the first | |
| variation, and its positivity on the closed positive cone. -/ | |
| noncomputable section | |
| namespace OAI.LinearAlgebra.Moore | |
| open Matrix OAI.Analysis.PDE.Dirichlet OAI.Analysis.Calculus.Quaternion | |
| open scoped MatrixOrder ComplexOrder | |
| def quaternionDualVector (L : Quaternion β ββ[β] β) : Quaternion β := | |
| β¨L 1, L β¨0, 1, 0, 0β©, L β¨0, 0, 1, 0β©, L β¨0, 0, 0, 1β©β© | |
| theorem quaternionDualVector_apply (L : Quaternion β ββ[β] β) (q : Quaternion β) : | |
| (star (quaternionDualVector L) * q).re = L q := by | |
| have hq : q = q.re β’ (1 : Quaternion β) + q.imI β’ β¨0, 1, 0, 0β© + | |
| q.imJ β’ β¨0, 0, 1, 0β© + q.imK β’ β¨0, 0, 0, 1β© := by | |
| ext <;> simp | |
| have hL : L q = q.re * L 1 + q.imI * L β¨0, 1, 0, 0β© + | |
| q.imJ * L β¨0, 0, 1, 0β© + q.imK * L β¨0, 0, 0, 1β© := by | |
| conv_lhs => rw [hq] | |
| simp only [map_add, map_smul, smul_eq_mul] | |
| rw [hL] | |
| simp [quaternionDualVector] | |
| ring | |
| def quaternionEntryLinear {n : β} (i j : Fin n) : | |
| Quaternion β ββ[β] Matrix (Fin n) (Fin n) (Quaternion β) where | |
| toFun := Matrix.single i j | |
| map_add' := Matrix.single_add i j | |
| map_smul' := fun c q β¦ (Matrix.smul_single c i j q).symm | |
| def mooreDifferentialLinear (n : β) (A : Matrix (Fin n) (Fin n) (Quaternion β)) : | |
| Matrix (Fin n) (Fin n) (Quaternion β) ββ[β] β where | |
| toFun := mooreDifferential n A | |
| map_add' := mooreDifferential_add n A | |
| map_smul' := fun c D β¦ mooreDifferential_smul n c A D | |
| def rawCofactor (n : β) (A : Matrix (Fin n) (Fin n) (Quaternion β)) : | |
| Matrix (Fin n) (Fin n) (Quaternion β) := | |
| fun i j β¦ star (quaternionDualVector ((mooreDifferentialLinear n A).comp | |
| (quaternionEntryLinear j i))) | |
| def realTrace {n : β} (A : Matrix (Fin n) (Fin n) (Quaternion β)) : β := A.trace.re | |
| theorem quaternion_re_sum {ΞΉ : Type*} (s : Finset ΞΉ) (f : ΞΉ β Quaternion β) : | |
| (s.sum f).re = s.sum (fun i β¦ (f i).re) := by | |
| classical | |
| induction s using Finset.induction_on with | |
| | empty => simp | |
| | @insert i s hi ih => simp [hi, ih] | |
| theorem realTrace_mul_comm {n : β} (A B : Matrix (Fin n) (Fin n) (Quaternion β)) : | |
| realTrace (A * B) = realTrace (B * A) := by | |
| change (β i, (A * B) i i).re = (β i, (B * A) i i).re | |
| simpa only [quaternion_re_sum] using quaternionRealTrace_mul_comm n A B | |
| theorem realTrace_conjTranspose {n : β} (A : Matrix (Fin n) (Fin n) (Quaternion β)) : | |
| realTrace Aα΄΄ = realTrace A := by | |
| simp [realTrace, Matrix.trace_conjTranspose] | |
| theorem realTrace_add {n : β} (A B : Matrix (Fin n) (Fin n) (Quaternion β)) : | |
| realTrace (A + B) = realTrace A + realTrace B := by simp [realTrace] | |
| theorem realTrace_smul {n : β} (c : β) (A : Matrix (Fin n) (Fin n) (Quaternion β)) : | |
| realTrace (c β’ A) = c * realTrace A := by simp [realTrace] | |
| theorem rawCofactor_pairing (n : β) (A D : Matrix (Fin n) (Fin n) (Quaternion β)) : | |
| realTrace (rawCofactor n A * D) = mooreDifferential n A D := by | |
| change (β i, (rawCofactor n A * D) i i).re = mooreDifferentialLinear n A D | |
| conv_rhs => rw [Matrix.matrix_eq_sum_single D] | |
| simp only [map_sum, quaternion_re_sum, Matrix.mul_apply] | |
| rw [Finset.sum_comm] | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| apply Finset.sum_congr rfl | |
| intro j _ | |
| exact quaternionDualVector_apply ((mooreDifferentialLinear n A).comp (quaternionEntryLinear i j)) | |
| (D i j) | |
| /-- The Hermitian cofactor, defined without invertibility and with the usual | |
| real-trace normalization of the Moore determinant's differential. -/ | |
| def mooreCofactor (n : β) (A : Matrix (Fin n) (Fin n) (Quaternion β)) : | |
| Matrix (Fin n) (Fin n) (Quaternion β) := | |
| (1 / 2 : β) β’ (rawCofactor n A + (rawCofactor n A)α΄΄) | |
| theorem mooreCofactor_isHermitian (n : β) | |
| (A : Matrix (Fin n) (Fin n) (Quaternion β)) : (mooreCofactor n A).IsHermitian := by | |
| rw [Matrix.IsHermitian, mooreCofactor, quaternionMatrix_conjTranspose_real_smul, | |
| Matrix.conjTranspose_add, Matrix.conjTranspose_conjTranspose, add_comm] | |
| theorem realTrace_star_left {n : β} (C D : Matrix (Fin n) (Fin n) (Quaternion β)) | |
| (hD : D.IsHermitian) : realTrace (Cα΄΄ * D) = realTrace (C * D) := by | |
| have hDe : Dα΄΄ = D := hD | |
| calc | |
| realTrace (Cα΄΄ * D) = realTrace (D * C)α΄΄ := by rw [Matrix.conjTranspose_mul, hDe] | |
| _ = realTrace (D * C) := realTrace_conjTranspose _ | |
| _ = realTrace (C * D) := realTrace_mul_comm _ _ | |
| theorem mooreCofactor_pairing (n : β) (A D : Matrix (Fin n) (Fin n) (Quaternion β)) | |
| (hD : D.IsHermitian) : realTrace (mooreCofactor n A * D) = mooreDifferential n A D := by | |
| rw [mooreCofactor, Matrix.smul_mul, Matrix.add_mul, realTrace_smul, realTrace_add, | |
| realTrace_star_left _ _ hD, rawCofactor_pairing] | |
| ring | |
| theorem quaternion_re_mul_comm (p q : Quaternion β) : (p * q).re = (q * p).re := by | |
| simp only [Quaternion.re_mul] | |
| ring | |
| theorem realTrace_mul_outer {n : β} (C : Matrix (Fin n) (Fin n) (Quaternion β)) | |
| (z : Fin n β Quaternion β) : realTrace (C * OAI.Analysis.Calculus.Quaternion.outer z) = (OAI.Analysis.PDE.Dirichlet.quaternionForm C z).re := by | |
| change (β i, (C * OAI.Analysis.Calculus.Quaternion.outer z) i i).re = (β i, β j, star (z i) * C i j * z j).re | |
| simp only [Matrix.mul_apply, OAI.Analysis.Calculus.Quaternion.outer, quaternion_re_sum] | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| apply Finset.sum_congr rfl | |
| intro j _ | |
| simpa only [mul_assoc] using quaternion_re_mul_comm (C i j * z j) (star (z i)) | |
| theorem complexify_outer_posSemidef {n : β} (z : Fin n β Quaternion β) : | |
| (complexify (OAI.Analysis.Calculus.Quaternion.outer z)).PosSemidef := | |
| (complexify_posSemidef_iff (OAI.Analysis.Calculus.Quaternion.outer_isHermitian z)).mpr (OAI.Analysis.PDE.Dirichlet.quaternionForm_outer_nonneg z) | |
| /-- Positivity of the actual cofactor matrix, including at singular positive | |
| semidefinite backgrounds. -/ | |
| theorem mooreCofactor_posSemidef {n : β} | |
| (A : Matrix (Fin n) (Fin n) (Quaternion β)) (hA : (complexify A).PosSemidef) : | |
| (complexify (mooreCofactor n A)).PosSemidef := by | |
| apply (complexify_posSemidef_iff (mooreCofactor_isHermitian n A)).mpr | |
| intro z | |
| rw [β realTrace_mul_outer, mooreCofactor_pairing n A (OAI.Analysis.Calculus.Quaternion.outer z) (OAI.Analysis.Calculus.Quaternion.outer_isHermitian z)] | |
| exact mooreDifferential_nonneg_of_posSemidef A (OAI.Analysis.Calculus.Quaternion.outer z) hA (complexify_outer_posSemidef z) | |
| end OAI.LinearAlgebra.Moore | |