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 And, CartExp, Equals, Exists, Forall, InSet, Set
from proveit.numbers import Complex, Interval, Min, NaturalPos, 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([m, n], Conditional(Forall(instance_param_or_params = [var_ket_psi], instance_expr = 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(), domain = TensorProd(sub_expr4, sub_expr3)).with_wrapping(), And(InSet(m, NaturalPos), InSet(n, NaturalPos)))))
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, n\right) \mapsto \left\{\begin{array}{l}\forall_{\lvert \psi \rangle \in \mathbb{C}^{m} {\otimes} \mathbb{C}^{n}}~\\
\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}\right]\end{array} \textrm{ if } m \in \mathbb{N}^+ ,  n \in \mathbb{N}^+\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: 119
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 69
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameter: 76
body: 12
9Operationoperator: 99
operands: 13
10Operationoperator: 99
operands: 14
11ExprTuple76
12Conditionalvalue: 15
condition: 16
13ExprTuple122, 17
14ExprTuple123, 17
15Operationoperator: 45
operand: 20
16Operationoperator: 99
operands: 19
17Literal
18ExprTuple20
19ExprTuple76, 21
20Lambdaparameters: 22
body: 23
21Operationoperator: 24
operands: 25
22ExprTuple26
23Conditionalvalue: 27
condition: 28
24Literal
25ExprTuple43, 64
26ExprRangelambda_map: 29
start_index: 113
end_index: 122
27Operationoperator: 45
operand: 32
28Operationoperator: 99
operands: 31
29Lambdaparameter: 105
body: 81
30ExprTuple32
31ExprTuple33, 34
32Lambdaparameters: 35
body: 36
33Operationoperator: 71
operand: 42
34Operationoperator: 57
operand: 43
35ExprTuple39
36Conditionalvalue: 40
condition: 41
37ExprTuple42
38ExprTuple43
39ExprRangelambda_map: 44
start_index: 113
end_index: 123
40Operationoperator: 45
operand: 50
41Operationoperator: 99
operands: 47
42Operationoperator: 71
operands: 48
43Operationoperator: 73
operands: 49
44Lambdaparameter: 105
body: 96
45Literal
46ExprTuple50
47ExprTuple51, 52
48ExprTuple53
49ExprTuple80, 122
50Lambdaparameters: 54
body: 55
51Operationoperator: 71
operand: 63
52Operationoperator: 57
operand: 64
53ExprRangelambda_map: 59
start_index: 113
end_index: 122
54ExprTuple60
55Conditionalvalue: 61
condition: 62
56ExprTuple63
57Literal
58ExprTuple64
59Lambdaparameter: 105
body: 65
60ExprRangelambda_map: 66
start_index: 113
end_index: 114
61Operationoperator: 67
operands: 68
62Operationoperator: 69
operands: 70
63Operationoperator: 71
operands: 72
64Operationoperator: 73
operands: 74
65Operationoperator: 116
operand: 81
66Lambdaparameter: 105
body: 94
67Literal
68ExprTuple76, 77
69Literal
70ExprTuple78
71Literal
72ExprTuple79
73Literal
74ExprTuple80, 123
75ExprTuple81
76Variable
77Operationoperator: 82
operand: 86
78ExprRangelambda_map: 84
start_index: 113
end_index: 114
79ExprRangelambda_map: 85
start_index: 113
end_index: 123
80Literal
81IndexedVarvariable: 124
index: 105
82Literal
83ExprTuple86
84Lambdaparameter: 105
body: 87
85Lambdaparameter: 105
body: 88
86Lambdaparameter: 127
body: 89
87Operationoperator: 99
operands: 90
88Operationoperator: 116
operand: 96
89Conditionalvalue: 92
condition: 93
90ExprTuple94, 95
91ExprTuple96
92Operationoperator: 97
operands: 98
93Operationoperator: 99
operands: 100
94IndexedVarvariable: 106
index: 105
95Literal
96IndexedVarvariable: 125
index: 105
97Literal
98ExprTuple102, 103
99Literal
100ExprTuple127, 104
101ExprTuple105
102IndexedVarvariable: 106
index: 127
103Operationoperator: 107
operands: 108
104Operationoperator: 109
operands: 110
105Variable
106Variable
107Literal
108ExprTuple111, 112
109Literal
110ExprTuple113, 114
111Operationoperator: 116
operand: 120
112Operationoperator: 116
operand: 121
113Literal
114Operationoperator: 118
operands: 119
115ExprTuple120
116Literal
117ExprTuple121
118Literal
119ExprTuple122, 123
120IndexedVarvariable: 124
index: 127
121IndexedVarvariable: 125
index: 127
122Variable
123Variable
124Variable
125Variable
126ExprTuple127
127Variable