logo

Expression of type Lambda

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, 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 = 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())
\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..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 63
body: 2
1ExprTuple63
2Conditionalvalue: 3
condition: 4
3Operationoperator: 32
operand: 7
4Operationoperator: 86
operands: 6
5ExprTuple7
6ExprTuple63, 8
7Lambdaparameters: 9
body: 10
8Operationoperator: 11
operands: 12
9ExprTuple13
10Conditionalvalue: 14
condition: 15
11Literal
12ExprTuple30, 51
13ExprRangelambda_map: 16
start_index: 100
end_index: 109
14Operationoperator: 32
operand: 19
15Operationoperator: 86
operands: 18
16Lambdaparameter: 92
body: 68
17ExprTuple19
18ExprTuple20, 21
19Lambdaparameters: 22
body: 23
20Operationoperator: 58
operand: 29
21Operationoperator: 44
operand: 30
22ExprTuple26
23Conditionalvalue: 27
condition: 28
24ExprTuple29
25ExprTuple30
26ExprRangelambda_map: 31
start_index: 100
end_index: 110
27Operationoperator: 32
operand: 37
28Operationoperator: 86
operands: 34
29Operationoperator: 58
operands: 35
30Operationoperator: 60
operands: 36
31Lambdaparameter: 92
body: 83
32Literal
33ExprTuple37
34ExprTuple38, 39
35ExprTuple40
36ExprTuple67, 109
37Lambdaparameters: 41
body: 42
38Operationoperator: 58
operand: 50
39Operationoperator: 44
operand: 51
40ExprRangelambda_map: 46
start_index: 100
end_index: 109
41ExprTuple47
42Conditionalvalue: 48
condition: 49
43ExprTuple50
44Literal
45ExprTuple51
46Lambdaparameter: 92
body: 52
47ExprRangelambda_map: 53
start_index: 100
end_index: 101
48Operationoperator: 54
operands: 55
49Operationoperator: 56
operands: 57
50Operationoperator: 58
operands: 59
51Operationoperator: 60
operands: 61
52Operationoperator: 103
operand: 68
53Lambdaparameter: 92
body: 81
54Literal
55ExprTuple63, 64
56Literal
57ExprTuple65
58Literal
59ExprTuple66
60Literal
61ExprTuple67, 110
62ExprTuple68
63Variable
64Operationoperator: 69
operand: 73
65ExprRangelambda_map: 71
start_index: 100
end_index: 101
66ExprRangelambda_map: 72
start_index: 100
end_index: 110
67Literal
68IndexedVarvariable: 111
index: 92
69Literal
70ExprTuple73
71Lambdaparameter: 92
body: 74
72Lambdaparameter: 92
body: 75
73Lambdaparameter: 114
body: 76
74Operationoperator: 86
operands: 77
75Operationoperator: 103
operand: 83
76Conditionalvalue: 79
condition: 80
77ExprTuple81, 82
78ExprTuple83
79Operationoperator: 84
operands: 85
80Operationoperator: 86
operands: 87
81IndexedVarvariable: 93
index: 92
82Literal
83IndexedVarvariable: 112
index: 92
84Literal
85ExprTuple89, 90
86Literal
87ExprTuple114, 91
88ExprTuple92
89IndexedVarvariable: 93
index: 114
90Operationoperator: 94
operands: 95
91Operationoperator: 96
operands: 97
92Variable
93Variable
94Literal
95ExprTuple98, 99
96Literal
97ExprTuple100, 101
98Operationoperator: 103
operand: 107
99Operationoperator: 103
operand: 108
100Literal
101Operationoperator: 105
operands: 106
102ExprTuple107
103Literal
104ExprTuple108
105Literal
106ExprTuple109, 110
107IndexedVarvariable: 111
index: 114
108IndexedVarvariable: 112
index: 114
109Variable
110Variable
111Variable
112Variable
113ExprTuple114
114Variable