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, MatrixSpace, OrthoNormBases, ScalarMult, VecSum, VecZero
from proveit.logic import And, CartExp, 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(MatrixSpace(field = Complex, rows = n, columns = n))), 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(CartExp(Complex, n)))).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(\mathbb{C}^{n \times n}\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(\mathbb{C}^{n}\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: 50
operands: 3
2Operationoperator: 18
operand: 7
3ExprTuple5, 6
4ExprTuple7
5Operationoperator: 8
operands: 9
6Operationoperator: 10
operand: 13
7Lambdaparameters: 27
body: 12
8Literal
9ExprTuple54, 56
10Literal
11ExprTuple13
12Conditionalvalue: 14
condition: 15
13Operationoperator: 16
operands: 17
14Operationoperator: 18
operand: 21
15Operationoperator: 80
operands: 20
16Literal
17NamedExprsfield: 69
rows: 95
columns: 95
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: 94
end_index: 95
31ExprRangelambda_map: 37
start_index: 94
end_index: 95
32Operationoperator: 39
operands: 38
33Operationoperator: 39
operands: 40
34ExprRangelambda_map: 41
start_index: 94
end_index: 95
35Operationoperator: 42
operands: 43
36Lambdaparameter: 76
body: 67
37Lambdaparameter: 76
body: 68
38ExprTuple44, 45
39Literal
40ExprTuple46, 47
41Lambdaparameter: 76
body: 48
42Literal
43ExprTuple69, 95
44Operationoperator: 50
operands: 49
45Operationoperator: 50
operands: 51
46ExprRangelambda_map: 52
start_index: 94
end_index: 95
47ExprRangelambda_map: 53
start_index: 94
end_index: 95
48IndexedVarvariable: 100
index: 76
49ExprTuple54, 55
50Literal
51ExprTuple56, 57
52Lambdaparameter: 76
body: 58
53Lambdaparameter: 76
body: 59
54Variable
55Operationoperator: 61
operand: 65
56Variable
57Operationoperator: 61
operand: 66
58Operationoperator: 80
operands: 63
59Operationoperator: 80
operands: 64
60ExprTuple65
61Literal
62ExprTuple66
63ExprTuple67, 69
64ExprTuple68, 69
65Lambdaparameter: 102
body: 70
66Lambdaparameter: 102
body: 71
67IndexedVarvariable: 86
index: 76
68IndexedVarvariable: 87
index: 76
69Literal
70Conditionalvalue: 73
condition: 75
71Conditionalvalue: 74
condition: 75
72ExprTuple76
73Operationoperator: 78
operands: 77
74Operationoperator: 78
operands: 79
75Operationoperator: 80
operands: 81
76Variable
77ExprTuple82, 84
78Literal
79ExprTuple83, 84
80Literal
81ExprTuple102, 85
82IndexedVarvariable: 86
index: 102
83IndexedVarvariable: 87
index: 102
84Operationoperator: 88
operands: 89
85Operationoperator: 90
operands: 91
86Variable
87Variable
88Literal
89ExprTuple92, 93
90Literal
91ExprTuple94, 95
92Operationoperator: 96
operand: 99
93Operationoperator: 97
operand: 99
94Literal
95Variable
96Literal
97Literal
98ExprTuple99
99IndexedVarvariable: 100
index: 102
100Variable
101ExprTuple102
102Variable