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 ExprTuple, 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, OrthoNormBases, ScalarMult, VecSum
from proveit.logic import Equals, Exists, 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(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())
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(M^{\dagger} \thinspace M\right) = \left(M \thinspace M^{\dagger}\right), \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)
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: 36
operands: 3
2Operationoperator: 19
operand: 7
3ExprTuple5, 6
4ExprTuple7
5Operationoperator: 71
operands: 8
6Operationoperator: 71
operands: 9
7Lambdaparameters: 10
body: 11
8ExprTuple12, 42
9ExprTuple42, 12
10ExprTuple13
11Conditionalvalue: 14
condition: 15
12Operationoperator: 16
operand: 42
13ExprRangelambda_map: 18
start_index: 77
end_index: 78
14Operationoperator: 19
operand: 22
15Operationoperator: 63
operands: 21
16Literal
17ExprTuple42
18Lambdaparameter: 69
body: 60
19Literal
20ExprTuple22
21ExprTuple23, 24
22Lambdaparameters: 25
body: 26
23Operationoperator: 40
operand: 33
24Operationoperator: 28
operand: 34
25ExprTuple30
26Conditionalvalue: 31
condition: 32
27ExprTuple33
28Literal
29ExprTuple34
30ExprRangelambda_map: 35
start_index: 77
end_index: 78
31Operationoperator: 36
operands: 37
32Operationoperator: 38
operands: 39
33Operationoperator: 40
operands: 41
34Variable
35Lambdaparameter: 69
body: 58
36Literal
37ExprTuple42, 43
38Literal
39ExprTuple44
40Literal
41ExprTuple45
42Variable
43Operationoperator: 46
operand: 50
44ExprRangelambda_map: 48
start_index: 77
end_index: 78
45ExprRangelambda_map: 49
start_index: 77
end_index: 78
46Literal
47ExprTuple50
48Lambdaparameter: 69
body: 51
49Lambdaparameter: 69
body: 52
50Lambdaparameter: 85
body: 53
51Operationoperator: 63
operands: 54
52Operationoperator: 79
operand: 60
53Conditionalvalue: 56
condition: 57
54ExprTuple58, 59
55ExprTuple60
56Operationoperator: 61
operands: 62
57Operationoperator: 63
operands: 64
58IndexedVarvariable: 70
index: 69
59Literal
60IndexedVarvariable: 83
index: 69
61Literal
62ExprTuple66, 67
63Literal
64ExprTuple85, 68
65ExprTuple69
66IndexedVarvariable: 70
index: 85
67Operationoperator: 71
operands: 72
68Operationoperator: 73
operands: 74
69Variable
70Variable
71Literal
72ExprTuple75, 76
73Literal
74ExprTuple77, 78
75Operationoperator: 79
operand: 82
76Operationoperator: 80
operand: 82
77Literal
78Variable
79Literal
80Literal
81ExprTuple82
82IndexedVarvariable: 83
index: 85
83Variable
84ExprTuple85
85Variable