Functor

Functor#

class discopy.hopf.Functor(ob_map=None, ar_map=None, dom=None, cod=None, colour_map=None)[source]#

Bases: discopy.ribbon.Functor

A ribbon functor from ribbon diagrams to Intertwiner, i.e. it sends a knot to the tensor network of \(\mathrm{Rep}(H)\) that computes its invariant. Contract it yourself with tensor.Diagram.eval().

Parameters:
  • ob_map – A mapping from atomic ribbon.Ty to Representation.

  • ar_map – A mapping from generating ribbon.Box to arrays.

  • cod – The category Intertwiner[H] of the target algebra.

The inherited ribbon dispatch does the work: an atom goes to its Representation (its dual l or r when the winding is odd), a product of atoms to the product of modules, and a cup/cap/twist to Intertwiner.cups/caps/twist(). The one override routes both crossings of a braid to Intertwiner.braid(), the under-crossing being the antipode inverse rather than the tensor adjoint.

Example

The twist followed by the trace of the inverse braid is the identity in any ribbon category. The functor maps this ribbon diagram to a tensor network that contracts to the identity, drawn as the tensor.CMap:

>>> import numpy as np
>>> D = Double(Algebra.cyclic(2))
>>> e = Representation[D].anyon(0, -1)
>>> m = Representation[D].anyon(1, 1)
>>> V = Representation[D].direct_sum([e, m])
>>> x = ribbon.Ty('x')
>>> F = Functor(ob_map={x: V}, ar_map={}, cod=Intertwiner[D])
>>> d = ribbon.Twist(x) >> ribbon.Braid(x, x)[::-1].trace()
>>> network = F(d)
>>> assert network.eval(dtype=complex).is_close(
...     F(ribbon.Id(x)).eval(dtype=complex))
>>> network.to_map().draw(  
...     doctest='docs/_static/hopf/ribbon-functor.dot')

