Equation#
- class discopy.cat.Equation(*terms, symbol='=', symbols=None, up_to=None)[source]#
Bases:
builtins.objectAn equation is a list of
termsto be compared up to a functionup_to, the identity by default. Casting it toboolchecks 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_toif 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)