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 Lambda, Q, f
from proveit.core_expr_types import A_1_to_m, C_1_to_n, Q__b_1_to_j, b_1_to_j, f__b_1_to_j
from proveit.linear_algebra import VecSum
from proveit.linear_algebra.addition import vec_summation_b1toj_fQ
from proveit.logic import Equals, Implies, InClass
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Qmult(A_1_to_m, vec_summation_b1toj_fQ, C_1_to_n)
expr = Lambda([A_1_to_m, C_1_to_n, f, Q], Implies(InClass(sub_expr1, QmultCodomain), Equals(sub_expr1, VecSum(index_or_indices = [b_1_to_j], summand = Qmult(A_1_to_m, f__b_1_to_j, C_1_to_n), condition = Q__b_1_to_j)).with_wrapping_at(1)).with_wrapping_at(2))
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_{m}, C_{1}, C_{2}, \ldots, C_{n}, f, Q\right) \mapsto \left(\begin{array}{c} \begin{array}{l} \left(\left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{m} \thinspace \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right]\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) \underset{{\scriptscriptstyle c}}{\in} \mathcal{Q^*}\right) \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{m} \thinspace \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right]\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) \\  = \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{m} \thinspace f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right)\right] \end{array} \end{array}\right) \end{array} \end{array}\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple27, 29, 33, 30
2Operationoperator: 3
operands: 4
3Literal
4ExprTuple5, 6
5Operationoperator: 7
operands: 8
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple12, 11
9Literal
10ExprTuple12, 13
11Literal
12Operationoperator: 24
operands: 14
13Operationoperator: 18
operand: 17
14ExprTuple27, 16, 29
15ExprTuple17
16Operationoperator: 18
operand: 21
17Lambdaparameters: 34
body: 20
18Literal
19ExprTuple21
20Conditionalvalue: 22
condition: 26
21Lambdaparameters: 34
body: 23
22Operationoperator: 24
operands: 25
23Conditionalvalue: 28
condition: 26
24Literal
25ExprTuple27, 28, 29
26Operationoperator: 30
operands: 34
27ExprRangelambda_map: 31
start_index: 42
end_index: 32
28Operationoperator: 33
operands: 34
29ExprRangelambda_map: 35
start_index: 42
end_index: 36
30Variable
31Lambdaparameter: 48
body: 37
32Variable
33Variable
34ExprTuple38
35Lambdaparameter: 48
body: 39
36Variable
37IndexedVarvariable: 40
index: 48
38ExprRangelambda_map: 41
start_index: 42
end_index: 43
39IndexedVarvariable: 44
index: 48
40Variable
41Lambdaparameter: 48
body: 45
42Literal
43Variable
44Variable
45IndexedVarvariable: 46
index: 48
46Variable
47ExprTuple48
48Variable