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 HilbertSpaces, LinMap, OrthoNormBases, VecSum
from proveit.logic import And, Equals, Forall, InClass, 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([V, W], Conditional(Forall(instance_param_or_params = [A], instance_expr = Forall(instance_param_or_params = [m, n], instance_expr = 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(), domain = NaturalPos), domain = LinMap(V, W)), And(InClass(V, HilbertSpaces), InClass(W, HilbertSpaces)))))
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, W\right) \mapsto \left\{\forall_{A \in \mathcal{L}\left(V, W\right)}~\left[\forall_{m, n \in \mathbb{N}^+}~\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}\right]\right] \textrm{ if } V \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces} ,  W \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces}\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: 25
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 43
operand: 7
4Operationoperator: 29
operands: 6
5ExprTuple7
6ExprTuple8, 9
7Lambdaparameter: 101
body: 11
8Operationoperator: 13
operands: 12
9Operationoperator: 13
operands: 14
10ExprTuple101
11Conditionalvalue: 15
condition: 16
12ExprTuple57, 17
13Literal
14ExprTuple75, 17
15Operationoperator: 43
operand: 20
16Operationoperator: 98
operands: 19
17Literal
18ExprTuple20
19ExprTuple101, 21
20Lambdaparameters: 22
body: 23
21Operationoperator: 24
operands: 25
22ExprTuple94, 115
23Conditionalvalue: 26
condition: 27
24Literal
25ExprTuple57, 75
26Operationoperator: 43
operand: 31
27Operationoperator: 29
operands: 30
28ExprTuple31
29Literal
30ExprTuple32, 33
31Lambdaparameters: 34
body: 35
32Operationoperator: 98
operands: 36
33Operationoperator: 98
operands: 37
34ExprTuple38
35Conditionalvalue: 39
condition: 40
36ExprTuple94, 41
37ExprTuple115, 41
38ExprRangelambda_map: 42
start_index: 114
end_index: 94
39Operationoperator: 43
operand: 46
40Operationoperator: 98
operands: 45
41Literal
42Lambdaparameter: 95
body: 76
43Literal
44ExprTuple46
45ExprTuple47, 48
46Lambdaparameters: 49
body: 50
47Operationoperator: 68
operands: 51
48Operationoperator: 70
operand: 57
49ExprTuple53
50Conditionalvalue: 54
condition: 55
51ExprTuple56
52ExprTuple57
53ExprRangelambda_map: 58
start_index: 114
end_index: 115
54Operationoperator: 59
operands: 60
55Operationoperator: 98
operands: 61
56ExprRangelambda_map: 62
start_index: 114
end_index: 94
57Variable
58Lambdaparameter: 95
body: 88
59Literal
60ExprTuple101, 63
61ExprTuple64, 65
62Lambdaparameter: 95
body: 66
63Operationoperator: 82
operand: 73
64Operationoperator: 68
operands: 69
65Operationoperator: 70
operand: 75
66Operationoperator: 106
operand: 76
67ExprTuple73
68Literal
69ExprTuple74
70Literal
71ExprTuple75
72ExprTuple76
73Lambdaparameter: 121
body: 77
74ExprRangelambda_map: 78
start_index: 114
end_index: 115
75Variable
76IndexedVarvariable: 118
index: 95
77Conditionalvalue: 79
condition: 80
78Lambdaparameter: 95
body: 81
79Operationoperator: 82
operand: 86
80Operationoperator: 98
operands: 84
81Operationoperator: 106
operand: 88
82Literal
83ExprTuple86
84ExprTuple121, 87
85ExprTuple88
86Lambdaparameter: 120
body: 89
87Operationoperator: 110
operands: 90
88IndexedVarvariable: 116
index: 95
89Conditionalvalue: 92
condition: 93
90ExprTuple114, 94
91ExprTuple95
92Operationoperator: 96
operands: 97
93Operationoperator: 98
operands: 99
94Variable
95Variable
96Literal
97ExprTuple100, 101, 102, 103, 104
98Literal
99ExprTuple120, 105
100Operationoperator: 108
operand: 112
101Variable
102Operationoperator: 106
operand: 113
103Operationoperator: 106
operand: 112
104Operationoperator: 108
operand: 113
105Operationoperator: 110
operands: 111
106Literal
107ExprTuple112
108Literal
109ExprTuple113
110Literal
111ExprTuple114, 115
112IndexedVarvariable: 116
index: 120
113IndexedVarvariable: 118
index: 121
114Literal
115Variable
116Variable
117ExprTuple120
118Variable
119ExprTuple121
120Variable
121Variable