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, Lambda, M, 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 Adj, Dim, HilbertSpaces, Hspace, LinMap, OrthoNormBases, ScalarMult, VecSum
from proveit.logic import Equals, Exists, Forall, Iff, 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 = Adj(M)
expr = ExprTuple(Lambda(n, Conditional(Forall(instance_param_or_params = [Hspace], instance_expr = Forall(instance_param_or_params = [M], instance_expr = Iff(Equals(Qmult(sub_expr1, M), Qmult(M, sub_expr1)), Exists(instance_param_or_params = [v_1_to_n], instance_expr = Exists(instance_param_or_params = [a_1_to_n], instance_expr = Equals(M, VecSum(index_or_indices = [i], summand = ScalarMult(a_i, Qmult(Ket(v_i), Bra(v_i))), domain = Interval(one, n))), domain = Complex).with_wrapping(), condition = InSet(Set(v_1_to_n_kets), OrthoNormBases(Hspace))).with_wrapping()).with_wrapping_at(2), domain = LinMap(Hspace, Hspace)), 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[\forall_{M \in \mathcal{L}\left(\mathcal{H}, \mathcal{H}\right)}~\left(\begin{array}{c} \begin{array}{l} \left(\left(M^{\dagger} \thinspace M\right) = \left(M \thinspace M^{\dagger}\right)\right) \Leftrightarrow  \\ \left[\begin{array}{l}\exists_{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[\begin{array}{l}\exists_{a_{1}, a_{2}, \ldots, a_{n} \in \mathbb{C}}~\\
\left(M = \left(\sum_{i=1}^{n} \left(a_{i} \cdot \left(\lvert v_{i} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right)\right)\end{array}\right]\end{array}\right] \end{array} \end{array}\right)\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: 111
body: 3
2ExprTuple111
3Conditionalvalue: 4
condition: 5
4Operationoperator: 13
operand: 8
5Operationoperator: 96
operands: 7
6ExprTuple8
7ExprTuple111, 9
8Lambdaparameter: 67
body: 10
9Literal
10Conditionalvalue: 11
condition: 12
11Operationoperator: 13
operand: 16
12Operationoperator: 71
operands: 15
13Literal
14ExprTuple16
15ExprTuple17, 18
16Lambdaparameter: 75
body: 19
17Operationoperator: 20
operands: 21
18Operationoperator: 69
operands: 22
19Conditionalvalue: 23
condition: 24
20Literal
21ExprTuple67, 25
22ExprTuple26, 111
23Operationoperator: 27
operands: 28
24Operationoperator: 96
operands: 29
25Literal
26Operationoperator: 30
operand: 67
27Literal
28ExprTuple31, 32
29ExprTuple75, 33
30Literal
31Operationoperator: 69
operands: 34
32Operationoperator: 52
operand: 40
33Operationoperator: 36
operands: 37
34ExprTuple38, 39
35ExprTuple40
36Literal
37ExprTuple67, 67
38Operationoperator: 104
operands: 41
39Operationoperator: 104
operands: 42
40Lambdaparameters: 43
body: 44
41ExprTuple45, 75
42ExprTuple75, 45
43ExprTuple46
44Conditionalvalue: 47
condition: 48
45Operationoperator: 49
operand: 75
46ExprRangelambda_map: 51
start_index: 110
end_index: 111
47Operationoperator: 52
operand: 55
48Operationoperator: 96
operands: 54
49Literal
50ExprTuple75
51Lambdaparameter: 102
body: 93
52Literal
53ExprTuple55
54ExprTuple56, 57
55Lambdaparameters: 58
body: 59
56Operationoperator: 73
operand: 66
57Operationoperator: 61
operand: 67
58ExprTuple63
59Conditionalvalue: 64
condition: 65
60ExprTuple66
61Literal
62ExprTuple67
63ExprRangelambda_map: 68
start_index: 110
end_index: 111
64Operationoperator: 69
operands: 70
65Operationoperator: 71
operands: 72
66Operationoperator: 73
operands: 74
67Variable
68Lambdaparameter: 102
body: 91
69Literal
70ExprTuple75, 76
71Literal
72ExprTuple77
73Literal
74ExprTuple78
75Variable
76Operationoperator: 79
operand: 83
77ExprRangelambda_map: 81
start_index: 110
end_index: 111
78ExprRangelambda_map: 82
start_index: 110
end_index: 111
79Literal
80ExprTuple83
81Lambdaparameter: 102
body: 84
82Lambdaparameter: 102
body: 85
83Lambdaparameter: 118
body: 86
84Operationoperator: 96
operands: 87
85Operationoperator: 112
operand: 93
86Conditionalvalue: 89
condition: 90
87ExprTuple91, 92
88ExprTuple93
89Operationoperator: 94
operands: 95
90Operationoperator: 96
operands: 97
91IndexedVarvariable: 103
index: 102
92Literal
93IndexedVarvariable: 116
index: 102
94Literal
95ExprTuple99, 100
96Literal
97ExprTuple118, 101
98ExprTuple102
99IndexedVarvariable: 103
index: 118
100Operationoperator: 104
operands: 105
101Operationoperator: 106
operands: 107
102Variable
103Variable
104Literal
105ExprTuple108, 109
106Literal
107ExprTuple110, 111
108Operationoperator: 112
operand: 115
109Operationoperator: 113
operand: 115
110Literal
111Variable
112Literal
113Literal
114ExprTuple115
115IndexedVarvariable: 116
index: 118
116Variable
117ExprTuple118
118Variable