Diagram#

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

Bases: discopy.braided.Diagram

A symmetric diagram is a braided diagram with Swap 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 swap(left, right)[source]#

The diagram that swaps the left and right wires.

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

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

Return type

Diagram

Note

This calls braided.hexagon() and braid_factory.

classmethod permutation(xs, dom=None)[source]#

The diagram that encodes a given permutation.

Parameters
  • xs (list[int]) – A list of integers representing a permutation.

  • dom (Optional[Ty]) – A type of the same length as permutation, default is PRO(len(permutation)).

Return type

Diagram

permute(*xs)[source]#

Post-compose with a permutation.

Parameters

xs (int) – A list of integers representing a permutation.

Return type

Diagram

Examples

>>> x, y, z = Ty('x'), Ty('y'), Ty('z')
>>> assert Id(x @ y @ z).permute(2, 0, 1).cod == z @ x @ y
braid_factory#

alias of Swap

factory#

alias of Diagram