logo

Expression of type ExprTuple

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 ExprTuple, 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 = ExprTuple(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(\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)\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple28, 30, 34, 31
3Operationoperator: 4
operands: 5
4Literal
5ExprTuple6, 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple13, 12
10Literal
11ExprTuple13, 14
12Literal
13Operationoperator: 25
operands: 15
14Operationoperator: 19
operand: 18
15ExprTuple28, 17, 30
16ExprTuple18
17Operationoperator: 19
operand: 22
18Lambdaparameters: 35
body: 21
19Literal
20ExprTuple22
21Conditionalvalue: 23
condition: 27
22Lambdaparameters: 35
body: 24
23Operationoperator: 25
operands: 26
24Conditionalvalue: 29
condition: 27
25Literal
26ExprTuple28, 29, 30
27Operationoperator: 31
operands: 35
28ExprRangelambda_map: 32
start_index: 43
end_index: 33
29Operationoperator: 34
operands: 35
30ExprRangelambda_map: 36
start_index: 43
end_index: 37
31Variable
32Lambdaparameter: 49
body: 38
33Variable
34Variable
35ExprTuple39
36Lambdaparameter: 49
body: 40
37Variable
38IndexedVarvariable: 41
index: 49
39ExprRangelambda_map: 42
start_index: 43
end_index: 44
40IndexedVarvariable: 45
index: 49
41Variable
42Lambdaparameter: 49
body: 46
43Literal
44Variable
45Variable
46IndexedVarvariable: 47
index: 49
47Variable
48ExprTuple49
49Variable