DisCoPy is a Python toolkit for computing with string diagrams.
- Organisation: https://discopy.org
- Documentation: https://docs.discopy.org
- Source code: https://github.com/discopy/discopy
- Paper (for applied category theorists): https://doi.org/10.4204/EPTCS.333.13
- Paper (for quantum computer scientists): https://arxiv.org/abs/2205.05190
DisCoPy began as an implementation of DisCoCat and QNLP. This has now become its own library: lambeq.
- a data structure for arrows in free dagger categories with formal sums, unary operators and symbolic variables from SymPy
- data structures for string diagrams in any (pre)monoidal category in the hierarchy of graphical languages (braids, twists, spiders, etc.)
- methods for diagram composition, drawing, rewriting and evaluation as:
- Python code, i.e. wires as types and boxes as functions
- tensor networks, i.e. wires as dimensions and boxes as arrays from NumPy, PyTorch, TensorFlow, TensorNetwork and JAX
- an implementation of categorical quantum mechanics interfacing with:
- tket for circuit compilation
- PyZX for optimisation with the ZX calculus
- PennyLane for automatic differentiation
- an implementation of formal grammars (context-free, categorial, pregroup or dependency) with interfaces to lambeq, spaCy and NLTK
Software dependencies between modules go top-to-bottom, left-to-right and forgetful functors between categories go the other way.
pip install discopy
If you want to see DisCoPy in action, check out the QNLP tutorial!
We're keen to welcome new contributors!
First, read the contributing guidelines. Then get in touch on Discord or open an issue.
If you wish to cite DisCoPy in an academic publication, we suggest you cite:
- G. de Felice, A. Toumi & B. Coecke, DisCoPy: Monoidal Categories in Python, EPTCS 333, 2021, pp. 183-197, DOI: 10.4204/EPTCS.333.13
If furthermore your work is related to quantum computing, you can also cite:
- A. Toumi, G. de Felice & R. Yeung, DisCoPy for the quantum computer scientist, arXiv:2205.05190