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 B, Conditional, Lambda, alpha
from proveit.core_expr_types import A_1_to_l, C_1_to_n
from proveit.linear_algebra import ScalarMult
from proveit.logic import Equals, InClass
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
expr = Lambda([A_1_to_l, B, C_1_to_n], Conditional(Equals(Qmult(A_1_to_l, ScalarMult(alpha, B), C_1_to_n), Qmult(A_1_to_l, alpha, B, C_1_to_n)).with_wrapping_at(2), InClass(Qmult(A_1_to_l, B, C_1_to_n), 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}, B, C_{1}, C_{2}, \ldots, C_{n}\right) \mapsto \left\{\begin{array}{c} \begin{array}{l} \left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l} \thinspace \left(\alpha \cdot B\right)\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) =  \\ \left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l} \thinspace \alpha \thinspace B\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) \end{array} \end{array} \textrm{ if } \left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l} \thinspace B\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\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
12ExprTuple17, 16, 18
13ExprTuple17, 26, 27, 18
14Literal
15ExprTuple17, 27, 18
16Operationoperator: 19
operands: 20
17ExprRangelambda_map: 21
start_index: 24
end_index: 22
18ExprRangelambda_map: 23
start_index: 24
end_index: 25
19Literal
20ExprTuple26, 27
21Lambdaparameter: 33
body: 28
22Variable
23Lambdaparameter: 33
body: 29
24Literal
25Variable
26Variable
27Variable
28IndexedVarvariable: 30
index: 33
29IndexedVarvariable: 31
index: 33
30Variable
31Variable
32ExprTuple33
33Variable