mathlib4 review helperopen PRs by @themathqueen on leanprover-community/mathlib4

← queue

#42067 feat(RingTheory): define Frobenius algebras

t-ring-theory CI success

+331 −21 · 4 files · 91 commits · head 950c34a · updated 47 days ago · Files changed on GitHub

In plain words

Defines Frobenius algebras: a (possibly non-unital, non-associative) -algebra with a chosen linear functional such that is a bijection . Basic API: the isomorphism with the dual and nondegeneracy of the form; constructors from an associative isomorphism or from a left-separating associative bilinear form; finite-dimensionality over a field; the Nakayama automorphism; matrix algebras with the trace. A second file connects this to the existing Coalgebra.IsFrobenius. Over a field, a Frobenius algebra carries a coalgebra structure (not an instance) satisfying the Frobenius equations. Conversely, an algebra with a coalgebra structure satisfying them is a Frobenius algebra with the counit. Three nondegeneracy lemmas move from Coalgebra/IsFrobenius.lean to the new file and are reproved from the general ones.

Transcriptions are drafted with an LLM from the diff and are a reading aid, not a verified statement: the Lean code is the reference.

PR description

A FrobeniusAlgebra is an algebra that is equipped with a dual : Module.Dual R A such that the bilinear form (LinearMap.mul R A).compr₂ dual is bijective.

A straightforward example: a matrix over a field with the trace as its dual is a Frobenius algebra. (Not an instance because there can be other choices of the dual.)

A FrobeniusAlgebra induces a coalgebra such that it satisfies the Frobenius equations (Coalgebra.IsFrobenius). Note that this is not an instance since you can have a different coalgebra that is not equal to this one (for example, if you have a Bialgebra R A where A is not isomorphic to R then the coalgebra cannot satisfy the Frobenius equations, so this is not equal to the coalgebra coming from a FrobeniusAlgebra R A).

A coalgebra that satisfies the Frobenius equations (Coalgebra.IsFrobenius) naturally induces a Frobenius algebra (FrobeniusAlgebra).


![Open in Gitpod](gitpod.io/from-referrer/)

Conversation on GitHub 5
github-actions[bot] · comment · 2026-07-24
PR summary 950c34ab99
Import changes for modified files

No significant changes to the import graph

<details><summary>Import changes for all files</summary>

|Files|Import difference| |-|-| | Mathlib.RingTheory.FrobeniusAlgebra.Basic (new file)|1621| | Mathlib.RingTheory.FrobeniusAlgebra.IsFrobenius (new file)|1629|

</details>


<details><summary>

Declarations diff (regex)

</summary>

+ FrobeniusAlgebra + _root_.Matrix.frobeniusAlgebra + _root_.Matrix.frobeniusAlgebraDual_eq_traceLinearMap + algEquiv_eq_nakayamaAlgEquiv_iff + comulLeft + comulLeft_eq_comulRight + comulRight + dual_apply_symm_equivDual_mul + dual_nakayamaAlgEquiv + dual_nakayamaAlgEquiv_mul + equivDual + equivDual_apply + equivDual_apply_apply + forall_dual_mul_left_eq_zero_iff + forall_dual_mul_right_eq_zero_iff + instFiniteDimensional + instance : FrobeniusAlgebra R R + isFrobenius_toCoalgebra + lTensor_dual_comp_comulLeft_comp_lid + nakayamaAlgEquiv + nondegenerate_equivDual + ofBilinForm + ofIsFrobenius + ofIsFrobenius_dual_eq + ofLinearEquiv + rTensor_comp_comulRight_comp_rid + symm_equivDual_compr₂_mul_dual + toCoalgebra + toLinearMap_equivDual <details> <summary>You can run this locally as follows</summary>

## 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>

</details>

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

</details>

<details><summary>

Declarations diff (Lean)

</summary>

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

  • +40 new declarations
  • −0 removed declarations
+FrobeniusAlgebra
+FrobeniusAlgebra.algEquiv_eq_nakayamaAlgEquiv_iff
+FrobeniusAlgebra.bijective_compr₂_mul
+FrobeniusAlgebra.casesOn
+FrobeniusAlgebra.comulLeft
+FrobeniusAlgebra.comulLeft_eq_comulRight
+FrobeniusAlgebra.comulRight
+FrobeniusAlgebra.ctorIdx
+FrobeniusAlgebra.dual
+FrobeniusAlgebra.dual_apply_symm_equivDual_mul
+FrobeniusAlgebra.dual_nakayamaAlgEquiv
+FrobeniusAlgebra.dual_nakayamaAlgEquiv_mul
+FrobeniusAlgebra.equivDual
+FrobeniusAlgebra.equivDual_apply
+FrobeniusAlgebra.equivDual_apply_apply
+FrobeniusAlgebra.forall_dual_mul_left_eq_zero_iff
+FrobeniusAlgebra.forall_dual_mul_right_eq_zero_iff
+FrobeniusAlgebra.inst
+FrobeniusAlgebra.instFiniteDimensional
+FrobeniusAlgebra.isFrobenius_toCoalgebra
+FrobeniusAlgebra.lTensor_dual_comp_comulLeft_comp_lid
+FrobeniusAlgebra.mk
+FrobeniusAlgebra.mk.noConfusion
+FrobeniusAlgebra.nakayamaAlgEquiv
+FrobeniusAlgebra.nakayamaAlgEquiv.congr_simp
+FrobeniusAlgebra.noConfusion
+FrobeniusAlgebra.noConfusionType
+FrobeniusAlgebra.nondegenerate_equivDual
+FrobeniusAlgebra.ofBilinForm
+FrobeniusAlgebra.ofIsFrobenius
+FrobeniusAlgebra.ofIsFrobenius_dual_eq
+FrobeniusAlgebra.ofLinearEquiv
+FrobeniusAlgebra.rTensor_comp_comulRight_comp_rid
+FrobeniusAlgebra.rec
+FrobeniusAlgebra.recOn
+FrobeniusAlgebra.symm_equivDual_compr₂_mul_dual
+FrobeniusAlgebra.toCoalgebra
+FrobeniusAlgebra.toLinearMap_equivDual
+Matrix.frobeniusAlgebra
+Matrix.frobeniusAlgebraDual_eq_traceLinearMap

</details>


No changes to strong technical debt. No changes to weak technical debt.

Current commit 950c34ab99 Reference commit 8b63df8c67

This script lives in the undefined 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[bot] · comment · 2026-07-24
✅ PR Title Formatted Correctly

The title of this PR has been updated to match our commit style conventions. Thank you!

mathlib-merge-conflicts[bot] · comment · 2026-08-17

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

JX-Mo · comment · 2026-09-07

Just a remark. In my Hecke repo, I constructed a non-degenerate symmetric pairing by evaluating at one composed with multiplication, which is very close to what is happening here. But from there we can already construct trace elements for compact representations, which are central, and note that the Hecke algebra is usually infinite dimensional. It would be great if we can have some more general machinery.

mathlib-dependent-issues[bot] · comment · 2026-09-19

This PR/issue depends on:

  • ~~leanprover-community/mathlib4#27493~~
  • ~~leanprover-community/mathlib4#42077~~

By Dependent Issues (🤖). Happy coding!

Mathlib.lean +2 −0

public import Mathlib.RingTheory.FractionalIdeal.Operations
6884public import Mathlib.RingTheory.FreeCommRing
6885public import Mathlib.RingTheory.FreeRing
6886public import Mathlib.RingTheory.Frobenius
6887public import Mathlib.RingTheory.FrobeniusAlgebra.Basic
6888public import Mathlib.RingTheory.FrobeniusAlgebra.IsFrobenius
6889public import Mathlib.RingTheory.GradedAlgebra.AlgHom
6890public import Mathlib.RingTheory.GradedAlgebra.Basic
6891public import Mathlib.RingTheory.GradedAlgebra.FiniteType

Mathlib/RingTheory/Coalgebra/IsFrobenius.lean +3 −21

import Mathlib.RingTheory.Coalgebra.CoassocSimps
17This file defines `Coalgebra.IsFrobenius` and shows some elementary results.
−A coalgebra with an algebra structure is said to be Frobenius when the Frobenius equation
19A coalgebra with an algebra structure is said to be **Frobenius** when the Frobenius equation
20is satisfied:
21`(id ⊗ mul') ∘ assoc ∘ (comul ⊗ id) = (mul' ⊗ id) ∘ assoc.symm ∘ (id ⊗ comul)`,
22which in diagrams looks like
In texts, this is what the Frobenius equations are usually referred to as.
55* `Coalgebra.IsFrobenius.instFinite`: a coalgebra satisfying the Frobenius equations is finite
56* `Coalgebra.IsFrobenius.instProjective`: a coalgebra satisfying the Frobenius equations is
57 projective
−* `Bialgebra.nonempty_algEquiv_of_isFrobenius`: when an `R`-bialgebra `A` satisfies the Frobenius
− equations, `R` is isomorphic to `A`
58* `Bialgebra.algebraOfId_bijective_of_isFrobenius`: when an `R`-bialgebra `A` satisfies the
59 Frobenius equations, `R` is isomorphic to `A`
61## TODO
instance instProjective : Module.Projective R A := by
167 refine Module.projective_def'.mpr ⟨∑ p ∈ S, (ε ∘ₗ mulRight R p.1).smulRight (.single p.2 1), ?_⟩
168 ext; simp [sum_counit_mul_left_smul_of_comul_one hS]
lemma forall_counit_mul_left_eq_zero_iff removedLundefined–undefined
−/-- The bilinear form `(mul R A).compr₂ counit` is separating left.
−This is the simplified version, see `nondegenerate_compr₂_mul_counit`. -/
−lemma forall_counit_mul_left_eq_zero_iff {a : A} : (∀ b, (ε : _ →ₗ[R] _) (a * b) = 0) ↔ a = 0 := by
− refine ⟨fun h ↦ ?_, fun h _ ↦ by simp [h]⟩
− have ⟨S, hS⟩ := exists_finset (R := R) (δ (1 : A))
− simpa [h] using (sum_counit_mul_left_smul_of_comul_one hS a).symm
lemma forall_counit_mul_right_eq_zero_iff removedLundefined–undefined
−/-- The bilinear form `(mul R A).compr₂ counit` is separating right.
−This is the simplified version, see `nondegenerate_compr₂_mul_counit`. -/
−lemma forall_counit_mul_right_eq_zero_iff {a : A} : (∀ b, (ε : _ →ₗ[R] _) (b * a) = 0) ↔ a = 0 := by
− refine ⟨fun h ↦ ?_, fun h _ ↦ by simp [h]⟩
− have ⟨S, hS⟩ := exists_finset (R := R) (δ (1 : A))
− simpa [hS, sum_tmul, h] using (sum_counit_mul_right_smul_of_comul_one hS a).symm
lemma nondegenerate_compr₂_mul_counit removedLundefined–undefined
−/-- The bilinear form `mul.compr₂ counit` is nondegenerate. -/
−lemma nondegenerate_compr₂_mul_counit : ((mul R A).compr₂ ε).Nondegenerate :=
− ⟨fun _ ↦ forall_counit_mul_left_eq_zero_iff.mp, fun _ ↦ forall_counit_mul_right_eq_zero_iff.mp⟩
170/-- The bilinear form `mul.compr₂ counit` is bijective. -/
171lemma compr₂_mul_counit_bijective : (⇑((mul R A).compr₂ ε)).Bijective := by
172 have ⟨S, hS⟩ := exists_finset (R := R) (δ (1 : A))

Mathlib/RingTheory/FrobeniusAlgebra/Basic.lean +166 −0 new file

1/-
2Copyright (c) 2026 Monica Omar. All rights reserved.
3Released under Apache 2.0 license as described in the file LICENSE.
4Authors: Monica Omar
5-/
6module
7
8public import Mathlib.LinearAlgebra.Dual.Lemmas
9public import Mathlib.LinearAlgebra.Matrix.Trace
10public import Mathlib.LinearAlgebra.PerfectPairing.Basic
12/-!
13# Frobenius algebras
15A Frobenius algebra is an algebra equipped with a `dual : Dual R A` such that the bilinear form
16`(mul R a).compr₂ dual` is bijective and nondegenerate.
17This means `A ≃ₗ[R] Module.Dual R A` and so over fields, a Frobenius algebra is finite-dimensional.
19We also define the Nakayama automorphism `A ≃ₐ[R] A` such that
20for all `a` and `b`, we have `dual (nakayamaAlgEquiv R A b * a) = dual (a * b)`.
22## Main definitions and results
24* `FrobeniusAlgebra`: the **Frobenius algebra** class, which contains a `dual : Dual R A` such that
25 `mul.compr₂ dual` is bijective
26* `FrobeniusAlgebra.equivDual`: the isomorphism of a Frobenius algebra with its dual
27* `FrobeniusAlgebra.ofLinearEquiv` and `FrobeniusAlgebra.ofBilinForm`: inducing a Frobenius algebra
28 via a linear equivalence `σ : A ≃ₗ[R] Dual R A` or, respectively, via a left-separating bilinear
29 form `σ` such that `σ (a * b) c = σ a (b * c)`
30* `FrobeniusAlgebra.instFiniteDimensional`: a Frobenius algebra over a field is finite-dimensional
31* `FrobeniusAlgebra.nakayamaAlgEquiv`: the Nakayama automorphism such that
32 `dual (nakayamaAlgEquiv R A b * a) = dual (a * b)`
33-/
35variable {R A : Type*} [CommSemiring R]
37open scoped RingTheory.LinearMap
38open LinearMap Module TensorProduct
40public section
42variable (R A) in
class FrobeniusAlgebra newL43–51
43/-- A **Frobenius algebra** is an algebra equipped with a dual such that
44`mul.compr₂ dual` is bijective.
46The bilinear form `mul.compr₂ dual` is nondegenerate. -/
47class FrobeniusAlgebra [NonUnitalNonAssocSemiring A] [Module R A] [SMulCommClass R A A]
48 [IsScalarTower R A A] where
49 /-- The dual of a Frobenius algebra. -/
50 dual : Dual R A
JX-Mo · 2026-10-12

dual sounds weird to me. I think it is just a linear functional. "The dual of a Frobenius algebra" sounds like another algebra.

JX-Mo · 2026-10-13

Should this be part of data so that we write [FrobeniusAlgebra R A Φ] where Φ is the linear functional? I wouldn't assume such functionals are canonical.

themathqueen · 2026-10-17

dual is indeed a weird name for the function, I'll change it.

As for your second question, I think that could be a separate definition IsFrobeniusAlgebra? I guess depends on usefulness

JX-Mo · 2026-10-18

The problem is that if you have two functionals how can you express them in your variable? [FrobeniusAlgebra k A] and [Frobenius k A]??? note that such functionals are not unique, e.g. any nontrivial scaling over a field would again gives one. This natually arises from group algebra: you can use evaluation at one, but you can also take the trace of regular representation differing by the scalar |G|. This feels like writing Module V without the coeff k. I think it is as reasonable as CommRing R which can be IsMulCommutative + Ring in principle.

Another option is to use type synonyms. OK, I am not sure which is better.

JX-Mo · 2026-10-18

I will push the draft SymmNondegenerateAlg soon where I will capital Φ. Probably we should share some notations. Will let you know.

themathqueen · 2026-10-18

Yes you can have multiple Frobenius algebra structures, just like you can have multiple coalgebra and algebra structures. It's usage should be up to the user, this is just the basic framework that allows you to work in this setting.

themathqueen · 2026-10-18

Another option is to use type synonyms

Yes, that's the idea I think. When you want to have multiple structures, you should use type synonyms. For example, see instMulWithConvMatrix where we're using type synonyms to have two separate algebra structures

JX-Mo · 2026-10-20

Here it is #45067

51 bijective_compr₂_mul : Function.Bijective ((mul R A).compr₂ dual)
JX-Mo · 2026-10-12

Can you explain why we use bijective_compr₂_mul as the field? In my Hecke repo, I need a similar class

class SymmNondegenerateAlgebra (k A : Type*) [CommSemiring k] [NonUnitalNonAssocSemiring A]
    [Module k A] [SMulCommClass k A A] [IsScalarTower k A A] where
  functional : A →ₗ[k] k
  isSymm : ∀ a b : A, functional (a * b) = functional (b * a)
  separatingLeft (a : A) : (∀ b : A, functional (a * b) = 0) → a = 0

Note that separatingLeft is weaker than bijective. For infinite dimensional algebras, being bijective is too strong. Is it possible to define a class NondegenerateAlgebra so that both your Frobenius and my SymmNondegenerate extends it?

JX-Mo · 2026-10-12

When you specialize to FiniteDimensional A Ring A, NondegenerateAlgebra will recover your FrobeniusAlgebra

JX-Mo · 2026-10-12

If the generality of FrobeniusAlgebra does not buy anything away from Field k Ring A, I would question why not choose NondegenearteAlgebra as the main API since it has application in the infinite dimensional case.

themathqueen · 2026-10-12

But then it wouldn't induce a coalgebra that satisfies the Frobenius equations (Coalgebra.IsFrobenius). I'll need to think about this more

themathqueen · 2026-10-19

I'm not convinced that we want this in that generality. We'd be losing a lot of usefulness from Frobenius algebras. I think if we do eventually want an almost Frobenius algebra (the one from your definition without the symmetry), then we can add it and have the definition of Frobenius algebra extend it.

JX-Mo · 2026-10-19

I'm not convinced either. For me, Symm is essential. But there is an old annals paper exactly using that definition www.jstor.org/stable/1970189. It seems that this definition is rarely used later, so I am not completely sure.

53namespace FrobeniusAlgebra
55section NonUnital
56variable [NonUnitalNonAssocSemiring A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]
57variable [FrobeniusAlgebra R A]
59variable (R A) in
def equivDual newL60–62
60/-- The isomorphism of a Frobenius algebra with its dual, induced by the linear functional. -/
61@[expose]
62noncomputable def equivDual : A ≃ₗ[R] Module.Dual R A := .ofBijective _ bijective_compr₂_mul
lemma equivDual_apply newL64–64
64@[simp low] lemma equivDual_apply (a : A) : equivDual R A a = (mul R A).compr₂ dual a := rfl
lemma equivDual_apply_apply newL65–65
65lemma equivDual_apply_apply (a b : A) : equivDual R A a b = dual (a * b) := by simp
lemma toLinearMap_equivDual newL66–66
66@[simp] lemma toLinearMap_equivDual : (equivDual R A).toLinearMap = (mul R A).compr₂ dual := rfl
lemma dual_apply_symm_equivDual_mul newL68–69
68@[simp] lemma dual_apply_symm_equivDual_mul (f : Dual R A) (a : A) :
69 dual ((equivDual R A).symm f * a) = f a := by simp [← equivDual_apply_apply]
lemma symm_equivDual_compr₂_mul_dual newL71–72
71@[simp] lemma symm_equivDual_compr₂_mul_dual (a : A) :
72 (equivDual R A).symm (((mul R A).compr₂ dual) a) = a := by simp [equivDual]
lemma forall_dual_mul_left_eq_zero_iff newL74–75
74lemma forall_dual_mul_left_eq_zero_iff {a : A} : (∀ b : A, dual (R := R) (a * b) = 0) ↔ a = 0 :=
75 ⟨fun h ↦ (equivDual R A).injective (by ext; simp [h]), fun h ↦ by simp [h]⟩
lemma forall_dual_mul_right_eq_zero_iff newL77–81
77lemma forall_dual_mul_right_eq_zero_iff {a : A} : (∀ b : A, dual (R := R) (b * a) = 0) ↔ a = 0 := by
78 refine ⟨fun h ↦ ?_, fun h ↦ by simp [h]⟩
79 simp_rw [← forall_dual_mul_left_eq_zero_iff (R := R)]
80 intro x
81 simpa using h ((equivDual R A).symm (dual ∘ₗ (mul R A).flip x))
lemma nondegenerate_equivDual newL83–84
83lemma nondegenerate_equivDual : (equivDual R A).Nondegenerate :=
JX-Mo · 2026-10-12

I think here we have a coe toLinearMap hidden. Should we name the bilinear map (equivDual R A).toLinearMap explicitly?