graph cmap { graph [bgcolor="white", fontname="DejaVu Sans", layout="dot", margin="0.04", outputorder="edgesfirst", overlap="false", rankdir="TB", splines="true"]; node [color="black", fontname="DejaVu Sans", fontsize="12", margin="0", shape="plain"]; edge [color="black", fontname="DejaVu Sans", fontsize="9", headclip="true", penwidth="1.4", tailclip="true"]; v0 [label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0"><TR><TD BORDER="1" CELLPADDING="6" COLSPAN="2" WIDTH="36">ν</TD></TR><TR><TD PORT="p2" TOOLTIP="cod 0: Dim(2) (down, down)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD><TD PORT="p1" TOOLTIP="cod 1: Dim(2) (down, down)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD></TR></TABLE>>]; v1 [label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0"><TR><TD PORT="p3" TOOLTIP="dom 0: Dim(2) (up, up)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD><TD PORT="p4" TOOLTIP="dom 1: Dim(2) (up, up)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD><TD PORT="p5" TOOLTIP="dom 2: Dim(2) (up, up)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD></TR><TR><TD BORDER="1" CELLPADDING="6" COLSPAN="3" WIDTH="54">ρ</TD></TR><TR><TD PORT="p6" TOOLTIP="cod 0: Dim(2) (down, down)" BORDER="0" CELLPADDING="0" COLSPAN="3" WIDTH="54" HEIGHT="0"></TD></TR></TABLE>>]; v2 [label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0"><TR><TD BORDER="1" CELLPADDING="6" COLSPAN="1" WIDTH="18">ε</TD></TR><TR><TD PORT="p7" TOOLTIP="cod 0: Dim(2) (down, down)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD></TR></TABLE>>]; v3 [label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0"><TR><TD BORDER="1" CELLPADDING="6" COLSPAN="1" WIDTH="18">η</TD></TR><TR><TD PORT="p8" TOOLTIP="cod 0: Dim(2) (down, down)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD></TR></TABLE>>]; v4 [label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0"><TR><TD BORDER="1" CELLPADDING="6" COLSPAN="1" WIDTH="18">ε</TD></TR><TR><TD PORT="p9" TOOLTIP="cod 0: Dim(2) (down, down)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD></TR></TABLE>>]; v5 [label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0"><TR><TD PORT="p10" TOOLTIP="dom 0: Dim(2) (up, up)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD></TR><TR><TD BORDER="1" CELLPADDING="6" COLSPAN="1" WIDTH="18">S⁻¹</TD></TR><TR><TD PORT="p11" TOOLTIP="cod 0: Dim(2) (down, down)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD></TR></TABLE>>]; v6 [label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0"><TR><TD PORT="p12" TOOLTIP="dom 0: Dim(2) (up, up)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD></TR><TR><TD BORDER="1" CELLPADDING="6" COLSPAN="1" WIDTH="18">S</TD></TR><TR><TD PORT="p13" TOOLTIP="cod 0: Dim(2) (down, down)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD></TR></TABLE>>]; v7 [label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0"><TR><TD BORDER="1" CELLPADDING="6" COLSPAN="1" WIDTH="18">η</TD></TR><TR><TD PORT="p14" TOOLTIP="cod 0: Dim(2) (down, down)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD></TR></TABLE>>]; v8 [label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0"><TR><TD PORT="p15" TOOLTIP="dom 0: Dim(2) (up, up)" BORDER="0" CELLPADDING="0" COLSPAN="2" WIDTH="36" HEIGHT="0"></TD></TR><TR><TD BORDER="1" CELLPADDING="6" COLSPAN="2" WIDTH="36">Δ</TD></TR><TR><TD PORT="p17" TOOLTIP="cod 0: Dim(2) (down, down)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD><TD PORT="p16" TOOLTIP="cod 1: Dim(2) (down, down)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD></TR></TABLE>>]; v9 [label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0"><TR><TD PORT="p18" TOOLTIP="dom 0: Dim(2) (up, up)" BORDER="0" CELLPADDING="0" COLSPAN="2" WIDTH="36" HEIGHT="0"></TD></TR><TR><TD BORDER="1" CELLPADDING="6" COLSPAN="2" WIDTH="36">Δ</TD></TR><TR><TD PORT="p20" TOOLTIP="cod 0: Dim(2) (down, down)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD><TD PORT="p19" TOOLTIP="cod 1: Dim(2) (down, down)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD></TR></TABLE>>]; v10 [label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0"><TR><TD PORT="p21" TOOLTIP="dom 0: Dim(2) (up, up)" BORDER="0" CELLPADDING="0" COLSPAN="2" WIDTH="36" HEIGHT="0"></TD></TR><TR><TD BORDER="1" CELLPADDING="6" COLSPAN="2" WIDTH="36">∇</TD></TR><TR><TD PORT="p23" TOOLTIP="cod 0: Dim(2) (down, down)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD><TD PORT="p22" TOOLTIP="cod 1: Dim(2) (down, down)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD></TR></TABLE>>]; v11 [label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0"><TR><TD PORT="p24" TOOLTIP="dom 0: Dim(2) (up, up)" BORDER="0" CELLPADDING="0" COLSPAN="2" WIDTH="36" HEIGHT="0"></TD></TR><TR><TD BORDER="1" CELLPADDING="6" COLSPAN="2" WIDTH="36">∇</TD></TR><TR><TD PORT="p26" TOOLTIP="cod 0: Dim(2) (down, down)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD><TD PORT="p25" TOOLTIP="cod 1: Dim(2) (down, down)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD></TR></TABLE>>]; v12 [label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0"><TR><TD PORT="p27" TOOLTIP="dom 0: Dim(2) (up, up)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD></TR><TR><TD BORDER="1" CELLPADDING="6" COLSPAN="1" WIDTH="18">S⁻¹</TD></TR><TR><TD PORT="p28" TOOLTIP="cod 0: Dim(2) (down, down)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD></TR></TABLE>>]; v13 [label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0"><TR><TD PORT="p29" TOOLTIP="dom 0: Dim(2) (up, up)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD><TD PORT="p30" TOOLTIP="dom 1: Dim(2) (up, up)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD></TR><TR><TD BORDER="1" CELLPADDING="6" COLSPAN="2" WIDTH="36">Δ</TD></TR><TR><TD PORT="p31" TOOLTIP="cod 0: Dim(2) (down, down)" BORDER="0" CELLPADDING="0" COLSPAN="2" WIDTH="36" HEIGHT="0"></TD></TR></TABLE>>]; v14 [label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0"><TR><TD PORT="p32" TOOLTIP="dom 0: Dim(2) (up, up)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD><TD PORT="p33" TOOLTIP="dom 1: Dim(2) (up, up)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD></TR><TR><TD BORDER="1" CELLPADDING="6" COLSPAN="2" WIDTH="36">∇</TD></TR><TR><TD PORT="p34" TOOLTIP="cod 0: Dim(2) (down, down)" BORDER="0" CELLPADDING="0" COLSPAN="2" WIDTH="36" HEIGHT="0"></TD></TR></TABLE>>]; v15 [label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0"><TR><TD PORT="p35" TOOLTIP="dom 0: Dim(2) (up, up)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD><TD PORT="p36" TOOLTIP="dom 1: Dim(2) (up, up)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD><TD PORT="p37" TOOLTIP="dom 2: Dim(2) (up, up)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD></TR><TR><TD BORDER="1" CELLPADDING="6" COLSPAN="3" WIDTH="54">ρ</TD></TR><TR><TD PORT="p38" TOOLTIP="cod 0: Dim(2) (down, down)" BORDER="0" CELLPADDING="0" COLSPAN="3" WIDTH="54" HEIGHT="0"></TD></TR></TABLE>>]; v16 [label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0"><TR><TD PORT="p39" TOOLTIP="dom 0: Dim(2) (up, up)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD><TD PORT="p40" TOOLTIP="dom 1: Dim(2) (up, up)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD><TD PORT="p41" TOOLTIP="dom 2: Dim(2) (up, up)" BORDER="0" CELLPADDING="0" COLSPAN="1" WIDTH="18" HEIGHT="0"></TD></TR><TR><TD BORDER="1" CELLPADDING="6" COLSPAN="3" WIDTH="54">ρ</TD></TR><TR><TD PORT="p42" TOOLTIP="cod 0: Dim(2) (down, down)" BORDER="0" CELLPADDING="0" COLSPAN="3" WIDTH="54" HEIGHT="0"></TD></TR></TABLE>>]; input [label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0"><TR><TD PORT="p0" TOOLTIP="input 0: Dim(2)" BORDER="0" CELLPADDING="4"></TD></TR></TABLE>>]; output [label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0"><TR><TD PORT="p43" TOOLTIP="output 0: Dim(2)" BORDER="0" CELLPADDING="4"></TD></TR></TABLE>>]; { rank=min; input; } { rank=max; output; } input:p0:s -- v1:p5:n [label="Dim(2)", labeldistance="1.6", len="0.85"]; v0:p1:s -- v1:p4:n [label="Dim(2)", labeldistance="1.6", len="0.85"]; v0:p2:s -- v1:p3:n [label="Dim(2)", labeldistance="1.6", len="0.85"]; v1:p6:s -- v16:p41:n [label="Dim(2)", labeldistance="1.6", len="0.85"]; v2:p7:s -- v5:p10:n [label="Dim(2)", labeldistance="1.6", len="0.85"]; v3:p8:s -- v16:p40:n [label="Dim(2)", labeldistance="1.6", len="0.85"]; v4:p9:s -- v13:p29:n [label="Dim(2)", labeldistance="1.6", len="0.85"]; v5:p11:s -- v10:p21:n [label="Dim(2)", labeldistance="1.6", len="0.85"]; v6:p12:n -- v16:p39:n [label="Dim(2)", labeldistance="1.6", len="0.85"]; v6:p13:s -- v8:p15:n [label="Dim(2)", labeldistance="1.6", len="0.85"]; v7:p14:s -- v14:p33:n [label="Dim(2)", labeldistance="1.6", len="0.85"]; v8:p16:s -- v12:p27:n [label="Dim(2)", labeldistance="1.6", len="0.85"]; v8:p17:s -- v9:p18:n [label="Dim(2)", labeldistance="1.6", len="0.85"]; v9:p19:s -- v14:p32:n [label="Dim(2)", labeldistance="1.6", len="0.85"]; v9:p20:s -- v10:p22:s [label="Dim(2)", labeldistance="1.6", len="0.85"]; v10:p23:s -- v11:p24:n [label="Dim(2)", labeldistance="1.6", len="0.85"]; v11:p25:s -- v13:p30:n [label="Dim(2)", labeldistance="1.6", len="0.85"]; v11:p26:s -- v12:p28:s [label="Dim(2)", labeldistance="1.6", len="0.85"]; v13:p31:s -- v15:p35:n [label="Dim(2)", labeldistance="1.6", len="0.85"]; v14:p34:s -- v15:p36:n [label="Dim(2)", labeldistance="1.6", len="0.85"]; v15:p37:n -- v16:p42:s [label="Dim(2)", labeldistance="1.6", len="0.85"]; v15:p38:s -- output:p43:n [label="Dim(2)", labeldistance="1.6", len="0.85"]; }

A single braid contracts to the braiding matrix of the toric code:

>>> matrix = F(ribbon.Braid(x, x)).eval(dtype=complex).array
>>> assert np.allclose(matrix.reshape(4, 4), [[1, 0, 0, 0], [0, 0, -1, 0],
...                                           [0, 1, 0, 0], [0, 0, 0, 1]])
dom#

alias of Diagram

cod#

alias of Intertwiner