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, Conditional, ExprTuple, Lambda, 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 Adj, Commutator, MatrixSpace, OrthoNormBases, ScalarMult, VecSum, VecZero
from proveit.logic import And, CartExp, Equals, Exists, Forall, Iff, InSet, Set
from proveit.numbers import Complex, Interval, NaturalPos, one
from proveit.physics.quantum import Bra, Ket, Qmult
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [i]
sub_expr2 = MatrixSpace(field = Complex, rows = n, columns = n)
sub_expr3 = Interval(one, n)
sub_expr4 = Qmult(Ket(v_i), Bra(v_i))
expr = ExprTuple(Lambda(n, Conditional(Forall(instance_param_or_params = [A, B], instance_expr = Iff(Equals(Commutator(A, B), VecZero(sub_expr2)), 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_expr4), domain = sub_expr3)), Equals(B, VecSum(index_or_indices = sub_expr1, summand = ScalarMult(b_i, sub_expr4), domain = sub_expr3))).with_wrapping_at(2), domain = Complex).with_wrapping(), condition = InSet(Set(v_1_to_n), OrthoNormBases(CartExp(Complex, n)))).with_wrapping()).with_wrapping_at(2), domain = sub_expr2, conditions = [Equals(Adj(A), A), Equals(Adj(B), B)]).with_wrapping(), 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(n \mapsto \left\{\begin{array}{l}\forall_{A, B \in \mathbb{C}^{n \times n}~|~A^{\dagger} = A, B^{\dagger} = B}~\\
\left(\begin{array}{c} \begin{array}{l} \left(\left[A, B\right] = \vec{0}\left(\mathbb{C}^{n \times n}\right)\right) \Leftrightarrow  \\ \left[\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] \end{array} \end{array}\right)\end{array} \textrm{ if } 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
1Lambdaparameter: 124
body: 3
2ExprTuple124
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 109
operands: 8
6Literal
7ExprTuple9
8ExprTuple124, 10
9Lambdaparameters: 35
body: 11
10Literal
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operands: 15
13Operationoperator: 68
operands: 16
14Literal
15ExprTuple17, 18
16ExprTuple19, 20, 21, 22
17Operationoperator: 79
operands: 23
18Operationoperator: 47
operand: 31
19Operationoperator: 109
operands: 25
20Operationoperator: 109
operands: 26
21Operationoperator: 79
operands: 27
22Operationoperator: 79
operands: 28
23ExprTuple29, 30
24ExprTuple31
25ExprTuple83, 42
26ExprTuple85, 42
27ExprTuple32, 83
28ExprTuple33, 85
29Operationoperator: 34
operands: 35
30Operationoperator: 36
operand: 42
31Lambdaparameters: 56
body: 38
32Operationoperator: 40
operand: 83
33Operationoperator: 40
operand: 85
34Literal
35ExprTuple83, 85
36Literal
37ExprTuple42
38Conditionalvalue: 43
condition: 44
39ExprTuple83
40Literal
41ExprTuple85
42Operationoperator: 45
operands: 46
43Operationoperator: 47
operand: 50
44Operationoperator: 109
operands: 49
45Literal
46NamedExprsfield: 98
rows: 124
columns: 124
47Literal
48ExprTuple50
49ExprTuple51, 52
50Lambdaparameters: 53
body: 54
51Operationoperator: 55
operands: 56
52Operationoperator: 57
operand: 64
53ExprTuple59, 60
54Conditionalvalue: 61
condition: 62
55Literal
56ExprTuple63
57Literal
58ExprTuple64
59ExprRangelambda_map: 65
start_index: 123
end_index: 124
60ExprRangelambda_map: 66
start_index: 123
end_index: 124
61Operationoperator: 68
operands: 67
62Operationoperator: 68
operands: 69
63ExprRangelambda_map: 70
start_index: 123
end_index: 124
64Operationoperator: 71
operands: 72
65Lambdaparameter: 105
body: 96
66Lambdaparameter: 105
body: 97
67ExprTuple73, 74
68Literal
69ExprTuple75, 76
70Lambdaparameter: 105
body: 77
71Literal
72ExprTuple98, 124
73Operationoperator: 79
operands: 78
74Operationoperator: 79
operands: 80
75ExprRangelambda_map: 81
start_index: 123
end_index: 124
76ExprRangelambda_map: 82
start_index: 123
end_index: 124
77IndexedVarvariable: 129
index: 105
78ExprTuple83, 84
79Literal
80ExprTuple85, 86
81Lambdaparameter: 105
body: 87
82Lambdaparameter: 105
body: 88
83Variable
84Operationoperator: 90
operand: 94
85Variable
86Operationoperator: 90
operand: 95
87Operationoperator: 109
operands: 92
88Operationoperator: 109
operands: 93
89ExprTuple94
90Literal
91ExprTuple95
92ExprTuple96, 98
93ExprTuple97, 98
94Lambdaparameter: 131
body: 99
95Lambdaparameter: 131
body: 100
96IndexedVarvariable: 115
index: 105
97IndexedVarvariable: 116
index: 105
98Literal
99Conditionalvalue: 102
condition: 104
100Conditionalvalue: 103
condition: 104
101ExprTuple105
102Operationoperator: 107
operands: 106
103Operationoperator: 107
operands: 108
104Operationoperator: 109
operands: 110
105Variable
106ExprTuple111, 113
107Literal
108ExprTuple112, 113
109Literal
110ExprTuple131, 114
111IndexedVarvariable: 115
index: 131
112IndexedVarvariable: 116
index: 131
113Operationoperator: 117
operands: 118
114Operationoperator: 119
operands: 120
115Variable
116Variable
117Literal
118ExprTuple121, 122
119Literal
120ExprTuple123, 124
121Operationoperator: 125
operand: 128
122Operationoperator: 126
operand: 128
123Literal
124Variable
125Literal
126Literal
127ExprTuple128
128IndexedVarvariable: 129
index: 131
129Variable
130ExprTuple131
131Variable