Let#
- class discopy.closed.Let(expression, variables, body)[source]#
Bases:
CompoundThe evaluation of an
expressionterm, binding a tuple ofvariablesto the factors of its result inside abodyterm, i.e. the statementlet (x, ..., z) = expression in body.- Parameters:
expression (Term) – The term that is evaluated.
variables (tuple[Variable, ...]) – The variables binding the factors of the result.
body (Term) – The term in which the variables are bound.
Note
The codomain of
expressionunpacks either as the factors of itsProducttype or as the tensor of the variables’ types. Bound variables may be discarded or copied by the body, seelet()for the introspection helper that builds the statement from a function.Example
>>> X, Y = Ty("X"), Ty("Y") >>> f, x, y = (X >> Y)("f"), Variable("x", X), Variable("y", Y) >>> term = Let(f(x), (y, ), Tuple(y, y)) >>> print(term) let(f(x), lambda y: Tuple(y, y)) >>> assert term.cod == Y * Y and not term.is_linear
- property name#
The term as printed, computed once from its parts when first read.
- property constants#
The constants of the term, in order of occurrence.