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

feat(Matrix): extracting entries as a linear map #17535

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Conversation

b-mehta
Copy link
Contributor

@b-mehta b-mehta commented Oct 8, 2024

Strictly speaking, something like this was available as LinearMap.proj, but actually using it in practice is awkward as unification struggles (see line 1227 in this PR).

I'm happy to take name suggestions, as well as ideas for other generalities.


Open in Gitpod

Copy link

github-actions bot commented Oct 8, 2024

PR summary 6f3aca5ef8

Import changes for modified files

Dependency changes

File Base Count Head Count Change
Mathlib.Data.Matrix.Basic 806 808 +2 (+0.25%)
Import changes for all files
Files Import difference
13 files Mathlib.Data.Matrix.Auto Mathlib.Combinatorics.SimpleGraph.StronglyRegular Mathlib.Data.Matrix.Basis Mathlib.GroupTheory.Coxeter.Matrix Mathlib.GroupTheory.Coxeter.Basic Mathlib.Data.Matrix.Reflection Mathlib.LinearAlgebra.Matrix.Trace Mathlib.GroupTheory.Coxeter.Inversion Mathlib.GroupTheory.Coxeter.Length Mathlib.Data.Matrix.Hadamard Mathlib.Combinatorics.Optimization.ValuedCSP Mathlib.Data.Matrix.Notation Mathlib.Combinatorics.SimpleGraph.AdjMatrix
1
14 files Mathlib.Data.Matrix.Invertible Mathlib.Data.Matrix.Composition Mathlib.Data.Matrix.Basic Mathlib.Data.Matrix.PEquiv Mathlib.Data.Matrix.CharP Mathlib.Data.Matrix.Block Mathlib.CategoryTheory.Preadditive.Mat Mathlib.Topology.UniformSpace.Matrix Mathlib.LinearAlgebra.Matrix.Symmetric Mathlib.Data.Matrix.RowCol Mathlib.Data.Matrix.DualNumber Mathlib.Combinatorics.SimpleGraph.IncMatrix Mathlib.LinearAlgebra.Matrix.Circulant Mathlib.LinearAlgebra.Matrix.Orthogonal
2

Declarations diff

+ entryAddHom
+ entryAddHom_comp_mapMatrix
+ entryAddHom_eq_comp
+ entryAddMonoidHom
+ entryAddMonoidHom_comp_mapMatrix
+ entryAddMonoidHom_eq_comp
+ entryAddMonoidHom_toAddHom
+ entryLinearMap
+ entryLinearMap_eq
+ entryLinearMap_toAddHom
+ entryLinearMap_toAddMonoidHom
+ evalAddMonoidHom_comp_diagAddMonoidHom
+ mapMatrix_toLinearMap
+ proj_comp_diagLinearMap
++ entryLinearMap_comp_mapMatrix

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.

@github-actions github-actions bot added the t-data Data (lists, quotients, numbers, etc) label Oct 8, 2024
@b-mehta b-mehta added the WIP Work in progress label Oct 8, 2024
@b-mehta
Copy link
Contributor Author

b-mehta commented Oct 8, 2024

(Oops, putting this back to WIP because I realised I want to add a bit more to it!)

@b-mehta b-mehta removed the WIP Work in progress label Oct 8, 2024
Mathlib/Data/Matrix/Basic.lean Outdated Show resolved Hide resolved
Mathlib/Data/Matrix/Basic.lean Outdated Show resolved Hide resolved
Mathlib/Data/Matrix/Basic.lean Outdated Show resolved Hide resolved
Comment on lines 1286 to 1290
@[simp] lemma elemLinearMap_toAddMonoidHom {i : m} {j : n} :
(elemLinearMap R α i j).toAddMonoidHom = elemAddMonoidHom α i j := rfl

@[simp] lemma elemLinearMap_toAddHom {i : m} {j : n} :
(elemLinearMap R α i j).toAddHom = elemAddHom α i j := rfl
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason to have these as opposed to the versions utilizing the hom class coercions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, the first one gets elaborated to the hom class coercions but the second doesn't, that's a mistake on my part. Will amend.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, actually they are all utilizing the hom class coercions already. Could you clarify what you meant then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the spelling for clarity.

Comment on lines 1256 to 1257
@[simp] lemma elemAddMonoidHom_toAddHom {i : m} {j : n} :
(elemAddMonoidHom α i j).toAddHom = Matrix.elemAddHom α i j := rfl
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here


-- The type ascription on the RHS is necessary for unification to succeed on the composition.
lemma elemAddHom_eq_comp {i : m} {j : n} :
elemAddHom α i j = (Pi.evalAddHom _ j).comp (Pi.evalAddHom _ i : AddHom _ (n → α)) :=
Copy link
Member

Choose a reason for hiding this comment

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

Arguably you should launder through of here to avoid needing the type ascription.

Copy link
Contributor Author

@b-mehta b-mehta Oct 8, 2024

Choose a reason for hiding this comment

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

I'm not quite sure I follow - of is for building matrices, but both sides here are maps out of a matrix space. I'm happy to use of, but I don't see how it fits here.
Oops, didn't realise of was an equiv. I'm still not sure how to make it fit though, because it doesn't give me a linear map

Copy link
Member

Choose a reason for hiding this comment

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

You could add an ofLinearEquiv as a linear version of of.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds potentially helpful but a can of worms I'd rather not open here (AddEquiv; LinearEquiv; RingEquiv; AlgebraEquiv...). Would you be happy with a todo instead?

Copy link
Member

Choose a reason for hiding this comment

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

I think it's fine to just add the bundling you need; the simp-normal form would remain of

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t-data Data (lists, quotients, numbers, etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants