Skip to content

Conversation

@MohanadAhmed
Copy link
Contributor

@MohanadAhmed MohanadAhmed commented May 30, 2023

Determinant and Trace are Product and Sum of Eigenvalues
The eigenvalue as defined here is the same as the eigenvalue defined by mathlib for endomorphisms.

  1. root_charpoly_iff_has_eigenvalue and lemmas for both directions
  2. mem_eigs_iff_eigenvalue and lemmas for both directions

@eric-wieser
Copy link
Owner

Please merge master to resolve the conflicts

Comment on lines 38 to 123
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
Copy link
Owner

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?

Copy link
Contributor Author

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?

Copy link
Owner

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!

Copy link
Contributor Author

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?

@eric-wieser eric-wieser added the lean3 This PR needs converting to Lean 4 if it is not already merged label Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lean3 This PR needs converting to Lean 4 if it is not already merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants