feat: generalized Kronecker delta definition#1192
Conversation
|
Thank you for this PR, which will now be reviewed. If you are submitting to ./PhyslibAlpha there will be a lighter review process, If you want to bring attention to this PR, please write a message on this |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a Lean definition of the generalized Kronecker delta (as a determinant of a matrix of Kronecker deltas) to the existing KroneckerDelta development.
Changes:
- Introduces a new “Generalized Kronecker delta” section with brief module documentation.
- Defines an integer-valued entry function
δℤfrom the existingkroneckerDelta. - Defines
generalizedKroneckerDeltaasMatrix.det (δℤ (μ i) (ν j)).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| open Matrix | ||
|
|
||
| /-- Integer-valued Kronecker entry via the existing `kroneckerDelta`. -/ | ||
| local notation "δℤ" => (fun ρ σ => ((kroneckerDelta ρ σ : ℕ) : ℤ)) |
There was a problem hiding this comment.
Didn't want to redefine the existing kroneckerDelta without discussion, but open to it.
There was a problem hiding this comment.
I agree with the way you have done this not how copilot is suggesting it. The decision to define the dirac-delta in terms of natural numbers was a deliberate one.
| local notation "δℤ" => (fun ρ σ => ((kroneckerDelta ρ σ : ℕ) : ℤ)) | ||
|
|
||
| /-- Generalized Kronecker delta: | ||
| `δ^{μ₁...μₙ}_{ν₁...νₙ} = det (δ[μᵢ, νⱼ])`. |
There was a problem hiding this comment.
| `δ^{μ₁...μₙ}_{ν₁...νₙ} = det (δ[μᵢ, νⱼ])`. | |
| `δ^{μ₁...μₙ}_{ν₁...νₙ} = det (δ[μᵢ, νⱼ])`. |
Linter is complaining about this trailing whitespace.
| This is defined for any finite type `α` with decidable equality. -/ | ||
| def generalizedKroneckerDelta {α : Type} [DecidableEq α] [Fintype α] (n : ℕ) | ||
| (μ : Fin n → α) (ν : Fin n → α) : ℤ := | ||
| Matrix.det (fun i j => δℤ (μ i) (ν j)) |
There was a problem hiding this comment.
I wonder if this is more general still
| This is defined for any finite type `α` with decidable equality. -/ | |
| def generalizedKroneckerDelta {α : Type} [DecidableEq α] [Fintype α] (n : ℕ) | |
| (μ : Fin n → α) (ν : Fin n → α) : ℤ := | |
| Matrix.det (fun i j => δℤ (μ i) (ν j)) | |
| This is defined for any finite type `α` with decidable equality. -/ | |
| def generalizedKroneckerDelta {α ι : Type} [DecidableEq α] [Fintype α] | |
| [DecidableEq ι] [Fintype ι] | |
| (μ : ι → α) (ν : ι → α) : ℤ := | |
| Matrix.det (fun i j => δℤ (μ i) (ν j)) |
|
Also some build issue here maybe down to a lack of an import? |
This is my first small definitional PR on the way to proving the gamma matrix trace identities in QFT, part assisted by AI and as part of a general Lean learning trajectory:
Review map:
This PR only changes Physlib/Mathematics/KroneckerDelta.lean (where the 1D Kronecker delta is already), and adds the definition of the generalized Kronecker delta. Due to the sign, this must be over ℤ, not just ℕ.
Due to this being inside Physlib, I'm using a d = 3 default spatial dimensions.Indices can be any finite type with decidable equality.Future work:
I'm hoping to extend this gradually (potentially putting some things in PhyslibAlpha) with additional proofs.
and the associated contraction identities (based on
generalizedKroneckerDelta_contraction)and the associated identities.
The heavy lift is the generalized Kronecker delta contraction identity which relies on Laplace expansion (cofactor expansion) and I couldn't find a lot of pre-existing functionality in mathlib. I'm not happy with that and hope to figure out a more compact proof.
AI disclosure
This particular definition is minor enough and has been modified a few times by me (e.g. to prefer ℤ over ℝ, and to reuse the existing definition), but it originates in an AI session. The pitfalls addressed in the AI instructions in #1187 are relevant (i.e. AI reinventing stuff that's already in mathlib).