discopy
discopy copied to clipboard
Substitution of nested diagrams
For now we have a substitution method f.substitute(g, i) which works with plain diagrams but it's not possible to substitute within a bubble.
This substitution method can be extended by using a vector of indices i0, i1, ... rather than a single index: if f.boxes[i0] is a bubble then we can provide an extra index to a box inside it, i.e. f.boxes[i0].inside.boxes[i1]. The syntax can be the same but with extra arguments f.substitute(g, i0, i1).
I think it's nice because it works with any box and nesting level. I'll send a PR.