# Diagram#

class discopy.braided.Diagram(inside, dom, cod, _scan=True)[source]#

A braided diagram is a monoidal diagram with `Braid` boxes.

Parameters:
• inside (Layer) – The layers inside the diagram.

• dom (monoidal.Ty) – The domain of the diagram, i.e. its input.

• cod (monoidal.Ty) – The codomain of the diagram, i.e. its output.

classmethod braid(left, right)[source]#

The diagram braiding `left` over `right`.

Parameters:
• left (Ty) – The type on the top left and bottom right.

• right (Ty) – The type on the top right and bottom left.

Return type:

Diagram

simplify()[source]#

Remove braids followed by their dagger.

Return type:

Diagram

naturality(i, left=True, down=True, braid=None)[source]#

Slide a box through a braid.

Parameters:
• i (int) – The index of the box to slide.

• left – Whether to slide left or right.

• down – Whether to slide down or up.

• braid – The braiding method to be used.

Return type:

Diagram

Examples

```>>> x, y, z = map(Ty, "xyz")
>>> f = Box('f', x, y)
>>> top_left = f @ z >> Braid(y, z)
>>> top_right = z @ f >> Braid(z, y)
>>> bot_left = Braid(z, x) >> f @ z
>>> bot_right = Braid(x, z) >> z @ f
>>> assert top_right.naturality(0) == bot_left
>>> assert top_left.naturality(0, left=False) == bot_right
>>> assert bot_right.naturality(1, down=False) == top_left
>>> assert bot_left.naturality(1, left=False, down=False) == top_right
```
braid_factory#

alias of `Braid`

factory#

alias of `Diagram`

sum_factory#

alias of `Sum`