Skip to content

refactor: reduce defeq abuse in Representation.asModule - #43885

Open
plp127 wants to merge 12 commits into
leanprover-community:masterfrom
plp127:aliu/representation
Open

plp127 wants to merge 12 commits into
leanprover-community:masterfrom
plp127:aliu/representation

Conversation

@plp127

@plp127 plp127 commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Reduce defeq abuse around Representation.asModule by adding explicitly uses of Representation.asModuleEquiv to convert between V and ρ.asModule. Also reorganize some @[simp] lemmas and fix some naming issues.


Open in Gitpod

@github-actions github-actions Bot added the tech debt Fixes cross-cutting technical debt, see the "technical debt counters" stream on zulip label Sep 16, 2026
@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

PR summary 620b1fc34a

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

+ asModuleEquiv_apply_single_smul
+ asModuleEquiv_apply_smul
+ asModuleEquiv_symm_apply_apply
+ single_smul_asModuleEquiv_symm_apply

You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.

Declarations diff (Lean)

✅ Lean-aware diff — post-build, computed from the Lean environment (commit 620b1fc).

  • +4 new declarations
  • −0 removed declarations
+Representation.asModuleEquiv_apply_single_smul
+Representation.asModuleEquiv_apply_smul
+Representation.asModuleEquiv_symm_apply_apply
+Representation.single_smul_asModuleEquiv_symm_apply

Decrease in strong tech debt: (relative, absolute) = (1.01, 0.09)
Current number Change Type (strong)
3509 -4 backward.isDefEq.respectTransparency
12 -1 backward.isDefEq.respectTransparency.instanceSearchTypes
362 -1 adaptation notes
No changes to weak technical debt.

Current commit 620b1fc34a
Reference commit 29c91d5f70

This script lives in the mathlib-ci repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.py pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@github-actions github-actions Bot added the t-algebra Algebra (groups, rings, fields, etc) label Sep 16, 2026
Comment thread Mathlib/RepresentationTheory/Basic.lean Outdated
simp

@[simp]
theorem asModuleEquiv_symm_map_rho (g : G) (x : V) :

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is rho really a mathlib style name?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

now that I'm looking at this this is indeed not a good name, do you have any suggestions for a better name?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not really, but I don't mind an @[deprecated] since it follows from simp now

@JX-Mo JX-Mo Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

First of all, MonoidAlgebra.of k G g is just a wrapper of single g (1 : k) so this lemma follows from your single_smul_asModuleEquiv_symm_apply. We can record it as a rewrite lemma

lemma single_one_smul_asModuleEquiv_symm_apply (g : G) (x : V) :
    single g (1 : k) • ρ.asModuleEquiv.symm x = ρ.asModuleEquiv.symm (ρ g x) := by
  simp

By the way, in line 83 RepresentationTheory.Submodule.lean we can use a better proof

    exact ρ.asModuleEquiv.injective (by simp)⟩

@[simp]
theorem asModuleEquiv_symm_map_rho (g : G) (x : V) :
ρ.asModuleEquiv.symm (ρ g x) = MonoidAlgebra.of k G g • ρ.asModuleEquiv.symm x := by
rw [LinearEquiv.symm_apply_eq]

@JX-Mo JX-Mo Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Now this lemma follows from by simp with the helf of your new design single_smul_asModuleEquiv_symm_apply

Comment thread Mathlib/RepresentationTheory/Basic.lean Resolved
Comment thread Mathlib/RepresentationTheory/Basic.lean Resolved
Comment thread Mathlib/RepresentationTheory/Basic.lean Resolved
Comment thread Mathlib/RepresentationTheory/Basic.lean Resolved
Comment thread Mathlib/RepresentationTheory/Basic.lean Resolved
Comment thread Mathlib/RepresentationTheory/Basic.lean Resolved
Comment thread Mathlib/RepresentationTheory/Basic.lean Outdated
@@ -174,12 +174,25 @@ theorem asModuleEquiv_symm_map_smul (r : k) (x : V) :
rw [LinearEquiv.symm_apply_eq]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This lemma can be proved from by simp now with the help of single_smul_asModuleEquiv_symm_apply

