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, TensorProd, 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)
sub_expr3 = CartExp(Complex, n)
sub_expr4 = CartExp(Complex, m)
expr = ExprTuple(Lambda(var_ket_psi, Conditional(Exists(instance_param_or_params = [a_1_to_m], instance_expr = 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(sub_expr3))).with_wrapping(), condition = InSet(Set(a_1_to_m_kets), OrthoNormBases(sub_expr4))).with_wrapping(), InSet(var_ket_psi, TensorProd(sub_expr4, sub_expr3)))))
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(\lvert \psi \rangle \mapsto \left\{\begin{array}{l}\exists_{a_{1}, a_{2}, \ldots, a_{m}~|~\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)}~\\
\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}\right]\end{array} \textrm{ if } \lvert \psi \rangle \in \left(\mathbb{C}^{m} {\otimes} \mathbb{C}^{n}\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: 64
body: 3
2ExprTuple64
3Conditionalvalue: 4
condition: 5
4Operationoperator: 33
operand: 8
5Operationoperator: 87
operands: 7
6ExprTuple8
7ExprTuple64, 9
8Lambdaparameters: 10
body: 11
9Operationoperator: 12
operands: 13
10ExprTuple14
11Conditionalvalue: 15
condition: 16
12Literal
13ExprTuple31, 52
14ExprRangelambda_map: 17
start_index: 101
end_index: 110
15Operationoperator: 33
operand: 20
16Operationoperator: 87
operands: 19
17Lambdaparameter: 93
body: 69
18ExprTuple20
19ExprTuple21, 22
20Lambdaparameters: 23
body: 24
21Operationoperator: 59
operand: 30
22Operationoperator: 45
operand: 31
23ExprTuple27
24Conditionalvalue: 28
condition: 29
25ExprTuple30
26ExprTuple31
27ExprRangelambda_map: 32
start_index: 101
end_index: 111
28Operationoperator: 33
operand: 38
29Operationoperator: 87
operands: 35
30Operationoperator: 59
operands: 36
31Operationoperator: 61
operands: 37
32Lambdaparameter: 93
body: 84
33Literal
34ExprTuple38
35ExprTuple39, 40
36ExprTuple41
37ExprTuple68, 110
38Lambdaparameters: 42
body: 43
39Operationoperator: 59
operand: 51
40Operationoperator: 45
operand: 52
41ExprRangelambda_map: 47
start_index: 101
end_index: 110
42ExprTuple48
43Conditionalvalue: 49
condition: 50
44ExprTuple51
45Literal
46ExprTuple52
47Lambdaparameter: 93
body: 53
48ExprRangelambda_map: 54
start_index: 101
end_index: 102
49Operationoperator: 55
operands: 56
50Operationoperator: 57
operands: 58
51Operationoperator: 59
operands: 60
52Operationoperator: 61
operands: 62
53Operationoperator: 104
operand: 69
54Lambdaparameter: 93
body: 82
55Literal
56ExprTuple64, 65
57Literal
58ExprTuple66
59Literal
60ExprTuple67
61Literal
62ExprTuple68, 111
63ExprTuple69
64Variable
65Operationoperator: 70
operand: 74
66ExprRangelambda_map: 72
start_index: 101
end_index: 102
67ExprRangelambda_map: 73
start_index: 101
end_index: 111
68Literal
69IndexedVarvariable: 112
index: 93
70Literal
71ExprTuple74
72Lambdaparameter: 93
body: 75
73Lambdaparameter: 93
body: 76
74Lambdaparameter: 115
body: 77
75Operationoperator: 87
operands: 78
76Operationoperator: 104
operand: 84
77Conditionalvalue: 80
condition: 81
78ExprTuple82, 83
79ExprTuple84
80Operationoperator: 85
operands: 86
81Operationoperator: 87
operands: 88
82IndexedVarvariable: 94
index: 93
83Literal
84IndexedVarvariable: 113
index: 93
85Literal
86ExprTuple90, 91
87Literal
88ExprTuple115, 92
89ExprTuple93
90IndexedVarvariable: 94
index: 115
91Operationoperator: 95
operands: 96
92Operationoperator: 97
operands: 98
93Variable
94Variable
95Literal
96ExprTuple99, 100
97Literal
98ExprTuple101, 102
99Operationoperator: 104
operand: 108
100Operationoperator: 104
operand: 109
101Literal
102Operationoperator: 106
operands: 107
103ExprTuple108
104Literal
105ExprTuple109
106Literal
107ExprTuple110, 111
108IndexedVarvariable: 112
index: 115
109IndexedVarvariable: 113
index: 115
110Variable
111Variable
112Variable
113Variable
114ExprTuple115
115Variable