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, ExprTuple, Function, Lambda, f, i, n
from proveit.core_expr_types import a_1_to_n, a_i, v_1_to_n, v_i
from proveit.linear_algebra import Hspace, OrthoNormBases, ScalarMult, VecSum
from proveit.logic import Equals, Forall, Functions, InSet, Set
from proveit.numbers import Complex, Interval, one
from proveit.physics.quantum import Bra, Ket, Qmult
from proveit.physics.quantum.algebra import v_1_to_n_kets
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(Forall(instance_param_or_params = [a_1_to_n], instance_expr = Forall(instance_param_or_params = [f], instance_expr = Equals(Function(f, [VecSum(index_or_indices = sub_expr1, summand = ScalarMult(a_i, sub_expr3), domain = sub_expr2)]), VecSum(index_or_indices = sub_expr1, summand = ScalarMult(Function(f, [a_i]), sub_expr3), domain = sub_expr2)), domain = Functions(Complex, Complex)), domain = Complex), InSet(Set(v_1_to_n_kets), 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\{\forall_{a_{1}, a_{2}, \ldots, a_{n} \in \mathbb{C}}~\left[\forall_{f \in \left[\mathbb{C} \rightarrow \mathbb{C}\right]}~\left(f\left(\sum_{i=1}^{n} \left(a_{i} \cdot \left(\lvert v_{i} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right) = \left(\sum_{i=1}^{n} \left(f\left(a_{i}\right) \cdot \left(\lvert v_{i} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right)\right)\right] \textrm{ if } \left\{\left\{\lvert v_{1} \rangle, \lvert v_{2} \rangle, \ldots, \lvert v_{n} \rangle\right\}\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: 2
body: 3
2ExprTuple4
3Conditionalvalue: 5
condition: 6
4ExprRangelambda_map: 7
start_index: 86
end_index: 87
5Operationoperator: 24
operand: 10
6Operationoperator: 72
operands: 9
7Lambdaparameter: 59
body: 50
8ExprTuple10
9ExprTuple11, 12
10Lambdaparameters: 13
body: 14
11Operationoperator: 28
operand: 21
12Operationoperator: 16
operand: 22
13ExprTuple18
14Conditionalvalue: 19
condition: 20
15ExprTuple21
16Literal
17ExprTuple22
18ExprRangelambda_map: 23
start_index: 86
end_index: 87
19Operationoperator: 24
operand: 30
20Operationoperator: 26
operands: 27
21Operationoperator: 28
operands: 29
22Variable
23Lambdaparameter: 59
body: 49
24Literal
25ExprTuple30
26Literal
27ExprTuple31
28Literal
29ExprTuple32
30Lambdaparameter: 74
body: 34
31ExprRangelambda_map: 35
start_index: 86
end_index: 87
32ExprRangelambda_map: 36
start_index: 86
end_index: 87
33ExprTuple74
34Conditionalvalue: 37
condition: 38
35Lambdaparameter: 59
body: 39
36Lambdaparameter: 59
body: 40
37Operationoperator: 41
operands: 42
38Operationoperator: 72
operands: 43
39Operationoperator: 72
operands: 44
40Operationoperator: 88
operand: 50
41Literal
42ExprTuple46, 47
43ExprTuple74, 48
44ExprTuple49, 58
45ExprTuple50
46Operationoperator: 74
operand: 56
47Operationoperator: 60
operand: 57
48Operationoperator: 53
operands: 54
49IndexedVarvariable: 83
index: 59
50IndexedVarvariable: 92
index: 59
51ExprTuple56
52ExprTuple57
53Literal
54ExprTuple58, 58
55ExprTuple59
56Operationoperator: 60
operand: 63
57Lambdaparameter: 94
body: 62
58Literal
59Variable
60Literal
61ExprTuple63
62Conditionalvalue: 64
condition: 68
63Lambdaparameter: 94
body: 65
64Operationoperator: 70
operands: 66
65Conditionalvalue: 67
condition: 68
66ExprTuple69, 76
67Operationoperator: 70
operands: 71
68Operationoperator: 72
operands: 73
69Operationoperator: 74
operand: 78
70Literal
71ExprTuple78, 76
72Literal
73ExprTuple94, 77
74Variable
75ExprTuple78
76Operationoperator: 79
operands: 80
77Operationoperator: 81
operands: 82
78IndexedVarvariable: 83
index: 94
79Literal
80ExprTuple84, 85
81Literal
82ExprTuple86, 87
83Variable
84Operationoperator: 88
operand: 91
85Operationoperator: 89
operand: 91
86Literal
87Variable
88Literal
89Literal
90ExprTuple91
91IndexedVarvariable: 92
index: 94
92Variable
93ExprTuple94
94Variable