2024-10-07 12:20:53 +00:00
|
|
|
|
/-
|
|
|
|
|
Copyright (c) 2024 Joseph Tooby-Smith. All rights reserved.
|
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
Authors: Joseph Tooby-Smith
|
|
|
|
|
-/
|
|
|
|
|
import HepLean.Tensors.ColorCat.Basic
|
|
|
|
|
/-!
|
|
|
|
|
|
|
|
|
|
## Tensor trees
|
|
|
|
|
|
|
|
|
|
-/
|
|
|
|
|
|
|
|
|
|
open IndexNotation
|
|
|
|
|
open CategoryTheory
|
|
|
|
|
|
2024-10-08 07:52:55 +00:00
|
|
|
|
/-- The sturcture of a type of tensors e.g. Lorentz tensors, Einstien tensors,
|
|
|
|
|
complex Lorentz tensors.
|
|
|
|
|
Note: This structure is not fully defined yet. -/
|
2024-10-07 12:20:53 +00:00
|
|
|
|
structure TensorStruct where
|
2024-10-08 07:52:55 +00:00
|
|
|
|
/-- The colors of indices e.g. up or down. -/
|
2024-10-07 12:20:53 +00:00
|
|
|
|
C : Type
|
2024-10-08 07:52:55 +00:00
|
|
|
|
/-- The symmetry group acting on these tensor e.g. the Lorentz group or SL(2,ℂ). -/
|
2024-10-07 12:20:53 +00:00
|
|
|
|
G : Type
|
2024-10-08 07:52:55 +00:00
|
|
|
|
/-- An instance of `G` as a group. -/
|
2024-10-07 12:20:53 +00:00
|
|
|
|
G_group : Group G
|
2024-10-08 07:52:55 +00:00
|
|
|
|
/-- The field over which we want to consider the tensors to live in, usually `ℝ` or `ℂ`. -/
|
2024-10-07 12:20:53 +00:00
|
|
|
|
k : Type
|
2024-10-08 07:52:55 +00:00
|
|
|
|
/-- An instance of `k` as a commutative ring. -/
|
2024-10-07 12:20:53 +00:00
|
|
|
|
k_commRing : CommRing k
|
2024-10-08 07:52:55 +00:00
|
|
|
|
/-- A `MonoidalFunctor` from `OverColor C` giving the rep corresponding to a map of colors
|
|
|
|
|
`X → C`. -/
|
2024-10-07 12:20:53 +00:00
|
|
|
|
F : MonoidalFunctor (OverColor C) (Rep k G)
|
2024-10-08 07:52:55 +00:00
|
|
|
|
/-- A map from `C` to `C`. An involution. -/
|
2024-10-07 12:20:53 +00:00
|
|
|
|
τ : C → C
|
2024-10-08 07:52:55 +00:00
|
|
|
|
/-- A specification of the dimension of each color in C. This will be used for explicit
|
|
|
|
|
evaluation of tensors. -/
|
|
|
|
|
evalNo : C → ℕ
|
2024-10-07 12:20:53 +00:00
|
|
|
|
|
|
|
|
|
namespace TensorStruct
|
|
|
|
|
|
|
|
|
|
variable (S : TensorStruct)
|
|
|
|
|
|
|
|
|
|
instance : CommRing S.k := S.k_commRing
|
|
|
|
|
|
|
|
|
|
instance : Group S.G := S.G_group
|
|
|
|
|
|
|
|
|
|
end TensorStruct
|
|
|
|
|
|
2024-10-08 07:52:55 +00:00
|
|
|
|
/-- A syntax tree for tensor expressions. -/
|
2024-10-07 12:20:53 +00:00
|
|
|
|
inductive TensorTree (S : TensorStruct) : ∀ {n : ℕ}, (Fin n → S.C) → Type where
|
2024-10-08 07:52:55 +00:00
|
|
|
|
| tensorNode {n : ℕ} {c : Fin n → S.C} (T : S.F.obj (OverColor.mk c)) : TensorTree S c
|
2024-10-07 12:20:53 +00:00
|
|
|
|
| add {n : ℕ} {c : Fin n → S.C} : TensorTree S c → TensorTree S c → TensorTree S c
|
|
|
|
|
| perm {n m : ℕ} {c : Fin n → S.C} {c1 : Fin m → S.C}
|
|
|
|
|
(σ : (OverColor.mk c) ⟶ (OverColor.mk c1)) (t : TensorTree S c) : TensorTree S c1
|
|
|
|
|
| prod {n m : ℕ} {c : Fin n → S.C} {c1 : Fin m → S.C}
|
|
|
|
|
(t : TensorTree S c) (t1 : TensorTree S c1) : TensorTree S (Sum.elim c c1 ∘ finSumFinEquiv.symm)
|
2024-10-08 15:45:51 +00:00
|
|
|
|
| smul {n : ℕ} {c : Fin n → S.C} : S.k → TensorTree S c → TensorTree S c
|
2024-10-07 12:20:53 +00:00
|
|
|
|
| mult {n m : ℕ} {c : Fin n.succ → S.C} {c1 : Fin m.succ → S.C} :
|
|
|
|
|
(i : Fin n.succ) → (j : Fin m.succ) → TensorTree S c → TensorTree S c1 →
|
|
|
|
|
TensorTree S (Sum.elim (c ∘ Fin.succAbove i) (c1 ∘ Fin.succAbove j) ∘ finSumFinEquiv.symm)
|
|
|
|
|
| contr {n : ℕ} {c : Fin n.succ.succ → S.C} : (i : Fin n.succ.succ) →
|
|
|
|
|
(j : Fin n.succ) → TensorTree S c → TensorTree S (c ∘ Fin.succAbove i ∘ Fin.succAbove j)
|
2024-10-08 07:52:55 +00:00
|
|
|
|
| jiggle {n : ℕ} {c : Fin n → S.C} : (i : Fin n) → TensorTree S c →
|
|
|
|
|
TensorTree S (Function.update c i (S.τ (c i)))
|
2024-10-08 07:26:23 +00:00
|
|
|
|
| eval {n : ℕ} {c : Fin n.succ → S.C} :
|
|
|
|
|
(i : Fin n.succ) → (x : Fin (S.evalNo (c i))) → TensorTree S c →
|
2024-10-08 07:52:55 +00:00
|
|
|
|
TensorTree S (c ∘ Fin.succAbove i)
|
2024-10-07 12:20:53 +00:00
|
|
|
|
|
|
|
|
|
namespace TensorTree
|
|
|
|
|
|
|
|
|
|
variable {S : TensorStruct} {n : ℕ} {c : Fin n → S.C} (T : TensorTree S c)
|
|
|
|
|
|
|
|
|
|
open MonoidalCategory
|
|
|
|
|
open TensorProduct
|
|
|
|
|
|
2024-10-08 07:52:55 +00:00
|
|
|
|
/-- The number of nodes in a tensor tree. -/
|
|
|
|
|
def size : ∀ {n : ℕ} {c : Fin n → S.C}, TensorTree S c → ℕ := fun
|
2024-10-07 12:20:53 +00:00
|
|
|
|
| tensorNode _ => 1
|
|
|
|
|
| add t1 t2 => t1.size + t2.size + 1
|
|
|
|
|
| perm _ t => t.size + 1
|
2024-10-08 15:45:51 +00:00
|
|
|
|
| smul _ t => t.size + 1
|
2024-10-07 12:20:53 +00:00
|
|
|
|
| prod t1 t2 => t1.size + t2.size + 1
|
|
|
|
|
| mult _ _ t1 t2 => t1.size + t2.size + 1
|
|
|
|
|
| contr _ _ t => t.size + 1
|
|
|
|
|
| jiggle _ t => t.size + 1
|
2024-10-08 07:26:23 +00:00
|
|
|
|
| eval _ _ t => t.size + 1
|
2024-10-07 12:20:53 +00:00
|
|
|
|
|
|
|
|
|
noncomputable section
|
|
|
|
|
|
2024-10-08 07:52:55 +00:00
|
|
|
|
/-- The underlying tensor a tensor tree corresponds to.
|
|
|
|
|
Note: This function is not fully defined yet. -/
|
|
|
|
|
def tensor : ∀ {n : ℕ} {c : Fin n → S.C}, TensorTree S c → S.F.obj (OverColor.mk c) := fun
|
2024-10-07 12:20:53 +00:00
|
|
|
|
| tensorNode t => t
|
|
|
|
|
| add t1 t2 => t1.tensor + t2.tensor
|
|
|
|
|
| perm σ t => (S.F.map σ).hom t.tensor
|
2024-10-08 15:45:51 +00:00
|
|
|
|
| smul a t => a • t.tensor
|
2024-10-07 12:20:53 +00:00
|
|
|
|
| prod t1 t2 => (S.F.map (OverColor.equivToIso finSumFinEquiv).hom).hom
|
|
|
|
|
((S.F.μ _ _).hom (t1.tensor ⊗ₜ t2.tensor))
|
|
|
|
|
| _ => 0
|
|
|
|
|
|
|
|
|
|
lemma tensor_tensorNode {c : Fin n → S.C} (T : S.F.obj (OverColor.mk c)) :
|
|
|
|
|
(tensorNode T).tensor = T := rfl
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end TensorTree
|