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, V, W, i, j, m, n
from proveit.core_expr_types import v_1_to_m, v_i, w_1_to_n, w_j
from proveit.linear_algebra import OrthoNormBases, VecSum
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Interval, one
from proveit.physics.quantum import Bra, Ket, Qmult
from proveit.physics.quantum.algebra import v_1_to_m_kets, w_1_to_n_kets
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([v_1_to_m], Conditional(Forall(instance_param_or_params = [w_1_to_n], instance_expr = 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))), condition = InSet(w_1_to_n_kets, OrthoNormBases(W))).with_wrapping(), InSet(v_1_to_m_kets, OrthoNormBases(V)))))
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(v_{1}, v_{2}, \ldots, v_{m}\right) \mapsto \left\{\begin{array}{l}\forall_{w_{1}, w_{2}, \ldots, w_{n}~|~\left\{\lvert w_{1} \rangle, \lvert w_{2} \rangle, \ldots, \lvert w_{n} \rangle\right\} \in \textrm{O.N.Bases}\left(W\right)}~\\
\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)\right)\end{array} \textrm{ if } \left\{\lvert v_{1} \rangle, \lvert v_{2} \rangle, \ldots, \lvert v_{m} \rangle\right\} \in \textrm{O.N.Bases}\left(V\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: 79
end_index: 59
5Operationoperator: 8
operand: 11
6Operationoperator: 63
operands: 10
7Lambdaparameter: 60
body: 41
8Literal
9ExprTuple11
10ExprTuple12, 13
11Lambdaparameters: 14
body: 15
12Operationoperator: 33
operands: 16
13Operationoperator: 35
operand: 22
14ExprTuple18
15Conditionalvalue: 19
condition: 20
16ExprTuple21
17ExprTuple22
18ExprRangelambda_map: 23
start_index: 79
end_index: 80
19Operationoperator: 24
operands: 25
20Operationoperator: 63
operands: 26
21ExprRangelambda_map: 27
start_index: 79
end_index: 59
22Variable
23Lambdaparameter: 60
body: 53
24Literal
25ExprTuple66, 28
26ExprTuple29, 30
27Lambdaparameter: 60
body: 31
28Operationoperator: 47
operand: 38
29Operationoperator: 33
operands: 34
30Operationoperator: 35
operand: 40
31Operationoperator: 71
operand: 41
32ExprTuple38
33Literal
34ExprTuple39
35Literal
36ExprTuple40
37ExprTuple41
38Lambdaparameter: 86
body: 42
39ExprRangelambda_map: 43
start_index: 79
end_index: 80
40Variable
41IndexedVarvariable: 83
index: 60
42Conditionalvalue: 44
condition: 45
43Lambdaparameter: 60
body: 46
44Operationoperator: 47
operand: 51
45Operationoperator: 63
operands: 49
46Operationoperator: 71
operand: 53
47Literal
48ExprTuple51
49ExprTuple86, 52
50ExprTuple53
51Lambdaparameter: 85
body: 54
52Operationoperator: 75
operands: 55
53IndexedVarvariable: 81
index: 60
54Conditionalvalue: 57
condition: 58
55ExprTuple79, 59
56ExprTuple60
57Operationoperator: 61
operands: 62
58Operationoperator: 63
operands: 64
59Variable
60Variable
61Literal
62ExprTuple65, 66, 67, 68, 69
63Literal
64ExprTuple85, 70
65Operationoperator: 73
operand: 77
66Variable
67Operationoperator: 71
operand: 78
68Operationoperator: 71
operand: 77
69Operationoperator: 73
operand: 78
70Operationoperator: 75
operands: 76
71Literal
72ExprTuple77
73Literal
74ExprTuple78
75Literal
76ExprTuple79, 80
77IndexedVarvariable: 81
index: 85
78IndexedVarvariable: 83
index: 86
79Literal
80Variable
81Variable
82ExprTuple85
83Variable
84ExprTuple86
85Variable
86Variable