{ "cells": [ { "cell_type": "markdown", "source": [ "# Drawing wiring diagrams in TikZ\n", "\n", "\n", "Catlab can draw morphism expressions as TikZ pictures. To use this feature,\n", "LaTeX must be installed and the Julia package\n", "[TikzPictures.jl](https://github.com/sisl/TikzPictures.jl) must be loaded.\n", "\n", "For best results, it is recommended to load the packages\n", "[Convex.j](https://github.com/JuliaOpt/Convex.jl) and\n", "[SCS.jl](https://github.com/JuliaOpt/SCS.jl). When available they are used to\n", "optimize the layout of the outer ports." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "using Catlab.WiringDiagrams, Catlab.Graphics\n", "\n", "import Convex, SCS\n", "import TikzPictures" ], "metadata": {}, "execution_count": 1 }, { "cell_type": "markdown", "source": [ "## Examples" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "### Symmetric monoidal category" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "using Catlab.Theories\n", "\n", "A, B, C, D = Ob(FreeSymmetricMonoidalCategory, :A, :B, :C, :D)\n", "f, g = Hom(:f, A, B), Hom(:g, B, A);" ], "metadata": {}, "execution_count": 2 }, { "cell_type": "markdown", "source": [ "To start, here are a few very simple examples." ], "metadata": {} }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"6\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"4\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n1\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\\$f\\$\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"root.west\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n1.west\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=south] {\\$A\\$};}\")]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.east\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"root.east\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=south] {\\$B\\$};}\")])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"rectangle\", nothing), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"solid\", nothing), Catlab.Graphics.TikZ.Property(\"rounded corners\", nothing)]), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"postaction\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"decorate\", nothing)]), Catlab.Graphics.TikZ.Property(\"decoration\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"markings\", nothing), Catlab.Graphics.TikZ.Property(\"mark\", \"at position 0.5 with {#1}\")])])]), [\"calc\", \"shapes.geometric\", \"decorations.markings\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 3 } ], "cell_type": "code", "source": [ "to_tikz(f, labels=true)" ], "metadata": {}, "execution_count": 3 }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"10\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"4\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n1\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"-2\", \"0\"), \"\\$f\\$\"), Catlab.Graphics.TikZ.Node(\"n2\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"2\", \"0\"), \"\\$g\\$\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"root.west\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n1.west\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=south] {\\$A\\$};}\")]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.east\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n2.west\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=south] {\\$B\\$};}\")]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n2.east\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"root.east\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=south] {\\$A\\$};}\")])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"rectangle\", nothing), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"solid\", nothing), Catlab.Graphics.TikZ.Property(\"rounded corners\", nothing)]), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"postaction\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"decorate\", nothing)]), Catlab.Graphics.TikZ.Property(\"decoration\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"markings\", nothing), Catlab.Graphics.TikZ.Property(\"mark\", \"at position 0.5 with {#1}\")])])]), [\"calc\", \"shapes.geometric\", \"decorations.markings\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 4 } ], "cell_type": "code", "source": [ "to_tikz(f⋅g, labels=true)" ], "metadata": {}, "execution_count": 4 }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"7\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"6\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n1\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"-1.5\", \"0\"), \"\\$f\\$\"), Catlab.Graphics.TikZ.Node(\"n2\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"1.5\", \"0\"), \"\\$g\\$\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.north)+(-1.5,0)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-90\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n1.north\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=east] {\\$A\\$};}\")]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.north)+(1.5,0)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-90\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n2.north\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=east] {\\$B\\$};}\")]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.south\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-90\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.south)+(-1.5,0)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=east] {\\$B\\$};}\")]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n2.south\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-90\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.south)+(1.5,0)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=east] {\\$A\\$};}\")])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"rectangle\", nothing), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"solid\", nothing), Catlab.Graphics.TikZ.Property(\"rounded corners\", nothing)]), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"postaction\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"decorate\", nothing)]), Catlab.Graphics.TikZ.Property(\"decoration\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"markings\", nothing), Catlab.Graphics.TikZ.Property(\"mark\", \"at position 0.5 with {#1}\")])])]), [\"calc\", \"shapes.geometric\", \"decorations.markings\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 5 } ], "cell_type": "code", "source": [ "to_tikz(f⊗g, labels=true, orientation=TopToBottom)" ], "metadata": {}, "execution_count": 5 }, { "cell_type": "markdown", "source": [ "Here is a more complex example, involving generators with compound domains and\n", "codomains." ], "metadata": {} }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"22\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"13\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n1\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"-8\", \"4.5\"), \"\\$f\\$\"), Catlab.Graphics.TikZ.Node(\"n2\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"-8\", \"1.5\"), \"\\$g\\$\"), Catlab.Graphics.TikZ.Node(\"n3\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"-8\", \"-1.5\"), \"\\$h\\$\"), Catlab.Graphics.TikZ.Node(\"n4\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"-8\", \"-4.5\"), \"\\$k\\$\"), Catlab.Graphics.TikZ.Node(\"n5\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"2\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"5\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"-4\", \"3\"), \"\\$m\\$\"), Catlab.Graphics.TikZ.Node(\"n6\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"2\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"5\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"-4\", \"-3\"), \"\\$n\\$\"), Catlab.Graphics.TikZ.Node(\"n7\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"2\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"11\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\\$l\\$\"), Catlab.Graphics.TikZ.Node(\"n8\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"2\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"5\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"4\", \"3\"), \"\\$n\\$\"), Catlab.Graphics.TikZ.Node(\"n9\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"2\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"5\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"4\", \"-3\"), \"\\$m\\$\") … Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(n6.east)+(0,1.5)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(n7.west)+(0,-1.5)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(n5.east)+(0,-1.5)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(n7.west)+(0,1.5)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n4.east\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(n6.west)+(0,-1.5)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.east\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(n5.west)+(0,1.5)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n3.east\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(n6.west)+(0,1.5)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n2.east\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(n5.west)+(0,-1.5)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n10.east\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.east)+(0,4.501)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n11.east\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.east)+(0,1.5)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n12.east\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.east)+(0,-1.5)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n13.east\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.east)+(0,-4.501)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"rectangle\", nothing), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"solid\", nothing), Catlab.Graphics.TikZ.Property(\"rounded corners\", nothing)]), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing)])]), [\"calc\", \"shapes.geometric\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 6 } ], "cell_type": "code", "source": [ "h, k = Hom(:h, C, D), Hom(:k, D, C)\n", "m, n = Hom(:m, B⊗A, A⊗B), Hom(:n, D⊗C, C⊗D)\n", "q = Hom(:l, A⊗B⊗C⊗D, D⊗C⊗B⊗A)\n", "\n", "to_tikz((f⊗g⊗h⊗k)⋅(m⊗n)⋅q⋅(n⊗m)⋅(h⊗k⊗f⊗g))" ], "metadata": {}, "execution_count": 6 }, { "cell_type": "markdown", "source": [ "Identities and braidings appear as wires." ], "metadata": {} }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"4\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"root.west\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"root.east\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=south] {\\$A\\$};}\")])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"postaction\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"decorate\", nothing)]), Catlab.Graphics.TikZ.Property(\"decoration\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"markings\", nothing), Catlab.Graphics.TikZ.Property(\"mark\", \"at position 0.5 with {#1}\")])])]), [\"calc\", \"shapes.geometric\", \"decorations.markings\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 7 } ], "cell_type": "code", "source": [ "to_tikz(id(A), labels=true)" ], "metadata": {}, "execution_count": 7 }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"4\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"7\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.west)+(0,1.5)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"135\")]), Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-45\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.east)+(0,-1.5)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=south] {\\$A\\$};}\")]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.west)+(0,-1.5)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-135\")]), Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"45\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.east)+(0,1.5)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=south] {\\$B\\$};}\")])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"postaction\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"decorate\", nothing)]), Catlab.Graphics.TikZ.Property(\"decoration\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"markings\", nothing), Catlab.Graphics.TikZ.Property(\"mark\", \"at position 0.25 with {#1}\")])])]), [\"calc\", \"shapes.geometric\", \"decorations.markings\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 8 } ], "cell_type": "code", "source": [ "to_tikz(braid(A,B), labels=true, labels_pos=0.25)" ], "metadata": {}, "execution_count": 8 }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"10\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"7\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n1\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"1.5\"), \"\\$g\\$\"), Catlab.Graphics.TikZ.Node(\"n2\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"-1.5\"), \"\\$f\\$\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.west)+(0,-1.5)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-135\")]), Catlab.Graphics.TikZ.Coordinate(\"-3\", \"0\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"45\"), Catlab.Graphics.TikZ.Property(\"in\", \"-180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n1.west\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.west)+(0,1.5)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"135\")]), Catlab.Graphics.TikZ.Coordinate(\"-3\", \"0\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-45\"), Catlab.Graphics.TikZ.Property(\"in\", \"-180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n2.west\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n2.east\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-135\")]), Catlab.Graphics.TikZ.Coordinate(\"3\", \"0\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"45\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.east)+(0,1.5)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.east\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"135\")]), Catlab.Graphics.TikZ.Coordinate(\"3\", \"0\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-45\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.east)+(0,-1.5)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"rectangle\", nothing), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"solid\", nothing), Catlab.Graphics.TikZ.Property(\"rounded corners\", nothing)]), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing)])]), [\"calc\", \"shapes.geometric\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 9 } ], "cell_type": "code", "source": [ "to_tikz(braid(A,B) ⋅ (g⊗f) ⋅ braid(A,B))" ], "metadata": {}, "execution_count": 9 }, { "cell_type": "markdown", "source": [ "The isomorphism $A \\otimes B \\otimes C \\to C \\otimes B \\otimes A$ induced by\n", "the permutation $(3\\ 2\\ 1)$ is a composite of braidings and identities." ], "metadata": {} }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"8\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"10\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"root.west\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-135\")]), Catlab.Graphics.TikZ.Coordinate(\"-2\", \"1.5\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"45\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.Coordinate(\"0\", \"3\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"135\")]), Catlab.Graphics.TikZ.Coordinate(\"2\", \"1.5\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-45\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"root.east\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=south] {\\$B\\$};}\"), Catlab.Graphics.TikZ.Property(\"->\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.west)+(0,-3)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.Coordinate(\"-2\", \"-3\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-135\")]), Catlab.Graphics.TikZ.Coordinate(\"0\", \"-1.5\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"45\"), Catlab.Graphics.TikZ.Property(\"in\", \"-135\")]), Catlab.Graphics.TikZ.Coordinate(\"2\", \"1.5\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"45\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.east)+(0,3)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=south] {\\$C\\$};}\"), Catlab.Graphics.TikZ.Property(\"->\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.west)+(0,3)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"135\")]), Catlab.Graphics.TikZ.Coordinate(\"-2\", \"1.5\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-45\"), Catlab.Graphics.TikZ.Property(\"in\", \"135\")]), Catlab.Graphics.TikZ.Coordinate(\"0\", \"-1.5\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-45\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.Coordinate(\"2\", \"-3\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.east)+(0,-3)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=south] {\\$A\\$};}\"), Catlab.Graphics.TikZ.Property(\"->\", nothing)])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"postaction\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"decorate\", nothing)]), Catlab.Graphics.TikZ.Property(\"decoration\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"markings\", nothing), Catlab.Graphics.TikZ.Property(\"mark\", \"at position 0.1pt with {#1}\")])]), Catlab.Graphics.TikZ.Property(\"->/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"postaction\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"decorate\", nothing)]), Catlab.Graphics.TikZ.Property(\"decoration\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"markings\", nothing), Catlab.Graphics.TikZ.Property(\"mark\", \"at position -0.1pt with {\\\\arrow{Stealth}}\")])]), Catlab.Graphics.TikZ.Property(\"<-/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"postaction\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"decorate\", nothing)]), Catlab.Graphics.TikZ.Property(\"decoration\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"markings\", nothing), Catlab.Graphics.TikZ.Property(\"mark\", \"at position -0.1pt with {\\\\arrow{Stealth[reversed]}}\")])])]), [\"calc\", \"shapes.geometric\", \"decorations.markings\", \"arrows.meta\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 10 } ], "cell_type": "code", "source": [ "σ = (braid(A,B) ⊗ id(C)) ⋅ (id(B) ⊗ braid(A,C) ⋅ (braid(B,C) ⊗ id(A)))\n", "\n", "to_tikz(σ, arrowtip=\"Stealth\", arrowtip_pos=\"-0.1pt\",\n", " labels=true, labels_pos=\"0.1pt\")" ], "metadata": {}, "execution_count": 10 }, { "cell_type": "markdown", "source": [ "By default, anchor points are added along identity and braiding wires to\n", "reproduce the expression structure in the layout. The anchors can be disabled\n", "to get a more \"unbiased\" layout." ], "metadata": {} }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"8\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"10\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"root.west\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"root.east\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=south] {\\$B\\$};}\"), Catlab.Graphics.TikZ.Property(\"->\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.west)+(0,-3)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.east)+(0,3)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=south] {\\$C\\$};}\"), Catlab.Graphics.TikZ.Property(\"->\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.west)+(0,3)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.east)+(0,-3)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=south] {\\$A\\$};}\"), Catlab.Graphics.TikZ.Property(\"->\", nothing)])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"postaction\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"decorate\", nothing)]), Catlab.Graphics.TikZ.Property(\"decoration\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"markings\", nothing), Catlab.Graphics.TikZ.Property(\"mark\", \"at position 0.1pt with {#1}\")])]), Catlab.Graphics.TikZ.Property(\"->/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"postaction\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"decorate\", nothing)]), Catlab.Graphics.TikZ.Property(\"decoration\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"markings\", nothing), Catlab.Graphics.TikZ.Property(\"mark\", \"at position -0.1pt with {\\\\arrow{Stealth}}\")])]), Catlab.Graphics.TikZ.Property(\"<-/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"postaction\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"decorate\", nothing)]), Catlab.Graphics.TikZ.Property(\"decoration\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"markings\", nothing), Catlab.Graphics.TikZ.Property(\"mark\", \"at position -0.1pt with {\\\\arrow{Stealth[reversed]}}\")])])]), [\"calc\", \"shapes.geometric\", \"decorations.markings\", \"arrows.meta\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 11 } ], "cell_type": "code", "source": [ "to_tikz(σ, anchor_wires=false, arrowtip=\"Stealth\", arrowtip_pos=\"-0.1pt\",\n", " labels=true, labels_pos=\"0.1pt\")" ], "metadata": {}, "execution_count": 11 }, { "cell_type": "markdown", "source": [ "### Biproduct category" ], "metadata": {} }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"4.5\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"7\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n1\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"junction\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"0.5\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"root.west\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n1.180\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=south] {\\$A\\$};}\")]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.30\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"30\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.east)+(0.0,1.5)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.-30\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-30\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.east)+(0.0,-1.5)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"junction/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"circle\", nothing), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"fill\", nothing), Catlab.Graphics.TikZ.Property(\"inner sep\", \"0\")]), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"postaction\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"decorate\", nothing)]), Catlab.Graphics.TikZ.Property(\"decoration\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"markings\", nothing), Catlab.Graphics.TikZ.Property(\"mark\", \"at position 0.5 with {#1}\")])])]), [\"calc\", \"shapes.geometric\", \"decorations.markings\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 12 } ], "cell_type": "code", "source": [ "A, B, C = Ob(FreeBiproductCategory, :A, :B, :C)\n", "f = Hom(:f, A, B)\n", "\n", "to_tikz(mcopy(A), labels=true)" ], "metadata": {}, "execution_count": 12 }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"4.5\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"4\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n1\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"junction\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"0.5\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"root.west\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n1.180\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=south] {\\$A\\$};}\")])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"junction/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"circle\", nothing), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"fill\", nothing), Catlab.Graphics.TikZ.Property(\"inner sep\", \"0\")]), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"postaction\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"decorate\", nothing)]), Catlab.Graphics.TikZ.Property(\"decoration\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"markings\", nothing), Catlab.Graphics.TikZ.Property(\"mark\", \"at position 0.5 with {#1}\")])])]), [\"calc\", \"shapes.geometric\", \"decorations.markings\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 13 } ], "cell_type": "code", "source": [ "to_tikz(delete(A), labels=true)" ], "metadata": {}, "execution_count": 13 }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"11\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"7\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n1\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"junction\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"0.5\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"-3.25\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n2\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"1.5\"), \"\\$f\\$\"), Catlab.Graphics.TikZ.Node(\"n3\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"-1.5\"), \"\\$f\\$\"), Catlab.Graphics.TikZ.Node(\"n4\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"junction\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"0.5\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"3.25\", \"0\"), \"\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"root.west\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n1.180\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=south] {\\$A\\$};}\")]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n3.east\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-150\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n4.-150\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n2.east\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"150\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n4.150\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.-30\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-30\"), Catlab.Graphics.TikZ.Property(\"in\", \"-180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n3.west\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.30\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"30\"), Catlab.Graphics.TikZ.Property(\"in\", \"-180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n2.west\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n4.0\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"root.east\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=south] {\\$B\\$};}\")])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"rectangle\", nothing), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"solid\", nothing), Catlab.Graphics.TikZ.Property(\"rounded corners\", nothing)]), Catlab.Graphics.TikZ.Property(\"junction/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"circle\", nothing), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"fill\", nothing), Catlab.Graphics.TikZ.Property(\"inner sep\", \"0\")]), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"postaction\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"decorate\", nothing)]), Catlab.Graphics.TikZ.Property(\"decoration\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"markings\", nothing), Catlab.Graphics.TikZ.Property(\"mark\", \"at position 0.5 with {#1}\")])])]), [\"calc\", \"shapes.geometric\", \"decorations.markings\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 14 } ], "cell_type": "code", "source": [ "to_tikz(mcopy(A)⋅(f⊗f)⋅mmerge(B), labels=true)" ], "metadata": {}, "execution_count": 14 }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"13\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"6.5\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n1\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"junction\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"0.5\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"-3\", \"1\"), \"\"), Catlab.Graphics.TikZ.Node(\"n2\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"junction\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"0.5\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"3\", \"1\"), \"\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.north)+(-3,0.0)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-90\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n1.90\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=east] {\\$A\\$};}\")]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.north)+(3,0.0)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-90\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n2.90\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=east] {\\$B\\$};}\")]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n2.-60\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-60\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.south)+(4.5,-0.0)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.-120\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-120\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.south)+(-4.5,-0.0)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n2.-120\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-120\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.south)+(-1.5,-0.0)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.-60\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-60\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.south)+(1.5,-0.0)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"junction/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"circle\", nothing), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"fill\", nothing), Catlab.Graphics.TikZ.Property(\"inner sep\", \"0\")]), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"postaction\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"decorate\", nothing)]), Catlab.Graphics.TikZ.Property(\"decoration\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"markings\", nothing), Catlab.Graphics.TikZ.Property(\"mark\", \"at position 0.5 with {#1}\")])])]), [\"calc\", \"shapes.geometric\", \"decorations.markings\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 15 } ], "cell_type": "code", "source": [ "to_tikz(mcopy(A⊗B), orientation=TopToBottom, labels=true)" ], "metadata": {}, "execution_count": 15 }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"19\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"6.5\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n1\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"junction\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"0.5\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"-6\", \"1\"), \"\"), Catlab.Graphics.TikZ.Node(\"n2\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"junction\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"0.5\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"1\"), \"\"), Catlab.Graphics.TikZ.Node(\"n3\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"junction\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"0.5\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"6\", \"1\"), \"\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.north)+(-6,0.0)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-90\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n1.90\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=east] {\\$A\\$};}\")]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"root.north\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-90\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n2.90\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=east] {\\$B\\$};}\")]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.north)+(6,0.0)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-90\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n3.90\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=east] {\\$C\\$};}\")]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n3.-120\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-120\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.south)+(-1.5,-0.0)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.-120\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-120\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.south)+(-7.5,-0.0)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n2.-60\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-60\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.south)+(4.5,-0.0)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.-60\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-60\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.south)+(1.5,-0.0)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n3.-60\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-60\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.south)+(7.5,-0.0)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n2.-120\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-120\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.south)+(-4.5,-0.0)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"junction/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"circle\", nothing), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"fill\", nothing), Catlab.Graphics.TikZ.Property(\"inner sep\", \"0\")]), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"postaction\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"decorate\", nothing)]), Catlab.Graphics.TikZ.Property(\"decoration\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"markings\", nothing), Catlab.Graphics.TikZ.Property(\"mark\", \"at position 0.5 with {#1}\")])])]), [\"calc\", \"shapes.geometric\", \"decorations.markings\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 16 } ], "cell_type": "code", "source": [ "to_tikz(mcopy(A⊗B⊗C), orientation=TopToBottom, labels=true)" ], "metadata": {}, "execution_count": 16 }, { "cell_type": "markdown", "source": [ "### Compact closed category" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "The unit and co-unit of a compact closed category appear as caps and cups." ], "metadata": {} }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"4\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"7\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n1\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"invisible\", nothing)], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.center\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"90\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.east)+(0,1.5)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=south] {\\$A\\$};}\"), Catlab.Graphics.TikZ.Property(\"->\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.center\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-90\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.east)+(0,-1.5)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=south] {\\$A\\$};}\"), Catlab.Graphics.TikZ.Property(\"->\", nothing)])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"invisible/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\"), Catlab.Graphics.TikZ.Property(\"inner sep\", \"0\")]), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"postaction\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"decorate\", nothing)]), Catlab.Graphics.TikZ.Property(\"decoration\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"markings\", nothing), Catlab.Graphics.TikZ.Property(\"mark\", \"at position 0.5 with {#1}\")])]), Catlab.Graphics.TikZ.Property(\"->/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"postaction\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"decorate\", nothing)]), Catlab.Graphics.TikZ.Property(\"decoration\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"markings\", nothing), Catlab.Graphics.TikZ.Property(\"mark\", \"at position 0.5 with {\\\\arrow{Stealth}}\")])]), Catlab.Graphics.TikZ.Property(\"<-/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"postaction\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"decorate\", nothing)]), Catlab.Graphics.TikZ.Property(\"decoration\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"markings\", nothing), Catlab.Graphics.TikZ.Property(\"mark\", \"at position 0.5 with {\\\\arrow{Stealth[reversed]}}\")])])]), [\"calc\", \"shapes.geometric\", \"decorations.markings\", \"arrows.meta\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 17 } ], "cell_type": "code", "source": [ "A, B = Ob(FreeCompactClosedCategory, :A, :B)\n", "\n", "to_tikz(dunit(A), arrowtip=\"Stealth\", labels=true)" ], "metadata": {}, "execution_count": 17 }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"4\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"7\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n1\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"invisible\", nothing)], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.west)+(0,1.5)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n1.center\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=south] {\\$A\\$};}\"), Catlab.Graphics.TikZ.Property(\"->\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.west)+(0,-1.5)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n1.center\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", \"{\\\\node[anchor=south] {\\$A\\$};}\"), Catlab.Graphics.TikZ.Property(\"->\", nothing)])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"invisible/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\"), Catlab.Graphics.TikZ.Property(\"inner sep\", \"0\")]), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"postaction\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"decorate\", nothing)]), Catlab.Graphics.TikZ.Property(\"decoration\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"markings\", nothing), Catlab.Graphics.TikZ.Property(\"mark\", \"at position 0.5 with {#1}\")])]), Catlab.Graphics.TikZ.Property(\"->/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"postaction\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"decorate\", nothing)]), Catlab.Graphics.TikZ.Property(\"decoration\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"markings\", nothing), Catlab.Graphics.TikZ.Property(\"mark\", \"at position 0.5 with {\\\\arrow{Stealth}}\")])]), Catlab.Graphics.TikZ.Property(\"<-/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"postaction\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"decorate\", nothing)]), Catlab.Graphics.TikZ.Property(\"decoration\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"markings\", nothing), Catlab.Graphics.TikZ.Property(\"mark\", \"at position 0.5 with {\\\\arrow{Stealth[reversed]}}\")])])]), [\"calc\", \"shapes.geometric\", \"decorations.markings\", \"arrows.meta\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 18 } ], "cell_type": "code", "source": [ "to_tikz(dcounit(A), arrowtip=\"Stealth\", labels=true)" ], "metadata": {}, "execution_count": 18 }, { "cell_type": "markdown", "source": [ "In a self-dual compact closed category, such as a bicategory of relations,\n", "every morphism $f: A \\to B$ has a transpose $f^\\dagger: B \\to A$ given by\n", "bending wires:" ], "metadata": {} }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"10\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n1\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"invisible\", nothing)], Catlab.Graphics.TikZ.Coordinate(\"-3\", \"1.5\"), \"\"), Catlab.Graphics.TikZ.Node(\"n2\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\\$f\\$\"), Catlab.Graphics.TikZ.Node(\"n3\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"invisible\", nothing)], Catlab.Graphics.TikZ.Coordinate(\"3\", \"-1.5\"), \"\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.west)+(0,-3)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.Coordinate(\"-3\", \"-3\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.Coordinate(\"0\", \"-3\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n3.center\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.center\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-90\"), Catlab.Graphics.TikZ.Property(\"in\", \"-180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n2.west\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n2.east\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n3.center\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.center\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"90\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.Coordinate(\"0\", \"3\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.Coordinate(\"3\", \"3\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.east)+(0,3)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"rectangle\", nothing), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"solid\", nothing), Catlab.Graphics.TikZ.Property(\"rounded corners\", nothing)]), Catlab.Graphics.TikZ.Property(\"invisible/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\"), Catlab.Graphics.TikZ.Property(\"inner sep\", \"0\")]), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing)])]), [\"calc\", \"shapes.geometric\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 19 } ], "cell_type": "code", "source": [ "A, B = Ob(FreeBicategoryRelations, :A, :B)\n", "f = Hom(:f, A, B)\n", "\n", "to_tikz((dunit(A) ⊗ id(B)) ⋅ (id(A) ⊗ f ⊗ id(B)) ⋅ (id(A) ⊗ dcounit(B)))" ], "metadata": {}, "execution_count": 19 }, { "cell_type": "markdown", "source": [ "### Abelian bicategory of relations" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "In an abelian bicategory of relations, such as the category of linear\n", "relations, the duplication morphisms $\\Delta_X: X \\to X \\oplus X$ and addition\n", "morphisms $\\blacktriangledown_X: X \\oplus X \\to X$ belong to a bimonoid. Among\n", "other things, this means that the following two morphisms are equal." ], "metadata": {} }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"7\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n1\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"variant junction\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"0.5\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"-1.25\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n2\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"junction\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"0.5\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"1.25\", \"0\"), \"\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.west)+(-0.0,1.5)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"150\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n1.150\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.west)+(-0.0,-1.5)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-150\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n1.-150\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.0\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n2.180\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n2.30\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"30\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.east)+(0.0,1.5)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n2.-30\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-30\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.east)+(0.0,-1.5)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"junction/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"circle\", nothing), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"fill\", nothing), Catlab.Graphics.TikZ.Property(\"inner sep\", \"0\")]), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"variant junction/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"circle\", nothing), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"solid\", nothing), Catlab.Graphics.TikZ.Property(\"inner sep\", \"0\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing)])]), [\"calc\", \"shapes.geometric\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 20 } ], "cell_type": "code", "source": [ "X = Ob(FreeAbelianBicategoryRelations, :X)\n", "\n", "to_tikz(plus(X) ⋅ mcopy(X))" ], "metadata": {}, "execution_count": 20 }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"9\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"13\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n1\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"junction\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"0.5\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"-2.25\", \"3\"), \"\"), Catlab.Graphics.TikZ.Node(\"n2\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"junction\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"0.5\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"-2.25\", \"-3\"), \"\"), Catlab.Graphics.TikZ.Node(\"n3\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"variant junction\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"0.5\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"2.25\", \"3\"), \"\"), Catlab.Graphics.TikZ.Node(\"n4\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"variant junction\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"0.5\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"2.25\", \"-3\"), \"\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.west)+(-0.0,3)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n1.180\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.west)+(-0.0,-3)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n2.180\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n2.-30\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-30\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.Coordinate(\"0\", \"-4.5\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-150\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n4.-150\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.30\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"30\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.Coordinate(\"0\", \"4.5\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"150\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n3.150\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.-30\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-30\"), Catlab.Graphics.TikZ.Property(\"in\", \"150\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n4.150\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n2.30\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"30\"), Catlab.Graphics.TikZ.Property(\"in\", \"-150\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n3.-150\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n3.0\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.east)+(0.0,3)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n4.0\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.east)+(0.0,-3)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"junction/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"circle\", nothing), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"fill\", nothing), Catlab.Graphics.TikZ.Property(\"inner sep\", \"0\")]), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"variant junction/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"circle\", nothing), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"solid\", nothing), Catlab.Graphics.TikZ.Property(\"inner sep\", \"0\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing)])]), [\"calc\", \"shapes.geometric\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 21 } ], "cell_type": "code", "source": [ "to_tikz((mcopy(X)⊕mcopy(X)) ⋅ (id(X)⊕swap(X,X)⊕id(X)) ⋅ (plus(X)⊕plus(X)))" ], "metadata": {}, "execution_count": 21 }, { "cell_type": "markdown", "source": [ "## Custom styles" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "The visual appearance of wiring diagrams can be customized using the builtin\n", "options or by redefining the TikZ styles for the boxes or wires." ], "metadata": {} }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"10\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"4\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n1\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"-2\", \"0\"), \"\\$f\\$\"), Catlab.Graphics.TikZ.Node(\"n2\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"2\", \"0\"), \"\\$g\\$\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"root.west\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n1.west\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.east\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n2.west\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n2.east\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"root.east\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"fill\", \"{rgb,255: red,230; green,230; blue,250}\")]), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing)])]), [\"calc\", \"shapes.geometric\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 22 } ], "cell_type": "code", "source": [ "A, B, = Ob(FreeSymmetricMonoidalCategory, :A, :B)\n", "f, g = Hom(:f, A, B), Hom(:g, B, A)\n", "\n", "pic = to_tikz(f⋅g, styles=Dict(\n", " \"box\" => [\"draw\", \"fill\"=>\"{rgb,255: red,230; green,230; blue,250}\"],\n", "))" ], "metadata": {}, "execution_count": 22 }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"7\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n1\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"variant junction\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"0.5\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"-1.25\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n2\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"junction\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"0.5\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"1.25\", \"0\"), \"\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.west)+(-0.0,1.5)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"150\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n1.150\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.west)+(-0.0,-1.5)\\$\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-150\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n1.-150\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.0\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n2.180\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n2.30\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"30\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.east)+(0.0,1.5)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n2.-30\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-30\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"\\$(root.east)+(0.0,-1.5)\\$\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"junction/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"circle\", nothing), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"fill\", \"red\"), Catlab.Graphics.TikZ.Property(\"inner sep\", \"0\")]), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"variant junction/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"circle\", nothing), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"fill\", \"blue\"), Catlab.Graphics.TikZ.Property(\"inner sep\", \"0\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing)])]), [\"calc\", \"shapes.geometric\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 23 } ], "cell_type": "code", "source": [ "X = Ob(FreeAbelianBicategoryRelations, :X)\n", "\n", "to_tikz(plus(X) ⋅ mcopy(X), styles=Dict(\n", " \"junction\" => [\"circle\", \"draw\", \"fill\"=>\"red\", \"inner sep\"=>\"0\"],\n", " \"variant junction\" => [\"circle\", \"draw\", \"fill\"=>\"blue\", \"inner sep\"=>\"0\"],\n", "))" ], "metadata": {}, "execution_count": 23 }, { "cell_type": "markdown", "source": [ "By default, the boxes are rectangular (`:rectangle`). Other available shapes\n", "include circles (`:circle`), ellipses (`:ellipse`), triangles (`:triangle`,\n", "`:invtriangle`), and trapezoids (`:trapezium`, `:invtrapezium`)." ], "metadata": {} }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"10\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"4\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n1\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"circular box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"-2\", \"0\"), \"\\$f\\$\"), Catlab.Graphics.TikZ.Node(\"n2\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"circular box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"2\", \"0\"), \"\\$g\\$\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"root.west\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n1.180\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.0\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n2.180\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n2.0\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"root.east\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"circular box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"circle\", nothing), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"solid\", nothing)]), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing)])]), [\"calc\", \"shapes.geometric\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 24 } ], "cell_type": "code", "source": [ "to_tikz(f⋅g, default_box_shape=:circle)" ], "metadata": {}, "execution_count": 24 }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"10\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"4\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n1\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"triangular box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"-2\", \"0\"), \"\\$f\\$\"), Catlab.Graphics.TikZ.Node(\"n2\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"inverse triangular box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"2\", \"0\"), \"\\$g\\$\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"root.west\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n1.west\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.east\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n2.west\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n2.east\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"root.east\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"inverse triangular box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"isosceles triangle\", nothing), Catlab.Graphics.TikZ.Property(\"isosceles triangle stretches\", nothing), Catlab.Graphics.TikZ.Property(\"shape border rotate\", \"0\"), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"solid\", nothing), Catlab.Graphics.TikZ.Property(\"sharp corners\", nothing), Catlab.Graphics.TikZ.Property(\"inner sep\", \"0\")]), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"triangular box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"isosceles triangle\", nothing), Catlab.Graphics.TikZ.Property(\"isosceles triangle stretches\", nothing), Catlab.Graphics.TikZ.Property(\"shape border rotate\", \"180\"), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"solid\", nothing), Catlab.Graphics.TikZ.Property(\"sharp corners\", nothing), Catlab.Graphics.TikZ.Property(\"inner sep\", \"0\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing)])]), [\"calc\", \"shapes.geometric\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 25 } ], "cell_type": "code", "source": [ "to_tikz(f⋅g, rounded_boxes=false, box_shapes=Dict(\n", " f => :triangle, g => :invtriangle,\n", "))" ], "metadata": {}, "execution_count": 25 }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"4\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"10\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n1\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"triangular box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"2\"), \"\\$f\\$\"), Catlab.Graphics.TikZ.Node(\"n2\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"inverse triangular box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"-2\"), \"\\$g\\$\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"root.north\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-90\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n1.north\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.south\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-90\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n2.north\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n2.south\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"-90\"), Catlab.Graphics.TikZ.Property(\"in\", \"90\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"root.south\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"inverse triangular box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"isosceles triangle\", nothing), Catlab.Graphics.TikZ.Property(\"isosceles triangle stretches\", nothing), Catlab.Graphics.TikZ.Property(\"shape border rotate\", \"270\"), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"solid\", nothing), Catlab.Graphics.TikZ.Property(\"sharp corners\", nothing), Catlab.Graphics.TikZ.Property(\"inner sep\", \"0\")]), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"triangular box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"isosceles triangle\", nothing), Catlab.Graphics.TikZ.Property(\"isosceles triangle stretches\", nothing), Catlab.Graphics.TikZ.Property(\"shape border rotate\", \"90\"), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"solid\", nothing), Catlab.Graphics.TikZ.Property(\"sharp corners\", nothing), Catlab.Graphics.TikZ.Property(\"inner sep\", \"0\")]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing)])]), [\"calc\", \"shapes.geometric\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 26 } ], "cell_type": "code", "source": [ "to_tikz(f⋅g, orientation=TopToBottom, rounded_boxes=false, box_shapes=Dict(\n", " f => :triangle, g => :invtriangle,\n", "))" ], "metadata": {}, "execution_count": 26 }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Catlab.Graphics.TikZ.Document(Catlab.Graphics.TikZ.Picture(Catlab.Graphics.TikZ.Statement[Catlab.Graphics.TikZ.Node(\"root\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"outer box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum width\", \"10\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"minimum height\", \"4\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"0\", \"0\"), \"\"), Catlab.Graphics.TikZ.Node(\"n1\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"inverse trapezoidal box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"-2\", \"0\"), \"\\$f\\$\"), Catlab.Graphics.TikZ.Node(\"n2\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"trapezoidal box\", nothing), Catlab.Graphics.TikZ.Property(\"minimum size\", \"2\\\\tikzunit\")], Catlab.Graphics.TikZ.Coordinate(\"2\", \"0\"), \"\\$g\\$\"), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"root.west\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n1.west\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n1.east\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"-180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"n2.west\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)]), Catlab.Graphics.TikZ.Edge(Catlab.Graphics.TikZ.PathExpression[Catlab.Graphics.TikZ.NodeCoordinate(\"n2.east\"), Catlab.Graphics.TikZ.PathOperation(\"to\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"out\", \"0\"), Catlab.Graphics.TikZ.Property(\"in\", \"180\")]), Catlab.Graphics.TikZ.NodeCoordinate(\"root.east\")], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"wire\", nothing)])], Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"unit length/.code\", \"{{\\\\newdimen\\\\tikzunit}\\\\setlength{\\\\tikzunit}{#1}}\"), Catlab.Graphics.TikZ.Property(\"unit length\", \"4mm\"), Catlab.Graphics.TikZ.Property(\"x\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"y\", \"\\\\tikzunit\"), Catlab.Graphics.TikZ.Property(\"semithick\", nothing), Catlab.Graphics.TikZ.Property(\"inverse trapezoidal box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"trapezium\", nothing), Catlab.Graphics.TikZ.Property(\"trapezium angle\", \"80\"), Catlab.Graphics.TikZ.Property(\"trapezium stretches body\", nothing), Catlab.Graphics.TikZ.Property(\"shape border rotate\", \"270\"), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"solid\", nothing), Catlab.Graphics.TikZ.Property(\"rounded corners\", nothing)]), Catlab.Graphics.TikZ.Property(\"outer box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", \"none\")]), Catlab.Graphics.TikZ.Property(\"trapezoidal box/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"trapezium\", nothing), Catlab.Graphics.TikZ.Property(\"trapezium angle\", \"80\"), Catlab.Graphics.TikZ.Property(\"trapezium stretches body\", nothing), Catlab.Graphics.TikZ.Property(\"shape border rotate\", \"90\"), Catlab.Graphics.TikZ.Property(\"draw\", nothing), Catlab.Graphics.TikZ.Property(\"solid\", nothing), Catlab.Graphics.TikZ.Property(\"rounded corners\", nothing)]), Catlab.Graphics.TikZ.Property(\"wire/.style\", Catlab.Graphics.TikZ.Property[Catlab.Graphics.TikZ.Property(\"draw\", nothing)])]), [\"calc\", \"shapes.geometric\"], [\"amssymb\"])", "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "metadata": {}, "execution_count": 27 } ], "cell_type": "code", "source": [ "to_tikz(f⋅g, box_shapes=Dict(\n", " f => :invtrapezium, g => :trapezium,\n", "))" ], "metadata": {}, "execution_count": 27 }, { "cell_type": "markdown", "source": [ "## Output formats" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "The function `to_tikz` returns an object of type `TikZ.Document`, representing\n", "a TikZ picture and its TikZ library dependencies as an abstract syntax tree.\n", "When displayed interactively, this object is compiled by LaTeX to PDF and then\n", "converted to SVG." ], "metadata": {} }, { "cell_type": "markdown", "source": [ "To generate the LaTeX source code, use the builtin pretty-printer. This\n", "feature does not require LaTeX or TikzPictures.jl to be installed." ], "metadata": {} }, { "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\\usepackage{amssymb}\n", "\\usetikzlibrary{calc}\n", "\\usetikzlibrary{shapes.geometric}\n", "\\begin{tikzpicture}[unit length/.code={{\\newdimen\\tikzunit}\\setlength{\\tikzunit}{#1}},unit length=4mm,x=\\tikzunit,y=\\tikzunit,semithick,box/.style={rectangle,draw,solid,rounded corners},outer box/.style={draw=none},wire/.style={draw}]\n", " \\node[outer box,minimum width=10\\tikzunit,minimum height=4\\tikzunit] (root) at (0,0) {};\n", " \\node[box,minimum size=2\\tikzunit] (n1) at (-2,0) {$f$};\n", " \\node[box,minimum size=2\\tikzunit] (n2) at (2,0) {$g$};\n", " \\path[wire] (root.west) to[out=0,in=-180] (n1.west);\n", " \\path[wire] (n1.east) to[out=0,in=-180] (n2.west);\n", " \\path[wire] (n2.east) to[out=0,in=180] (root.east);\n", "\\end{tikzpicture}" ] } ], "cell_type": "code", "source": [ "import Catlab.Graphics: TikZ\n", "\n", "doc = to_tikz(f⋅g)\n", "TikZ.pprint(doc)" ], "metadata": {}, "execution_count": 28 } ], "nbformat_minor": 3, "metadata": { "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.10.2" }, "kernelspec": { "name": "julia-1.10", "display_name": "Julia 1.10.2", "language": "julia" } }, "nbformat": 4 }