logo

Expression of type Lambda

from the theory of proveit.physics.quantum.algebra

In [1]:
import proveit
# Automation is not needed when building an expression:
proveit.defaults.automation = False # This will speed things up.
proveit.defaults.inline_pngs = False # Makes files smaller.
%load_expr # Load the stored expression as 'stored_expr'
# import Expression classes needed to build the expression
from proveit import Conditional, Lambda
from proveit.core_expr_types import A_1_to_l, b_1_to_j
from proveit.logic import Equals, InClass
from proveit.numbers import Mult
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
expr = Lambda([A_1_to_l], Conditional(Equals(Qmult(b_1_to_j, A_1_to_l), Qmult(Mult(b_1_to_j), A_1_to_l)).with_wrapping_at(2), InClass(Qmult(A_1_to_l), QmultCodomain)))
expr:
In [3]:
# check that the built expression is the same as the stored expression
assert expr == stored_expr
assert expr._style_id == stored_expr._style_id
print("Passed sanity check: expr matches stored_expr")
Passed sanity check: expr matches stored_expr
In [4]:
# Show the LaTeX representation of the expression for convenience if you need it.
print(stored_expr.latex())
\left(A_{1}, A_{2}, \ldots, A_{l}\right) \mapsto \left\{\begin{array}{c} \begin{array}{l} \left(b_{1} \thinspace  b_{2} \thinspace  \ldots \thinspace  b_{j}\thinspace A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\right) =  \\ \left(\left(b_{1} \cdot  b_{2} \cdot  \ldots \cdot  b_{j}\right)\thinspace A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\right) \end{array} \end{array} \textrm{ if } \left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\right) \underset{{\scriptscriptstyle c}}{\in} \mathcal{Q^*}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 15
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operands: 5
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8, 9
6Literal
7ExprTuple10, 11
8Operationoperator: 14
operands: 12
9Operationoperator: 14
operands: 13
10Operationoperator: 14
operands: 15
11Literal
12ExprTuple22, 17
13ExprTuple16, 17
14Literal
15ExprTuple17
16Operationoperator: 18
operands: 19
17ExprRangelambda_map: 20
start_index: 25
end_index: 21
18Literal
19ExprTuple22
20Lambdaparameter: 31
body: 23
21Variable
22ExprRangelambda_map: 24
start_index: 25
end_index: 26
23IndexedVarvariable: 27
index: 31
24Lambdaparameter: 31
body: 28
25Literal
26Variable
27Variable
28IndexedVarvariable: 29
index: 31
29Variable
30ExprTuple31
31Variable