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 And, Equals, Forall, InSet
from proveit.numbers import Interval, NaturalPos, 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([m, n], Conditional(Forall(instance_param_or_params = [v_1_to_m], instance_expr = 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(), condition = InSet(v_1_to_m_kets, OrthoNormBases(V))).with_wrapping(), And(InSet(m, NaturalPos), InSet(n, NaturalPos)))))
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(m, n\right) \mapsto \left\{\begin{array}{l}\forall_{v_{1}, v_{2}, \ldots, v_{m}~|~\left\{\lvert v_{1} \rangle, \lvert v_{2} \rangle, \ldots, \lvert v_{m} \rangle\right\} \in \textrm{O.N.Bases}\left(V\right)}~\\
\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}\right]\end{array} \textrm{ if } m \in \mathbb{N}^+ ,  n \in \mathbb{N}^+\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
2ExprTuple72, 93
3Conditionalvalue: 4
condition: 5
4Operationoperator: 21
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple10, 11
9Lambdaparameters: 12
body: 13
10Operationoperator: 76
operands: 14
11Operationoperator: 76
operands: 15
12ExprTuple16
13Conditionalvalue: 17
condition: 18
14ExprTuple72, 19
15ExprTuple93, 19
16ExprRangelambda_map: 20
start_index: 92
end_index: 72
17Operationoperator: 21
operand: 24
18Operationoperator: 76
operands: 23
19Literal
20Lambdaparameter: 73
body: 54
21Literal
22ExprTuple24
23ExprTuple25, 26
24Lambdaparameters: 27
body: 28
25Operationoperator: 46
operands: 29
26Operationoperator: 48
operand: 35
27ExprTuple31
28Conditionalvalue: 32
condition: 33
29ExprTuple34
30ExprTuple35
31ExprRangelambda_map: 36
start_index: 92
end_index: 93
32Operationoperator: 37
operands: 38
33Operationoperator: 76
operands: 39
34ExprRangelambda_map: 40
start_index: 92
end_index: 72
35Variable
36Lambdaparameter: 73
body: 66
37Literal
38ExprTuple79, 41
39ExprTuple42, 43
40Lambdaparameter: 73
body: 44
41Operationoperator: 60
operand: 51
42Operationoperator: 46
operands: 47
43Operationoperator: 48
operand: 53
44Operationoperator: 84
operand: 54
45ExprTuple51
46Literal
47ExprTuple52
48Literal
49ExprTuple53
50ExprTuple54
51Lambdaparameter: 99
body: 55
52ExprRangelambda_map: 56
start_index: 92
end_index: 93
53Variable
54IndexedVarvariable: 96
index: 73
55Conditionalvalue: 57
condition: 58
56Lambdaparameter: 73
body: 59
57Operationoperator: 60
operand: 64
58Operationoperator: 76
operands: 62
59Operationoperator: 84
operand: 66
60Literal
61ExprTuple64
62ExprTuple99, 65
63ExprTuple66
64Lambdaparameter: 98
body: 67
65Operationoperator: 88
operands: 68
66IndexedVarvariable: 94
index: 73
67Conditionalvalue: 70
condition: 71
68ExprTuple92, 72
69ExprTuple73
70Operationoperator: 74
operands: 75
71Operationoperator: 76
operands: 77
72Variable
73Variable
74Literal
75ExprTuple78, 79, 80, 81, 82
76Literal
77ExprTuple98, 83
78Operationoperator: 86
operand: 90
79Variable
80Operationoperator: 84
operand: 91
81Operationoperator: 84
operand: 90
82Operationoperator: 86
operand: 91
83Operationoperator: 88
operands: 89
84Literal
85ExprTuple90
86Literal
87ExprTuple91
88Literal
89ExprTuple92, 93
90IndexedVarvariable: 94
index: 98
91IndexedVarvariable: 96
index: 99
92Literal
93Variable
94Variable
95ExprTuple98
96Variable
97ExprTuple99
98Variable
99Variable