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 Dim, HilbertSpaces, Hspace, OrthoNormBases, ScalarMult, VecSum
from proveit.logic import And, Equals, Forall, Functions, InClass, 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(Hspace, Conditional(Forall(instance_param_or_params = [v_1_to_n], instance_expr = 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), condition = InSet(Set(v_1_to_n_kets), OrthoNormBases(Hspace))).with_wrapping(), And(InClass(Hspace, HilbertSpaces), Equals(Dim(Hspace), 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(\mathcal{H} \mapsto \left\{\begin{array}{l}\forall_{v_{1}, v_{2}, \ldots, v_{n}~|~\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)}~\\
\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]\right]\end{array} \textrm{ if } \mathcal{H} \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces} ,  \textrm{Dim}\left(\mathcal{H}\right) = 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
0ExprTuple1
1Lambdaparameter: 36
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 38
operand: 7
4Operationoperator: 40
operands: 6
5ExprTuple7
6ExprTuple8, 9
7Lambdaparameters: 10
body: 11
8Operationoperator: 12
operands: 13
9Operationoperator: 55
operands: 14
10ExprTuple15
11Conditionalvalue: 16
condition: 17
12Literal
13ExprTuple36, 18
14ExprTuple19, 101
15ExprRangelambda_map: 20
start_index: 100
end_index: 101
16Operationoperator: 38
operand: 24
17Operationoperator: 86
operands: 22
18Literal
19Operationoperator: 23
operand: 36
20Lambdaparameter: 73
body: 64
21ExprTuple24
22ExprTuple25, 26
23Literal
24Lambdaparameters: 27
body: 28
25Operationoperator: 42
operand: 35
26Operationoperator: 30
operand: 36
27ExprTuple32
28Conditionalvalue: 33
condition: 34
29ExprTuple35
30Literal
31ExprTuple36
32ExprRangelambda_map: 37
start_index: 100
end_index: 101
33Operationoperator: 38
operand: 44
34Operationoperator: 40
operands: 41
35Operationoperator: 42
operands: 43
36Variable
37Lambdaparameter: 73
body: 63
38Literal
39ExprTuple44
40Literal
41ExprTuple45
42Literal
43ExprTuple46
44Lambdaparameter: 88
body: 48
45ExprRangelambda_map: 49
start_index: 100
end_index: 101
46ExprRangelambda_map: 50
start_index: 100
end_index: 101
47ExprTuple88
48Conditionalvalue: 51
condition: 52
49Lambdaparameter: 73
body: 53
50Lambdaparameter: 73
body: 54
51Operationoperator: 55
operands: 56
52Operationoperator: 86
operands: 57
53Operationoperator: 86
operands: 58
54Operationoperator: 102
operand: 64
55Literal
56ExprTuple60, 61
57ExprTuple88, 62
58ExprTuple63, 72
59ExprTuple64
60Operationoperator: 88
operand: 70
61Operationoperator: 74
operand: 71
62Operationoperator: 67
operands: 68
63IndexedVarvariable: 97
index: 73
64IndexedVarvariable: 106
index: 73
65ExprTuple70
66ExprTuple71
67Literal
68ExprTuple72, 72
69ExprTuple73
70Operationoperator: 74
operand: 77
71Lambdaparameter: 108
body: 76
72Literal
73Variable
74Literal
75ExprTuple77
76Conditionalvalue: 78
condition: 82
77Lambdaparameter: 108
body: 79
78Operationoperator: 84
operands: 80
79Conditionalvalue: 81
condition: 82
80ExprTuple83, 90
81Operationoperator: 84
operands: 85
82Operationoperator: 86
operands: 87
83Operationoperator: 88
operand: 92
84Literal
85ExprTuple92, 90
86Literal
87ExprTuple108, 91
88Variable
89ExprTuple92
90Operationoperator: 93
operands: 94
91Operationoperator: 95
operands: 96
92IndexedVarvariable: 97
index: 108
93Literal
94ExprTuple98, 99
95Literal
96ExprTuple100, 101
97Variable
98Operationoperator: 102
operand: 105
99Operationoperator: 103
operand: 105
100Literal
101Variable
102Literal
103Literal
104ExprTuple105
105IndexedVarvariable: 106
index: 108
106Variable
107ExprTuple108
108Variable