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 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
expr = ExprTuple(Lambda([v_1_to_n], Conditional(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(), InSet(Set(v_1_to_n_kets), OrthoNormBases(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(\left(v_{1}, v_{2}, \ldots, v_{n}\right) \mapsto \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} \textrm{ if } \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)\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
1Lambdaparameters: 2
body: 3
2ExprTuple4
3Conditionalvalue: 5
condition: 6
4ExprRangelambda_map: 7
start_index: 66
end_index: 67
5Operationoperator: 8
operand: 11
6Operationoperator: 52
operands: 10
7Lambdaparameter: 58
body: 49
8Literal
9ExprTuple11
10ExprTuple12, 13
11Lambdaparameters: 14
body: 15
12Operationoperator: 29
operand: 22
13Operationoperator: 17
operand: 23
14ExprTuple19
15Conditionalvalue: 20
condition: 21
16ExprTuple22
17Literal
18ExprTuple23
19ExprRangelambda_map: 24
start_index: 66
end_index: 67
20Operationoperator: 25
operands: 26
21Operationoperator: 27
operands: 28
22Operationoperator: 29
operands: 30
23Variable
24Lambdaparameter: 58
body: 47
25Literal
26ExprTuple31, 32
27Literal
28ExprTuple33
29Literal
30ExprTuple34
31Variable
32Operationoperator: 35
operand: 39
33ExprRangelambda_map: 37
start_index: 66
end_index: 67
34ExprRangelambda_map: 38
start_index: 66
end_index: 67
35Literal
36ExprTuple39
37Lambdaparameter: 58
body: 40
38Lambdaparameter: 58
body: 41
39Lambdaparameter: 74
body: 42
40Operationoperator: 52
operands: 43
41Operationoperator: 68
operand: 49
42Conditionalvalue: 45
condition: 46
43ExprTuple47, 48
44ExprTuple49
45Operationoperator: 50
operands: 51
46Operationoperator: 52
operands: 53
47IndexedVarvariable: 59
index: 58
48Literal
49IndexedVarvariable: 72
index: 58
50Literal
51ExprTuple55, 56
52Literal
53ExprTuple74, 57
54ExprTuple58
55IndexedVarvariable: 59
index: 74
56Operationoperator: 60
operands: 61
57Operationoperator: 62
operands: 63
58Variable
59Variable
60Literal
61ExprTuple64, 65
62Literal
63ExprTuple66, 67
64Operationoperator: 68
operand: 71
65Operationoperator: 69
operand: 71
66Literal
67Variable
68Literal
69Literal
70ExprTuple71
71IndexedVarvariable: 72
index: 74
72Variable
73ExprTuple74
74Variable