84 ⟨fun _ ↦ forall_dual_mul_left_eq_zero_iff.mp, fun _ ↦ forall_dual_mul_right_eq_zero_iff.mp⟩
instance (anonymous instance) newL86–88
86instance : FrobeniusAlgebra R R where
87 dual := .id
88 bijective_compr₂_mul := ⟨fun _ _ h ↦ by simpa using congr($h 1), fun f ↦ ⟨f 1, by ext; simp⟩⟩
90end NonUnital
92section NonAssoc
93variable [NonAssocSemiring A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]
abbrev ofLinearEquiv newL95–102
95/-- An algebra with an isomorphism `σ : A ≃ₗ[R] Dual R A` such that
96`σ (a * b) c = σ a (b * c)` induces a Frobenius algebra, where its dual will be `σ.flip 1`. -/
97abbrev ofLinearEquiv (σ : A ≃ₗ[R] Module.Dual R A) (hσ : ∀ a b c : A, σ (a * b) c = σ a (b * c)) :
98 FrobeniusAlgebra R A where
99 dual := σ.toLinearMap.flip 1
100 bijective_compr₂_mul := by
101 convert σ.bijective
102 ext; simp [hσ]
abbrev ofBilinForm newL104–112
104/-- A finite-dimensional algebra with a separating left bilinear form `σ` such that
105`σ (a * b) c = σ a (b * c)` induces a Frobenius algebra, where its dual will be `σ.flip 1`. -/
106noncomputable abbrev ofBilinForm {K A : Type*} [Field K] [Ring A] [Algebra K A]
107 [FiniteDimensional K A] (σ : LinearMap.BilinForm K A) (hσ : σ.SeparatingLeft)
108 (hσ₂ : ∀ a b c : A, σ (a * b) c = σ a (b * c)) : FrobeniusAlgebra K A :=
109 .ofLinearEquiv
110 (.ofBijective σ (by simp [Function.Bijective, ← injective_iff_surjective_of_finrank_eq_finrank,
111 ker_eq_bot.mp (separatingLeft_iff_ker_eq_bot.mp hσ)]))
112 hσ₂
instance instFiniteDimensional newL114–117
114/-- A Frobenius algebra over a field is finite-dimensional. -/
115instance instFiniteDimensional {K A : Type*} [Field K] [Ring A] [Algebra K A]
116 [FrobeniusAlgebra K A] : FiniteDimensional K A :=
117 Basis.linearEquiv_dual_iff_finiteDimensional.mp ⟨equivDual K A⟩
119end NonAssoc
121section Semiring
122variable [Semiring A] [Algebra R A] [Module.IsReflexive R A] [FrobeniusAlgebra R A]
124variable (R A) in
def nakayamaAlgEquiv newL125–130
125/-- The Nakayama automorphism `nakayamaAlgEquiv R A` such that
126`dual (nakayamaAlgEquiv R A b * a) = dual (a * b)` for all `a, b`. -/
127@[expose] noncomputable def nakayamaAlgEquiv : A ≃ₐ[R] A :=
128 .ofLinearEquiv ((equivDual R A).flip.trans (equivDual R A).symm)
129 ((equivDual R A).injective (by simp [LinearMap.ext_iff]))
130 (by simp [← (equivDual R A).injective.eq_iff, LinearMap.ext_iff, mul_assoc])
theorem dual_nakayamaAlgEquiv_mul newL132–134
132@[simp] theorem dual_nakayamaAlgEquiv_mul (a b : A) :
133 dual (R := R) (nakayamaAlgEquiv R A b * a) = dual (a * b) := by
134 simp [nakayamaAlgEquiv, AlgEquiv.ofLinearEquiv]
theorem dual_nakayamaAlgEquiv newL136–138
136@[simp] theorem dual_nakayamaAlgEquiv (a : A) :
137 dual (R := R) (nakayamaAlgEquiv R A a) = dual a := by
138 simpa using dual_nakayamaAlgEquiv_mul 1 a
theorem algEquiv_eq_nakayamaAlgEquiv_iff newL140–143
140theorem algEquiv_eq_nakayamaAlgEquiv_iff {f : A ≃ₐ[R] A} :
141 f = nakayamaAlgEquiv R A ↔ ∀ a b, dual (R := R) (f b * a) = dual (a * b) := by
142 refine ⟨fun h ↦ h ▸ dual_nakayamaAlgEquiv_mul, fun h ↦ AlgEquiv.ext fun a ↦ ?_⟩
143 simp [← bijective_compr₂_mul (R := R).injective.eq_iff, LinearMap.ext_iff, h]
145end Semiring
147open Matrix
abbrev _root_.Matrix.frobeniusAlgebra newL149–160
149/-- Matrix rings induce a natural Frobenius algebra, where the dual is the trace. -/
150noncomputable abbrev _root_.Matrix.frobeniusAlgebra (R n : Type*) [CommSemiring R] [Fintype n] :
151 FrobeniusAlgebra R (Matrix n n R) where
152 dual := traceLinearMap n R R
153 bijective_compr₂_mul := by
154 classical
155 refine ⟨fun a b hab ↦ ?_, fun f ↦ ⟨of fun i j ↦ f (.single j i 1), ext fun x ↦ ?_⟩⟩
156 · simpa [LinearMap.ext_iff, ← ext_iff_trace_mul_right] using hab
157 simp only [compr₂_apply, mul_apply_apply, traceLinearMap_apply, trace, diag_apply, mul_apply,
158 of_apply, mul_comm]
159 simp_rw [← smul_eq_mul, ← map_smul, smul_single, ← map_sum, smul_eq_mul, mul_one]
160 rw [Finset.sum_comm, ← matrix_eq_sum_single]
162attribute [local instance] Matrix.frobeniusAlgebra in
lemma _root_.Matrix.frobeniusAlgebraDual_eq_traceLinearMap newL163–164
163lemma _root_.Matrix.frobeniusAlgebraDual_eq_traceLinearMap (R n : Type*) [CommSemiring R]
164 [Fintype n] : dual (R := R) (A := Matrix n n R) = traceLinearMap n R R := rfl
166end FrobeniusAlgebra

Mathlib/RingTheory/FrobeniusAlgebra/IsFrobenius.lean +160 −0 new file

