Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Gauge theory on a finite graph: connections, gauge groupoid, holonomy maps and functors

Definition
GaugeFunctor_defs

by Alien60 · Oct 9, 2026 · Mathlib 0df444a (Lean v4.33.1)

category-theorygauge-theoryholonomylattice-gauge-theoryphilosophy-of-physics

A finite directed graph XXX (vertices V={0,…,nV−1}V=\{0,\dots,n_V-1\}V={0,…,nV​−1}, edges EEE, maps src,tgt:EoV\mathrm{src},\mathrm{tgt}:E o Vsrc,tgt:EoV); steps (an edge traversed forwards or backwards), walks from xxx to yyy, and connectivity from a vertex xxx. For a group GGG: connections A:EoGA:E o GA:EoG, their holonomy holA(w)\mathrm{hol}_A(w)holA​(w) along walks, and the gauge action (g⋅A)(e)=g(src e)A(e)g(tgt e)−1(g\cdot A)(e)=g(\mathrm{src}\,e)A(e)g(\mathrm{tgt}\,e)^{-1}(g⋅A)(e)=g(srce)A(e)g(tgte)−1 of g:VoGg:V o Gg:VoG, with the covariance holg⋅A(w)=g(x) holA(w) g(y)−1\mathrm{hol}_{g\cdot A}(w)=g(x)\,\mathrm{hol}_A(w)\,g(y)^{-1}holg⋅A​(w)=g(x)holA​(w)g(y)−1 for a walk xoyx o yxoy (proved). The category PotG(X)\mathsf{Pot}_G(X)PotG​(X) of connections with gauge arrows; the category Holx\mathsf{Hol}_xHolx​ of holonomy maps at xxx (multiplicative on loops at xxx, invariant under inserting a backtrack) with conjugation arrows; the functors holx\mathrm{hol}_xholx​ (A↦holAA\mapsto\mathrm{hol}_AA↦holA​, g↦g(x)g\mapsto g(x)g↦g(x)) and orb\mathrm{orb}orb (to the discrete category of gauge orbits); 2-complexes (graphs with faces, each with a base vertex and a boundary loop) and the curvature functor curvY\mathrm{curv}_YcurvY​ (conjugacy classes of face holonomies, into a discrete category); and the examples: the triangle graph, its face-free version ∂Δ\partial\Delta∂Δ (a circle) and the filled triangle Δ\DeltaΔ.

Definition code
import Mathlib

/-!
# Non-abelian lattice gauge theory on a finite graph, as categories

Discrete setting for the gauge-functor classification. A finite directed graph carries
`G`-valued connections (one group element per edge, as in Baez, "Spin network states in
gauge theory", Adv. Math. 117 (1996), §2) and gauge transformations (one group element per
vertex).