Comment on lines +493 to 517
noncomputable def equivLinearMapAsModule :
IntertwiningMap ρ σ ≃ₗ[A] ρ.asModule →ₗ[A[G]] σ.asModule where
toFun f :=
{ toFun := f.toLinearMap
map_add' := f.toLinearMap.map_add'
{ toFun := σ.asModuleEquiv.symm ∘ₗ f.toLinearMap ∘ₗ ρ.asModuleEquiv
map_add' := by simp
map_smul' m v := by
induction m using MonoidAlgebra.induction_linear with
| zero => simp [f.toLinearMap.map_zero]
| zero => simp
| add x y hx hy => simp [add_smul, map_add, hx, hy]
| single g a => simp [f.isIntertwining]; rfl }
| single g a => simp [f.isIntertwining] }
invFun f :=
{ toLinearMap := { f with
{ toLinearMap :=
{ σ.asModuleEquiv.toLinearMap ∘ₗ f.restrictScalars A ∘ₗ ρ.asModuleEquiv.symm.toLinearMap with
map_smul' a v := by simp }
isIntertwining' g := by ext v; simpa using! f.map_smul' (MonoidAlgebra.single g 1) v }
isIntertwining' g := by
ext v
calc
_ = _ := by simp
_ = _ := congrArg σ.asModuleEquiv
(f.map_smul' (MonoidAlgebra.single g 1) (ρ.asModuleEquiv.symm v))
_ = _ := by simp }
map_add' g₁ g₂ := by ext; simp
map_smul' t g := by ext; simp
left_inv f := rfl
right_inv f := rfl

@JX-Mo JX-Mo Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
noncomputable def equivLinearMapAsModule :
IntertwiningMap ρ σ ≃ₗ[A] ρ.asModule →ₗ[A[G]] σ.asModule where
toFun f :=
{ toFun := σ.asModuleEquiv.symm ∘ₗ f.toLinearMap ∘ₗ ρ.asModuleEquiv
map_add' := by simp
map_smul' m _ := by
refine MonoidAlgebra.induction_linear m (by simp) ?_ (by simp [f.isIntertwining])
exact fun _ _ hx hy => by simp [add_smul, map_add, hx, hy] }
invFun f :=
{ toLinearMap := σ.asModuleEquiv.toLinearMap ∘ₗ f ∘ₗ ρ.asModuleEquiv.symm.toLinearMap
isIntertwining' g := LinearMap.ext fun v => by simpa using congrArg σ.asModuleEquiv <|
(f.map_smul' (MonoidAlgebra.single g 1) (ρ.asModuleEquiv.symm v)) }
map_add' _ _ := by ext; simp
map_smul' _ _ := by ext; simp
left_inv _ := rfl
right_inv _ := rfl

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I prefer using the induction tactic to do induction.

@JX-Mo JX-Mo Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
invFun f :=
{ toLinearMap := σ.asModuleEquiv.toLinearMap ∘ₗ f ∘ₗ ρ.asModuleEquiv.symm.toLinearMap

This should be an improvement

@plp127 plp127 changed the title chore: reduce defeq abuse in Representation.asModule refactor: reduce defeq abuse in Representation.asModule Sep 20, 2026
Comment thread Mathlib/RepresentationTheory/Basic.lean Resolved
@mathlib-merge-conflicts mathlib-merge-conflicts Bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Nov 24, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

This pull request has conflicts, please merge master and resolve them.

@github-actions github-actions Bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Nov 24, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-algebra Algebra (groups, rings, fields, etc) tech debt Fixes cross-cutting technical debt, see the "technical debt counters" stream on zulip

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants