Function#

class discopy.python.additive.Function(inside, dom, cod, is_swap_of=None)[source]#

Bases: discopy.python.function.Function, discopy.abc.SymmetricCategory

Python functions with disjoint union as tensor.

Parameters:
  • inside (Callable) – The callable Python object inside the function.

  • dom (List[type]) – The domain of the function, i.e. its list of input types.

  • cod (List[type]) – The codomain of the function, i.e. its list of output types.

Summary

tensor(other)

The disjoint union of two functions, called with @.

swap(x, y)

Swap the tags of a disjoint union from x @ y to y @ x.

trace([n, left])

The additive trace of a function.

tensor(other)[source]#

The disjoint union of two functions, called with @.

Parameters:

other (Function) – The other function to compose in sequence.

Return type:

Function

static swap(x, y)[source]#

Swap the tags of a disjoint union from x @ y to y @ x.

Parameters:
  • x (List[type]) – The list of types on the left.

  • y (List[type]) – The list of types on the right.

Return type:

Function

classmethod permutation(xs, doms)[source]#

Permute the tags of a disjoint union.

Return type:

Self

trace(n=1, left=False)[source]#

The additive trace of a function.

Parameters:

n – The number of types to trace over.

static merge(x, n=2)[source]#

Merge n copies of a list of types x into one.

Parameters:
  • x (List[type]) – The list of types to merge.

  • n – The number of copies.

Return type:

Function

braid(y)#

Swap the tags of a disjoint union from x @ y to y @ x.

Parameters:
  • x (List[type]) – The list of types on the left.

  • y (List[type]) – The list of types on the right.

Return type:

Function

classmethod twist(dom)#

The identity function on a given list of types dom.

Parameters:

dom (type) – The list of types on which to take the identity.

Return type:

Function