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, 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 = 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(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..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple3
2Conditionalvalue: 4
condition: 5
3ExprRangelambda_map: 6
start_index: 90
end_index: 99
4Operationoperator: 22
operand: 9
5Operationoperator: 76
operands: 8
6Lambdaparameter: 82
body: 58
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameters: 12
body: 13
10Operationoperator: 48
operand: 19
11Operationoperator: 34
operand: 20
12ExprTuple16
13Conditionalvalue: 17
condition: 18
14ExprTuple19
15ExprTuple20
16ExprRangelambda_map: 21
start_index: 90
end_index: 100
17Operationoperator: 22
operand: 27
18Operationoperator: 76
operands: 24
19Operationoperator: 48
operands: 25
20Operationoperator: 50
operands: 26
21Lambdaparameter: 82
body: 73
22Literal
23ExprTuple27
24ExprTuple28, 29
25ExprTuple30
26ExprTuple57, 99
27Lambdaparameters: 31
body: 32
28Operationoperator: 48
operand: 40
29Operationoperator: 34
operand: 41
30ExprRangelambda_map: 36
start_index: 90
end_index: 99
31ExprTuple37
32Conditionalvalue: 38
condition: 39
33ExprTuple40
34Literal
35ExprTuple41
36Lambdaparameter: 82
body: 42
37ExprRangelambda_map: 43
start_index: 90
end_index: 91
38Operationoperator: 44
operands: 45
39Operationoperator: 46
operands: 47
40Operationoperator: 48
operands: 49
41Operationoperator: 50
operands: 51
42Operationoperator: 93
operand: 58
43Lambdaparameter: 82
body: 71
44Literal
45ExprTuple53, 54
46Literal
47ExprTuple55
48Literal
49ExprTuple56
50Literal
51ExprTuple57, 100
52ExprTuple58
53Variable
54Operationoperator: 59
operand: 63
55ExprRangelambda_map: 61
start_index: 90
end_index: 91
56ExprRangelambda_map: 62
start_index: 90
end_index: 100
57Literal
58IndexedVarvariable: 101
index: 82
59Literal
60ExprTuple63
61Lambdaparameter: 82
body: 64
62Lambdaparameter: 82
body: 65
63Lambdaparameter: 104
body: 66
64Operationoperator: 76
operands: 67
65Operationoperator: 93
operand: 73
66Conditionalvalue: 69
condition: 70
67ExprTuple71, 72
68ExprTuple73
69Operationoperator: 74
operands: 75
70Operationoperator: 76
operands: 77
71IndexedVarvariable: 83
index: 82
72Literal
73IndexedVarvariable: 102
index: 82
74Literal
75ExprTuple79, 80
76Literal
77ExprTuple104, 81
78ExprTuple82
79IndexedVarvariable: 83
index: 104
80Operationoperator: 84
operands: 85
81Operationoperator: 86
operands: 87
82Variable
83Variable
84Literal
85ExprTuple88, 89
86Literal
87ExprTuple90, 91
88Operationoperator: 93
operand: 97
89Operationoperator: 93
operand: 98
90Literal
91Operationoperator: 95
operands: 96
92ExprTuple97
93Literal
94ExprTuple98
95Literal
96ExprTuple99, 100
97IndexedVarvariable: 101
index: 104
98IndexedVarvariable: 102
index: 104
99Variable
100Variable
101Variable
102Variable
103ExprTuple104
104Variable