-
Notifications
You must be signed in to change notification settings - Fork 20
Eq 12 and Eq 18: Determinant and Trace are Product and Sum of Eigenvalues #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Please merge master to resolve the conflicts |
4c6a767 to
a4f683c
Compare
src/matrix_cookbook/lib/eigs.lean
Outdated
| lemma root_charpoly_of_has_eigenvalue (A: matrix n n R)(μ: R): | ||
| has_eigenvalue (matrix.to_lin' A) μ → A.charpoly.is_root μ:= | ||
| begin | ||
| intro heig, | ||
| have va := has_eigenvalue.exists_has_eigenvector heig, | ||
| have xa : (∃ (v : n → R) (H : v ≠ 0), (μ • 1 - A).mul_vec v = 0), | ||
| { cases va with v hv, | ||
| use v, | ||
| rw [has_eigenvector, mem_eigenspace_iff,to_lin'_apply, and_comm, eq_comm] at hv, | ||
| rwa [sub_mul_vec, smul_mul_vec_assoc, one_mul_vec, sub_eq_zero], }, | ||
| rw [matrix.charpoly, is_root, eval_det, mat_poly_equiv_charmatrix, | ||
| eval_sub, eval_C, eval_X, coe_scalar,← (matrix.exists_mul_vec_eq_zero_iff.1 xa)], | ||
| end | ||
|
|
||
| lemma has_eigenvalue_of_root_charpoly (A: matrix n n R)(μ: R): | ||
| A.charpoly.is_root μ → has_eigenvalue (matrix.to_lin' A) μ := | ||
| begin | ||
| rw [matrix.charpoly, is_root, eval_det, mat_poly_equiv_charmatrix,eval_sub], | ||
| rw [eval_C, eval_X, coe_scalar], | ||
| dsimp, | ||
|
|
||
| intro h, | ||
| have h := matrix.exists_mul_vec_eq_zero_iff.2 h, | ||
| rcases h with ⟨v, hv_nz, hv⟩, | ||
| rw [sub_mul_vec, smul_mul_vec_assoc, one_mul_vec, sub_eq_zero, eq_comm] at hv, | ||
| rw [has_eigenvalue, submodule.ne_bot_iff], | ||
| use v, | ||
| rw [mem_eigenspace_iff, to_lin'_apply], | ||
| split, assumption', | ||
| end | ||
|
|
||
| lemma root_charpoly_iff_has_eigenvalue (A: matrix n n R)(μ: R) : | ||
| A.charpoly.is_root μ ↔ has_eigenvalue (matrix.to_lin' A) μ := | ||
| begin | ||
| split, | ||
| apply has_eigenvalue_of_root_charpoly, | ||
| apply root_charpoly_of_has_eigenvalue, | ||
| end | ||
|
|
||
| lemma root_charpoly_iff_root_minpoly (A: matrix n n R)(μ: R) : | ||
| (minpoly R (matrix.to_lin' A)).is_root μ ↔ A.charpoly.is_root μ := | ||
| begin | ||
| split, | ||
| /- Bridge over has_eigenvalue to connect root_chapoly and root minpoly linear map-/ | ||
| intro h, | ||
| rw root_charpoly_iff_has_eigenvalue, | ||
| apply has_eigenvalue_iff_is_root.2 h, | ||
|
|
||
| rw root_charpoly_iff_has_eigenvalue, | ||
| intro h, | ||
| apply has_eigenvalue_iff_is_root.1 h, | ||
| end | ||
|
|
||
| lemma eig_if_eigenvalue (A: matrix n n R)(μ: R) : | ||
| μ ∈ eigs A → has_eigenvalue (matrix.to_lin' A) μ := | ||
| begin | ||
| rw eigs, | ||
| rw mem_roots', | ||
| intro h, | ||
| cases h with hne hcp, | ||
| exact has_eigenvalue_of_root_charpoly _ _ hcp, | ||
| end | ||
|
|
||
| lemma eigenvalue_if_eig [nonempty n](A: matrix n n R)(μ: R) : | ||
| has_eigenvalue (matrix.to_lin' A) μ → μ ∈ eigs A := | ||
| begin | ||
| rw eigs, rw mem_roots, | ||
| intro h, | ||
| exact root_charpoly_of_has_eigenvalue _ _ h, | ||
| have p_nz : matrix.charpoly A ≠ 0, | ||
| { by_contra, | ||
| replace h := congr_arg nat_degree h, | ||
| have p_deg := matrix.charpoly_nat_degree_eq_dim A, | ||
| have hn: fintype.card n ≠ 0, {exact fintype.card_ne_zero,}, | ||
| rw [nat_degree_zero, p_deg] at h, | ||
| exact hn h, }, | ||
| exact p_nz, | ||
| end | ||
|
|
||
| lemma mem_eigs_iff_eigenvalue [nonempty n] (A: matrix n n R)(μ: R): | ||
| μ ∈ eigs A ↔ has_eigenvalue (matrix.to_lin' A) μ := | ||
| begin | ||
| split, | ||
| apply eig_if_eigenvalue, | ||
| apply eigenvalue_if_eig, | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should PR these straight to mathlib! They're not actually used in the cookbook, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last two are related to the definition eig which is only here in the matrix cookbook. For the others I think you are probably right. Where do you think I should put them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed a handful of golfs; even if this code goes straight to mathlib, we'll want them there. Hopefully seeing them is useful to you too!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In which file in mathlib do you think they are suitable?
Determinant and Trace are Product and Sum of Eigenvalues
The eigenvalue as defined here is the same as the eigenvalue defined by
mathlibfor endomorphisms.root_charpoly_iff_has_eigenvalueand lemmas for both directionsmem_eigs_iff_eigenvalueand lemmas for both directions