Equation

Contents

Equation#

class discopy.cat.Equation(*terms, symbol='=', symbols=None, up_to=None)[source]#

Bases: builtins.object

An equation is a list of terms to be compared up to a function up_to, the identity by default. Casting it to bool checks whether its terms are all equal up to that function.

Parameters:
  • terms (Arrow) – The terms of the equation.

  • symbol – The symbol between each pair of terms, "=" by default.

  • symbols – The symbols between each pair of terms, overriding symbol; len(terms) * (symbol, ) by default.

  • up_to – The function up to which bool(equation) compares its terms, overriding the subclass’ up_to if given.

Example

The number of boxes inside an arrow is left unchanged by associativity, so we can compare arrows up to the function that counts them modulo 2:

>>> x = Ob('x')
>>> f, g = Box('f', x, x), Box('g', x, x)
>>> parity = lambda term: len(term.inside) % 2
>>> assert not Equation(f, f >> g >> g)
>>> assert Equation(f, f >> g >> g, up_to=parity)