* `PotG X G`   — connections with gauge transformations as arrows (the groupoid `CA` of
  Nguyen–Teh–Wells, arXiv:1712.01228, §3.2; Weatherall's EM3, arXiv:1505.02229).
* `HolMap X G x`, `HolCat` — generalized holonomy maps at a base vertex `x`: multiplicative on
  loops and invariant under inserting a backtrack (discrete thin equivalence), with
  conjugations as arrows (Rosenstock–Weatherall, arXiv:1504.02401, §I–II).
* `holF : PotG ⥤ HolMap`  — `A ↦ hol A`, `g ↦ g x`.
* `orbitF : PotG ⥤ Discrete (gauge orbits)` — the functor `Γ` of Nguyen–Teh–Wells.
* `curvF : PotG ⥤ Discrete (faces → conjugacy classes)` — the non-abelian field strength of
  a 2-complex: the conjugacy class of the holonomy around each face.
-/

open CategoryTheory

namespace GaugeFunctor

/-- A finite directed graph: `nV` vertices, `nE` edges, edge `e` runs from `src e` to `tgt e`. -/
structure Graph where
  nV : ℕ
  nE : ℕ
  src : Fin nE → Fin nV
  tgt : Fin nE → Fin nV

namespace Graph

variable (X : Graph)

/-- A step of a walk: an edge traversed forwards (`true`) or backwards (`false`). -/
abbrev Step := Fin X.nE × Bool

/-- Start vertex of a step. -/
def stepSrc (s : X.Step) : Fin X.nV := if s.2 then X.src s.1 else X.tgt s.1

/-- End vertex of a step. -/
def stepTgt (s : X.Step) : Fin X.nV := if s.2 then X.tgt s.1 else X.src s.1

/-- The same edge traversed in the opposite direction. -/
def flip (s : X.Step) : X.Step := (s.1, !s.2)

/-- `IsPath x w y`: the list of steps `w` is a walk from vertex `x` to vertex `y`. -/
def IsPath : Fin X.nV → List X.Step → Fin X.nV → Prop
  | x, [], y => x = y
  | x, s :: w, y => X.stepSrc s = x ∧ IsPath (X.stepTgt s) w y

/-- Every vertex can be reached from `x` by a walk (edges may be used in either direction). -/
def Connected (x : Fin X.nV) : Prop := ∀ y, ∃ w, X.IsPath x w y

end Graph

variable (X : Graph) (G : Type) [Group G]

/-- Parallel transport of a connection `A` along one step. -/
def stepHol (A : Fin X.nE → G) (s : X.Step) : G := if s.2 then A s.1 else (A s.1)⁻¹

/-- Holonomy (ordered product of parallel transports) of `A` along a list of steps. -/
def hol (A : Fin X.nE → G) (w : List X.Step) : G := (w.map (stepHol X G A)).prod

/-- Gauge transformation `g : V → G` acting on a connection:
`(g • A) e = g (src e) * A e * (g (tgt e))⁻¹`. -/
def gaugeAct (g : Fin X.nV → G) (A : Fin X.nE → G) : Fin X.nE → G :=
  fun e => g (X.src e) * A e * (g (X.tgt e))⁻¹

variable {X G}

theorem hol_append (A : Fin X.nE → G) (w w' : List X.Step) :
    hol X G A (w ++ w') = hol X G A w * hol X G A w' := by
  simp [hol, List.map_append, List.prod_append]

theorem hol_backtrack (A : Fin X.nE → G) (p q : List X.Step) (s : X.Step) :
    hol X G A (p ++ s :: X.flip s :: q) = hol X G A (p ++ q) := by
  rcases s with ⟨e, b⟩
  cases b <;> simp [hol, stepHol, Graph.flip]

theorem gaugeAct_one (A : Fin X.nE → G) : gaugeAct X G 1 A = A := by
  funext e; simp [gaugeAct]

theorem gaugeAct_mul (g k : Fin X.nV → G) (A : Fin X.nE → G) :
    gaugeAct X G (k * g) A = gaugeAct X G k (gaugeAct X G g A) := by
  funext e; simp [gaugeAct, mul_assoc]

/-- Gauge covariance of holonomy along a walk from `x` to `y`. -/
theorem hol_gaugeAct (g : Fin X.nV → G) (A : Fin X.nE → G) :
    ∀ (w : List X.Step) (x y : Fin X.nV), X.IsPath x w y →
      hol X G (gaugeAct X G g A) w = g x * hol X G A w * (g y)⁻¹
  | [], x, y, h => by
      simp only [Graph.IsPath] at h; subst h; simp [hol]
  | s :: w, x, y, h => by
      obtain ⟨hs, hw⟩ := h
      have ih := hol_gaugeAct g A w _ y hw
      have hstep : stepHol X G (gaugeAct X G g A) s
          = g x * stepHol X G A s * (g (X.stepTgt s))⁻¹ := by
        subst hs
        rcases s with ⟨e, b⟩
        cases b <;> simp [stepHol, gaugeAct, Graph.stepSrc, Graph.stepTgt, mul_assoc]
      have h1 : hol X G (gaugeAct X G g A) (s :: w)
          = stepHol X G (gaugeAct X G g A) s * hol X G (gaugeAct X G g A) w := by
        simp [hol]
      have h2 : hol X G A (s :: w) = stepHol X G A s * hol X G A w := by simp [hol]
      rw [h1, h2, hstep, ih]; group

variable (X G)

/-! ### The groupoid of connections with gauge arrows -/

/-- Objects: `G`-connections on `X`. -/
structure PotG where
  conn : Fin X.nE → G

/-- Arrows `A ⟶ B`: gauge transformations `g` with `g • A = B`. -/
instance : Category (PotG X G) where
  Hom A B := {g : Fin X.nV → G // gaugeAct X G g A.conn = B.conn}
  id A := ⟨1, gaugeAct_one _⟩
  comp f k := ⟨k.1 * f.1, by rw [gaugeAct_mul, f.2, k.2]⟩
  id_comp f := Subtype.ext (mul_one _)
  comp_id f := Subtype.ext (one_mul _)
  assoc f k l := Subtype.ext (mul_assoc _ _ _).symm

/-! ### Holonomy maps at a base vertex -/

/-- A generalized holonomy map at the base vertex `x`: an assignment of group elements to
walks that is multiplicative on loops at `x` and unchanged by inserting a backtrack
`s, flip s` into a loop at `x`. Only its values on loops at `x` matter. -/
structure HolMap (x : Fin X.nV) where
  toFun : List X.Step → G
  mul : ∀ γ δ, X.IsPath x γ x → X.IsPath x δ x → toFun (γ ++ δ) = toFun γ * toFun δ
  backtrack : ∀ (p q : List X.Step) (s : X.Step) (y : Fin X.nV),
    X.IsPath x p y → X.stepSrc s = y → X.IsPath y q x →
      toFun (p ++ s :: X.flip s :: q) = toFun (p ++ q)

/-- Arrows `H ⟶ H'` of holonomy maps: `h : G` with `H' γ = h * H γ * h⁻¹` on every loop at `x`. -/
instance (x : Fin X.nV) : Category (HolMap X G x) where
  Hom H H' := {h : G // ∀ γ, X.IsPath x γ x → H'.toFun γ = h * H.toFun γ * h⁻¹}
  id H := ⟨1, fun γ _ => by simp⟩
  comp f k := ⟨k.1 * f.1, fun γ hγ => by rw [k.2 γ hγ, f.2 γ hγ]; group⟩
  id_comp f := Subtype.ext (mul_one _)
  comp_id f := Subtype.ext (one_mul _)
  assoc f k l := Subtype.ext (mul_assoc _ _ _).symm

/-- The holonomy map of a connection at `x`. -/
def holMapOf (x : Fin X.nV) (A : Fin X.nE → G) : HolMap X G x where
  toFun := hol X G A
  mul γ δ _ _ := hol_append A γ δ
  backtrack p q s _ _ _ _ := hol_backtrack A p q s

/-- The holonomy functor `A ↦ hol A`, `g ↦ g x`. -/
def holF (x : Fin X.nV) : PotG X G ⥤ HolMap X G x where
  obj A := holMapOf X G x A.conn
  map {A B} g := ⟨g.1 x, fun γ hγ => by
    have h := hol_gaugeAct (X := X) (G := G) g.1 A.conn γ x x hγ
    rw [show gaugeAct X G g.1 A.conn = B.conn from g.2] at h
    exact h⟩
  map_id _ := rfl
  map_comp _ _ := rfl

/-! ### Gauge orbits and curvature -/

/-- Gauge equivalence of connections. -/
def gaugeSetoid : Setoid (Fin X.nE → G) where
  r A B := ∃ g, gaugeAct X G g A = B
  iseqv := ⟨fun A => ⟨1, gaugeAct_one A⟩,
    fun ⟨g, h⟩ => ⟨g⁻¹, by rw [← h, ← gaugeAct_mul, inv_mul_cancel, gaugeAct_one]⟩,
    fun ⟨g, h⟩ ⟨k, h'⟩ => ⟨k * g, by rw [gaugeAct_mul, h, h']⟩⟩

/-- The orbit functor: a connection goes to its gauge orbit, every arrow to an identity. -/
def orbitF : PotG X G ⥤ Discrete (Quotient (gaugeSetoid X G)) where
  obj A := Discrete.mk (Quotient.mk _ A.conn)
  map {A B} g := eqToHom (by
    congr 1; exact Quotient.sound ⟨g.1, g.2⟩)

/-- A finite 2-complex: a graph together with faces; face `f` has a base vertex and a
boundary walk `bd f`, a loop at `base f`. -/
structure Complex2 extends Graph where
  nF : ℕ
  base : Fin nF → Fin nV
  bd : Fin nF → List toGraph.Step
  bd_loop : ∀ f, toGraph.IsPath (base f) (bd f) (base f)

/-- The curvature (non-abelian field strength) functor on a 2-complex: a connection goes to
the family of conjugacy classes of its holonomies around the faces; arrows go to identities. -/
def curvF (Y : Complex2) : PotG Y.toGraph G ⥤ Discrete (Fin Y.nF → ConjClasses G) where
  obj A := Discrete.mk (fun f => ConjClasses.mk (hol Y.toGraph G A.conn (Y.bd f)))
  map {A B} g := eqToHom (by
    congr 1; funext f
    have h := hol_gaugeAct (X := Y.toGraph) (G := G) g.1 A.conn (Y.bd f) _ _ (Y.bd_loop f)
    rw [show gaugeAct Y.toGraph G g.1 A.conn = B.conn from g.2] at h
    rw [h, ConjClasses.mk_eq_mk_iff_isConj, isConj_iff]
    exact ⟨g.1 (Y.base f), rfl⟩)

/-! ### Example complexes -/

/-- The triangle graph: vertices `0,1,2`, edge `e` runs from `e` to `e + 1`. -/
abbrev triangle : Graph where
  nV := 3
  nE := 3
  src e := ⟨e.1, by omega⟩
  tgt e := ⟨(e.1 + 1) % 3, Nat.mod_lt _ (by norm_num)⟩

/-- The boundary of a triangle (a circle): the triangle graph with no faces. -/
def circleC : Complex2 where
  toGraph := triangle
  nF := 0
  base f := f.elim0
  bd f := f.elim0
  bd_loop f := f.elim0

/-- The filled triangle: the triangle graph with one face, based at `0`, whose boundary is
the loop `0 → 1 → 2 → 0`. -/
def filledC : Complex2 where
  toGraph := triangle
  nF := 1
  base _ := (0 : Fin 3)
  bd _ := [((0 : Fin 3), true), ((1 : Fin 3), true), ((2 : Fin 3), true)]
  bd_loop _ := by simp [Graph.IsPath, Graph.stepSrc, Graph.stepTgt]

end GaugeFunctor
Source
J. C. Baez, Spin network states in gauge theory, Adv. Math. 117 (1996) 253-272, https://arxiv.org/abs/gr-qc/9411007, §2 (gauge theory on a graph); S. Rosenstock, J. O. Weatherall, A categorical equivalence between generalized holonomy maps on a connected manifold and principal connections on bundles over that manifold, J. Math. Phys. 57 (2016) 102902, https://arxiv.org/abs/1504.02401, pp. 2-3 (generalized holonomy maps); J. Nguyen, N. J. Teh, L. Wells, Why surplus structure is not superfluous, Brit. J. Phil. Sci. 71 (2020), https://arxiv.org/abs/1712.01228, §3.2 (the groupoid of gauge fields with gauge arrows)
Read-back

What the Lean code literally says, in plain math · claude-opus-5-5

Graphs and walks. A graph XXX consists of nVn_VnV​ vertices {0,…,nV−1}\{0,\dots,n_V-1\}{0,…,nV​−1}, nEn_EnE​ edges {0,…,nE−1}\{0,\dots,n_E-1\}{0,…,nE​−1} and maps src,tgt\mathrm{src},\mathrm{tgt}src,tgt from edges to vertices (multi-edges and self-loops allowed; nV=0n_V=0nV​=0 or nE=0n_E=0nE​=0 allowed). A step is a pair (e,b)(e,b)(e,b) with b∈{forward,backward}b\in\{\text{forward},\text{backward}\}b∈{forward,backward}; it starts at src e\mathrm{src}\,esrce and ends at tgt e\mathrm{tgt}\,etgte if forward, the reverse if backward; (e,b)‾=(e,¬b)\overline{(e,b)}=(e,\neg b)(e,b)​=(e,¬b). A finite list of steps www is a walk from xxx to yyy if consecutive steps chain up; the empty list is a walk from xxx to yyy iff x=yx=yx=y. XXX is connected from xxx if every vertex yyy is reached by some walk from xxx (edges may be used in either direction). Since vertices are elements of a finite type, any statement quantifying over a base vertex xxx is vacuous when nV=0n_V=0nV​=0.

Connections and gauge. For a group GGG, a connection is any map A:{edges}→GA:\{\text{edges}\}\to GA:{edges}→G. Transport along a step is A(e)A(e)A(e) forwards and A(e)−1A(e)^{-1}A(e)−1 backwards; the holonomy holA(w)\mathrm{hol}_A(w)holA​(w) is the ordered product along www (so holA(∅)=1\mathrm{hol}_A(\emptyset)=1holA​(∅)=1; it is defined for every list of steps, chained or not). A gauge transformation is any g:{vertices}→Gg:\{\text{vertices}\}\to Gg:{vertices}→G, acting by

(g⋅A)(e)=g(src e) A(e) g(tgt e)−1.(g\cdot A)(e)=g(\mathrm{src}\,e)\,A(e)\,g(\mathrm{tgt}\,e)^{-1}.(g⋅A)(e)=g(srce)A(e)g(tgte)−1.

Proved lemmas: hol\mathrm{hol}hol is multiplicative under concatenation, invariant under deleting a backtrack s sˉs\,\bar sssˉ (for any lists), 1⋅A=A1\cdot A=A1⋅A=A, (kg)⋅A=k⋅(g⋅A)(kg)\cdot A=k\cdot(g\cdot A)(kg)⋅A=k⋅(g⋅A), and for a walk www from xxx to yyy: holg⋅A(w)=g(x) holA(w) g(y)−1\mathrm{hol}_{g\cdot A}(w)=g(x)\,\mathrm{hol}_A(w)\,g(y)^{-1}holg⋅A​(w)=g(x)holA​(w)g(y)−1.

Category PotG(X,G)\mathrm{PotG}(X,G)PotG(X,G). Objects: connections AAA. Morphisms A→BA\to BA→B: gauge transformations ggg with g⋅A=Bg\cdot A=Bg⋅A=B; composition of g:A→Bg:A\to Bg:A→B then k:B→Ck:B\to Ck:B→C is the pointwise product kgkgkg; identity is the constant map 111.

Holonomy maps HolMap(X,G,x)\mathrm{HolMap}(X,G,x)HolMap(X,G,x). An object is a function HHH from all lists of steps to GGG such that

  1. H(γδ)=H(γ)H(δ)H(\gamma\delta)=H(\gamma)H(\delta)H(γδ)=H(γ)H(δ) whenever γ,δ\gamma,\deltaγ,δ are both loops at xxx (hence H(∅)=1H(\emptyset)=1H(∅)=1);
  2. whenever ppp is a walk x→yx\to yx→y, sss is a step starting at yyy, and qqq is a walk y→xy\to xy→x: H(p s sˉ q)=H(p q)H(p\,s\,\bar s\,q)=H(p\,q)H(pssˉq)=H(pq).

No condition constrains HHH on lists that are not loops at xxx: these are junk values, and distinct objects may differ only there. A morphism H→H′H\to H'H→H′ is an element h∈Gh\in Gh∈G with H′(γ)=h H(γ) h−1H'(\gamma)=h\,H(\gamma)\,h^{-1}H′(γ)=hH(γ)h−1 for every loop γ\gammaγ at xxx; composition is multiplication in GGG (later after earlier), identity 111. Consequently two objects that agree on all loops at xxx are isomorphic.

Functors.

  • holFx:PotG→HolMap(x)\mathrm{holF}_x:\mathrm{PotG}\to\mathrm{HolMap}(x)holFx​:PotG→HolMap(x) sends AAA to holA\mathrm{hol}_AholA​ (as a function on all lists) and a gauge arrow ggg to g(x)g(x)g(x).
  • Gauge equivalence: A∼BA\sim BA∼B iff ∃g, g⋅A=B\exists g,\ g\cdot A=B∃g, g⋅A=B. orbitF:PotG→\mathrm{orbitF}:\mathrm{PotG}\toorbitF:PotG→ the discrete category on the set of ∼\sim∼-classes, A↦[A]A\mapsto[A]A↦[A], arrows to identities.
  • A 2-complex YYY is a graph plus nFn_FnF​ faces, each face fff having a base vertex b(f)b(f)b(f) and a boundary list ∂f\partial f∂f which is required to be a loop at b(f)b(f)b(f). curvFY:PotG(Y,G)→\mathrm{curvF}_Y:\mathrm{PotG}(Y,G)\tocurvFY​:PotG(Y,G)→ the discrete category on functions {faces}→ConjClasses(G)\{\text{faces}\}\to\mathrm{ConjClasses}(G){faces}→ConjClasses(G), A↦(f↦[holA(∂f)]conj)A\mapsto\big(f\mapsto[\mathrm{hol}_A(\partial f)]_{\text{conj}}\big)A↦(f↦[holA​(∂f)]conj​), arrows to identities.

Examples. The triangle graph has vertices 0,1,20,1,20,1,2 and edges e0:0→1e_0:0\to1e0​:0→1, e1:1→2e_1:1\to2e1​:1→2, e2:2→0e_2:2\to0e2​:2→0. circleC\mathrm{circleC}circleC = triangle with no faces (nF=0n_F=0nF​=0). filledC\mathrm{filledC}filledC = triangle with one face based at 000 with boundary e0e1e2e_0e_1e_2e0​e1​e2​ (all forward).

Observations for the auditor: all docstrings agree with the code. The discrete target categories have subsingleton hom-sets, so for orbitF\mathrm{orbitF}orbitF and curvF\mathrm{curvF}curvF "faithful" means "every hom-set of PotG\mathrm{PotG}PotG has at most one element", and "full" means "objects with equal image are joined by at least one gauge arrow".

Human review
  • Endorsed by Shuze Chen · Oct 11, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Alien60 · Oct 11, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me