Skip to content

Scripts I use for string and surface diagrams. (WIP)

License

Notifications You must be signed in to change notification settings

mroman42/cuerda

Repository files navigation

Cuerda

Cuerda is a library for producing string and surface diagrams on Tikz. It is very loosely inspired on the theory of associative n-categories for its internal representation (see Dorn (2018) and Reutter and Vicary (2019)) in that unitality is not strict. For the end user, this means you will have to introduce some identity morphisms by hand, but the internal representation is greatly simplified because of this.

Usage example

This is an example of how to use Cuerda in org-mode.

2d diagrams

import Cuerda
c = obj "\\mathbb{C}"
o = morph "\\mu" [c,c] [c]
i = morph "\\eta" [] [c]
main = do
  putStr "\\["
  latex2D [[i,idt c],[o]]
  putStr "\\quad = \\quad"
  latex2D [[idt c],[idt c]]
  putStr "\\quad = \\quad"
  latex2D [[idt c,i],[o]]
  putStr "\\]"

https://github.com/mroman42/cuerda/raw/master/example1.png

3d diagrams

import Cuerda
c = obj "\\mathbb{C}"
o = morph "\\otimes" [c,c] [c]
i = morph "I" [] [c]
alpha = transf "\\hat\\alpha" [[idt c,o],[o]] [[o,idt c],[o]]
alphainv = transf "\\hat\\alpha" [[o,idt c],[o]] [[idt c,o],[o]]
lambda = transf "\\lambda" [[i,idt c],[o]] [[idt c],[idt c]]
lambdainv = transf "\\lambda" [[idt c],[idt c]] [[i,idt c],[o]]
rho = transf "\\rho" [[idt c,i],[o]] [[idt c],[idt c]]
rhoinv = transf "\\rho" [[idt c],[idt c]] [[idt c,i],[o]]

main :: IO ()
main = do
  putStr "\\["
  latex3D [[[alphainv]],[[alpha]]]
  putStr "\\quad = \\quad"
  latex3D [[[alphainv]],[[alpha]]]
  putStr "\\]"

https://github.com/mroman42/cuerda/raw/master/example2.png

Prior art and related

  • Homotopy.io, Heidemann, Hu, Vicary (2019). A full implementation of associative n-categories on Javascript. It allows manipulation of diagrams and visualization in both 2d and 3d. It does not provide (as of June 2020) any way of exporting to Tikz. It is an inspiration for the approach here.
  • Discokitty, Román (2019). An educational implementation of DisCoCat that also happened to generate string diagrams on Tikz.
  • Discopy, Toumi, de Felice, Meichanetzidis, Rizzo (2020). A toolbox for computing with monoidal categories, focused on DisCoCat and quantum computing.
  • Tikz, Tantau, Feuersänger (2005). Our target language.

Referencing Cuerda

As of June 2020, the best way of referencing Cuerda is by pointing to its GitHub repository.

@misc{cuerda20,
  author = {Mario Román},
  title = {Cuerda library, Version 0.1},
  howpublished = {GitHub \url{https://github.com/mroman42/cuerda}},
  year = {2020}
}

About

Scripts I use for string and surface diagrams. (WIP)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published