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 Conditional, ExprTuple, Lambda, M, i, n
from proveit.core_expr_types import a_1_to_n, a_i, v_1_to_n, v_i
from proveit.linear_algebra import Adj, Hspace, LinMap, OrthoNormBases, ScalarMult, VecSum
from proveit.logic import Equals, Exists, Iff, InSet, Set
from proveit.numbers import Complex, Interval, one
from proveit.physics.quantum import Bra, Ket, Qmult
from proveit.physics.quantum.algebra import v_1_to_n_kets
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Adj(M)
expr = ExprTuple(Lambda(M, Conditional(Iff(Equals(Qmult(sub_expr1, M), Qmult(M, sub_expr1)), Exists(instance_param_or_params = [v_1_to_n], instance_expr = Exists(instance_param_or_params = [a_1_to_n], instance_expr = Equals(M, VecSum(index_or_indices = [i], summand = ScalarMult(a_i, Qmult(Ket(v_i), Bra(v_i))), domain = Interval(one, n))), domain = Complex).with_wrapping(), condition = InSet(Set(v_1_to_n_kets), OrthoNormBases(Hspace))).with_wrapping()).with_wrapping_at(2), InSet(M, LinMap(Hspace, Hspace)))))
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(M \mapsto \left\{\begin{array}{c} \begin{array}{l} \left(\left(M^{\dagger} \thinspace M\right) = \left(M \thinspace M^{\dagger}\right)\right) \Leftrightarrow  \\ \left[\begin{array}{l}\exists_{v_{1}, v_{2}, \ldots, v_{n}~|~\left\{\left\{\lvert v_{1} \rangle, \lvert v_{2} \rangle, \ldots, \lvert v_{n} \rangle\right\}\right\} \in \textrm{O.N.Bases}\left(\mathcal{H}\right)}~\\
\left[\begin{array}{l}\exists_{a_{1}, a_{2}, \ldots, a_{n} \in \mathbb{C}}~\\
\left(M = \left(\sum_{i=1}^{n} \left(a_{i} \cdot \left(\lvert v_{i} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right)\right)\end{array}\right]\end{array}\right] \end{array} \end{array} \textrm{ if } M \in \mathcal{L}\left(\mathcal{H}, \mathcal{H}\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: 52
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 73
operands: 7
5Literal
6ExprTuple8, 9
7ExprTuple52, 10
8Operationoperator: 46
operands: 11
9Operationoperator: 29
operand: 17
10Operationoperator: 13
operands: 14
11ExprTuple15, 16
12ExprTuple17
13Literal
14ExprTuple44, 44
15Operationoperator: 81
operands: 18
16Operationoperator: 81
operands: 19
17Lambdaparameters: 20
body: 21
18ExprTuple22, 52
19ExprTuple52, 22
20ExprTuple23
21Conditionalvalue: 24
condition: 25
22Operationoperator: 26
operand: 52
23ExprRangelambda_map: 28
start_index: 87
end_index: 88
24Operationoperator: 29
operand: 32
25Operationoperator: 73
operands: 31
26Literal
27ExprTuple52
28Lambdaparameter: 79
body: 70
29Literal
30ExprTuple32
31ExprTuple33, 34
32Lambdaparameters: 35
body: 36
33Operationoperator: 50
operand: 43
34Operationoperator: 38
operand: 44
35ExprTuple40
36Conditionalvalue: 41
condition: 42
37ExprTuple43
38Literal
39ExprTuple44
40ExprRangelambda_map: 45
start_index: 87
end_index: 88
41Operationoperator: 46
operands: 47
42Operationoperator: 48
operands: 49
43Operationoperator: 50
operands: 51
44Variable
45Lambdaparameter: 79
body: 68
46Literal
47ExprTuple52, 53
48Literal
49ExprTuple54
50Literal
51ExprTuple55
52Variable
53Operationoperator: 56
operand: 60
54ExprRangelambda_map: 58
start_index: 87
end_index: 88
55ExprRangelambda_map: 59
start_index: 87
end_index: 88
56Literal
57ExprTuple60
58Lambdaparameter: 79
body: 61
59Lambdaparameter: 79
body: 62
60Lambdaparameter: 95
body: 63
61Operationoperator: 73
operands: 64
62Operationoperator: 89
operand: 70
63Conditionalvalue: 66
condition: 67
64ExprTuple68, 69
65ExprTuple70
66Operationoperator: 71
operands: 72
67Operationoperator: 73
operands: 74
68IndexedVarvariable: 80
index: 79
69Literal
70IndexedVarvariable: 93
index: 79
71Literal
72ExprTuple76, 77
73Literal
74ExprTuple95, 78
75ExprTuple79
76IndexedVarvariable: 80
index: 95
77Operationoperator: 81
operands: 82
78Operationoperator: 83
operands: 84
79Variable
80Variable
81Literal
82ExprTuple85, 86
83Literal
84ExprTuple87, 88
85Operationoperator: 89
operand: 92
86Operationoperator: 90
operand: 92
87Literal
88Variable
89Literal
90Literal
91ExprTuple92
92IndexedVarvariable: 93
index: 95
93Variable
94ExprTuple95
95Variable