Skip to content
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

[Merged by Bors] - feat(linear_algebra/matrix/charpoly/eigs): det and trace are product and sum of eigenvalues #19079

Closed
wants to merge 28 commits into from

Conversation

MohanadAhmed
Copy link
Collaborator

@MohanadAhmed MohanadAhmed commented May 24, 2023

This adds two lemmas:

  1. det_eq_prod_roots_charpoly: the determinant of a square matrix is the product of the characteristic polynomial roots of that matrix.
  2. trace_eq_sum_roots_charpoly: the trace is similarly the sum of the characteristic polynomial roots.

These two lemmas are more commonly stated as trace is the sum of eigenvalues and determinant is the product of eigenvalues. Mathlib has already defined eigenvalues in linear_algebra.eigenspace as the roots of the minimal polynomial of a linear endomorphism. These do not have correct multiplicity and cannot be used in the theorems above. Hence we express these theorems in terms of the roots of the characteristic polynomial directly.


Open in Gitpod

Only algebraically closed fields
@MohanadAhmed MohanadAhmed changed the title Det and Trace are product and sum of eigenvalues feat(linear_algebra/matrix/charpoly/eigs): determinant and trace are product and sum of eigenvalues (roots of charpoly) May 24, 2023
@MohanadAhmed MohanadAhmed added the awaiting-review The author would like community review of the PR label May 24, 2023
@eric-wieser
Copy link
Member

Can you add a note to the module docstring explaining the link to eigenvalues?

MohanadAhmed and others added 2 commits May 24, 2023 19:10
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
MohanadAhmed and others added 4 commits May 24, 2023 19:31
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@MohanadAhmed
Copy link
Collaborator Author

@eric-wieser
Why the need to open linear_map module.End?

@eric-wieser eric-wieser changed the title feat(linear_algebra/matrix/charpoly/eigs): determinant and trace are product and sum of eigenvalues (roots of charpoly) feat(linear_algebra/matrix/charpoly/eigs): det and trace are product and sum of eigenvalues May 25, 2023
@MohanadAhmed
Copy link
Collaborator Author

MohanadAhmed commented May 26, 2023

So I figured out I can get away with using (ring_hom.id R) in place of the "bundled ring homomorphism". I still have no idea what that one is or this one is!!

…ces and do the splitting themselves.

The longer names ones ...... well split hairs and prefer if you don't call them!!!
@MohanadAhmed
Copy link
Collaborator Author

I think the condition [is_alg_closed], although stronger, is probably easier to understand and use (and if picked up as an instance more transparent to users with humble knowledge of ring homomorphisms). In this last bunch of commits I suggest we have two versions.

  • The plain named ones det_eq_prod_roots_charpoly and trace_eq_sum_roots_charpoly which attempt to pick up the is_alg_closed instances themselves.
  • We also have det_eq_prod_roots_charpoly_of_splits and trace_eq_sum_roots_charpoly_of_splits for the brave souls that can prove (or assume) their polynomial splits.

@MohanadAhmed
Copy link
Collaborator Author

MohanadAhmed commented May 26, 2023

What do you think @eric-wieser and @Vierkantor ? I mean about having two versions.

MohanadAhmed and others added 3 commits May 26, 2023 09:54
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
MohanadAhmed and others added 2 commits May 26, 2023 10:35
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@MohanadAhmed MohanadAhmed added awaiting-review The author would like community review of the PR and removed awaiting-author A reviewer has asked the author a question or requested changes labels May 26, 2023
@Vierkantor
Copy link
Collaborator

So I figured out I can get away with using (ring_hom.id R) in place of the "bundled ring homomorphism". I still have no idea what that one is or this one is!!

That's an issue with the documentation if there is no explanation what we mean by the jargon "bundled". Could you point me to where you read this?

Ideally, to do mathematics in Lean we would only encounter ring homomorphisms in their bundled form. So if you don't see "unbundled" anywhere, don't worry about the word "bundled". So ring_hom.id R is a perfectly fine example of a homomorphism you can use here.

What we mean by "bundled" in mathlib is that objects carry proofs with them. So an element of R →+* S doesn't only contain the data of the map R → S but also the proofs showing that this map respects the ring structure.

Copy link
Collaborator

@Vierkantor Vierkantor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes!

I tried to unify the commonalities with norm_gen_eq_prod_roots and trace_gen_eq_sum_roots myself, but had a few issues since prod_roots_eq_coeff_zero_of_monic_of_split is not quite general enough. So I propose that we merge this now with this TODO comment, and then come back to this later (after the mathlib4 port, probably). @eric-wieser, do you agree?

bors d+

src/linear_algebra/matrix/charpoly/eigs.lean Show resolved Hide resolved
@bors
Copy link

bors bot commented May 30, 2023

✌️ MohanadAhmed can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@leanprover-community-bot-assistant leanprover-community-bot-assistant added delegated The PR author may merge after reviewing final suggestions. and removed awaiting-review The author would like community review of the PR labels May 30, 2023
@MohanadAhmed
Copy link
Collaborator Author

v MohanadAhmed can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

bors r+

Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
@bors
Copy link

bors bot commented May 30, 2023

Canceled.

@MohanadAhmed
Copy link
Collaborator Author

bors r+

bors bot pushed a commit that referenced this pull request May 30, 2023
…and sum of eigenvalues (#19079)

This adds two lemmas:
1. `det_eq_prod_roots_charpoly`: the determinant of a square matrix is the product of the characteristic polynomial roots of that matrix.
2. `trace_eq_sum_roots_charpoly`: the trace is similarly the sum of the characteristic polynomial roots.

These two lemmas are more commonly stated as trace is the sum of eigenvalues and determinant is the product of eigenvalues. Mathlib has already defined eigenvalues in [linear_algebra.eigenspace](https://leanprover-community.github.io/mathlib_docs/linear_algebra/eigenspace.html#module.End.eigenvalues) as the roots of the minimal polynomial of a linear endomorphism. These do not have correct multiplicity and cannot be used in the theorems above. Hence we express these theorems in terms of the roots of the characteristic polynomial directly.




Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@bors
Copy link

bors bot commented May 30, 2023

Pull request successfully merged into master.

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot changed the title feat(linear_algebra/matrix/charpoly/eigs): det and trace are product and sum of eigenvalues [Merged by Bors] - feat(linear_algebra/matrix/charpoly/eigs): det and trace are product and sum of eigenvalues May 30, 2023
@bors bors bot closed this May 30, 2023
@bors bors bot deleted the MohanadAhmed/det_trace_eigs branch May 30, 2023 19:56
`norm_gen_eq_prod_roots` and `trace_gen_eq_sum_roots` respectively, but the
dependencies are not general enough to unify them. We should refactor
`polynomial.prod_roots_eq_coeff_zero_of_monic_of_split` and
`polynomial.sum_roots_eq_next_coeff_of_monic_of_split` to assume splitting over an arbitrary map.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does polynomial.splits take a morphism at all? Doesn't polynomial.splits_map_iff demonstrate that it's useless and we should just use (p.map f).splits instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
delegated The PR author may merge after reviewing final suggestions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants