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 Equals, Forall, Functions, InSet, Set
from proveit.numbers import Complex, Interval, NaturalPos, 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(n, Conditional(Forall(instance_param_or_params = [Hspace], instance_expr = 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(), domain = HilbertSpaces, condition = Equals(Dim(Hspace), n)).with_wrapping(), InSet(n, NaturalPos))))
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(n \mapsto \left\{\begin{array}{l}\forall_{\mathcal{H} \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces}~|~\textrm{Dim}\left(\mathcal{H}\right) = n}~\\
\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}\right]\end{array} \textrm{ if } n \in \mathbb{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: 109
body: 3
2ExprTuple109
3Conditionalvalue: 4
condition: 5
4Operationoperator: 46
operand: 8
5Operationoperator: 94
operands: 7
6ExprTuple8
7ExprTuple109, 9
8Lambdaparameter: 44
body: 10
9Literal
10Conditionalvalue: 11
condition: 12
11Operationoperator: 46
operand: 15
12Operationoperator: 48
operands: 14
13ExprTuple15
14ExprTuple16, 17
15Lambdaparameters: 18
body: 19
16Operationoperator: 20
operands: 21
17Operationoperator: 63
operands: 22
18ExprTuple23
19Conditionalvalue: 24
condition: 25
20Literal
21ExprTuple44, 26
22ExprTuple27, 109
23ExprRangelambda_map: 28
start_index: 108
end_index: 109
24Operationoperator: 46
operand: 32
25Operationoperator: 94
operands: 30
26Literal
27Operationoperator: 31
operand: 44
28Lambdaparameter: 81
body: 72
29ExprTuple32
30ExprTuple33, 34
31Literal
32Lambdaparameters: 35
body: 36
33Operationoperator: 50
operand: 43
34Operationoperator: 38
operand: 44
35ExprTuple40
36Conditionalvalue: 41
condition: 42
37ExprTuple43
38Literal
39ExprTuple44
40ExprRangelambda_map: 45
start_index: 108
end_index: 109
41Operationoperator: 46
operand: 52
42Operationoperator: 48
operands: 49
43Operationoperator: 50
operands: 51
44Variable
45Lambdaparameter: 81
body: 71
46Literal
47ExprTuple52
48Literal
49ExprTuple53
50Literal
51ExprTuple54
52Lambdaparameter: 96
body: 56
53ExprRangelambda_map: 57
start_index: 108
end_index: 109
54ExprRangelambda_map: 58
start_index: 108
end_index: 109
55ExprTuple96
56Conditionalvalue: 59
condition: 60
57Lambdaparameter: 81
body: 61
58Lambdaparameter: 81
body: 62
59Operationoperator: 63
operands: 64
60Operationoperator: 94
operands: 65
61Operationoperator: 94
operands: 66
62Operationoperator: 110
operand: 72
63Literal
64ExprTuple68, 69
65ExprTuple96, 70
66ExprTuple71, 80
67ExprTuple72
68Operationoperator: 96
operand: 78
69Operationoperator: 82
operand: 79
70Operationoperator: 75
operands: 76
71IndexedVarvariable: 105
index: 81
72IndexedVarvariable: 114
index: 81
73ExprTuple78
74ExprTuple79
75Literal
76ExprTuple80, 80
77ExprTuple81
78Operationoperator: 82
operand: 85
79Lambdaparameter: 116
body: 84
80Literal
81Variable
82Literal
83ExprTuple85
84Conditionalvalue: 86
condition: 90
85Lambdaparameter: 116
body: 87
86Operationoperator: 92
operands: 88
87Conditionalvalue: 89
condition: 90
88ExprTuple91, 98
89Operationoperator: 92
operands: 93
90Operationoperator: 94
operands: 95
91Operationoperator: 96
operand: 100
92Literal
93ExprTuple100, 98
94Literal
95ExprTuple116, 99
96Variable
97ExprTuple100
98Operationoperator: 101
operands: 102
99Operationoperator: 103
operands: 104
100IndexedVarvariable: 105
index: 116
101Literal
102ExprTuple106, 107
103Literal
104ExprTuple108, 109
105Variable
106Operationoperator: 110
operand: 113
107Operationoperator: 111
operand: 113
108Literal
109Variable
110Literal
111Literal
112ExprTuple113
113IndexedVarvariable: 114
index: 116
114Variable
115ExprTuple116
116Variable