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_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 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([b_1_to_n], Conditional(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(), InSet(Set(b_1_to_n_kets), OrthoNormBases(CartExp(Complex, n))))))
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(b_{1}, b_{2}, \ldots, b_{n}\right) \mapsto \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} \textrm{ if } \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)\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: 69
end_index: 79
5Operationoperator: 8
operand: 11
6Operationoperator: 55
operands: 10
7Lambdaparameter: 61
body: 52
8Literal
9ExprTuple11
10ExprTuple12, 13
11Lambdaparameters: 14
body: 15
12Operationoperator: 29
operand: 22
13Operationoperator: 17
operand: 23
14ExprTuple19
15Conditionalvalue: 20
condition: 21
16ExprTuple22
17Literal
18ExprTuple23
19ExprRangelambda_map: 24
start_index: 69
end_index: 70
20Operationoperator: 25
operands: 26
21Operationoperator: 27
operands: 28
22Operationoperator: 29
operands: 30
23Operationoperator: 31
operands: 32
24Lambdaparameter: 61
body: 50
25Literal
26ExprTuple33, 34
27Literal
28ExprTuple35
29Literal
30ExprTuple36
31Literal
32ExprTuple37, 79
33Variable
34Operationoperator: 38
operand: 42
35ExprRangelambda_map: 40
start_index: 69
end_index: 70
36ExprRangelambda_map: 41
start_index: 69
end_index: 79
37Literal
38Literal
39ExprTuple42
40Lambdaparameter: 61
body: 43
41Lambdaparameter: 61
body: 44
42Lambdaparameter: 83
body: 45
43Operationoperator: 55
operands: 46
44Operationoperator: 72
operand: 52
45Conditionalvalue: 48
condition: 49
46ExprTuple50, 51
47ExprTuple52
48Operationoperator: 53
operands: 54
49Operationoperator: 55
operands: 56
50IndexedVarvariable: 62
index: 61
51Literal
52IndexedVarvariable: 81
index: 61
53Literal
54ExprTuple58, 59
55Literal
56ExprTuple83, 60
57ExprTuple61
58IndexedVarvariable: 62
index: 83
59Operationoperator: 63
operands: 64
60Operationoperator: 65
operands: 66
61Variable
62Variable
63Literal
64ExprTuple67, 68
65Literal
66ExprTuple69, 70
67Operationoperator: 72
operand: 76
68Operationoperator: 72
operand: 77
69Literal
70Operationoperator: 74
operands: 75
71ExprTuple76
72Literal
73ExprTuple77
74Literal
75ExprTuple78, 79
76IndexedVarvariable: 80
index: 83
77IndexedVarvariable: 81
index: 83
78Variable
79Variable
80Variable
81Variable
82ExprTuple83
83Variable