Diagram#

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

Bases: discopy.braided.Diagram, discopy.traced.Diagram, discopy.abc.BalancedCategory

A balanced diagram is a braided diagram with Twist.

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.

Note

By default, our balanced diagrams are traced. Although not every balanced category embeds faithfully into a traced one (see the nLab), the free balanced category does have the desired cancellation property and it does in fact embed faithfully into the free balanced traced category.

classmethod twist(dom)[source]#

The twist on an object.

Parameters:

dom (Ty) – The domain of the twist.

Return type:

Diagram

Note

This calls twist_factory.

to_braided(width=None)[source]#

Doubles every object and sends the twist to the braid.

Parameters:

width (float) – The width of a ribbon, i.e. the gap between the two wires encoding each object, defaults to the ribbon_width in discopy.config.DRAWING_DEFAULT. Set to 0 to return the diagram as is, i.e. without doubling it into dual rails.

Example

>>> x = Ty('x')
>>> braided_twist = Diagram.twist(x).to_braided()
>>> Equation(Twist(x), braided_twist, symbol='$\\mapsto$').draw(
...     wire_labels=False,
...     path="docs/_static/balanced/twist_dual_rail.svg")
../_images/twist_dual_rail.svg
braid_factory#

alias of Braid

dual_rail_factory#

alias of DualRail

factory#

alias of Diagram

functor_factory#

alias of Functor

sum_factory#

alias of Sum

trace_factory#

alias of Trace

twist_factory#

alias of Twist