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 A, Conditional, ExprTuple, Lambda, W, i, j, m, n
from proveit.core_expr_types import v_i, w_1_to_n, w_j
from proveit.linear_algebra import OrthoNormBases, VecSum
from proveit.logic import Equals, InSet
from proveit.numbers import Interval, one
from proveit.physics.quantum import Bra, Ket, Qmult
from proveit.physics.quantum.algebra import w_1_to_n_kets
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([w_1_to_n], Conditional(Equals(A, VecSum(index_or_indices = [i], summand = VecSum(index_or_indices = [j], summand = Qmult(Bra(w_j), A, Ket(v_i), Ket(w_j), Bra(v_i)), domain = Interval(one, n)), domain = Interval(one, m))), InSet(w_1_to_n_kets, OrthoNormBases(W)))))
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(w_{1}, w_{2}, \ldots, w_{n}\right) \mapsto \left\{A = \left(\sum_{i=1}^{m} \left(\sum_{j=1}^{n} \left(\langle w_{j} \rvert \thinspace A \thinspace \lvert v_{i} \rangle \thinspace \lvert w_{j} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right) \textrm{ if } \left\{\lvert w_{1} \rangle, \lvert w_{2} \rangle, \ldots, \lvert w_{n} \rangle\right\} \in \textrm{O.N.Bases}\left(W\right)\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
2ExprTuple4
3Conditionalvalue: 5
condition: 6
4ExprRangelambda_map: 7
start_index: 59
end_index: 60
5Operationoperator: 8
operands: 9
6Operationoperator: 43
operands: 10
7Lambdaparameter: 40
body: 33
8Literal
9ExprTuple46, 11
10ExprTuple12, 13
11Operationoperator: 27
operand: 19
12Operationoperator: 15
operands: 16
13Operationoperator: 17
operand: 21
14ExprTuple19
15Literal
16ExprTuple20
17Literal
18ExprTuple21
19Lambdaparameter: 66
body: 22
20ExprRangelambda_map: 23
start_index: 59
end_index: 60
21Variable
22Conditionalvalue: 24
condition: 25
23Lambdaparameter: 40
body: 26
24Operationoperator: 27
operand: 31
25Operationoperator: 43
operands: 29
26Operationoperator: 51
operand: 33
27Literal
28ExprTuple31
29ExprTuple66, 32
30ExprTuple33
31Lambdaparameter: 65
body: 34
32Operationoperator: 55
operands: 35
33IndexedVarvariable: 61
index: 40
34Conditionalvalue: 37
condition: 38
35ExprTuple59, 39
36ExprTuple40
37Operationoperator: 41
operands: 42
38Operationoperator: 43
operands: 44
39Variable
40Variable
41Literal
42ExprTuple45, 46, 47, 48, 49
43Literal
44ExprTuple65, 50
45Operationoperator: 53
operand: 57
46Variable
47Operationoperator: 51
operand: 58
48Operationoperator: 51
operand: 57
49Operationoperator: 53
operand: 58
50Operationoperator: 55
operands: 56
51Literal
52ExprTuple57
53Literal
54ExprTuple58
55Literal
56ExprTuple59, 60
57IndexedVarvariable: 61
index: 65
58IndexedVarvariable: 63
index: 66
59Literal
60Variable
61Variable
62ExprTuple65
63Variable
64ExprTuple66
65Variable
66Variable