Ty#

class discopy.closed.Ty(*inside, dom=None, cod=None, _scan=True, **kwargs)[source]#

Bases: discopy.biclosed.Ty

A closed type is a biclosed type in a symmetric category where left and right exponentials coincide, i.e. X << Y == X ** Y == Y >> X.

Applying a closed type to a function yields an Term e.g.

>>> X, Y = Ty("X"), Ty("Y")
>>> t = X(lambda x: (X >> Y)(lambda f: f(x)))
>>> t.draw(
...     doctest='docs/_static/closed/diagram.svg',
...     aspect="auto", figsize=(8, 8), margins=(0.2, 0))
../_images/diagram.svg
Parameters:
  • inside (str | cat.Ob)

  • dom (C0)

  • cod (C0)

  • _scan (bool)

product(*others)[source]#

The Product of a type with a tuple of others.

Parameters:

others (Ty)

Return type:

Ty

property is_product#

Whether the type is a Product object.

Example

>>> x, y = Ty('x'), Ty('y')
>>> assert (x * y).is_product and (x * y @ Ty()).is_product
property factors#

The factors of a product type, assumes self.is_product.

classmethod from_biclosed(old)[source]#

Translate a biclosed type into a closed type, collapsing left and right exponentials into a single exponential.

Parameters:

old (Ty) – The biclosed type to translate.

Return type:

Ty

Example

>>> x, y = biclosed.Ty("x"), biclosed.Ty("y")
>>> assert Ty.from_biclosed(x << y) == Ty.from_biclosed(y >> x)
abstraction_factory#

alias of Abstraction

application_factory#

alias of Application

constant_factory#

alias of Constant

exp_factory#

alias of Exp

factory#

alias of Ty

over_factory#

alias of Exp

product_factory#

alias of Product

under_factory#

alias of Exp

variable_factory#

alias of Variable