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 A, B, Conditional, ExprTuple, Lambda, i, n
from proveit.core_expr_types import a_1_to_n, a_i, b_1_to_n, b_i, v_1_to_n, v_i
from proveit.linear_algebra import Hspace, OrthoNormBases, ScalarMult, VecSum
from proveit.logic import And, Equals, Exists, InSet, Set
from proveit.numbers import Complex, Interval, one
from proveit.physics.quantum import Bra, Ket, Qmult
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [i]
sub_expr2 = Interval(one, n)
sub_expr3 = Qmult(Ket(v_i), Bra(v_i))
expr = ExprTuple(Lambda([v_1_to_n], Conditional(Exists(instance_param_or_params = [a_1_to_n, b_1_to_n], instance_expr = And(Equals(A, VecSum(index_or_indices = sub_expr1, summand = ScalarMult(a_i, sub_expr3), domain = sub_expr2)), Equals(B, VecSum(index_or_indices = sub_expr1, summand = ScalarMult(b_i, sub_expr3), domain = sub_expr2))).with_wrapping_at(2), domain = Complex).with_wrapping(), InSet(Set(v_1_to_n), OrthoNormBases(Hspace)))))
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(v_{1}, v_{2}, \ldots, v_{n}\right) \mapsto \left\{\begin{array}{l}\exists_{a_{1}, a_{2}, \ldots, a_{n}, b_{1}, b_{2}, \ldots, b_{n} \in \mathbb{C}}~\\
\left(\begin{array}{c} \left(A = \left(\sum_{i=1}^{n} \left(a_{i} \cdot \left(\lvert v_{i} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right)\right) \land  \\ \left(B = \left(\sum_{i=1}^{n} \left(b_{i} \cdot \left(\lvert v_{i} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right)\right) \end{array}\right)\end{array} \textrm{ if } \left\{v_{1}, v_{2}, \ldots, v_{n}\right\} \in \textrm{O.N.Bases}\left(\mathcal{H}\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: 14
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 65
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameters: 11
body: 12
9Operationoperator: 13
operands: 14
10Operationoperator: 15
operand: 22
11ExprTuple17, 18
12Conditionalvalue: 19
condition: 20
13Literal
14ExprTuple21
15Literal
16ExprTuple22
17ExprRangelambda_map: 23
start_index: 79
end_index: 80
18ExprRangelambda_map: 24
start_index: 79
end_index: 80
19Operationoperator: 26
operands: 25
20Operationoperator: 26
operands: 27
21ExprRangelambda_map: 28
start_index: 79
end_index: 80
22Variable
23Lambdaparameter: 61
body: 52
24Lambdaparameter: 61
body: 53
25ExprTuple29, 30
26Literal
27ExprTuple31, 32
28Lambdaparameter: 61
body: 33
29Operationoperator: 35
operands: 34
30Operationoperator: 35
operands: 36
31ExprRangelambda_map: 37
start_index: 79
end_index: 80
32ExprRangelambda_map: 38
start_index: 79
end_index: 80
33IndexedVarvariable: 85
index: 61
34ExprTuple39, 40
35Literal
36ExprTuple41, 42
37Lambdaparameter: 61
body: 43
38Lambdaparameter: 61
body: 44
39Variable
40Operationoperator: 46
operand: 50
41Variable
42Operationoperator: 46
operand: 51
43Operationoperator: 65
operands: 48
44Operationoperator: 65
operands: 49
45ExprTuple50
46Literal
47ExprTuple51
48ExprTuple52, 54
49ExprTuple53, 54
50Lambdaparameter: 87
body: 55
51Lambdaparameter: 87
body: 56
52IndexedVarvariable: 71
index: 61
53IndexedVarvariable: 72
index: 61
54Literal
55Conditionalvalue: 58
condition: 60
56Conditionalvalue: 59
condition: 60
57ExprTuple61
58Operationoperator: 63
operands: 62
59Operationoperator: 63
operands: 64
60Operationoperator: 65
operands: 66
61Variable
62ExprTuple67, 69
63Literal
64ExprTuple68, 69
65Literal
66ExprTuple87, 70
67IndexedVarvariable: 71
index: 87
68IndexedVarvariable: 72
index: 87
69Operationoperator: 73
operands: 74
70Operationoperator: 75
operands: 76
71Variable
72Variable
73Literal
74ExprTuple77, 78
75Literal
76ExprTuple79, 80
77Operationoperator: 81
operand: 84
78Operationoperator: 82
operand: 84
79Literal
80Variable
81Literal
82Literal
83ExprTuple84
84IndexedVarvariable: 85
index: 87
85Variable
86ExprTuple87
87Variable