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, ExprRange, ExprTuple, IndexedVar, Lambda, Variable, i, lambda_, m, n
from proveit.core_expr_types import a_1_to_m, a_i, b_1_to_n, b_i, lambda_i
from proveit.linear_algebra import OrthoNormBases, ScalarMult, VecSum
from proveit.logic import CartExp, Equals, Exists, InSet, Set
from proveit.numbers import Complex, Interval, Min, RealNonNeg, one
from proveit.physics.quantum import Ket, Qmult, var_ket_psi
from proveit.physics.quantum.algebra import a_1_to_m_kets, b_1_to_n_kets
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = Min(m, n)
expr = ExprTuple(Lambda([a_1_to_m], Conditional(Exists(instance_param_or_params = [b_1_to_n], instance_expr = Exists(instance_param_or_params = [ExprRange(sub_expr1, IndexedVar(lambda_, sub_expr1), one, sub_expr2)], instance_expr = Equals(var_ket_psi, VecSum(index_or_indices = [i], summand = ScalarMult(lambda_i, Qmult(Ket(a_i), Ket(b_i))), domain = Interval(one, sub_expr2))), domain = RealNonNeg).with_wrapping(), condition = InSet(Set(b_1_to_n_kets), OrthoNormBases(CartExp(Complex, n)))).with_wrapping(), InSet(Set(a_1_to_m_kets), OrthoNormBases(CartExp(Complex, m))))))
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_{1}, a_{2}, \ldots, a_{m}\right) \mapsto \left\{\begin{array}{l}\exists_{b_{1}, b_{2}, \ldots, b_{n}~|~\left\{\left\{\lvert b_{1} \rangle, \lvert b_{2} \rangle, \ldots, \lvert b_{n} \rangle\right\}\right\} \in \textrm{O.N.Bases}\left(\mathbb{C}^{n}\right)}~\\
\left[\begin{array}{l}\exists_{\lambda_{1}, \lambda_{2}, \ldots, \lambda_{{\rm Min}\left(m, n\right)} \in \mathbb{R}^{\ge 0}}~\\
\left(\lvert \psi \rangle = \left(\sum_{i=1}^{{\rm Min}\left(m, n\right)} \left(\lambda_{i} \cdot \left(\lvert a_{i} \rangle \thinspace \lvert b_{i} \rangle\right)\right)\right)\right)\end{array}\right]\end{array} \textrm{ if } \left\{\left\{\lvert a_{1} \rangle, \lvert a_{2} \rangle, \ldots, \lvert a_{m} \rangle\right\}\right\} \in \textrm{O.N.Bases}\left(\mathbb{C}^{m}\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: 91
end_index: 100
5Operationoperator: 23
operand: 10
6Operationoperator: 77
operands: 9
7Lambdaparameter: 83
body: 59
8ExprTuple10
9ExprTuple11, 12
10Lambdaparameters: 13
body: 14
11Operationoperator: 49
operand: 20
12Operationoperator: 35
operand: 21
13ExprTuple17
14Conditionalvalue: 18
condition: 19
15ExprTuple20
16ExprTuple21
17ExprRangelambda_map: 22
start_index: 91
end_index: 101
18Operationoperator: 23
operand: 28
19Operationoperator: 77
operands: 25
20Operationoperator: 49
operands: 26
21Operationoperator: 51
operands: 27
22Lambdaparameter: 83
body: 74
23Literal
24ExprTuple28
25ExprTuple29, 30
26ExprTuple31
27ExprTuple58, 100
28Lambdaparameters: 32
body: 33
29Operationoperator: 49
operand: 41
30Operationoperator: 35
operand: 42
31ExprRangelambda_map: 37
start_index: 91
end_index: 100
32ExprTuple38
33Conditionalvalue: 39
condition: 40
34ExprTuple41
35Literal
36ExprTuple42
37Lambdaparameter: 83
body: 43
38ExprRangelambda_map: 44
start_index: 91
end_index: 92
39Operationoperator: 45
operands: 46
40Operationoperator: 47
operands: 48
41Operationoperator: 49
operands: 50
42Operationoperator: 51
operands: 52
43Operationoperator: 94
operand: 59
44Lambdaparameter: 83
body: 72
45Literal
46ExprTuple54, 55
47Literal
48ExprTuple56
49Literal
50ExprTuple57
51Literal
52ExprTuple58, 101
53ExprTuple59
54Variable
55Operationoperator: 60
operand: 64
56ExprRangelambda_map: 62
start_index: 91
end_index: 92
57ExprRangelambda_map: 63
start_index: 91
end_index: 101
58Literal
59IndexedVarvariable: 102
index: 83
60Literal
61ExprTuple64
62Lambdaparameter: 83
body: 65
63Lambdaparameter: 83
body: 66
64Lambdaparameter: 105
body: 67
65Operationoperator: 77
operands: 68
66Operationoperator: 94
operand: 74
67Conditionalvalue: 70
condition: 71
68ExprTuple72, 73
69ExprTuple74
70Operationoperator: 75
operands: 76
71Operationoperator: 77
operands: 78
72IndexedVarvariable: 84
index: 83
73Literal
74IndexedVarvariable: 103
index: 83
75Literal
76ExprTuple80, 81
77Literal
78ExprTuple105, 82
79ExprTuple83
80IndexedVarvariable: 84
index: 105
81Operationoperator: 85
operands: 86
82Operationoperator: 87
operands: 88
83Variable
84Variable
85Literal
86ExprTuple89, 90
87Literal
88ExprTuple91, 92
89Operationoperator: 94
operand: 98
90Operationoperator: 94
operand: 99
91Literal
92Operationoperator: 96
operands: 97
93ExprTuple98
94Literal
95ExprTuple99
96Literal
97ExprTuple100, 101
98IndexedVarvariable: 102
index: 105
99IndexedVarvariable: 103
index: 105
100Variable
101Variable
102Variable
103Variable
104ExprTuple105
105Variable