DisCoPy: Monoidal Categories in Python

We introduce DisCoPy, an open source toolbox for computing with monoidal categories. The library provides an intuitive syntax for defining string diagrams and monoidal functors. Its modularity allows the efficient implementation of computational experiments in the various applications of category theory where diagrams have become a lingua franca. As an example, we used DisCoPy to perform natural language processing on quantum hardware for the first time.

[1]  Bob Coecke,et al.  Towards Compositional Distributional Discourse Analysis , 2018, CAPNS@QI.

[2]  Jamie Vicary,et al.  Normalization for planar string diagrams and a quadratic equivalence algorithm , 2018 .

[3]  Steve Awodey,et al.  Category Theory , 2006 .

[4]  Jamie Vicary,et al.  Coherence for Frobenius pseudomonoids and the geometry of linear proofs , 2016, Log. Methods Comput. Sci..

[5]  Joachim Lambek,et al.  Type Grammars as Pregroups , 2001, Grammars.

[6]  Aleks Kissinger,et al.  Globular: an online proof assistant for higher-dimensional rewriting , 2016, Log. Methods Comput. Sci..

[7]  Mehrnoosh Sadrzadeh,et al.  Incremental Monoidal Grammars , 2020, ArXiv.

[8]  Dimitri Kartsaklis,et al.  A Unified Sentence Space for Categorical Distributional-Compositional Semantics: Theory and Experiments , 2012, COLING.

[9]  et al.,et al.  Jupyter Notebooks - a publishing format for reproducible computational workflows , 2016, ELPUB.

[10]  Yves Lafont,et al.  Towards an algebraic theory of Boolean circuits , 2003 .

[11]  B. Coecke Kindergarten Quantum Mechanics: Lecture Notes , 2006 .

[12]  Samson Abramsky,et al.  Retracing some paths in Process Algebra , 1996, CONCUR.

[13]  Evan Patterson,et al.  Knowledge Representation in Bicategories of Relations , 2017, ArXiv.

[14]  Anne Preller,et al.  Free compact 2-categories , 2007, Mathematical Structures in Computer Science.

[15]  Gaël Varoquaux,et al.  The NumPy Array: A Structure for Efficient Numerical Computation , 2011, Computing in Science & Engineering.

[16]  Martha Lewis,et al.  Interacting Conceptual Spaces , 2016, SLPCS@QPL.

[17]  Neil Ghani,et al.  Compositional Game Theory , 2016, LICS.

[19]  S. Lane Categories for the Working Mathematician , 1971 .

[20]  David Reutter,et al.  High-level methods for homotopy construction in associative n-categories , 2019, 2019 34th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS).

[21]  Adam Zalcman,et al.  TensorNetwork: A Library for Physics and Machine Learning , 2019, ArXiv.

[22]  Aleks Kissinger,et al.  Picturing Quantum Processes by Bob Coecke , 2017 .

[23]  Paul W. Wilson,et al.  CARTOGRAPHER: A Tool for String Diagrammatic Reasoning (Tool Paper) , 2019, CALCO.

[24]  Stephen Clark,et al.  Mathematical Foundations for a Compositional Distributional Model of Meaning , 2010, ArXiv.

[25]  Filippo Bonchi,et al.  Graphical Conjunctive Queries , 2018, CSL.

[26]  A. Joyal,et al.  The geometry of tensor calculus, I , 1991 .

[27]  Aleks Kissinger,et al.  A categorical semantics for causal structure , 2019, Log. Methods Comput. Sci..

[28]  Bob Coecke,et al.  The Mathematics of Text Structure , 2019, Joachim Lambek: The Interplay of Mathematics, Logic, and Linguistics.

[29]  Aleks Kissinger,et al.  Picturing Quantum Processes: A First Course in Quantum Theory and Diagrammatic Reasoning , 2017 .

[30]  David I. Spivak,et al.  Backprop as Functor: A compositional perspective on supervised learning , 2017, 2019 34th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS).

[31]  Robert W. Spekkens,et al.  Picturing classical and quantum Bayesian inference , 2011, Synthese.

[32]  Aleks Kissinger,et al.  PyZX: Large Scale Automated Diagrammatic Reasoning , 2019, Electronic Proceedings in Theoretical Computer Science.

[33]  F. W. Lawvere,et al.  FUNCTORIAL SEMANTICS OF ALGEBRAIC THEORIES. , 1963, Proceedings of the National Academy of Sciences of the United States of America.

