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 LinMap, OrthoNormBases, VecSum
from proveit.logic import 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(A, Conditional(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), InSet(A, LinMap(V, 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(A \mapsto \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] \textrm{ if } A \in \mathcal{L}\left(V, 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
1Lambdaparameter: 89
body: 3
2ExprTuple89
3Conditionalvalue: 4
condition: 5
4Operationoperator: 31
operand: 8
5Operationoperator: 86
operands: 7
6ExprTuple8
7ExprTuple89, 9
8Lambdaparameters: 10
body: 11
9Operationoperator: 12
operands: 13
10ExprTuple82, 103
11Conditionalvalue: 14
condition: 15
12Literal
13ExprTuple45, 63
14Operationoperator: 31
operand: 19
15Operationoperator: 17
operands: 18
16ExprTuple19
17Literal
18ExprTuple20, 21
19Lambdaparameters: 22
body: 23
20Operationoperator: 86
operands: 24
21Operationoperator: 86
operands: 25
22ExprTuple26
23Conditionalvalue: 27
condition: 28
24ExprTuple82, 29
25ExprTuple103, 29
26ExprRangelambda_map: 30
start_index: 102
end_index: 82
27Operationoperator: 31
operand: 34
28Operationoperator: 86
operands: 33
29Literal
30Lambdaparameter: 83
body: 64
31Literal
32ExprTuple34
33ExprTuple35, 36
34Lambdaparameters: 37
body: 38
35Operationoperator: 56
operands: 39
36Operationoperator: 58
operand: 45
37ExprTuple41
38Conditionalvalue: 42
condition: 43
39ExprTuple44
40ExprTuple45
41ExprRangelambda_map: 46
start_index: 102
end_index: 103
42Operationoperator: 47
operands: 48
43Operationoperator: 86
operands: 49
44ExprRangelambda_map: 50
start_index: 102
end_index: 82
45Variable
46Lambdaparameter: 83
body: 76
47Literal
48ExprTuple89, 51
49ExprTuple52, 53
50Lambdaparameter: 83
body: 54
51Operationoperator: 70
operand: 61
52Operationoperator: 56
operands: 57
53Operationoperator: 58
operand: 63
54Operationoperator: 94
operand: 64
55ExprTuple61
56Literal
57ExprTuple62
58Literal
59ExprTuple63
60ExprTuple64
61Lambdaparameter: 109
body: 65
62ExprRangelambda_map: 66
start_index: 102
end_index: 103
63Variable
64IndexedVarvariable: 106
index: 83
65Conditionalvalue: 67
condition: 68
66Lambdaparameter: 83
body: 69
67Operationoperator: 70
operand: 74
68Operationoperator: 86
operands: 72
69Operationoperator: 94
operand: 76
70Literal
71ExprTuple74
72ExprTuple109, 75
73ExprTuple76
74Lambdaparameter: 108
body: 77
75Operationoperator: 98
operands: 78
76IndexedVarvariable: 104
index: 83
77Conditionalvalue: 80
condition: 81
78ExprTuple102, 82
79ExprTuple83
80Operationoperator: 84
operands: 85
81Operationoperator: 86
operands: 87
82Variable
83Variable
84Literal
85ExprTuple88, 89, 90, 91, 92
86Literal
87ExprTuple108, 93
88Operationoperator: 96
operand: 100
89Variable
90Operationoperator: 94
operand: 101
91Operationoperator: 94
operand: 100
92Operationoperator: 96
operand: 101
93Operationoperator: 98
operands: 99
94Literal
95ExprTuple100
96Literal
97ExprTuple101
98Literal
99ExprTuple102, 103
100IndexedVarvariable: 104
index: 108
101IndexedVarvariable: 106
index: 109
102Literal
103Variable
104Variable
105ExprTuple108
106Variable
107ExprTuple109
108Variable
109Variable