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, B, ExprTuple, i, n
from proveit.core_expr_types import a_1_to_n, a_i, b_1_to_n, b_i, v_1_to_n, v_i
from proveit.linear_algebra import Commutator, Hspace, LinMap, OrthoNormBases, ScalarMult, VecSum, VecZero
from proveit.logic import And, Equals, Exists, InSet, Set
from proveit.numbers import Complex, Interval, one
from proveit.physics.quantum import Bra, Ket, Qmult
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [i]
sub_expr2 = Interval(one, n)
sub_expr3 = Qmult(Ket(v_i), Bra(v_i))
expr = ExprTuple(Equals(Commutator(A, B), VecZero(LinMap(Hspace, Hspace))), Exists(instance_param_or_params = [v_1_to_n], instance_expr = Exists(instance_param_or_params = [a_1_to_n, b_1_to_n], instance_expr = And(Equals(A, VecSum(index_or_indices = sub_expr1, summand = ScalarMult(a_i, sub_expr3), domain = sub_expr2)), Equals(B, VecSum(index_or_indices = sub_expr1, summand = ScalarMult(b_i, sub_expr3), domain = sub_expr2))).with_wrapping_at(2), domain = Complex).with_wrapping(), condition = InSet(Set(v_1_to_n), OrthoNormBases(Hspace))).with_wrapping())
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[A, B\right] = \vec{0}\left(\mathcal{L}\left(\mathcal{H}, \mathcal{H}\right)\right), \begin{array}{l}\exists_{v_{1}, v_{2}, \ldots, v_{n}~|~\left\{v_{1}, v_{2}, \ldots, v_{n}\right\} \in \textrm{O.N.Bases}\left(\mathcal{H}\right)}~\\
\left[\begin{array}{l}\exists_{a_{1}, a_{2}, \ldots, a_{n}, b_{1}, b_{2}, \ldots, b_{n} \in \mathbb{C}}~\\
\left(\begin{array}{c} \left(A = \left(\sum_{i=1}^{n} \left(a_{i} \cdot \left(\lvert v_{i} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right)\right) \land  \\ \left(B = \left(\sum_{i=1}^{n} \left(b_{i} \cdot \left(\lvert v_{i} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right)\right) \end{array}\right)\end{array}\right]\end{array}\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1Operationoperator: 48
operands: 3
2Operationoperator: 18
operand: 7
3ExprTuple5, 6
4ExprTuple7
5Operationoperator: 8
operands: 9
6Operationoperator: 10
operand: 13
7Lambdaparameters: 27
body: 12
8Literal
9ExprTuple52, 54
10Literal
11ExprTuple13
12Conditionalvalue: 14
condition: 15
13Operationoperator: 16
operands: 17
14Operationoperator: 18
operand: 21
15Operationoperator: 78
operands: 20
16Literal
17ExprTuple35, 35
18Literal
19ExprTuple21
20ExprTuple22, 23
21Lambdaparameters: 24
body: 25
22Operationoperator: 26
operands: 27
23Operationoperator: 28
operand: 35
24ExprTuple30, 31
25Conditionalvalue: 32
condition: 33
26Literal
27ExprTuple34
28Literal
29ExprTuple35
30ExprRangelambda_map: 36
start_index: 92
end_index: 93
31ExprRangelambda_map: 37
start_index: 92
end_index: 93
32Operationoperator: 39
operands: 38
33Operationoperator: 39
operands: 40
34ExprRangelambda_map: 41
start_index: 92
end_index: 93
35Variable
36Lambdaparameter: 74
body: 65
37Lambdaparameter: 74
body: 66
38ExprTuple42, 43
39Literal
40ExprTuple44, 45
41Lambdaparameter: 74
body: 46
42Operationoperator: 48
operands: 47
43Operationoperator: 48
operands: 49
44ExprRangelambda_map: 50
start_index: 92
end_index: 93
45ExprRangelambda_map: 51
start_index: 92
end_index: 93
46IndexedVarvariable: 98
index: 74
47ExprTuple52, 53
48Literal
49ExprTuple54, 55
50Lambdaparameter: 74
body: 56
51Lambdaparameter: 74
body: 57
52Variable
53Operationoperator: 59
operand: 63
54Variable
55Operationoperator: 59
operand: 64
56Operationoperator: 78
operands: 61
57Operationoperator: 78
operands: 62
58ExprTuple63
59Literal
60ExprTuple64
61ExprTuple65, 67
62ExprTuple66, 67
63Lambdaparameter: 100
body: 68
64Lambdaparameter: 100
body: 69
65IndexedVarvariable: 84
index: 74
66IndexedVarvariable: 85
index: 74
67Literal
68Conditionalvalue: 71
condition: 73
69Conditionalvalue: 72
condition: 73
70ExprTuple74
71Operationoperator: 76
operands: 75
72Operationoperator: 76
operands: 77
73Operationoperator: 78
operands: 79
74Variable
75ExprTuple80, 82
76Literal
77ExprTuple81, 82
78Literal
79ExprTuple100, 83
80IndexedVarvariable: 84
index: 100
81IndexedVarvariable: 85
index: 100
82Operationoperator: 86
operands: 87
83Operationoperator: 88
operands: 89
84Variable
85Variable
86Literal
87ExprTuple90, 91
88Literal
89ExprTuple92, 93
90Operationoperator: 94
operand: 97
91Operationoperator: 95
operand: 97
92Literal
93Variable
94Literal
95Literal
96ExprTuple97
97IndexedVarvariable: 98
index: 100
98Variable
99ExprTuple100
100Variable