[34]  Filippo Bonchi,et al.  A Categorical Semantics of Signal Flow Graphs , 2014, CONCUR.

[35]  G. M. Kelly,et al.  Algebraic categories with few monoidal biclosed structures or none , 1980 .

[36]  Edmund Robinson,et al.  Premonoidal categories and notions of computation , 1997, Mathematical Structures in Computer Science.

[37]  Mehrnoosh Sadrzadeh,et al.  Experimental Support for a Categorical Compositional Distributional Model of Meaning , 2011, EMNLP.

[38]  Giovanni de Felice,et al.  Functorial Question Answering , 2019, Electronic Proceedings in Theoretical Computer Science.

[39]  Bob Coecke,et al.  Quantum Algorithms for Compositional Natural Language Processing , 2016, SLPCS@QPL.

[40]  Frank Pollmann,et al.  Efficient numerical simulations with Tensor Networks: Tensor Network Python (TeNPy) , 2018, SciPost Physics Lecture Notes.

[41]  Aleks Kissinger,et al.  Globular: an online proof assistant for higher-dimensional rewriting , 2018, Log. Methods Comput. Sci..

[42]  Graham Hutton,et al.  Categories, allegories and circuit design , 1994, Proceedings Ninth Annual IEEE Symposium on Logic in Computer Science.

[43]  S. Maclane,et al.  Categories for the Working Mathematician , 1971 .

[44]  Günter Hotz Eine Algebraisierung des Syntheseproblems von Schaltkreisen II , 1965, J. Inf. Process. Cybern..

[45]  P. Selinger A Survey of Graphical Languages for Monoidal Categories , 2009, 0908.3347.

[46]  Martha Lewis,et al.  Interacting Conceptual Spaces I : Grammatical Composition of Concepts , 2017, Conceptual Spaces: Elaborations and Applications.

[47]  Roman Orus,et al.  A Practical Introduction to Tensor Networks: Matrix Product States and Projected Entangled Pair States , 2013, 1306.2164.

[48]  John C. Baez,et al.  Categories in Control , 2014, 1405.6881.

[49]  Joachim Lambek,et al.  Type Grammar Revisited , 1997, LACL.

[50]  Law Fw FUNCTORIAL SEMANTICS OF ALGEBRAIC THEORIES. , 1963 .

[51]  Samson Abramsky,et al.  Categorical quantum mechanics , 2008, 0808.1023.

[52]  Bart Jacobs,et al.  Disintegration and Bayesian inversion via string diagrams , 2017, Mathematical Structures in Computer Science.

[53]  Alexander Katovsky,et al.  Category Theory , 2010, Arch. Formal Proofs.

[54]  Brendan Fong,et al.  A Compositional Framework for Passive Linear Networks , 2015, 1504.05625.

[55]  S. Clark,et al.  A Compositional Distributional Model of Meaning , 2008 .

[56]  Günter Hotz,et al.  Eine Algebraisierung des Syntheseproblems von Schaltkreisen I , 1965, J. Inf. Process. Cybern..

[57]  Till Tantau,et al.  Journal of Graph Algorithms and Applications Graph Drawing in Tik Z , 2022 .

[58]  Maja Pantic,et al.  TensorLy: Tensor Learning in Python , 2016, J. Mach. Learn. Res..

[59]  Michael Johnson,et al.  Lenses and Learners , 2019, Bx@PLW.

[60]  John C. Baez,et al.  A Compositional Framework for Reaction Networks , 2017, 1704.02051.

[61]  Mitchell Riley Categories of Optics , 2018 .

[62]  Ross Duncan,et al.  t|ket⟩: a retargetable compiler for NISQ devices , 2020, Quantum Science and Technology.

[63]  Aleks Kissinger,et al.  A categorical semantics for causal structure , 2017, 2017 32nd Annual ACM/IEEE Symposium on Logic in Computer Science (LICS).

[64]  John C. Baez,et al.  Props in Network Theory , 2017, 1707.08321.

[65]  Bob Coecke,et al.  Interacting Quantum Observables , 2008, ICALP.

[66]  Aleks Kissinger,et al.  Quantomatic: A proof assistant for diagrammatic reasoning , 2015, CADE.

[67]  Dimitri Kartsaklis,et al.  Separating Disambiguation from Composition in Distributional Semantics , 2013, CoNLL.

[68]  Antonin Delpeuch Autonomization of Monoidal Categories , 2019, ACT.