From a5e9d04941c29cf57476c89f90ccef223a9c106b Mon Sep 17 00:00:00 2001 From: jstoobysmith <72603918+jstoobysmith@users.noreply.github.com> Date: Mon, 17 Jun 2024 14:05:45 -0400 Subject: [PATCH 1/3] feat: Add general definition of Feynman diagrams --- HepLean/FeynmanDiagrams/Basic.lean | 249 +++++++++++++++++++++++++++++ 1 file changed, 249 insertions(+) create mode 100644 HepLean/FeynmanDiagrams/Basic.lean diff --git a/HepLean/FeynmanDiagrams/Basic.lean b/HepLean/FeynmanDiagrams/Basic.lean new file mode 100644 index 0000000..97afc3f --- /dev/null +++ b/HepLean/FeynmanDiagrams/Basic.lean @@ -0,0 +1,249 @@ +/- +Copyright (c) 2024 Joseph Tooby-Smith. All rights reserved. +Released under Apache 2.0 license. +Authors: Joseph Tooby-Smith +-/ +import Mathlib.Logic.Equiv.Fin +import Mathlib.Tactic.FinCases +import Mathlib.Data.Finset.Card +import Mathlib.CategoryTheory.IsomorphismClasses +import Mathlib.CategoryTheory.Functor.Category +import Mathlib.CategoryTheory.Comma.Over +import Mathlib.Data.Fintype.Pi +import Mathlib.CategoryTheory.Limits.Shapes.Terminal +import Mathlib.Data.Fintype.Prod +import Mathlib.Data.Fintype.Perm +import Mathlib.Combinatorics.SimpleGraph.Basic +import Mathlib.Combinatorics.SimpleGraph.Connectivity +import Mathlib.SetTheory.Cardinal.Basic +/-! +# Feynman diagrams + +Feynman diagrams are a graphical representation of the terms in the perturbation expansion of +a quantum field theory. + + +-/ + +open CategoryTheory +/-! + +## The definition of Pre Feynman rules + +We define the notion of a pre-Feynman rule, which specifies the possible +half-edges, edges and vertices in a diagram. It does not specify how to turn a diagram +into an algebraic expression. + +## TODO +Prove that the `halfEdgeLimit` functor lands on limits of functors. + +-/ + +/-- A `PreFeynmanRule` is a set of rules specifying the allowed half-edges, + edges and vertices in a diagram. (It does not specify how to turn the diagram + into an algebraic expression.) -/ +structure PreFeynmanRule where + /-- The type labelling the different half-edges. -/ + HalfEdgeLabel : Type + /-- A type labelling the different types of edges. -/ + EdgeLabel : Type + /-- A type labelling the different types of vertices. -/ + VertexLabel : Type + /-- A function taking `EdgeLabels` to the half edges it contains. -/ + edgeLabelMap : EdgeLabel β†’ CategoryTheory.Over HalfEdgeLabel + /-- A function taking `VertexLabels` to the half edges it contains. -/ + vertexLabelMap : VertexLabel β†’ CategoryTheory.Over HalfEdgeLabel + +namespace PreFeynmanRule + +variable (P : PreFeynmanRule) + +/-- The functor from `Over (P.HalfEdgeLabel Γ— P.EdgeLabel Γ— P.VertexLabel)` + to `Over (P.VertexLabel)` induced by projections on products. -/ +@[simps!] +def toVertex {𝓔 π“₯ : Type} : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯) β₯€ Over π“₯ := + Over.map <| Prod.snd ∘ Prod.snd + +/-- The functor from `Over (P.HalfEdgeLabel Γ— P.EdgeLabel Γ— P.VertexLabel)` + to `Over (P.EdgeLabel)` induced by projections on products. -/ +@[simps!] +def toEdge {𝓔 π“₯ : Type} : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯) β₯€ Over 𝓔 := + Over.map <| Prod.fst ∘ Prod.snd + +/-- The functor from `Over (P.HalfEdgeLabel Γ— P.EdgeLabel Γ— P.VertexLabel)` + to `Over (P.HalfEdgeLabel)` induced by projections on products. -/ +@[simps!] +def toHalfEdge {𝓔 π“₯ : Type} : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯) β₯€ Over P.HalfEdgeLabel := + Over.map Prod.fst + +/-- The functor from `Over P.VertexLabel` to `Type` induced by pull-back along insertion of + `v : P.VertexLabel`. -/ +@[simps!] +def preimageType' {π“₯ : Type} (v : π“₯) : Over π“₯ β₯€ Type where + obj := fun f => f.hom ⁻¹' {v} + map {f g} F := fun x => + ⟨F.left x.1, by + have h := congrFun F.w x + simp only [Functor.const_obj_obj, Functor.id_obj, Functor.id_map, types_comp_apply, + CostructuredArrow.right_eq_id, Functor.const_obj_map, types_id_apply] at h + simpa [h] using x.2⟩ + +/-- The functor from `Over (P.HalfEdgeLabel Γ— P.EdgeLabel Γ— P.VertexLabel)` to + `Over P.HalfEdgeLabel` induced by pull-back along insertion of `v : P.VertexLabel`. -/ +def preimageVertex {𝓔 π“₯ : Type} (v : π“₯) : + Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯) β₯€ Over P.HalfEdgeLabel where + obj f := Over.mk (fun x => Prod.fst (f.hom x.1) : + (P.toVertex β‹™ preimageType' v).obj f ⟢ P.HalfEdgeLabel) + map {f g} F := Over.homMk ((P.toVertex β‹™ preimageType' v).map F) + (funext <| fun x => congrArg Prod.fst <| congrFun F.w x.1) + +/-- The functor from `Over (P.HalfEdgeLabel Γ— P.EdgeLabel Γ— P.VertexLabel)` to + `Over P.HalfEdgeLabel` induced by pull-back along insertion of `v : P.EdgeLabel`. -/ +def preimageEdge {𝓔 π“₯ : Type} (v : 𝓔) : + Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯) β₯€ Over P.HalfEdgeLabel where + obj f := Over.mk (fun x => Prod.fst (f.hom x.1) : + (P.toEdge β‹™ preimageType' v).obj f ⟢ P.HalfEdgeLabel) + map {f g} F := Over.homMk ((P.toEdge β‹™ preimageType' v).map F) + (funext <| fun x => congrArg Prod.fst <| congrFun F.w x.1) + +/-- The proposition on vertices which must be satisfied by an object + `F : Over (P.HalfEdgeLabel Γ— P.EdgeLabel Γ— P.VertexLabel)` for it to be a Feynman diagram. + This condition corresponds to the vertices of `F` having the correct half-edges associated + with them. -/ +def diagramVertexProp {𝓔 π“₯ : Type} (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) + (f : π“₯ ⟢ P.VertexLabel) := + βˆ€ v, IsIsomorphic (P.vertexLabelMap (f v)) ((P.preimageVertex v).obj F) + + +/-- The proposition on edges which must be satisfied by an object + `F : Over (P.HalfEdgeLabel Γ— P.EdgeLabel Γ— P.VertexLabel)` for it to be a Feynman diagram. + This condition corresponds to the edges of `F` having the correct half-edges associated + with them. -/ +def diagramEdgeProp {𝓔 π“₯ : Type} (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) + (f : 𝓔 ⟢ P.EdgeLabel) := + βˆ€ v, IsIsomorphic (P.edgeLabelMap (f v)) ((P.preimageEdge v).obj F) + +/-- The proposition which must be satisfied by an object + `F : Over (P.HalfEdgeLabel Γ— P.EdgeLabel Γ— P.VertexLabel)` for it to be a Feynman diagram. cs-/ +def diagramProp {𝓔 π“₯ : Type} (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) + (f𝓔 : 𝓔 ⟢ P.EdgeLabel) (fπ“₯ : π“₯ ⟢ P.VertexLabel) := + diagramVertexProp P F fπ“₯ ∧ diagramEdgeProp P F f𝓔 + +end PreFeynmanRule + +/-! + +## The definition of Feynman diagrams + +We now define the type of Feynman diagrams for a given pre-Feynman rule. + +-/ + +open PreFeynmanRule + +/-- The type of Feynman diagrams given a `PreFeynmanRule`. -/ +structure FeynmanDiagram (P : PreFeynmanRule) where + /-- The type of edges in the Feynman diagram, labelled by their type. -/ + π“”π“ž : Over P.EdgeLabel + /-- The type of vertices in the Feynman diagram, labelled by their type. -/ + π“₯π“ž : Over P.VertexLabel + /-- The type of half-edges in the Feynman diagram, labelled by their type, the edge it + belongs to, and the vertex they belong to. -/ + 𝓱𝓔To𝓔π“₯ : Over (P.HalfEdgeLabel Γ— π“”π“ž.left Γ— π“₯π“ž.left) + /-- Each edge has the correct type of half edges. -/ + 𝓔Cond : P.diagramEdgeProp 𝓱𝓔 π“”π“ž.hom + /-- Each vertex has the correct sort of half edges. -/ + π“₯Cond : P.diagramVertexProp 𝓱𝓔 π“₯π“ž.hom + +namespace FeynmanDiagram + +variable {P : PreFeynmanRule} (F : FeynmanDiagram P) + +/-- The type of edges. -/ +def 𝓔 : Type := F.π“”π“ž.left + +/-- The type of vertices. -/ +def π“₯ : Type := F.π“₯π“ž.left + +/-- The type of half-edges. -/ +def 𝓱𝓔 : Type := F.𝓱𝓔To𝓔π“₯.left + +/-- The object in Over P.HalfEdgeLabel generated by a Feynman diagram. -/ +def π“±π“”π“ž : Over P.HalfEdgeLabel := P.toHalfEdge.obj F.𝓱𝓔To𝓔π“₯ + +/-- Given two maps `F.π“”π“ž ⟢ G.π“”π“ž` and `F.π“₯π“ž ⟢ G.π“₯π“ž` the corresponding map + `P.HalfEdgeLabel Γ— F.π“”π“ž.left Γ— F.π“₯π“ž.left β†’ P.HalfEdgeLabel Γ— G.π“”π“ž.left Γ— G.π“₯π“ž.left`. -/ +def edgeVertexMap {F G : FeynmanDiagram P} (𝓔 : F.π“”π“ž ⟢ G.π“”π“ž) (π“₯ : F.π“₯π“ž ⟢ G.π“₯π“ž) : + P.HalfEdgeLabel Γ— F.π“”π“ž.left Γ— F.π“₯π“ž.left β†’ P.HalfEdgeLabel Γ— G.π“”π“ž.left Γ— G.π“₯π“ž.left := + fun x => ⟨x.1, 𝓔.left x.2.1, π“₯.left x.2.2⟩ + +/-- The functor of over-categories generated by `edgeVertexMap`. -/ +def edgeVertexFunc {F G : FeynmanDiagram P} (𝓔 : F.π“”π“ž ⟢ G.π“”π“ž) (π“₯ : F.π“₯π“ž ⟢ G.π“₯π“ž) : + Over (P.HalfEdgeLabel Γ— F.π“”π“ž.left Γ— F.π“₯π“ž.left) + β₯€ Over (P.HalfEdgeLabel Γ— G.π“”π“ž.left Γ— G.π“₯π“ž.left) := + Over.map <| edgeVertexMap 𝓔 π“₯ + +/-- A morphism of Feynman diagrams. -/ +structure Hom (F G : FeynmanDiagram P) where + /-- The morphism of edge objects. -/ + 𝓔 : F.π“”π“ž ⟢ G.π“”π“ž + /-- The morphism of vertex objects. -/ + π“₯ : F.π“₯π“ž ⟢ G.π“₯π“ž + /-- The morphism of half-edge objects. -/ + 𝓱𝓔 : (edgeVertexFunc 𝓔 π“₯).obj F.𝓱𝓔To𝓔π“₯ ⟢ G.𝓱𝓔To𝓔π“₯ + +namespace Hom + +/-- The identity morphism for a Feynman diagram. -/ +def id (F : FeynmanDiagram P) : Hom F F where + 𝓔 := πŸ™ F.π“”π“ž + π“₯ := πŸ™ F.π“₯π“ž + 𝓱𝓔 := πŸ™ F.𝓱𝓔To𝓔π“₯ + +/-- The composition of two morphisms of Feynman diagrams. -/ +def comp {F G H : FeynmanDiagram P} (f : Hom F G) (g : Hom G H) : Hom F H where + 𝓔 := f.𝓔 ≫ g.𝓔 + π“₯ := f.π“₯ ≫ g.π“₯ + 𝓱𝓔 := (edgeVertexFunc g.𝓔 g.π“₯).map f.𝓱𝓔 ≫ g.𝓱𝓔 + +lemma ext {F G : FeynmanDiagram P} {f g : Hom F G} (h𝓔 : f.𝓔 = g.𝓔) + (hπ“₯ : f.π“₯ = g.π“₯) (h𝓱𝓔 : f.𝓱𝓔.left = g.𝓱𝓔.left) : f = g := by + cases f + cases g + subst h𝓔 hπ“₯ + simp_all only [mk.injEq, heq_eq_eq, true_and] + ext a : 2 + simp_all only + +end Hom + +/-- Feynman diagrams form a category. -/ +instance : Category (FeynmanDiagram P) where + Hom := Hom + id := Hom.id + comp := Hom.comp + +/-- The functor from Feynman diagrams to category over edge labels. -/ +def toOverEdgeLabel : FeynmanDiagram P β₯€ Over P.EdgeLabel where + obj F := F.π“”π“ž + map f := f.𝓔 + +/-- The functor from Feynman diagrams to category over vertex labels. -/ +def toOverVertexLabel : FeynmanDiagram P β₯€ Over P.VertexLabel where + obj F := F.π“₯π“ž + map f := f.π“₯ + +/-- The functor from Feynman diagrams to category over half-edge labels. -/ +def toOverHalfEdgeLabel : FeynmanDiagram P β₯€ Over P.HalfEdgeLabel where + obj F := F.π“±π“”π“ž + map f := P.toHalfEdge.map f.𝓱𝓔 + +/-- The type of isomorphisms of a Feynman diagram. -/ +def symmetryType : Type := F β‰… F + +/-- The symmetry factor can be defined as the cardinal of the symmetry type. + In general this is not a finite number. -/ +def symmetryFactor : Cardinal := Cardinal.mk (F.symmetryType) + + +end FeynmanDiagram From 0a90f67a46dbe0e0dbe94df349ef560d75ac5bc0 Mon Sep 17 00:00:00 2001 From: jstoobysmith <72603918+jstoobysmith@users.noreply.github.com> Date: Tue, 18 Jun 2024 11:40:36 -0400 Subject: [PATCH 2/3] feat: Generalise Feynman diagrams --- HepLean/FeynmanDiagrams/Basic.lean | 522 ++++++++++++++-- .../Instances/ComplexScalar.lean | 100 +++ HepLean/FeynmanDiagrams/Instances/Phi4.lean | 83 +++ HepLean/FeynmanDiagrams/PhiFour/Basic.lean | 583 ------------------ 4 files changed, 669 insertions(+), 619 deletions(-) create mode 100644 HepLean/FeynmanDiagrams/Instances/ComplexScalar.lean create mode 100644 HepLean/FeynmanDiagrams/Instances/Phi4.lean delete mode 100644 HepLean/FeynmanDiagrams/PhiFour/Basic.lean diff --git a/HepLean/FeynmanDiagrams/Basic.lean b/HepLean/FeynmanDiagrams/Basic.lean index 97afc3f..0230d38 100644 --- a/HepLean/FeynmanDiagrams/Basic.lean +++ b/HepLean/FeynmanDiagrams/Basic.lean @@ -106,6 +106,100 @@ def preimageEdge {𝓔 π“₯ : Type} (v : 𝓔) : map {f g} F := Over.homMk ((P.toEdge β‹™ preimageType' v).map F) (funext <| fun x => congrArg Prod.fst <| congrFun F.w x.1) + +/-! + +## Finitness of pre-Feynman rules + +We define a class of `PreFeynmanRule` which have nice properties with regard to +decidablity and finitness. + +In practice, every pre-Feynman rule considered in the physics literature satisfies these +properties. + +-/ + +class IsFinitePreFeynmanRule (P : PreFeynmanRule) where + edgeLabelDecidable : DecidableEq P.EdgeLabel + vertexLabelDecidable : DecidableEq P.VertexLabel + halfEdgeLabelDecidable : DecidableEq P.HalfEdgeLabel + vertexMapFintype : βˆ€ v : P.VertexLabel, Fintype (P.vertexLabelMap v).left + vertexMapDecidable : βˆ€ v : P.VertexLabel, DecidableEq (P.vertexLabelMap v).left + edgeMapFintype : βˆ€ v : P.EdgeLabel, Fintype (P.edgeLabelMap v).left + edgeMapDecidable : βˆ€ v : P.EdgeLabel, DecidableEq (P.edgeLabelMap v).left + +instance preFeynmanRuleDecEq𝓔 (P : PreFeynmanRule) [IsFinitePreFeynmanRule P] : + DecidableEq P.EdgeLabel := + IsFinitePreFeynmanRule.edgeLabelDecidable + +instance preFeynmanRuleDecEqπ“₯ (P : PreFeynmanRule) [IsFinitePreFeynmanRule P] : + DecidableEq P.VertexLabel := + IsFinitePreFeynmanRule.vertexLabelDecidable + +instance preFeynmanRuleDecEq𝓱𝓔 (P : PreFeynmanRule) [IsFinitePreFeynmanRule P] : + DecidableEq P.HalfEdgeLabel := + IsFinitePreFeynmanRule.halfEdgeLabelDecidable + +instance [IsFinitePreFeynmanRule P] (v : P.VertexLabel) : Fintype (P.vertexLabelMap v).left := + IsFinitePreFeynmanRule.vertexMapFintype v + +instance [IsFinitePreFeynmanRule P] (v : P.VertexLabel) : DecidableEq (P.vertexLabelMap v).left := + IsFinitePreFeynmanRule.vertexMapDecidable v + +instance [IsFinitePreFeynmanRule P] (v : P.EdgeLabel) : Fintype (P.edgeLabelMap v).left := + IsFinitePreFeynmanRule.edgeMapFintype v + +instance [IsFinitePreFeynmanRule P] (v : P.EdgeLabel) : DecidableEq (P.edgeLabelMap v).left := + IsFinitePreFeynmanRule.edgeMapDecidable v + +instance preimageVertexDecidablePred {𝓔 π“₯ : Type} [DecidableEq π“₯] (v : π“₯) + (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) : + DecidablePred fun x => x ∈ (P.toVertex.obj F).hom ⁻¹' {v} := fun y => + match decEq ((P.toVertex.obj F).hom y) v with + | isTrue h => isTrue h + | isFalse h => isFalse h + +instance preimageEdgeDecidablePred {𝓔 π“₯ : Type} [DecidableEq 𝓔] (v : 𝓔) + (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) : + DecidablePred fun x => x ∈ (P.toEdge.obj F).hom ⁻¹' {v} := fun y => + match decEq ((P.toEdge.obj F).hom y) v with + | isTrue h => isTrue h + | isFalse h => isFalse h + +instance preimageVertexDecidable [IsFinitePreFeynmanRule P] {𝓔 π“₯ : Type} (v : π“₯) + (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) [DecidableEq F.left] : + DecidableEq ((P.preimageVertex v).obj F).left := Subtype.instDecidableEq + +instance preimageEdgeDecidable [IsFinitePreFeynmanRule P] {𝓔 π“₯ : Type} (v : 𝓔) + (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) [DecidableEq F.left] : + DecidableEq ((P.preimageEdge v).obj F).left := Subtype.instDecidableEq + +instance preimageVertexFintype [IsFinitePreFeynmanRule P] {𝓔 π“₯ : Type} [DecidableEq π“₯] [Fintype π“₯] + (v : π“₯) (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) [DecidableEq F.left] [h : Fintype F.left] : + Fintype ((P.preimageVertex v).obj F).left := @Subtype.fintype _ _ _ h + +instance preimageEdgeFintype [IsFinitePreFeynmanRule P] {𝓔 π“₯ : Type} [DecidableEq 𝓔] [Fintype 𝓔] + (v : 𝓔) (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) [DecidableEq F.left] [h : Fintype F.left] : + Fintype ((P.preimageEdge v).obj F).left := @Subtype.fintype _ _ _ h + +instance preimageVertexMapFintype [IsFinitePreFeynmanRule P] {𝓔 π“₯ : Type} [Fintype π“₯] + [DecidableEq π“₯] (v : π“₯) (f : π“₯ ⟢ P.VertexLabel) (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) + [DecidableEq F.left] [Fintype F.left]: + Fintype ((P.vertexLabelMap (f v)).left β†’ ((P.preimageVertex v).obj F).left) := + Pi.fintype + +instance preimageEdgeMapFintype [IsFinitePreFeynmanRule P] {𝓔 π“₯ : Type} [Fintype 𝓔] + [DecidableEq 𝓔] (v : 𝓔) (f : 𝓔 ⟢ P.EdgeLabel) (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) + [DecidableEq F.left] [Fintype F.left]: + Fintype ((P.edgeLabelMap (f v)).left β†’ ((P.preimageEdge v).obj F).left) := + Pi.fintype + +/-! + +## Conditions to form a diagram. + +-/ + /-- The proposition on vertices which must be satisfied by an object `F : Over (P.HalfEdgeLabel Γ— P.EdgeLabel Γ— P.VertexLabel)` for it to be a Feynman diagram. This condition corresponds to the vertices of `F` having the correct half-edges associated @@ -114,7 +208,6 @@ def diagramVertexProp {𝓔 π“₯ : Type} (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— (f : π“₯ ⟢ P.VertexLabel) := βˆ€ v, IsIsomorphic (P.vertexLabelMap (f v)) ((P.preimageVertex v).obj F) - /-- The proposition on edges which must be satisfied by an object `F : Over (P.HalfEdgeLabel Γ— P.EdgeLabel Γ— P.VertexLabel)` for it to be a Feynman diagram. This condition corresponds to the edges of `F` having the correct half-edges associated @@ -123,11 +216,56 @@ def diagramEdgeProp {𝓔 π“₯ : Type} (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— (f : 𝓔 ⟢ P.EdgeLabel) := βˆ€ v, IsIsomorphic (P.edgeLabelMap (f v)) ((P.preimageEdge v).obj F) -/-- The proposition which must be satisfied by an object - `F : Over (P.HalfEdgeLabel Γ— P.EdgeLabel Γ— P.VertexLabel)` for it to be a Feynman diagram. cs-/ -def diagramProp {𝓔 π“₯ : Type} (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) - (f𝓔 : 𝓔 ⟢ P.EdgeLabel) (fπ“₯ : π“₯ ⟢ P.VertexLabel) := - diagramVertexProp P F fπ“₯ ∧ diagramEdgeProp P F f𝓔 +lemma diagramVertexProp_iff {𝓔 π“₯ : Type} (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) + (f : π“₯ ⟢ P.VertexLabel) : P.diagramVertexProp F f ↔ + βˆ€ v, βˆƒ (ΞΊ : (P.vertexLabelMap (f v)).left β†’ ((P.preimageVertex v).obj F).left), + Function.Bijective ΞΊ + ∧ ((P.preimageVertex v).obj F).hom ∘ ΞΊ = (P.vertexLabelMap (f v)).hom := by + refine Iff.intro (fun h v => ?_) (fun h v => ?_) + obtain ⟨κ, ΞΊm1, h1, h2⟩ := h v + let f := (Over.forget P.HalfEdgeLabel).mapIso ⟨κ, ΞΊm1, h1, h2⟩ + refine ⟨f.hom, (isIso_iff_bijective f.hom).mp $ Iso.isIso_hom f, ΞΊ.w⟩ + obtain ⟨κ, h1, h2⟩ := h v + let f : (P.vertexLabelMap (f v)) ⟢ ((P.preimageVertex v).obj F) := Over.homMk ΞΊ h2 + have ft : IsIso ((Over.forget P.HalfEdgeLabel).map f) := (isIso_iff_bijective ΞΊ).mpr h1 + obtain ⟨fm, hf1, hf2⟩ := (isIso_of_reflects_iso _ (Over.forget P.HalfEdgeLabel) : IsIso f) + exact ⟨f, fm, hf1, hf2⟩ + +lemma diagramEdgeProp_iff {𝓔 π“₯ : Type} (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) + (f : 𝓔 ⟢ P.EdgeLabel) : P.diagramEdgeProp F f ↔ + βˆ€ v, βˆƒ (ΞΊ : (P.edgeLabelMap (f v)).left β†’ ((P.preimageEdge v).obj F).left), + Function.Bijective ΞΊ + ∧ ((P.preimageEdge v).obj F).hom ∘ ΞΊ = (P.edgeLabelMap (f v)).hom := by + refine Iff.intro (fun h v => ?_) (fun h v => ?_) + obtain ⟨κ, ΞΊm1, h1, h2⟩ := h v + let f := (Over.forget P.HalfEdgeLabel).mapIso ⟨κ, ΞΊm1, h1, h2⟩ + refine ⟨f.hom, (isIso_iff_bijective f.hom).mp $ Iso.isIso_hom f, ΞΊ.w⟩ + obtain ⟨κ, h1, h2⟩ := h v + let f : (P.edgeLabelMap (f v)) ⟢ ((P.preimageEdge v).obj F) := Over.homMk ΞΊ h2 + have ft : IsIso ((Over.forget P.HalfEdgeLabel).map f) := (isIso_iff_bijective ΞΊ).mpr h1 + obtain ⟨fm, hf1, hf2⟩ := (isIso_of_reflects_iso _ (Over.forget P.HalfEdgeLabel) : IsIso f) + exact ⟨f, fm, hf1, hf2⟩ + +instance diagramVertexPropDecidable + [IsFinitePreFeynmanRule P] {𝓔 π“₯ : Type} [Fintype π“₯] [DecidableEq π“₯] + (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) [DecidableEq F.left] [Fintype F.left] + (f : π“₯ ⟢ P.VertexLabel) : Decidable (P.diagramVertexProp F f) := + @decidable_of_decidable_of_iff _ _ + (@Fintype.decidableForallFintype _ _ (fun _ => @Fintype.decidableExistsFintype _ _ + (fun _ => @And.decidable _ _ _ (@Fintype.decidablePiFintype _ _ + (fun _ => P.preFeynmanRuleDecEq𝓱𝓔) _ _ _)) _ ) _) + (P.diagramVertexProp_iff F f).symm + +instance diagramEdgePropDecidable + [IsFinitePreFeynmanRule P] {𝓔 π“₯ : Type} [Fintype 𝓔] [DecidableEq 𝓔] + (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) [DecidableEq F.left] [Fintype F.left] + (f : 𝓔 ⟢ P.EdgeLabel) : Decidable (P.diagramEdgeProp F f) := + @decidable_of_decidable_of_iff _ _ + (@Fintype.decidableForallFintype _ _ (fun _ => @Fintype.decidableExistsFintype _ _ + (fun _ => @And.decidable _ _ _ (@Fintype.decidablePiFintype _ _ + (fun _ => P.preFeynmanRuleDecEq𝓱𝓔) _ _ _)) _ ) _) + (P.diagramEdgeProp_iff F f).symm + end PreFeynmanRule @@ -151,9 +289,9 @@ structure FeynmanDiagram (P : PreFeynmanRule) where belongs to, and the vertex they belong to. -/ 𝓱𝓔To𝓔π“₯ : Over (P.HalfEdgeLabel Γ— π“”π“ž.left Γ— π“₯π“ž.left) /-- Each edge has the correct type of half edges. -/ - 𝓔Cond : P.diagramEdgeProp 𝓱𝓔 π“”π“ž.hom + 𝓔Cond : P.diagramEdgeProp 𝓱𝓔To𝓔π“₯ π“”π“ž.hom /-- Each vertex has the correct sort of half edges. -/ - π“₯Cond : P.diagramVertexProp 𝓱𝓔 π“₯π“ž.hom + π“₯Cond : P.diagramVertexProp 𝓱𝓔To𝓔π“₯ π“₯π“ž.hom namespace FeynmanDiagram @@ -171,79 +309,391 @@ def 𝓱𝓔 : Type := F.𝓱𝓔To𝓔π“₯.left /-- The object in Over P.HalfEdgeLabel generated by a Feynman diagram. -/ def π“±π“”π“ž : Over P.HalfEdgeLabel := P.toHalfEdge.obj F.𝓱𝓔To𝓔π“₯ -/-- Given two maps `F.π“”π“ž ⟢ G.π“”π“ž` and `F.π“₯π“ž ⟢ G.π“₯π“ž` the corresponding map - `P.HalfEdgeLabel Γ— F.π“”π“ž.left Γ— F.π“₯π“ž.left β†’ P.HalfEdgeLabel Γ— G.π“”π“ž.left Γ— G.π“₯π“ž.left`. -/ -def edgeVertexMap {F G : FeynmanDiagram P} (𝓔 : F.π“”π“ž ⟢ G.π“”π“ž) (π“₯ : F.π“₯π“ž ⟢ G.π“₯π“ž) : - P.HalfEdgeLabel Γ— F.π“”π“ž.left Γ— F.π“₯π“ž.left β†’ P.HalfEdgeLabel Γ— G.π“”π“ž.left Γ— G.π“₯π“ž.left := - fun x => ⟨x.1, 𝓔.left x.2.1, π“₯.left x.2.2⟩ +/-! + +## Making a Feynman diagram + +-/ + +/-- The condition which must be satisfied by maps to form a Feynman diagram. -/ +def Cond {𝓔 π“₯ 𝓱𝓔 : Type} (π“”π“ž : 𝓔 β†’ P.EdgeLabel) (π“₯π“ž : π“₯ β†’ P.VertexLabel) + (𝓱𝓔To𝓔π“₯ : 𝓱𝓔 β†’ P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯) : Prop := + P.diagramEdgeProp (Over.mk 𝓱𝓔To𝓔π“₯) π“”π“ž ∧ + P.diagramVertexProp (Over.mk 𝓱𝓔To𝓔π“₯) π“₯π“ž + +lemma cond_self : Cond F.π“”π“ž.hom F.π“₯π“ž.hom F.𝓱𝓔To𝓔π“₯.hom := + ⟨F.𝓔Cond, F.π“₯Cond⟩ + +/-- `Cond` is decidable. -/ +instance CondDecidable [IsFinitePreFeynmanRule P] {𝓔 π“₯ 𝓱𝓔 : Type} (π“”π“ž : 𝓔 β†’ P.EdgeLabel) + (π“₯π“ž : π“₯ β†’ P.VertexLabel) + (𝓱𝓔To𝓔π“₯ : 𝓱𝓔 β†’ P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯) + [Fintype π“₯] [DecidableEq π“₯] [Fintype 𝓔] [DecidableEq 𝓔] [h : Fintype 𝓱𝓔] [DecidableEq 𝓱𝓔] : + Decidable (Cond π“”π“ž π“₯π“ž 𝓱𝓔To𝓔π“₯) := + @And.decidable _ _ + (@diagramEdgePropDecidable P _ _ _ _ _ (Over.mk 𝓱𝓔To𝓔π“₯) _ h π“”π“ž) + (@diagramVertexPropDecidable P _ _ _ _ _ (Over.mk 𝓱𝓔To𝓔π“₯) _ h π“₯π“ž) + + +/-- Making a Feynman diagram from maps of edges, vertices and half-edges. -/ +def mk' {𝓔 π“₯ 𝓱𝓔 : Type} (π“”π“ž : 𝓔 β†’ P.EdgeLabel) (π“₯π“ž : π“₯ β†’ P.VertexLabel) + (𝓱𝓔To𝓔π“₯ : 𝓱𝓔 β†’ P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯) + (C : Cond π“”π“ž π“₯π“ž 𝓱𝓔To𝓔π“₯): FeynmanDiagram P where + π“”π“ž := Over.mk π“”π“ž + π“₯π“ž := Over.mk π“₯π“ž + 𝓱𝓔To𝓔π“₯ := Over.mk 𝓱𝓔To𝓔π“₯ + 𝓔Cond := C.1 + π“₯Cond := C.2 + +lemma mk'_self : mk' F.π“”π“ž.hom F.π“₯π“ž.hom F.𝓱𝓔To𝓔π“₯.hom F.cond_self = F := rfl + +/-! + +## Finitness of Feynman diagrams + +As defined above our Feynman diagrams can have non-finite Types of half-edges etc. +We define the class of those Feynman diagrams which are `finite` in the appropriate sense. +In practice, every Feynman diagram considered in the physics literature is `finite`. + +This finiteness condition will be used to prove certain `Types` are `Fintype`, and prove +that certain propositions are decidable. + +-/ + +class IsFiniteDiagram (F : FeynmanDiagram P) where + 𝓔Fintype : Fintype F.𝓔 + 𝓔DecidableEq : DecidableEq F.𝓔 + π“₯Fintype : Fintype F.π“₯ + π“₯DecidableEq : DecidableEq F.π“₯ + 𝓱𝓔Fintype : Fintype F.𝓱𝓔 + 𝓱𝓔DecidableEq : DecidableEq F.𝓱𝓔 + +instance {F : FeynmanDiagram P} [IsFiniteDiagram F] : Fintype F.𝓔 := + IsFiniteDiagram.𝓔Fintype + +instance {F : FeynmanDiagram P} [IsFiniteDiagram F] : DecidableEq F.𝓔 := + IsFiniteDiagram.𝓔DecidableEq + +instance {F : FeynmanDiagram P} [IsFiniteDiagram F] : Fintype F.π“₯ := + IsFiniteDiagram.π“₯Fintype + +instance {F : FeynmanDiagram P} [IsFiniteDiagram F] : DecidableEq F.π“₯ := + IsFiniteDiagram.π“₯DecidableEq + +instance {F : FeynmanDiagram P} [IsFiniteDiagram F] : Fintype F.𝓱𝓔 := + IsFiniteDiagram.𝓱𝓔Fintype + +instance {F : FeynmanDiagram P} [IsFiniteDiagram F] : DecidableEq F.𝓱𝓔 := + IsFiniteDiagram.𝓱𝓔DecidableEq + +instance fintypeProdHalfEdgeLabel𝓔π“₯ {F : FeynmanDiagram P} [IsFinitePreFeynmanRule P] + [IsFiniteDiagram F] : DecidableEq (P.HalfEdgeLabel Γ— F.𝓔 Γ— F.π“₯) := + instDecidableEqProd + +/-! + +## Morphisms of Feynman diagrams + +We define a morphism between Feynman diagrams, and properties thereof. +This will be used to define the category of Feynman diagrams. + +-/ + +/-- Given two maps `F.𝓔 ⟢ G.𝓔` and `F.π“₯ ⟢ G.π“₯` the corresponding map + `P.HalfEdgeLabel Γ— F.𝓔 Γ— F.π“₯ β†’ P.HalfEdgeLabel Γ— G.𝓔 Γ— G.π“₯`. -/ +@[simps!] +def edgeVertexMap {F G : FeynmanDiagram P} (𝓔 : F.𝓔 ⟢ G.𝓔) (π“₯ : F.π“₯ ⟢ G.π“₯) : + P.HalfEdgeLabel Γ— F.𝓔 Γ— F.π“₯ β†’ P.HalfEdgeLabel Γ— G.𝓔 Γ— G.π“₯ := + fun x => ⟨x.1, 𝓔 x.2.1, π“₯ x.2.2⟩ + +/-- Given equivalences `F.𝓔 ≃ G.𝓔` and `F.π“₯ ≃ G.π“₯`, the induced equivalence between + `P.HalfEdgeLabel Γ— F.𝓔 Γ— F.π“₯` and `P.HalfEdgeLabel Γ— G.𝓔 Γ— G.π“₯ ` -/ +def edgeVertexEquiv {F G : FeynmanDiagram P} (𝓔 : F.𝓔 ≃ G.𝓔) (π“₯ : F.π“₯ ≃ G.π“₯) : + P.HalfEdgeLabel Γ— F.𝓔 Γ— F.π“₯ ≃ P.HalfEdgeLabel Γ— G.𝓔 Γ— G.π“₯ where + toFun := edgeVertexMap 𝓔.toFun π“₯.toFun + invFun := edgeVertexMap 𝓔.invFun π“₯.invFun + left_inv := by aesop_cat + right_inv := by aesop_cat /-- The functor of over-categories generated by `edgeVertexMap`. -/ -def edgeVertexFunc {F G : FeynmanDiagram P} (𝓔 : F.π“”π“ž ⟢ G.π“”π“ž) (π“₯ : F.π“₯π“ž ⟢ G.π“₯π“ž) : - Over (P.HalfEdgeLabel Γ— F.π“”π“ž.left Γ— F.π“₯π“ž.left) - β₯€ Over (P.HalfEdgeLabel Γ— G.π“”π“ž.left Γ— G.π“₯π“ž.left) := +@[simps!] +def edgeVertexFunc {F G : FeynmanDiagram P} (𝓔 : F.𝓔 ⟢ G.𝓔) (π“₯ : F.π“₯ ⟢ G.π“₯) : + Over (P.HalfEdgeLabel Γ— F.𝓔 Γ— F.π“₯) β₯€ Over (P.HalfEdgeLabel Γ— G.𝓔 Γ— G.π“₯) := Over.map <| edgeVertexMap 𝓔 π“₯ /-- A morphism of Feynman diagrams. -/ structure Hom (F G : FeynmanDiagram P) where /-- The morphism of edge objects. -/ - 𝓔 : F.π“”π“ž ⟢ G.π“”π“ž + π“”π“ž : F.π“”π“ž ⟢ G.π“”π“ž /-- The morphism of vertex objects. -/ - π“₯ : F.π“₯π“ž ⟢ G.π“₯π“ž + π“₯π“ž : F.π“₯π“ž ⟢ G.π“₯π“ž /-- The morphism of half-edge objects. -/ - 𝓱𝓔 : (edgeVertexFunc 𝓔 π“₯).obj F.𝓱𝓔To𝓔π“₯ ⟢ G.𝓱𝓔To𝓔π“₯ + 𝓱𝓔To𝓔π“₯ : (edgeVertexFunc π“”π“ž.left π“₯π“ž.left).obj F.𝓱𝓔To𝓔π“₯ ⟢ G.𝓱𝓔To𝓔π“₯ + namespace Hom +variable {F G : FeynmanDiagram P} +variable (f : Hom F G) + +/-- The map `F.𝓔 β†’ G.𝓔` induced by a homomorphism of Feynman diagrams. -/ +@[simp] +def 𝓔 : F.𝓔 β†’ G.𝓔 := f.π“”π“ž.left + +/-- The map `F.π“₯ β†’ G.π“₯` induced by a homomorphism of Feynman diagrams. -/ +@[simp] +def π“₯ : F.π“₯ β†’ G.π“₯ := f.π“₯π“ž.left + +/-- The map `F.𝓱𝓔 β†’ G.𝓱𝓔` induced by a homomorphism of Feynman diagrams. -/ +@[simp] +def 𝓱𝓔 : F.𝓱𝓔 β†’ G.𝓱𝓔 := f.𝓱𝓔To𝓔π“₯.left + + +/-- The morphism `F.π“±π“”π“ž ⟢ G.π“±π“”π“ž` induced by a homomorphism of Feynman diagrams. -/ +@[simp] +def π“±π“”π“ž : F.π“±π“”π“ž ⟢ G.π“±π“”π“ž := P.toHalfEdge.map f.𝓱𝓔To𝓔π“₯ + /-- The identity morphism for a Feynman diagram. -/ def id (F : FeynmanDiagram P) : Hom F F where - 𝓔 := πŸ™ F.π“”π“ž - π“₯ := πŸ™ F.π“₯π“ž - 𝓱𝓔 := πŸ™ F.𝓱𝓔To𝓔π“₯ + π“”π“ž := πŸ™ F.π“”π“ž + π“₯π“ž := πŸ™ F.π“₯π“ž + 𝓱𝓔To𝓔π“₯ := πŸ™ F.𝓱𝓔To𝓔π“₯ /-- The composition of two morphisms of Feynman diagrams. -/ +@[simps!] def comp {F G H : FeynmanDiagram P} (f : Hom F G) (g : Hom G H) : Hom F H where - 𝓔 := f.𝓔 ≫ g.𝓔 - π“₯ := f.π“₯ ≫ g.π“₯ - 𝓱𝓔 := (edgeVertexFunc g.𝓔 g.π“₯).map f.𝓱𝓔 ≫ g.𝓱𝓔 + π“”π“ž := f.π“”π“ž ≫ g.π“”π“ž + π“₯π“ž := f.π“₯π“ž ≫ g.π“₯π“ž + 𝓱𝓔To𝓔π“₯ := (edgeVertexFunc g.𝓔 g.π“₯).map f.𝓱𝓔To𝓔π“₯ ≫ g.𝓱𝓔To𝓔π“₯ -lemma ext {F G : FeynmanDiagram P} {f g : Hom F G} (h𝓔 : f.𝓔 = g.𝓔) - (hπ“₯ : f.π“₯ = g.π“₯) (h𝓱𝓔 : f.𝓱𝓔.left = g.𝓱𝓔.left) : f = g := by +lemma ext' {F G : FeynmanDiagram P} {f g : Hom F G} (h𝓔 : f.π“”π“ž = g.π“”π“ž) + (hπ“₯ : f.π“₯π“ž = g.π“₯π“ž) (h𝓱𝓔 : f.𝓱𝓔 = g.𝓱𝓔) : f = g := by cases f cases g subst h𝓔 hπ“₯ simp_all only [mk.injEq, heq_eq_eq, true_and] ext a : 2 - simp_all only + simp only [𝓱𝓔] at h𝓱𝓔 + exact congrFun h𝓱𝓔 a + +lemma ext {F G : FeynmanDiagram P} {f g : Hom F G} (h𝓔 : f.𝓔 = g.𝓔) + (hπ“₯ : f.π“₯ = g.π“₯) (h𝓱𝓔 : f.𝓱𝓔 = g.𝓱𝓔) : f = g := + ext' (Over.OverMorphism.ext h𝓔) (Over.OverMorphism.ext hπ“₯) h𝓱𝓔 + +def Cond {F G : FeynmanDiagram P} (𝓔 : F.𝓔 β†’ G.𝓔) (π“₯ : F.π“₯ β†’ G.π“₯) (𝓱𝓔 : F.𝓱𝓔 β†’ G.𝓱𝓔) : Prop := + (βˆ€ x, G.π“”π“ž.hom (𝓔 x) = F.π“”π“ž.hom x) ∧ + (βˆ€ x, G.π“₯π“ž.hom (π“₯ x) = F.π“₯π“ž.hom x) ∧ + (βˆ€ x, G.𝓱𝓔To𝓔π“₯.hom (𝓱𝓔 x) = edgeVertexMap 𝓔 π“₯ (F.𝓱𝓔To𝓔π“₯.hom x)) + +lemma cond_satisfied {F G : FeynmanDiagram P} (f : Hom F G) : + Cond f.𝓔 f.π“₯ f.𝓱𝓔 := + ⟨fun x => congrFun f.π“”π“ž.w x, fun x => congrFun f.π“₯π“ž.w x, fun x => congrFun f.𝓱𝓔To𝓔π“₯.w x ⟩ + +lemma cond_symm {F G : FeynmanDiagram P} (𝓔 : F.𝓔 ≃ G.𝓔) (π“₯ : F.π“₯ ≃ G.π“₯) (𝓱𝓔 : F.𝓱𝓔 ≃ G.𝓱𝓔) + (h : Cond 𝓔 π“₯ 𝓱𝓔) : Cond 𝓔.symm π“₯.symm 𝓱𝓔.symm := by + refine ⟨?_, ?_, ?_⟩ + simpa using fun x => (h.1 (𝓔.symm x)).symm + simpa using fun x => (h.2.1 (π“₯.symm x)).symm + intro x + have h1 := h.2.2 (𝓱𝓔.symm x) + simp at h1 + exact (edgeVertexEquiv 𝓔 π“₯).apply_eq_iff_eq_symm_apply.mp (h1).symm + +instance {F G : FeynmanDiagram P} [IsFiniteDiagram F] [IsFinitePreFeynmanRule P] + (𝓔 : F.𝓔 β†’ G.𝓔) : Decidable (βˆ€ x, G.π“”π“ž.hom (𝓔 x) = F.π“”π“ž.hom x) := + @Fintype.decidableForallFintype _ _ (fun _ => preFeynmanRuleDecEq𝓔 P _ _) _ + +instance {F G : FeynmanDiagram P} [IsFiniteDiagram F] [IsFinitePreFeynmanRule P] + (π“₯ : F.π“₯ β†’ G.π“₯) : Decidable (βˆ€ x, G.π“₯π“ž.hom (π“₯ x) = F.π“₯π“ž.hom x) := + @Fintype.decidableForallFintype _ _ (fun _ => preFeynmanRuleDecEqπ“₯ P _ _) _ + +instance {F G : FeynmanDiagram P} [IsFiniteDiagram F] [IsFiniteDiagram G] [IsFinitePreFeynmanRule P] + (𝓔 : F.𝓔 β†’ G.𝓔) (π“₯ : F.π“₯ β†’ G.π“₯) (𝓱𝓔 : F.𝓱𝓔 β†’ G.𝓱𝓔) : + Decidable (βˆ€ x, G.𝓱𝓔To𝓔π“₯.hom (𝓱𝓔 x) = edgeVertexMap 𝓔 π“₯ (F.𝓱𝓔To𝓔π“₯.hom x)) := + @Fintype.decidableForallFintype _ _ (fun _ => fintypeProdHalfEdgeLabel𝓔π“₯ _ _) _ + +instance {F G : FeynmanDiagram P} [IsFiniteDiagram F] [IsFiniteDiagram G] [IsFinitePreFeynmanRule P] + (𝓔 : F.𝓔 β†’ G.𝓔) (π“₯ : F.π“₯ β†’ G.π“₯) (𝓱𝓔 : F.𝓱𝓔 β†’ G.𝓱𝓔) : Decidable (Cond 𝓔 π“₯ 𝓱𝓔) := + And.decidable + + +/-- Making a Feynman diagram from maps of edges, vertices and half-edges. -/ +@[simps!] +def mk' {F G : FeynmanDiagram P} (𝓔 : F.𝓔 β†’ G.𝓔) (π“₯ : F.π“₯ β†’ G.π“₯) (𝓱𝓔 : F.𝓱𝓔 β†’ G.𝓱𝓔) + (C : Cond 𝓔 π“₯ 𝓱𝓔) : Hom F G where + π“”π“ž := Over.homMk 𝓔 $ funext C.1 + π“₯π“ž := Over.homMk π“₯ $ funext C.2.1 + 𝓱𝓔To𝓔π“₯ := Over.homMk 𝓱𝓔 $ funext C.2.2 + +lemma mk'_self {F G : FeynmanDiagram P} (f : Hom F G) : + mk' f.𝓔 f.π“₯ f.𝓱𝓔 f.cond_satisfied = f := rfl end Hom +/-! + +## The Category of Feynman diagrams + +Feynman diagrams, as defined above, form a category. +We will be able to use this category to define the symmetry factor of a Feynman diagram, +and the condition on whether a diagram is connected. +-/ + /-- Feynman diagrams form a category. -/ +@[simps!] instance : Category (FeynmanDiagram P) where Hom := Hom id := Hom.id comp := Hom.comp +/-- An isomorphism of Feynman diagrams from isomorphisms of edges, vertices and half-edges. -/ +def mkIso {F G : FeynmanDiagram P} (𝓔 : F.𝓔 ≃ G.𝓔) (π“₯ : F.π“₯ ≃ G.π“₯) (𝓱𝓔 : F.𝓱𝓔 ≃ G.𝓱𝓔) + (C : Hom.Cond 𝓔 π“₯ 𝓱𝓔) : F β‰… G where + hom := Hom.mk' 𝓔 π“₯ 𝓱𝓔 C + inv := Hom.mk' 𝓔.symm π“₯.symm 𝓱𝓔.symm (Hom.cond_symm 𝓔 π“₯ 𝓱𝓔 C) + hom_inv_id := by + apply Hom.ext + all_goals + aesop_cat + inv_hom_id := by + apply Hom.ext + all_goals + aesop_cat + /-- The functor from Feynman diagrams to category over edge labels. -/ -def toOverEdgeLabel : FeynmanDiagram P β₯€ Over P.EdgeLabel where +def funcπ“”π“ž : FeynmanDiagram P β₯€ Over P.EdgeLabel where obj F := F.π“”π“ž - map f := f.𝓔 + map f := f.π“”π“ž /-- The functor from Feynman diagrams to category over vertex labels. -/ -def toOverVertexLabel : FeynmanDiagram P β₯€ Over P.VertexLabel where +def funcπ“₯π“ž : FeynmanDiagram P β₯€ Over P.VertexLabel where obj F := F.π“₯π“ž - map f := f.π“₯ + map f := f.π“₯π“ž /-- The functor from Feynman diagrams to category over half-edge labels. -/ -def toOverHalfEdgeLabel : FeynmanDiagram P β₯€ Over P.HalfEdgeLabel where +def funcπ“±π“”π“ž : FeynmanDiagram P β₯€ Over P.HalfEdgeLabel where obj F := F.π“±π“”π“ž - map f := P.toHalfEdge.map f.𝓱𝓔 + map f := f.π“±π“”π“ž + +/-- The functor from Feynman diagrams to `Type` landing on edges. -/ +def func𝓔 : FeynmanDiagram P β₯€ Type where + obj F := F.𝓔 + map f := f.𝓔 + +/-- The functor from Feynman diagrams to `Type` landing on vertices. -/ +def funcπ“₯ : FeynmanDiagram P β₯€ Type where + obj F := F.π“₯ + map f := f.π“₯ + +/-- The functor from Feynman diagrams to `Type` landing on half-edges. -/ +def func𝓱𝓔 : FeynmanDiagram P β₯€ Type where + obj F := F.𝓱𝓔 + map f := f.𝓱𝓔 + +section symmetryFactor +/-! +## Symmetry factors + +The symmetry factor of a Feynman diagram is the cardinality of the group of automorphisms of that +diagram. + +We show that the symmetry factor for a finite Feynman diagram is finite. + +-/ /-- The type of isomorphisms of a Feynman diagram. -/ -def symmetryType : Type := F β‰… F +def SymmetryType : Type := F β‰… F + + +/-- An equivalence between `SymmetryType` and permutation of edges, vertices and half-edges + satisfying `Hom.Cond`. -/ +def symmetryTypeEquiv : + F.SymmetryType ≃ {S : Equiv.Perm F.𝓔 Γ— Equiv.Perm F.π“₯ Γ— Equiv.Perm F.𝓱𝓔 // + Hom.Cond S.1 S.2.1 S.2.2} where + toFun f := ⟨⟨(func𝓔.mapIso f).toEquiv, (funcπ“₯.mapIso f).toEquiv, + (func𝓱𝓔.mapIso f).toEquiv⟩, f.1.cond_satisfied⟩ + invFun S := mkIso S.1.1 S.1.2.1 S.1.2.2 S.2 + left_inv _ := rfl + right_inv _ := rfl + +instance [IsFinitePreFeynmanRule P] [IsFiniteDiagram F] : Fintype F.SymmetryType := + Fintype.ofEquiv _ F.symmetryTypeEquiv.symm /-- The symmetry factor can be defined as the cardinal of the symmetry type. In general this is not a finite number. -/ -def symmetryFactor : Cardinal := Cardinal.mk (F.symmetryType) +@[simp] +def cardSymmetryFactor : Cardinal := Cardinal.mk (F.SymmetryType) +@[simp] +def symmetryFactor [IsFinitePreFeynmanRule P] [IsFiniteDiagram F] : β„• := + (Fintype.card F.SymmetryType) + +@[simp] +lemma symmetryFactor_eq_cardSymmetryFactor [IsFinitePreFeynmanRule P] [IsFiniteDiagram F] : + F.symmetryFactor = F.cardSymmetryFactor := by + simp only [symmetryFactor, cardSymmetryFactor, Cardinal.mk_fintype] + +end symmetryFactor + +section connectedness +/-! + +## Connectedness + +Given a Feynman diagram we can create a simple graph based on the obvious adjacency relation. +A feynman diagram is connected if its simple graph is connected. + +## TODO + +- Complete this section. + +-/ + +/-- A relation on the vertices of Feynman diagrams. The proposition is true if the two + vertices are not equal and are connected by a single edge. -/ +@[simp] +def adjRelation : F.π“₯ β†’ F.π“₯ β†’ Prop := fun x y => + x β‰  y ∧ + βˆƒ (a b : F.𝓱𝓔), ((F.𝓱𝓔To𝓔π“₯.hom a).2.1 = (F.𝓱𝓔To𝓔π“₯.hom b).2.1 + ∧ (F.𝓱𝓔To𝓔π“₯.hom a).2.2 = x ∧ (F.𝓱𝓔To𝓔π“₯.hom b).2.2 = y) + +instance [IsFinitePreFeynmanRule P] [IsFiniteDiagram F] : DecidableRel F.adjRelation := fun _ _ => + @And.decidable _ _ _ $ + @Fintype.decidableExistsFintype _ _ (fun _ => @Fintype.decidableExistsFintype _ _ ( + fun _ => @And.decidable _ _ (instDecidableEq𝓔OfIsFiniteDiagram _ _) $ + @And.decidable _ _ (instDecidableEqπ“₯OfIsFiniteDiagram _ _) + (instDecidableEqπ“₯OfIsFiniteDiagram _ _)) _ ) _ + + +/-- From a Feynman diagram the simple graph showing those vertices which are connected. -/ +def toSimpleGraph : SimpleGraph F.π“₯ where + Adj := adjRelation F + symm := by + intro x y h + apply And.intro (Ne.symm h.1) + obtain ⟨a, b, hab⟩ := h.2 + use b, a + simp_all only [adjRelation, ne_eq, and_self] + loopless := by + intro x h + simp at h + +instance [IsFinitePreFeynmanRule P] [IsFiniteDiagram F] : DecidableRel F.toSimpleGraph.Adj := + instDecidableRelπ“₯AdjRelationOfIsFinitePreFeynmanRuleOfIsFiniteDiagram F + +instance [IsFinitePreFeynmanRule P] [IsFiniteDiagram F] : + Decidable (F.toSimpleGraph.Preconnected ∧ Nonempty F.π“₯) := + @And.decidable _ _ _ $ decidable_of_iff _ Finset.univ_nonempty_iff + +instance [IsFinitePreFeynmanRule P] [IsFiniteDiagram F] : Decidable F.toSimpleGraph.Connected := + decidable_of_iff _ (SimpleGraph.connected_iff F.toSimpleGraph).symm + +/-- We say a Feynman diagram is connected if its simple graph is connected. -/ +def Connected : Prop := F.toSimpleGraph.Connected + +instance [IsFinitePreFeynmanRule P] [IsFiniteDiagram F] : Decidable (Connected F) := + instDecidableConnectedπ“₯ToSimpleGraphOfIsFinitePreFeynmanRuleOfIsFiniteDiagram F + +end connectedness end FeynmanDiagram diff --git a/HepLean/FeynmanDiagrams/Instances/ComplexScalar.lean b/HepLean/FeynmanDiagrams/Instances/ComplexScalar.lean new file mode 100644 index 0000000..22801c8 --- /dev/null +++ b/HepLean/FeynmanDiagrams/Instances/ComplexScalar.lean @@ -0,0 +1,100 @@ +/- +Copyright (c) 2024 Joseph Tooby-Smith. All rights reserved. +Released under Apache 2.0 license. +Authors: Joseph Tooby-Smith +-/ +import HepLean.FeynmanDiagrams.Basic +/-! +# Feynman diagrams in a complex scalar field theory + + + +-/ + + +namespace PhiFour +open CategoryTheory +open FeynmanDiagram +open PreFeynmanRule + +@[simps!] +def complexScalarFeynmanRules : PreFeynmanRule where + /- There is 2 types of `half-edge`. -/ + HalfEdgeLabel := Fin 2 + /- There is only 1 type of `edge`. -/ + EdgeLabel := Fin 1 + /- There are two types of `vertex`, two external `0` and internal `1`. -/ + VertexLabel := Fin 3 + edgeLabelMap x := + match x with + | 0 => Over.mk ![0, 1] + vertexLabelMap x := + match x with + | 0 => Over.mk ![0] + | 1 => Over.mk ![1] + | 2 => Over.mk ![0, 0, 1, 1] + +instance (a : β„•) : OfNat complexScalarFeynmanRules.EdgeLabel a where + ofNat := (a : Fin _) + +instance (a : β„•) : OfNat complexScalarFeynmanRules.HalfEdgeLabel a where + ofNat := (a : Fin _) + +instance (a : β„•) : OfNat complexScalarFeynmanRules.VertexLabel a where + ofNat := (a : Fin _) + + +instance : IsFinitePreFeynmanRule complexScalarFeynmanRules where + edgeLabelDecidable := instDecidableEqFin _ + vertexLabelDecidable := instDecidableEqFin _ + halfEdgeLabelDecidable := instDecidableEqFin _ + vertexMapFintype := fun v => + match v with + | 0 => Fin.fintype _ + | 1 => Fin.fintype _ + | 2 => Fin.fintype _ + edgeMapFintype := fun v => + match v with + | 0 => Fin.fintype _ + vertexMapDecidable := fun v => + match v with + | 0 => instDecidableEqFin _ + | 1 => instDecidableEqFin _ + | 2 => instDecidableEqFin _ + edgeMapDecidable := fun v => + match v with + | 0 => instDecidableEqFin _ + + + + + +set_option maxRecDepth 1000 in +def loopProp : FeynmanDiagram complexScalarFeynmanRules := + mk' ![0, 0, 0] ![0, 2, 1] ![⟨0, 0, 0⟩, ⟨1, 0, 1⟩, + ⟨0, 1, 1⟩, ⟨1, 1, 1⟩, ⟨0, 2, 1⟩, ⟨1, 2, 2⟩] (by decide) + +instance : IsFiniteDiagram loopProp where + 𝓔Fintype := Fin.fintype _ + 𝓔DecidableEq := instDecidableEqFin _ + π“₯Fintype := Fin.fintype _ + π“₯DecidableEq := instDecidableEqFin _ + 𝓱𝓔Fintype := Fin.fintype _ + 𝓱𝓔DecidableEq := instDecidableEqFin _ + +def prop : FeynmanDiagram complexScalarFeynmanRules := + mk' ![0] ![0, 1] ![⟨0, 0, 0⟩, ⟨1, 0, 1⟩] (by decide) + +instance : IsFiniteDiagram prop where + 𝓔Fintype := Fin.fintype _ + 𝓔DecidableEq := instDecidableEqFin _ + π“₯Fintype := Fin.fintype _ + π“₯DecidableEq := instDecidableEqFin _ + 𝓱𝓔Fintype := Fin.fintype _ + 𝓱𝓔DecidableEq := instDecidableEqFin _ + +lemma prop_symmetryFactor_eq_one : symmetryFactor prop = 1 := by decide + + + +end PhiFour diff --git a/HepLean/FeynmanDiagrams/Instances/Phi4.lean b/HepLean/FeynmanDiagrams/Instances/Phi4.lean new file mode 100644 index 0000000..ef1d5e6 --- /dev/null +++ b/HepLean/FeynmanDiagrams/Instances/Phi4.lean @@ -0,0 +1,83 @@ +/- +Copyright (c) 2024 Joseph Tooby-Smith. All rights reserved. +Released under Apache 2.0 license. +Authors: Joseph Tooby-Smith +-/ +import HepLean.FeynmanDiagrams.Basic +/-! +# Feynman diagrams in Phi^4 theory + +The aim of this file is to start building up the theory of Feynman diagrams in the context of +Phi^4 theory. + + +-/ + + +namespace PhiFour +open CategoryTheory +open FeynmanDiagram +open PreFeynmanRule + +@[simps!] +def phi4PreFeynmanRules : PreFeynmanRule where + /- There is only 1 type of `half-edge`. -/ + HalfEdgeLabel := Fin 1 + /- There is only 1 type of `edge`. -/ + EdgeLabel := Fin 1 + /- There are two types of `vertex`, external `0` and internal `1`. -/ + VertexLabel := Fin 2 + edgeLabelMap x := + match x with + | 0 => Over.mk ![0, 0] + vertexLabelMap x := + match x with + | 0 => Over.mk ![0] + | 1 => Over.mk ![0, 0, 0, 0] + +instance (a : β„•) : OfNat phi4PreFeynmanRules.EdgeLabel a where + ofNat := (a : Fin _) + +instance (a : β„•) : OfNat phi4PreFeynmanRules.HalfEdgeLabel a where + ofNat := (a : Fin _) + +instance (a : β„•) : OfNat phi4PreFeynmanRules.VertexLabel a where + ofNat := (a : Fin _) + + +instance : IsFinitePreFeynmanRule phi4PreFeynmanRules where + edgeLabelDecidable := instDecidableEqFin _ + vertexLabelDecidable := instDecidableEqFin _ + halfEdgeLabelDecidable := instDecidableEqFin _ + vertexMapFintype := fun v => + match v with + | 0 => Fin.fintype _ + | 1 => Fin.fintype _ + edgeMapFintype := fun v => + match v with + | 0 => Fin.fintype _ + vertexMapDecidable := fun v => + match v with + | 0 => instDecidableEqFin _ + | 1 => instDecidableEqFin _ + edgeMapDecidable := fun v => + match v with + | 0 => instDecidableEqFin _ + + +def figureEight : FeynmanDiagram phi4PreFeynmanRules := + mk' ![0, 0] ![1] ![⟨0, 0, 0⟩, ⟨0, 0, 0⟩, ⟨0, 1, 0⟩, ⟨0, 1, 0⟩] (by decide) + +instance : IsFiniteDiagram figureEight where + 𝓔Fintype := Fin.fintype _ + 𝓔DecidableEq := instDecidableEqFin _ + π“₯Fintype := Fin.fintype _ + π“₯DecidableEq := instDecidableEqFin _ + 𝓱𝓔Fintype := Fin.fintype _ + 𝓱𝓔DecidableEq := instDecidableEqFin _ + +#eval symmetryFactor figureEight + +#eval Connected figureEight + +end PhiFour diff --git a/HepLean/FeynmanDiagrams/PhiFour/Basic.lean b/HepLean/FeynmanDiagrams/PhiFour/Basic.lean deleted file mode 100644 index 6291b2c..0000000 --- a/HepLean/FeynmanDiagrams/PhiFour/Basic.lean +++ /dev/null @@ -1,583 +0,0 @@ -/- -Copyright (c) 2024 Joseph Tooby-Smith. All rights reserved. -Released under Apache 2.0 license. -Authors: Joseph Tooby-Smith --/ -import Mathlib.Logic.Equiv.Fin -import Mathlib.Tactic.FinCases -import Mathlib.Data.Finset.Card -import Mathlib.CategoryTheory.IsomorphismClasses -import Mathlib.Data.Fintype.Pi -import Mathlib.CategoryTheory.Limits.Shapes.Terminal -import Mathlib.Data.Fintype.Prod -import Mathlib.Data.Fintype.Perm -import Mathlib.Combinatorics.SimpleGraph.Basic -import Mathlib.Combinatorics.SimpleGraph.Connectivity -/-! -# Feynman diagrams in Phi^4 theory - -The aim of this file is to start building up the theory of Feynman diagrams in the context of -Phi^4 theory. - -## References - -- The approach taking to defining Feynman diagrams is based on: - -Theo Johnson-Freyd (https://mathoverflow.net/users/78/theo-johnson-freyd), How to count symmetry -factors of Feynman diagrams? , URL (version: 2010-06-03): https://mathoverflow.net/q/26938 - -## TODO - -- Develop a way to display Feynman diagrams. -- Define a connected diagram. -- Define the Feynman rules, and perform an example calculation. -- Determine an efficent way to calculate symmetry factors. Currently there is a method, but -it will not work for large diagrams as it scales factorially with the number of half-edges. - --/ - -namespace PhiFour -open CategoryTheory - -/-- Edges in Ξ¦^4 internal `0`. - Here `Type` is the category in which half-edges live. In general `Type` will be e.g. - `Type Γ— Type` with more fields. -/ -def edgeType : Fin 1 β†’ Type - | 0 => Fin 2 - -/-- Vertices in Ξ¦^4, can either be `external` corresponding to `0`, or a `phi^4` interaction -corresponding to `1`. -/ -def vertexType : Fin 2 β†’ Type - | 0 => Fin 1 - | 1 => Fin 4 - -/-- The type of vacuum Feynman diagrams for Phi-4 theory. -/ -structure FeynmanDiagram where - /-- The type of half edges in the Feynman diagram. Sometimes also called `flags`. -/ - 𝓱𝓔 : Type - /-- The type of edges in the Feynman diagram. -/ - 𝓔 : Type - /-- Maps each edge to a label. Labels `0` if it is an external edge, - and labels `1` if an internal edge. -/ - 𝓔Label : 𝓔 β†’ Fin 1 - /-- Maps half-edges to edges. -/ - 𝓱𝓔To𝓔 : 𝓱𝓔 β†’ 𝓔 - /-- Requires that the fiber of the map `𝓱𝓔To𝓔` at `x ∈ 𝓔` agrees with the corresponding - `edgeType`. -/ - 𝓔Fiber : βˆ€ x, CategoryTheory.IsIsomorphic (𝓱𝓔To𝓔 ⁻¹' {x} : Type) $ (edgeType ∘ 𝓔Label) x - /-- The type of vertices in the Feynman diagram. -/ - π“₯ : Type - /-- Maps each vertex to a label. In this case this map contains no information since - there is only one type of vertex.. -/ - π“₯Label : π“₯ β†’ Fin 2 - /-- Maps half-edges to vertices. -/ - 𝓱𝓔Toπ“₯ : 𝓱𝓔 β†’ π“₯ - /-- Requires that the fiber of the map `𝓱𝓔Toπ“₯` at `x ∈ π“₯` agrees with the corresponding - `vertexType`. -/ - π“₯Fiber : βˆ€ x, CategoryTheory.IsIsomorphic (𝓱𝓔Toπ“₯ ⁻¹' {x} : Type) $ (vertexType ∘ π“₯Label) x - -namespace FeynmanDiagram - -variable (F : FeynmanDiagram) - -section Decidability -/-! - -## Decidability - -The aim of this section is to make it easy to prove the `𝓔Fiber` and `π“₯Fiber` conditions by -showing that they are decidable in cases when everything is finite and nice -(which in practice is always). - ---/ - -lemma fiber_cond_edge_iff_exists {𝓱𝓔 𝓔 : Type} (𝓱𝓔To𝓔 : 𝓱𝓔 β†’ 𝓔) (𝓔Label : 𝓔 β†’ Fin 1) (x : 𝓔) : - (CategoryTheory.IsIsomorphic (𝓱𝓔To𝓔 ⁻¹' {x} : Type) $ (edgeType ∘ 𝓔Label) x) - ↔ βˆƒ (f : 𝓱𝓔To𝓔 ⁻¹' {x} β†’ (edgeType ∘ 𝓔Label) x), Function.Bijective f := - Iff.intro - (fun h ↦ match h with - | ⟨f1, f2, h1, h2⟩ => ⟨f1, (isIso_iff_bijective f1).mp ⟨f2, h1, h2⟩⟩) - (fun ⟨f1, hb⟩ ↦ match (isIso_iff_bijective f1).mpr hb with - | ⟨f2, h1, h2⟩ => ⟨f1, f2, h1, h2⟩) - -lemma fiber_cond_vertex_iff_exists {𝓱π“₯ π“₯ : Type} (𝓱π“₯Toπ“₯ : 𝓱π“₯ β†’ π“₯) (π“₯Label : π“₯ β†’ Fin 2) (x : π“₯) : - (CategoryTheory.IsIsomorphic (𝓱π“₯Toπ“₯ ⁻¹' {x} : Type) $ (vertexType ∘ π“₯Label) x) - ↔ βˆƒ (f : 𝓱π“₯Toπ“₯ ⁻¹' {x} β†’ (vertexType ∘ π“₯Label) x), Function.Bijective f := - Iff.intro - (fun h ↦ match h with - | ⟨f1, f2, h1, h2⟩ => ⟨f1, (isIso_iff_bijective f1).mp ⟨f2, h1, h2⟩⟩) - (fun ⟨f1, hb⟩ ↦ match (isIso_iff_bijective f1).mpr hb with - | ⟨f2, h1, h2⟩ => ⟨f1, f2, h1, h2⟩) - -instance {𝓱𝓔 𝓔 : Type} [DecidableEq 𝓔] (𝓱𝓔To𝓔 : 𝓱𝓔 β†’ 𝓔) (x : 𝓔): - DecidablePred (fun y => y ∈ 𝓱𝓔To𝓔 ⁻¹' {x}) := fun y => - match decEq (𝓱𝓔To𝓔 y) x with - | isTrue h => isTrue h - | isFalse h => isFalse h - - -instance {𝓱𝓔 𝓔 : Type} [DecidableEq 𝓱𝓔] (𝓱𝓔To𝓔 : 𝓱𝓔 β†’ 𝓔) (x : 𝓔) : - DecidableEq $ (𝓱𝓔To𝓔 ⁻¹' {x}) := Subtype.instDecidableEq - -instance edgeTypeFintype (x : Fin 1) : Fintype (edgeType x) := - match x with - | 0 => Fin.fintype 2 - -instance edgeTypeDecidableEq (x : Fin 1) : DecidableEq (edgeType x) := - match x with - | 0 => instDecidableEqFin 2 - -instance vertexTypeFintype (x : Fin 2) : Fintype (vertexType x) := - match x with - | 0 => Fin.fintype 1 - | 1 => Fin.fintype 4 - -instance vertexTypeDecidableEq (x : Fin 2) : DecidableEq (vertexType x) := - match x with - | 0 => instDecidableEqFin 1 - | 1 => instDecidableEqFin 4 - -instance {𝓔 : Type} (𝓔Label : 𝓔 β†’ Fin 1) (x : 𝓔) : - DecidableEq ((edgeType ∘ 𝓔Label) x) := edgeTypeDecidableEq (𝓔Label x) - -instance {𝓔 : Type} (𝓔Label : 𝓔 β†’ Fin 1) (x : 𝓔) : - Fintype ((edgeType ∘ 𝓔Label) x) := edgeTypeFintype (𝓔Label x) - -instance {π“₯ : Type} (π“₯Label : π“₯ β†’ Fin 2) (x : π“₯) : - DecidableEq ((vertexType ∘ π“₯Label) x) := vertexTypeDecidableEq (π“₯Label x) - -instance {π“₯ : Type} (π“₯Label : π“₯ β†’ Fin 2) (x : π“₯) : - Fintype ((vertexType ∘ π“₯Label) x) := vertexTypeFintype (π“₯Label x) - - -instance {𝓱𝓔 𝓔 : Type} [Fintype 𝓱𝓔] [DecidableEq 𝓱𝓔] [DecidableEq 𝓔] - (𝓱𝓔To𝓔 : 𝓱𝓔 β†’ 𝓔) (𝓔Label : 𝓔 β†’ Fin 1) (x : 𝓔) : - Decidable (CategoryTheory.IsIsomorphic (𝓱𝓔To𝓔 ⁻¹' {x} : Type) $ (edgeType ∘ 𝓔Label) x) := - decidable_of_decidable_of_iff (fiber_cond_edge_iff_exists 𝓱𝓔To𝓔 𝓔Label x).symm - -instance {𝓱π“₯ π“₯ : Type} [Fintype 𝓱π“₯] [DecidableEq 𝓱π“₯] [DecidableEq π“₯] - (𝓱π“₯Toπ“₯ : 𝓱π“₯ β†’ π“₯) (π“₯Label : π“₯ β†’ Fin 2) (x : π“₯) : - Decidable (CategoryTheory.IsIsomorphic (𝓱π“₯Toπ“₯ ⁻¹' {x} : Type) $ (vertexType ∘ π“₯Label) x) := - decidable_of_decidable_of_iff (fiber_cond_vertex_iff_exists 𝓱π“₯Toπ“₯ π“₯Label x).symm - -end Decidability - -section Finiteness -/-! -## Finiteness - -As defined above our Feynman diagrams can have non-finite Types of half-edges etc. -We define the class of those Feynman diagrams which are `finite` in the appropriate sense. -In practice, every Feynman diagram considered in the physics literature is `finite`. - --/ - -/-- A Feynman diagram is said to be finite if its type of half-edges, edges and vertices -are finite and decidable. -/ -class IsFiniteDiagram (F : FeynmanDiagram) where - /-- The type `𝓔` is finite. -/ - 𝓔Fintype : Fintype F.𝓔 - /-- The type `𝓔` is decidable. -/ - 𝓔DecidableEq : DecidableEq F.𝓔 - /-- The type `π“₯` is finite. -/ - π“₯Fintype : Fintype F.π“₯ - /-- The type `π“₯` is decidable. -/ - π“₯DecidableEq : DecidableEq F.π“₯ - /-- The type `𝓱𝓔` is finite. -/ - 𝓱𝓔Fintype : Fintype F.𝓱𝓔 - /-- The type `𝓱𝓔` is decidable. -/ - 𝓱𝓔DecidableEq : DecidableEq F.𝓱𝓔 - -instance {F : FeynmanDiagram} [IsFiniteDiagram F] : Fintype F.𝓔 := - IsFiniteDiagram.𝓔Fintype - -instance {F : FeynmanDiagram} [IsFiniteDiagram F] : DecidableEq F.𝓔 := - IsFiniteDiagram.𝓔DecidableEq - -instance {F : FeynmanDiagram} [IsFiniteDiagram F] : Fintype F.π“₯ := - IsFiniteDiagram.π“₯Fintype - -instance {F : FeynmanDiagram} [IsFiniteDiagram F] : DecidableEq F.π“₯ := - IsFiniteDiagram.π“₯DecidableEq - -instance {F : FeynmanDiagram} [IsFiniteDiagram F] : Fintype F.𝓱𝓔 := - IsFiniteDiagram.𝓱𝓔Fintype - -instance {F : FeynmanDiagram} [IsFiniteDiagram F] : DecidableEq F.𝓱𝓔 := - IsFiniteDiagram.𝓱𝓔DecidableEq - -instance {F : FeynmanDiagram} [IsFiniteDiagram F] : Decidable (Nonempty F.π“₯) := - decidable_of_iff _ Finset.univ_nonempty_iff - -end Finiteness - -section categoryOfFeynmanDiagrams -/-! - -## The category of Feynman diagrams - -Feynman diagrams, as defined above, form a category. -We will be able to use this category to define the symmetry factor of a Feynman diagram, -and the condition on whether a diagram is connected. - --/ -/-- A morphism between two `FeynmanDiagram`. -/ -structure Hom (F1 F2 : FeynmanDiagram) where - /-- A morphism between half-edges. -/ - 𝓱𝓔 : F1.𝓱𝓔 ⟢ F2.𝓱𝓔 - /-- A morphism between edges. -/ - 𝓔 : F1.𝓔 ⟢ F2.𝓔 - /-- A morphism between vertices. -/ - π“₯ : F1.π“₯ ⟢ F2.π“₯ - /-- The morphism between edges must respect the labels. -/ - 𝓔Label : F1.𝓔Label = F2.𝓔Label ∘ 𝓔 - /-- The morphism between vertices must respect the labels. -/ - π“₯Label : F1.π“₯Label = F2.π“₯Label ∘ π“₯ - /-- The morphism between edges and half-edges must commute with `𝓱𝓔To𝓔`. -/ - 𝓱𝓔To𝓔 : 𝓔 ∘ F1.𝓱𝓔To𝓔 = F2.𝓱𝓔To𝓔 ∘ 𝓱𝓔 - /-- The morphism between vertices and half-edges must commute with `𝓱𝓔Toπ“₯`. -/ - 𝓱𝓔Toπ“₯ : π“₯ ∘ F1.𝓱𝓔Toπ“₯ = F2.𝓱𝓔Toπ“₯ ∘ 𝓱𝓔 - -namespace Hom - -lemma ext {F1 F2 : FeynmanDiagram} {f g : Hom F1 F2} (h1 : f.𝓱𝓔 = g.𝓱𝓔) - (h2 : f.𝓔 = g.𝓔) (h3 : f.π“₯ = g.π“₯) : f = g := by - cases f; cases g - simp_all only - -/-- The identity morphism from a Feynman diagram to itself. -/ -@[simps!] -def id (F : FeynmanDiagram) : Hom F F where - 𝓱𝓔 := πŸ™ F.𝓱𝓔 - 𝓔 := πŸ™ F.𝓔 - π“₯ := πŸ™ F.π“₯ - 𝓔Label := rfl - π“₯Label := rfl - 𝓱𝓔To𝓔 := rfl - 𝓱𝓔Toπ“₯ := rfl - -/-- Composition of morphisms between Feynman diagrams. -/ -@[simps!] -def comp {F1 F2 F3 : FeynmanDiagram} (f : Hom F1 F2) (g : Hom F2 F3) : Hom F1 F3 where - 𝓱𝓔 := f.𝓱𝓔 ≫ g.𝓱𝓔 - 𝓔 := f.𝓔 ≫ g.𝓔 - π“₯ := f.π“₯ ≫ g.π“₯ - 𝓔Label := by - ext - simp [f.𝓔Label, g.𝓔Label] - π“₯Label := by - ext x - simp [f.π“₯Label, g.π“₯Label] - 𝓱𝓔To𝓔 := by - rw [types_comp, types_comp, Function.comp.assoc] - rw [f.𝓱𝓔To𝓔, ← Function.comp.assoc, g.𝓱𝓔To𝓔] - rfl - 𝓱𝓔Toπ“₯ := by - rw [types_comp, types_comp, Function.comp.assoc] - rw [f.𝓱𝓔Toπ“₯, ← Function.comp.assoc, g.𝓱𝓔Toπ“₯] - rfl - -/-- The condition on a triplet of maps for them to form a morphism of Feynman diagrams. -/ -def Cond {F1 F2 : FeynmanDiagram} (f𝓱𝓔 : F1.𝓱𝓔 β†’ F2.𝓱𝓔) (f𝓔 : F1.𝓔 β†’ F2.𝓔) - (fπ“₯ : F1.π“₯ β†’ F2.π“₯) : Prop := - F1.𝓔Label = F2.𝓔Label ∘ f𝓔 ∧ F1.π“₯Label = F2.π“₯Label ∘ fπ“₯ ∧ - f𝓔 ∘ F1.𝓱𝓔To𝓔 = F2.𝓱𝓔To𝓔 ∘ f𝓱𝓔 ∧ fπ“₯ ∘ F1.𝓱𝓔Toπ“₯ = F2.𝓱𝓔Toπ“₯ ∘ f𝓱𝓔 - -instance {F1 F2 : FeynmanDiagram} [IsFiniteDiagram F1] [IsFiniteDiagram F2] - (f𝓱𝓔 : F1.𝓱𝓔 β†’ F2.𝓱𝓔) (f𝓔 : F1.𝓔 β†’ F2.𝓔) (fπ“₯ : F1.π“₯ β†’ F2.π“₯) : - Decidable (Cond f𝓱𝓔 f𝓔 fπ“₯) := - @And.decidable _ _ _ $ - @And.decidable _ _ _ $ - @And.decidable _ _ _ _ - -end Hom - -@[simps!] -instance : Category FeynmanDiagram where - Hom := Hom - id := Hom.id - comp := Hom.comp - - -/-- The functor from the category of Feynman diagrams to `Type` taking a feynman diagram - to its set of half-edges. -/ -def toHalfEdges : FeynmanDiagram β₯€ Type where - obj F := F.𝓱𝓔 - map f := f.𝓱𝓔 - -/-- The functor from the category of Feynman diagrams to `Type` taking a feynman diagram - to its set of edges. -/ -def toEdges : FeynmanDiagram β₯€ Type where - obj F := F.𝓔 - map f := f.𝓔 - -/-- The functor from the category of Feynman diagrams to `Type` taking a feynman diagram - to its set of vertices. -/ -def toVertices : FeynmanDiagram β₯€ Type where - obj F := F.π“₯ - map f := f.π“₯ - -lemma 𝓱𝓔_bijective_of_isIso {F1 F2 : FeynmanDiagram} (f : F1 ⟢ F2) [IsIso f] : - f.𝓱𝓔.Bijective := - (isIso_iff_bijective f.𝓱𝓔).mp $ Functor.map_isIso toHalfEdges f - -lemma 𝓔_bijective_of_isIso {F1 F2 : FeynmanDiagram} (f : F1 ⟢ F2) [IsIso f] : - f.𝓔.Bijective := - (isIso_iff_bijective f.𝓔).mp $ Functor.map_isIso toEdges f - -lemma π“₯_bijective_of_isIso {F1 F2 : FeynmanDiagram} (f : F1 ⟢ F2) [IsIso f] : - f.π“₯.Bijective := - (isIso_iff_bijective f.π“₯).mp $ Functor.map_isIso toVertices f - -/-- An isomorphism formed from an equivalence between the types of half-edges, edges and vertices - satisfying the appropriate conditions. -/ -def mkIso {F1 F2 : FeynmanDiagram} (f𝓱𝓔 : F1.𝓱𝓔 ≃ F2.𝓱𝓔) - (f𝓔 : F1.𝓔 ≃ F2.𝓔) (fπ“₯ : F1.π“₯ ≃ F2.π“₯) - (h𝓔Label : F1.𝓔Label = F2.𝓔Label ∘ f𝓔) - (hπ“₯Label : F1.π“₯Label = F2.π“₯Label ∘ fπ“₯) - (h𝓱𝓔To𝓔 : f𝓔 ∘ F1.𝓱𝓔To𝓔 = F2.𝓱𝓔To𝓔 ∘ f𝓱𝓔) - (h𝓱𝓔Toπ“₯ : fπ“₯ ∘ F1.𝓱𝓔Toπ“₯ = F2.𝓱𝓔Toπ“₯ ∘ f𝓱𝓔) : F1 β‰… F2 where - hom := Hom.mk f𝓱𝓔 f𝓔 fπ“₯ h𝓔Label hπ“₯Label h𝓱𝓔To𝓔 h𝓱𝓔Toπ“₯ - inv := Hom.mk f𝓱𝓔.symm f𝓔.symm fπ“₯.symm - (((Iso.eq_inv_comp f𝓔.toIso).mpr h𝓔Label.symm).trans (types_comp _ _)) - (((Iso.eq_inv_comp fπ“₯.toIso).mpr hπ“₯Label.symm).trans (types_comp _ _)) - ((Iso.comp_inv_eq f𝓔.toIso).mpr $ (Iso.eq_inv_comp f𝓱𝓔.toIso).mpr $ - (types_comp _ _).symm.trans (Eq.trans h𝓱𝓔To𝓔.symm (types_comp _ _))) - ((Iso.comp_inv_eq fπ“₯.toIso).mpr $ (Iso.eq_inv_comp f𝓱𝓔.toIso).mpr $ - (types_comp _ _).symm.trans (Eq.trans h𝓱𝓔Toπ“₯.symm (types_comp _ _))) - hom_inv_id := by - apply Hom.ext - ext a - simp only [instCategory_comp_𝓱𝓔, Equiv.symm_apply_apply, instCategory_id_𝓱𝓔] - ext a - simp only [instCategory_comp_𝓔, Equiv.symm_apply_apply, instCategory_id_𝓔] - ext a - simp only [instCategory_comp_π“₯, Equiv.symm_apply_apply, instCategory_id_π“₯] - inv_hom_id := by - apply Hom.ext - ext a - simp only [instCategory_comp_𝓱𝓔, Equiv.apply_symm_apply, instCategory_id_𝓱𝓔] - ext a - simp only [instCategory_comp_𝓔, Equiv.apply_symm_apply, instCategory_id_𝓔] - ext a - simp only [instCategory_comp_π“₯, Equiv.apply_symm_apply, instCategory_id_π“₯] - -lemma isIso_of_bijections {F1 F2 : FeynmanDiagram} (f : F1 ⟢ F2) - (h𝓱𝓔 : f.𝓱𝓔.Bijective) (h𝓔 : f.𝓔.Bijective) (hπ“₯ : f.π“₯.Bijective) : - IsIso f := - Iso.isIso_hom $ mkIso (Equiv.ofBijective f.𝓱𝓔 h𝓱𝓔) (Equiv.ofBijective f.𝓔 h𝓔) - (Equiv.ofBijective f.π“₯ hπ“₯) f.𝓔Label f.π“₯Label f.𝓱𝓔To𝓔 f.𝓱𝓔Toπ“₯ - - -lemma isIso_iff_all_bijective {F1 F2 : FeynmanDiagram} (f : F1 ⟢ F2) : - IsIso f ↔ f.𝓱𝓔.Bijective ∧ f.𝓔.Bijective ∧ f.π“₯.Bijective := - Iff.intro - (fun _ ↦ βŸ¨π“±π“”_bijective_of_isIso f, 𝓔_bijective_of_isIso f, π“₯_bijective_of_isIso f⟩) - (fun ⟨h𝓱𝓔, h𝓔, hπ“₯⟩ ↦ isIso_of_bijections f h𝓱𝓔 h𝓔 hπ“₯) - -/-- An equivalence between the isomorphism class of a Feynman diagram an - permutations of the half-edges, edges and vertices satisfying the `Hom.cond`. -/ -def isoEquivBijec {F : FeynmanDiagram} : - (F β‰… F) ≃ {S : Equiv.Perm F.𝓱𝓔 Γ— Equiv.Perm F.𝓔 Γ— Equiv.Perm F.π“₯ // - Hom.Cond S.1 S.2.1 S.2.2} where - toFun f := ⟨⟨(toHalfEdges.mapIso f).toEquiv, - (toEdges.mapIso f).toEquiv , (toVertices.mapIso f).toEquiv⟩, - f.hom.𝓔Label, f.hom.π“₯Label, f.hom.𝓱𝓔To𝓔, f.hom.𝓱𝓔Toπ“₯⟩ - invFun S := mkIso S.1.1 S.1.2.1 S.1.2.2 S.2.1 S.2.2.1 S.2.2.2.1 S.2.2.2.2 - left_inv _ := rfl - right_inv _ := rfl - -instance {F : FeynmanDiagram} [IsFiniteDiagram F] : - Fintype (F β‰… F) := - Fintype.ofEquiv _ isoEquivBijec.symm - -end categoryOfFeynmanDiagrams - -section symmetryFactors -/-! -## Symmetry factors - -The symmetry factor of a Feynman diagram is the cardinality of the group of automorphisms of that -diagram. In this section we define symmetry factors for Feynman diagrams which are -finite. - --/ - -/-- The symmetry factor is the cardinality of the set of isomorphisms of the Feynman diagram. -/ -def symmetryFactor (F : FeynmanDiagram) [IsFiniteDiagram F] : β„• := - Fintype.card (F β‰… F) - -end symmetryFactors - -section connectedness -/-! - -## Connectedness - -Given a Feynman diagram we can create a simple graph based on the obvious adjacency relation. -A feynman diagram is connected if its simple graph is connected. - --/ - -/-- A relation on the vertices of Feynman diagrams. The proposition is true if the two - vertices are not equal and are connected by a single edge. -/ -@[simp] -def adjRelation (F : FeynmanDiagram) : F.π“₯ β†’ F.π“₯ β†’ Prop := fun x y => - x β‰  y ∧ - βˆƒ (a b : F.𝓱𝓔), F.𝓱𝓔To𝓔 a = F.𝓱𝓔To𝓔 b ∧ F.𝓱𝓔Toπ“₯ a = x ∧ F.𝓱𝓔Toπ“₯ b = y - -/-- From a Feynman diagram the simple graph showing those vertices which are connected. -/ -def toSimpleGraph (F : FeynmanDiagram) : SimpleGraph F.π“₯ where - Adj := adjRelation F - symm := by - intro x y h - apply And.intro (Ne.symm h.1) - obtain ⟨a, b, hab⟩ := h.2 - exact ⟨b, a, ⟨hab.1.symm, hab.2.2, hab.2.1⟩⟩ - loopless := by - intro x h - simp at h - -instance {F : FeynmanDiagram} [IsFiniteDiagram F] : DecidableRel F.toSimpleGraph.Adj := fun _ _ => - And.decidable - -instance {F : FeynmanDiagram} [IsFiniteDiagram F] : - Decidable (F.toSimpleGraph.Preconnected ∧ Nonempty F.π“₯) := - @And.decidable _ _ _ _ - -instance {F : FeynmanDiagram} [IsFiniteDiagram F] : Decidable F.toSimpleGraph.Connected := - decidable_of_iff _ (SimpleGraph.connected_iff F.toSimpleGraph).symm - -/-- We say a Feynman diagram is connected if its simple graph is connected. -/ -def Connected (F : FeynmanDiagram) : Prop := F.toSimpleGraph.Connected - -instance {F : FeynmanDiagram} [IsFiniteDiagram F] : Decidable (Connected F) := - PhiFour.FeynmanDiagram.instDecidableConnectedπ“₯ToSimpleGraphOfIsFiniteDiagram - -end connectedness - -section examples -/-! - -## Examples - -In this section we give examples of Feynman diagrams in Phi^4 theory. - -Symmetry factors can be compared with e.g. those in -- https://arxiv.org/abs/0907.0859 - --/ - -/-- The propagator - - - - - - - - - -/ -def propagator : FeynmanDiagram where - 𝓱𝓔 := Fin 2 - 𝓔 := Fin 1 - 𝓔Label := ![0] - 𝓱𝓔To𝓔 := ![0, 0] - 𝓔Fiber := by decide - π“₯ := Fin 2 - π“₯Label := ![0, 0] - 𝓱𝓔Toπ“₯ := ![0, 1] - π“₯Fiber := by decide - -instance : IsFiniteDiagram propagator where - 𝓔Fintype := Fin.fintype 1 - 𝓔DecidableEq := instDecidableEqFin 1 - π“₯Fintype := Fin.fintype 2 - π“₯DecidableEq := instDecidableEqFin 2 - 𝓱𝓔Fintype := Fin.fintype 2 - 𝓱𝓔DecidableEq := instDecidableEqFin 2 - -lemma propagator_symmetryFactor : symmetryFactor propagator = 2 := by - decide - -/-- The figure 8 Feynman diagram - _ - / \ - / \ - \ / - \ / - \ / - / \ - / \ - \ / - \ __ / -/ -@[simps!] -def figureEight : FeynmanDiagram where - 𝓱𝓔 := Fin 4 - 𝓔 := Fin 2 - 𝓔Label := ![0, 0] - 𝓱𝓔To𝓔 := ![0, 0, 1, 1] - 𝓔Fiber := by decide - π“₯ := Fin 1 - π“₯Label := ![1] - 𝓱𝓔Toπ“₯ := ![0, 0, 0, 0] - π“₯Fiber := by decide - -instance : IsFiniteDiagram figureEight where - 𝓔Fintype := Fin.fintype 2 - 𝓔DecidableEq := instDecidableEqFin 2 - π“₯Fintype := Fin.fintype 1 - π“₯DecidableEq := instDecidableEqFin 1 - 𝓱𝓔Fintype := Fin.fintype 4 - 𝓱𝓔DecidableEq := instDecidableEqFin 4 - - -lemma figureEight_connected : Connected figureEight := by - decide - -lemma figureEight_symmetryFactor : symmetryFactor figureEight = 8 := by - decide - -/-- The feynman diagram - _ _ _ _ _ - / \ - / \ - - - - - - - - - - - - - - \ / - \ _ _ _ _ _/ --/ -def diagram1 : FeynmanDiagram where - 𝓱𝓔 := Fin 10 - 𝓔 := Fin 5 - 𝓔Label := ![0, 0, 0, 0, 0] - 𝓱𝓔To𝓔 := ![0, 0, 1, 1, 2, 2, 3, 3, 4, 4] - 𝓔Fiber := by decide - π“₯ := Fin 4 - π“₯Label := ![0, 1, 1, 0] - 𝓱𝓔Toπ“₯ := ![0, 1, 1, 2, 1, 2, 1, 2, 2, 3] - π“₯Fiber := by decide - -/-- An example of a disconnected Feynman diagram. -/ -def diagram2 : FeynmanDiagram where - 𝓱𝓔 := Fin 14 - 𝓔 := Fin 7 - 𝓔Label := ![0, 0, 0, 0, 0, 0, 0] - 𝓱𝓔To𝓔 := ![0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6] - 𝓔Fiber := by decide - π“₯ := Fin 5 - π“₯Label := ![0, 0, 1, 1, 1] - 𝓱𝓔Toπ“₯ := ![0, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4] - π“₯Fiber := by decide - -instance : IsFiniteDiagram diagram2 where - 𝓔Fintype := Fin.fintype _ - 𝓔DecidableEq := instDecidableEqFin _ - π“₯Fintype := Fin.fintype _ - π“₯DecidableEq := instDecidableEqFin _ - 𝓱𝓔Fintype := Fin.fintype _ - 𝓱𝓔DecidableEq := instDecidableEqFin _ - -lemma diagram2_not_connected : Β¬ Connected diagram2 := by - decide - - - -end examples - -end FeynmanDiagram - -end PhiFour From 4632b66854f0cb5abb2d714329d5fa37860c092b Mon Sep 17 00:00:00 2001 From: jstoobysmith <72603918+jstoobysmith@users.noreply.github.com> Date: Tue, 18 Jun 2024 13:07:49 -0400 Subject: [PATCH 3/3] refactor: Lint --- HepLean.lean | 4 +- HepLean/FeynmanDiagrams/Basic.lean | 60 ++++++++++++------- .../Instances/ComplexScalar.lean | 31 +--------- HepLean/FeynmanDiagrams/Instances/Phi4.lean | 15 +---- 4 files changed, 44 insertions(+), 66 deletions(-) diff --git a/HepLean.lean b/HepLean.lean index 42cdf18..18386db 100644 --- a/HepLean.lean +++ b/HepLean.lean @@ -48,7 +48,9 @@ import HepLean.AnomalyCancellation.SMNu.PlusU1.PlaneNonSols import HepLean.AnomalyCancellation.SMNu.PlusU1.QuadSol import HepLean.AnomalyCancellation.SMNu.PlusU1.QuadSolToSol import HepLean.BeyondTheStandardModel.TwoHDM.Basic -import HepLean.FeynmanDiagrams.PhiFour.Basic +import HepLean.FeynmanDiagrams.Basic +import HepLean.FeynmanDiagrams.Instances.ComplexScalar +import HepLean.FeynmanDiagrams.Instances.Phi4 import HepLean.FlavorPhysics.CKMMatrix.Basic import HepLean.FlavorPhysics.CKMMatrix.Invariants import HepLean.FlavorPhysics.CKMMatrix.PhaseFreedom diff --git a/HepLean/FeynmanDiagrams/Basic.lean b/HepLean/FeynmanDiagrams/Basic.lean index 0230d38..4611cca 100644 --- a/HepLean/FeynmanDiagrams/Basic.lean +++ b/HepLean/FeynmanDiagrams/Basic.lean @@ -119,13 +119,21 @@ properties. -/ +/-- A set of conditions on `PreFeynmanRule` for it to be considered finite. -/ class IsFinitePreFeynmanRule (P : PreFeynmanRule) where + /-- The type of edge labels is decidable. -/ edgeLabelDecidable : DecidableEq P.EdgeLabel + /-- The type of vertex labels is decidable. -/ vertexLabelDecidable : DecidableEq P.VertexLabel + /-- The type of half-edge labels is decidable. -/ halfEdgeLabelDecidable : DecidableEq P.HalfEdgeLabel + /-- The type of half-edges associated with a vertex is finite. -/ vertexMapFintype : βˆ€ v : P.VertexLabel, Fintype (P.vertexLabelMap v).left + /-- The type of half-edges associated with a vertex is decidable. -/ vertexMapDecidable : βˆ€ v : P.VertexLabel, DecidableEq (P.vertexLabelMap v).left + /-- The type of half-edges associated with an edge is finite. -/ edgeMapFintype : βˆ€ v : P.EdgeLabel, Fintype (P.edgeLabelMap v).left + /-- The type of half-edges associated with an edge is decidable. -/ edgeMapDecidable : βˆ€ v : P.EdgeLabel, DecidableEq (P.edgeLabelMap v).left instance preFeynmanRuleDecEq𝓔 (P : PreFeynmanRule) [IsFinitePreFeynmanRule P] : @@ -166,31 +174,31 @@ instance preimageEdgeDecidablePred {𝓔 π“₯ : Type} [DecidableEq 𝓔] (v : | isTrue h => isTrue h | isFalse h => isFalse h -instance preimageVertexDecidable [IsFinitePreFeynmanRule P] {𝓔 π“₯ : Type} (v : π“₯) +instance preimageVertexDecidable {𝓔 π“₯ : Type} (v : π“₯) (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) [DecidableEq F.left] : DecidableEq ((P.preimageVertex v).obj F).left := Subtype.instDecidableEq -instance preimageEdgeDecidable [IsFinitePreFeynmanRule P] {𝓔 π“₯ : Type} (v : 𝓔) +instance preimageEdgeDecidable {𝓔 π“₯ : Type} (v : 𝓔) (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) [DecidableEq F.left] : DecidableEq ((P.preimageEdge v).obj F).left := Subtype.instDecidableEq -instance preimageVertexFintype [IsFinitePreFeynmanRule P] {𝓔 π“₯ : Type} [DecidableEq π“₯] [Fintype π“₯] - (v : π“₯) (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) [DecidableEq F.left] [h : Fintype F.left] : +instance preimageVertexFintype {𝓔 π“₯ : Type} [DecidableEq π“₯] + (v : π“₯) (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) [h : Fintype F.left] : Fintype ((P.preimageVertex v).obj F).left := @Subtype.fintype _ _ _ h -instance preimageEdgeFintype [IsFinitePreFeynmanRule P] {𝓔 π“₯ : Type} [DecidableEq 𝓔] [Fintype 𝓔] - (v : 𝓔) (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) [DecidableEq F.left] [h : Fintype F.left] : +instance preimageEdgeFintype {𝓔 π“₯ : Type} [DecidableEq 𝓔] + (v : 𝓔) (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) [h : Fintype F.left] : Fintype ((P.preimageEdge v).obj F).left := @Subtype.fintype _ _ _ h -instance preimageVertexMapFintype [IsFinitePreFeynmanRule P] {𝓔 π“₯ : Type} [Fintype π“₯] +instance preimageVertexMapFintype [IsFinitePreFeynmanRule P] {𝓔 π“₯ : Type} [DecidableEq π“₯] (v : π“₯) (f : π“₯ ⟢ P.VertexLabel) (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) - [DecidableEq F.left] [Fintype F.left]: + [Fintype F.left] : Fintype ((P.vertexLabelMap (f v)).left β†’ ((P.preimageVertex v).obj F).left) := Pi.fintype -instance preimageEdgeMapFintype [IsFinitePreFeynmanRule P] {𝓔 π“₯ : Type} [Fintype 𝓔] +instance preimageEdgeMapFintype [IsFinitePreFeynmanRule P] {𝓔 π“₯ : Type} [DecidableEq 𝓔] (v : 𝓔) (f : 𝓔 ⟢ P.EdgeLabel) (F : Over (P.HalfEdgeLabel Γ— 𝓔 Γ— π“₯)) - [DecidableEq F.left] [Fintype F.left]: + [Fintype F.left] : Fintype ((P.edgeLabelMap (f v)).left β†’ ((P.preimageEdge v).obj F).left) := Pi.fintype @@ -360,12 +368,19 @@ that certain propositions are decidable. -/ +/-- A set of conditions on a Feynman diagram for it to be considered finite. -/ class IsFiniteDiagram (F : FeynmanDiagram P) where + /-- The type of edges is finite. -/ 𝓔Fintype : Fintype F.𝓔 + /-- The type of edges is decidable. -/ 𝓔DecidableEq : DecidableEq F.𝓔 + /-- The type of vertices is finite. -/ π“₯Fintype : Fintype F.π“₯ + /-- The type of vertices is decidable. -/ π“₯DecidableEq : DecidableEq F.π“₯ + /-- The type of half-edges is finite. -/ 𝓱𝓔Fintype : Fintype F.𝓱𝓔 + /-- The type of half-edges is decidable. -/ 𝓱𝓔DecidableEq : DecidableEq F.𝓱𝓔 instance {F : FeynmanDiagram P} [IsFiniteDiagram F] : Fintype F.𝓔 := @@ -418,7 +433,7 @@ def edgeVertexEquiv {F G : FeynmanDiagram P} (𝓔 : F.𝓔 ≃ G.𝓔) (π“₯ : /-- The functor of over-categories generated by `edgeVertexMap`. -/ @[simps!] def edgeVertexFunc {F G : FeynmanDiagram P} (𝓔 : F.𝓔 ⟢ G.𝓔) (π“₯ : F.π“₯ ⟢ G.π“₯) : - Over (P.HalfEdgeLabel Γ— F.𝓔 Γ— F.π“₯) β₯€ Over (P.HalfEdgeLabel Γ— G.𝓔 Γ— G.π“₯) := + Over (P.HalfEdgeLabel Γ— F.𝓔 Γ— F.π“₯) β₯€ Over (P.HalfEdgeLabel Γ— G.𝓔 Γ— G.π“₯) := Over.map <| edgeVertexMap 𝓔 π“₯ /-- A morphism of Feynman diagrams. -/ @@ -460,7 +475,7 @@ def id (F : FeynmanDiagram P) : Hom F F where 𝓱𝓔To𝓔π“₯ := πŸ™ F.𝓱𝓔To𝓔π“₯ /-- The composition of two morphisms of Feynman diagrams. -/ -@[simps!] +@[simps! π“”π“ž_left π“₯π“ž_left 𝓱𝓔To𝓔π“₯_left] def comp {F G H : FeynmanDiagram P} (f : Hom F G) (g : Hom G H) : Hom F H where π“”π“ž := f.π“”π“ž ≫ g.π“”π“ž π“₯π“ž := f.π“₯π“ž ≫ g.π“₯π“ž @@ -480,6 +495,8 @@ lemma ext {F G : FeynmanDiagram P} {f g : Hom F G} (h𝓔 : f.𝓔 = g.𝓔) (hπ“₯ : f.π“₯ = g.π“₯) (h𝓱𝓔 : f.𝓱𝓔 = g.𝓱𝓔) : f = g := ext' (Over.OverMorphism.ext h𝓔) (Over.OverMorphism.ext hπ“₯) h𝓱𝓔 +/-- The condition on maps of edges, vertices and half-edges for it to be lifted to a + morphism of Feynman diagrams. -/ def Cond {F G : FeynmanDiagram P} (𝓔 : F.𝓔 β†’ G.𝓔) (π“₯ : F.π“₯ β†’ G.π“₯) (𝓱𝓔 : F.𝓱𝓔 β†’ G.𝓱𝓔) : Prop := (βˆ€ x, G.π“”π“ž.hom (𝓔 x) = F.π“”π“ž.hom x) ∧ (βˆ€ x, G.π“₯π“ž.hom (π“₯ x) = F.π“₯π“ž.hom x) ∧ @@ -518,7 +535,7 @@ instance {F G : FeynmanDiagram P} [IsFiniteDiagram F] [IsFiniteDiagram G] [IsFin /-- Making a Feynman diagram from maps of edges, vertices and half-edges. -/ -@[simps!] +@[simps! π“”π“ž_left π“₯π“ž_left 𝓱𝓔To𝓔π“₯_left] def mk' {F G : FeynmanDiagram P} (𝓔 : F.𝓔 β†’ G.𝓔) (π“₯ : F.π“₯ β†’ G.π“₯) (𝓱𝓔 : F.𝓱𝓔 β†’ G.𝓱𝓔) (C : Cond 𝓔 π“₯ 𝓱𝓔) : Hom F G where π“”π“ž := Over.homMk 𝓔 $ funext C.1 @@ -540,7 +557,7 @@ and the condition on whether a diagram is connected. -/ /-- Feynman diagrams form a category. -/ -@[simps!] +@[simps! id_π“”π“ž_left id_π“₯π“ž_left id_𝓱𝓔To𝓔π“₯_left comp_π“”π“ž_left comp_π“₯π“ž_left comp_𝓱𝓔To𝓔π“₯_left] instance : Category (FeynmanDiagram P) where Hom := Hom id := Hom.id @@ -624,6 +641,7 @@ instance [IsFinitePreFeynmanRule P] [IsFiniteDiagram F] : Fintype F.SymmetryType @[simp] def cardSymmetryFactor : Cardinal := Cardinal.mk (F.SymmetryType) +/-- The symmetry factor of a Finite Feynman diagram, as a natural number. -/ @[simp] def symmetryFactor [IsFinitePreFeynmanRule P] [IsFiniteDiagram F] : β„• := (Fintype.card F.SymmetryType) @@ -657,7 +675,7 @@ def adjRelation : F.π“₯ β†’ F.π“₯ β†’ Prop := fun x y => βˆƒ (a b : F.𝓱𝓔), ((F.𝓱𝓔To𝓔π“₯.hom a).2.1 = (F.𝓱𝓔To𝓔π“₯.hom b).2.1 ∧ (F.𝓱𝓔To𝓔π“₯.hom a).2.2 = x ∧ (F.𝓱𝓔To𝓔π“₯.hom b).2.2 = y) -instance [IsFinitePreFeynmanRule P] [IsFiniteDiagram F] : DecidableRel F.adjRelation := fun _ _ => +instance [IsFiniteDiagram F] : DecidableRel F.adjRelation := fun _ _ => @And.decidable _ _ _ $ @Fintype.decidableExistsFintype _ _ (fun _ => @Fintype.decidableExistsFintype _ _ ( fun _ => @And.decidable _ _ (instDecidableEq𝓔OfIsFiniteDiagram _ _) $ @@ -678,21 +696,21 @@ def toSimpleGraph : SimpleGraph F.π“₯ where intro x h simp at h -instance [IsFinitePreFeynmanRule P] [IsFiniteDiagram F] : DecidableRel F.toSimpleGraph.Adj := - instDecidableRelπ“₯AdjRelationOfIsFinitePreFeynmanRuleOfIsFiniteDiagram F +instance [IsFiniteDiagram F] : DecidableRel F.toSimpleGraph.Adj := + instDecidableRelπ“₯AdjRelationOfIsFiniteDiagram F -instance [IsFinitePreFeynmanRule P] [IsFiniteDiagram F] : +instance [IsFiniteDiagram F] : Decidable (F.toSimpleGraph.Preconnected ∧ Nonempty F.π“₯) := @And.decidable _ _ _ $ decidable_of_iff _ Finset.univ_nonempty_iff -instance [IsFinitePreFeynmanRule P] [IsFiniteDiagram F] : Decidable F.toSimpleGraph.Connected := +instance [IsFiniteDiagram F] : Decidable F.toSimpleGraph.Connected := decidable_of_iff _ (SimpleGraph.connected_iff F.toSimpleGraph).symm /-- We say a Feynman diagram is connected if its simple graph is connected. -/ def Connected : Prop := F.toSimpleGraph.Connected -instance [IsFinitePreFeynmanRule P] [IsFiniteDiagram F] : Decidable (Connected F) := - instDecidableConnectedπ“₯ToSimpleGraphOfIsFinitePreFeynmanRuleOfIsFiniteDiagram F +instance [IsFiniteDiagram F] : Decidable (Connected F) := + instDecidableConnectedπ“₯ToSimpleGraphOfIsFiniteDiagram F end connectedness diff --git a/HepLean/FeynmanDiagrams/Instances/ComplexScalar.lean b/HepLean/FeynmanDiagrams/Instances/ComplexScalar.lean index 22801c8..6b77219 100644 --- a/HepLean/FeynmanDiagrams/Instances/ComplexScalar.lean +++ b/HepLean/FeynmanDiagrams/Instances/ComplexScalar.lean @@ -17,6 +17,7 @@ open CategoryTheory open FeynmanDiagram open PreFeynmanRule +/-- The pre-Feynman rules for a complex scalar theory. -/ @[simps!] def complexScalarFeynmanRules : PreFeynmanRule where /- There is 2 types of `half-edge`. -/ @@ -43,7 +44,6 @@ instance (a : β„•) : OfNat complexScalarFeynmanRules.HalfEdgeLabel a where instance (a : β„•) : OfNat complexScalarFeynmanRules.VertexLabel a where ofNat := (a : Fin _) - instance : IsFinitePreFeynmanRule complexScalarFeynmanRules where edgeLabelDecidable := instDecidableEqFin _ vertexLabelDecidable := instDecidableEqFin _ @@ -68,33 +68,4 @@ instance : IsFinitePreFeynmanRule complexScalarFeynmanRules where - -set_option maxRecDepth 1000 in -def loopProp : FeynmanDiagram complexScalarFeynmanRules := - mk' ![0, 0, 0] ![0, 2, 1] ![⟨0, 0, 0⟩, ⟨1, 0, 1⟩, - ⟨0, 1, 1⟩, ⟨1, 1, 1⟩, ⟨0, 2, 1⟩, ⟨1, 2, 2⟩] (by decide) - -instance : IsFiniteDiagram loopProp where - 𝓔Fintype := Fin.fintype _ - 𝓔DecidableEq := instDecidableEqFin _ - π“₯Fintype := Fin.fintype _ - π“₯DecidableEq := instDecidableEqFin _ - 𝓱𝓔Fintype := Fin.fintype _ - 𝓱𝓔DecidableEq := instDecidableEqFin _ - -def prop : FeynmanDiagram complexScalarFeynmanRules := - mk' ![0] ![0, 1] ![⟨0, 0, 0⟩, ⟨1, 0, 1⟩] (by decide) - -instance : IsFiniteDiagram prop where - 𝓔Fintype := Fin.fintype _ - 𝓔DecidableEq := instDecidableEqFin _ - π“₯Fintype := Fin.fintype _ - π“₯DecidableEq := instDecidableEqFin _ - 𝓱𝓔Fintype := Fin.fintype _ - 𝓱𝓔DecidableEq := instDecidableEqFin _ - -lemma prop_symmetryFactor_eq_one : symmetryFactor prop = 1 := by decide - - - end PhiFour diff --git a/HepLean/FeynmanDiagrams/Instances/Phi4.lean b/HepLean/FeynmanDiagrams/Instances/Phi4.lean index ef1d5e6..86404ea 100644 --- a/HepLean/FeynmanDiagrams/Instances/Phi4.lean +++ b/HepLean/FeynmanDiagrams/Instances/Phi4.lean @@ -19,6 +19,7 @@ open CategoryTheory open FeynmanDiagram open PreFeynmanRule +/-- The pre-Feynman rules for `Phi^4` theory. -/ @[simps!] def phi4PreFeynmanRules : PreFeynmanRule where /- There is only 1 type of `half-edge`. -/ @@ -65,19 +66,5 @@ instance : IsFinitePreFeynmanRule phi4PreFeynmanRules where | 0 => instDecidableEqFin _ -def figureEight : FeynmanDiagram phi4PreFeynmanRules := - mk' ![0, 0] ![1] ![⟨0, 0, 0⟩, ⟨0, 0, 0⟩, ⟨0, 1, 0⟩, ⟨0, 1, 0⟩] (by decide) - -instance : IsFiniteDiagram figureEight where - 𝓔Fintype := Fin.fintype _ - 𝓔DecidableEq := instDecidableEqFin _ - π“₯Fintype := Fin.fintype _ - π“₯DecidableEq := instDecidableEqFin _ - 𝓱𝓔Fintype := Fin.fintype _ - 𝓱𝓔DecidableEq := instDecidableEqFin _ - -#eval symmetryFactor figureEight - -#eval Connected figureEight end PhiFour