1/-
2Copyright (c) 2026 Monica Omar. All rights reserved.
3Released under Apache 2.0 license as described in the file LICENSE.
4Authors: Monica Omar
5-/
6module
7
8public import Mathlib.LinearAlgebra.Coevaluation
9public import Mathlib.RingTheory.Coalgebra.IsFrobenius
10public import Mathlib.RingTheory.FrobeniusAlgebra.Basic
12/-!
13# Frobenius algebras and the Frobenius equations
15In this file, we show that a `FrobeniusAlgebra` induces a `Coalgebra`, and that this
16coalgebra satisfies the Frobenius equations (`Coalgebra.IsFrobenius`).
17See `FrobeniusAlgebra.toCoalgebra` and `FrobeniusAlgebra.isFrobenius_toCoalgebra`.
18**Note** that this is not an instance since there can be other non equivalent coalgebras
19on your algebra.
21We also show that a coalgebra that satisfies the Frobenius equations induces
22a natural Frobenius algebra.
23-/
25open scoped RingTheory.LinearMap
26open LinearMap Module TensorProduct
28public section
30namespace FrobeniusAlgebra
31variable {K A : Type*} [Field K] [Ring A] [Algebra K A] [FrobeniusAlgebra K A]
33local notation3 "α" => (TensorProduct.assoc K _ _ _).toLinearMap
34local notation3 "α⁻¹" => (TensorProduct.assoc K _ _ _).symm.toLinearMap
35local notation3 "β" => (TensorProduct.lid K _).toLinearMap
36local notation3 "β⁻¹" => (TensorProduct.lid K _).symm.toLinearMap
37local notation3 "γ" => (TensorProduct.rid K _).toLinearMap
38local notation3 "γ⁻¹" => (TensorProduct.rid K _).symm.toLinearMap
39local notation "rT" => rTensor
40local notation "lT" => lTensor
42variable (K A) in
abbrev comulLeft newL43–45
43/-- The natural left-sided comultiplication. -/
44noncomputable abbrev comulLeft : A →ₗ[K] A ⊗[K] A :=
45 lT A μ[K] ∘ₗ α ∘ₗ rT A (lT A (equivDual K A).symm ∘ₗ coevaluation K A) ∘ₗ β⁻¹
47variable (K A) in
abbrev comulRight newL48–50
48/-- The natural right-sided comultiplication. -/
49noncomputable abbrev comulRight : A →ₗ[K] A ⊗[K] A :=
50 rT A μ[K] ∘ₗ α⁻¹ ∘ₗ lT A (lT A (equivDual K A).symm ∘ₗ coevaluation K A) ∘ₗ γ⁻¹
lemma lTensor_dual_comp_comulLeft_comp_lid newL52–56
52lemma lTensor_dual_comp_comulLeft_comp_lid :
53 lT A dual ∘ₗ comulLeft K A ∘ₗ β = TensorProduct.comm K K A := calc
54 _ = lT A (contractLeft K A) ∘ₗ α ∘ₗ rT A (coevaluation K A) := by
55 ext; simp [coevaluation_apply_one, sum_tmul, mul'_apply]
56 _ = _ := by ext; simp [contractLeft_assoc_coevaluation']
lemma rTensor_comp_comulRight_comp_rid newL58–64
58lemma rTensor_comp_comulRight_comp_rid :
59 rT A dual ∘ₗ comulRight K A ∘ₗ γ = TensorProduct.comm K A K := calc
60 _ = lT K (equivDual K A).symm ∘ₗ
61 (rT (Dual K A) (contractLeft K A) ∘ₗ α⁻¹ ∘ₗ lT (Dual K A) (coevaluation K A)) ∘ₗ
62 rT K (equivDual K A) := by
63 ext; simp [coevaluation_apply_one, tmul_sum, mul'_apply]
64 _ = _ := by ext; simp [contractLeft_assoc_coevaluation]
lemma comulLeft_eq_comulRight newL66–86
66/-- The left-sided and right-sided comultiplication maps are equal. -/
67lemma comulLeft_eq_comulRight : comulLeft K A = comulRight K A := by
68 obtain ⟨S, hS⟩ := exists_finset ((lT A (equivDual K A).symm.toLinearMap ∘ₗ coevaluation K A) 1)
69 ext a
70 calc
71 _ = ∑ p ∈ S, p.1 ⊗ₜ[K] (p.2 * a) := by simp [hS, sum_tmul]
72 _ = ∑ q ∈ S, (∑ p ∈ S, dual (p.2 * (a * q.1)) • p.1) ⊗ₜ[K] q.2 := by
73 simp_rw +singlePass [sum_tmul, Finset.sum_comm]
74 refine Finset.sum_congr rfl fun s hs ↦ ?_
75 have : ∑ x ∈ S, dual (R := K) (s.2 * a * x.1) • x.2 = s.2 * a := by
76 simpa [hS, tmul_sum] using
77 congr(β ($rTensor_comp_comulRight_comp_rid ((s.2 * a) ⊗ₜ[K] 1)))
78 rw [← this]
79 simp [tmul_sum, smul_tmul', mul_assoc]
80 rfl
81 _ = ∑ q ∈ S, (a * q.1) ⊗ₜ[K] q.2 := by
82 have (a : A) : ∑ x ∈ S, dual (R := K) (x.2 * a) • x.1 = a := by
83 simpa [hS, tmul_sum, sum_tmul] using
84 congr(γ ($lTensor_dual_comp_comulLeft_comp_lid (1 ⊗ₜ[K] a)))
85 simp_rw [this]
86 _ = _ := by simp [hS, tmul_sum]
88variable (K A) in
abbrev toCoalgebra newL89–110
89/-- A Frobenius algebra induces a coalgebra that satisfies the Frobenius equations
90(see `isFrobenius_toCoalgebra`).
91**Note** that this is not an instance since there can be other non equivalent coalgebras
92on your algebra. -/
93noncomputable abbrev toCoalgebra : Coalgebra K A where
94 comul := comulLeft K A
95 counit := dual
96 coassoc := by
97 ext
98 nth_rw 2 3 [comulLeft_eq_comulRight]
99 simp only [coe_comp, LinearEquiv.coe_coe, Function.comp_apply,
100 rid_symm_apply, lTensor_tmul, coevaluation_apply_one, tmul_sum, map_sum, assoc_symm_tmul,
101 rTensor_tmul, mul'_apply, lid_symm_apply, sum_tmul, assoc_tmul, mul_assoc]
102 rw [Finset.sum_comm]
103 rTensor_counit_comp_comul := by
104 rw [comulLeft_eq_comulRight, ← (TensorProduct.rid K _).eq_comp_toLinearMap_iff, comp_assoc,
105 rTensor_comp_comulRight_comp_rid]
106 ext; simp
107 lTensor_counit_comp_comul := by
108 rw [← (TensorProduct.lid K _).eq_comp_toLinearMap_iff, comp_assoc,
109 lTensor_dual_comp_comulLeft_comp_lid]
110 ext; simp
112open Coalgebra
114variable (K A) in
115attribute [local instance] toCoalgebra in
theorem isFrobenius_toCoalgebra newL116–122
116/-- The coalgebra coming from a Frobenius algebra satisfies the Frobenius equations. -/
117theorem isFrobenius_toCoalgebra : IsFrobenius K A where
118 left_eq_right := by
119 simp only [IsFrobenius.left_def, IsFrobenius.right_def, comul]
120 nth_rw 1 [comulLeft_eq_comulRight]
121 ext
122 simp [coevaluation_apply_one, tmul_sum, sum_tmul]
abbrev ofIsFrobenius newL124–130
124/-- A coalgebra that satisfies the Frobenius equations is a Frobenius algebra with the counit
125as its dual. -/
126abbrev ofIsFrobenius (R A : Type*) [CommSemiring R] [NonAssocSemiring A] [Module R A]
127 [Coalgebra R A] [SMulCommClass R A A] [IsScalarTower R A A] [IsFrobenius R A] :
128 FrobeniusAlgebra R A where
129 dual := counit
130 bijective_compr₂_mul := IsFrobenius.compr₂_mul_counit_bijective
132attribute [local instance] ofIsFrobenius in
lemma ofIsFrobenius_dual_eq newL133–135
133lemma ofIsFrobenius_dual_eq {R A : Type*} [CommSemiring R] [NonAssocSemiring A] [Module R A]
134 [Coalgebra R A] [SMulCommClass R A A] [IsScalarTower R A A] [IsFrobenius R A] :
135 dual (R := R) (A := A) = counit := rfl
137end FrobeniusAlgebra
139namespace Coalgebra.IsFrobenius
140variable {R A : Type*} [CommSemiring R] [NonAssocSemiring A] [Module R A] [Coalgebra R A]
141 [SMulCommClass R A A] [IsScalarTower R A A] [IsFrobenius R A]
lemma forall_counit_mul_left_eq_zero_iff newL143–147
143/-- The bilinear form `(mul R A).compr₂ counit` is separating left.
144This is the simplified version, see `nondegenerate_compr₂_mul_counit`. -/
145lemma forall_counit_mul_left_eq_zero_iff {a : A} : (∀ b, (ε : _ →ₗ[R] _) (a * b) = 0) ↔ a = 0 :=
146 let := FrobeniusAlgebra.ofIsFrobenius
147 FrobeniusAlgebra.forall_dual_mul_left_eq_zero_iff
lemma forall_counit_mul_right_eq_zero_iff newL149–153
149/-- The bilinear form `(mul R A).compr₂ counit` is separating right.
150This is the simplified version, see `nondegenerate_compr₂_mul_counit`. -/
151lemma forall_counit_mul_right_eq_zero_iff {a : A} : (∀ b, (ε : _ →ₗ[R] _) (b * a) = 0) ↔ a = 0 :=
152 let := FrobeniusAlgebra.ofIsFrobenius
153 FrobeniusAlgebra.forall_dual_mul_right_eq_zero_iff
lemma nondegenerate_compr₂_mul_counit newL155–158
155/-- The bilinear form `mul.compr₂ counit` is nondegenerate. -/
156lemma nondegenerate_compr₂_mul_counit : ((mul R A).compr₂ ε).Nondegenerate :=
157 let := FrobeniusAlgebra.ofIsFrobenius
158 FrobeniusAlgebra.nondegenerate_equivDual
160end Coalgebra.IsFrobenius
0/35 declarations checked

Your review, as Markdown

Paste it as a comment or a review on the PR. Line links to the head commit unfold into code snippets on GitHub.