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 And, Equals, Exists, Forall, Iff, 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 = Adj(M)
expr = ExprTuple(Lambda(Hspace, Conditional(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)), 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\{\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) \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: 59
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 63
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameter: 67
body: 11
9Operationoperator: 12
operands: 13
10Operationoperator: 61
operands: 14
11Conditionalvalue: 15
condition: 16
12Literal
13ExprTuple59, 17
14ExprTuple18, 103
15Operationoperator: 19
operands: 20
16Operationoperator: 88
operands: 21
17Literal
18Operationoperator: 22
operand: 59
19Literal
20ExprTuple23, 24
21ExprTuple67, 25
22Literal
23Operationoperator: 61
operands: 26
24Operationoperator: 44
operand: 32
25Operationoperator: 28
operands: 29
26ExprTuple30, 31
27ExprTuple32
28Literal
29ExprTuple59, 59
30Operationoperator: 96
operands: 33
31Operationoperator: 96
operands: 34
32Lambdaparameters: 35
body: 36
33ExprTuple37, 67
34ExprTuple67, 37
35ExprTuple38
36Conditionalvalue: 39
condition: 40
37Operationoperator: 41
operand: 67
38ExprRangelambda_map: 43
start_index: 102
end_index: 103
39Operationoperator: 44
operand: 47
40Operationoperator: 88
operands: 46
41Literal
42ExprTuple67
43Lambdaparameter: 94
body: 85
44Literal
45ExprTuple47
46ExprTuple48, 49
47Lambdaparameters: 50
body: 51
48Operationoperator: 65
operand: 58
49Operationoperator: 53
operand: 59
50ExprTuple55
51Conditionalvalue: 56
condition: 57
52ExprTuple58
53Literal
54ExprTuple59
55ExprRangelambda_map: 60
start_index: 102
end_index: 103
56Operationoperator: 61
operands: 62
57Operationoperator: 63
operands: 64
58Operationoperator: 65
operands: 66
59Variable
60Lambdaparameter: 94
body: 83
61Literal
62ExprTuple67, 68
63Literal
64ExprTuple69
65Literal
66ExprTuple70
67Variable
68Operationoperator: 71
operand: 75
69ExprRangelambda_map: 73
start_index: 102
end_index: 103
70ExprRangelambda_map: 74
start_index: 102
end_index: 103
71Literal
72ExprTuple75
73Lambdaparameter: 94
body: 76
74Lambdaparameter: 94
body: 77
75Lambdaparameter: 110
body: 78
76Operationoperator: 88
operands: 79
77Operationoperator: 104
operand: 85
78Conditionalvalue: 81
condition: 82
79ExprTuple83, 84
80ExprTuple85
81Operationoperator: 86
operands: 87
82Operationoperator: 88
operands: 89
83IndexedVarvariable: 95
index: 94
84Literal
85IndexedVarvariable: 108
index: 94
86Literal
87ExprTuple91, 92
88Literal
89ExprTuple110, 93
90ExprTuple94
91IndexedVarvariable: 95
index: 110
92Operationoperator: 96
operands: 97
93Operationoperator: 98
operands: 99
94Variable
95Variable
96Literal
97ExprTuple100, 101
98Literal
99ExprTuple102, 103
100Operationoperator: 104
operand: 107
101Operationoperator: 105
operand: 107
102Literal
103Variable
104Literal
105Literal
106ExprTuple107
107IndexedVarvariable: 108
index: 110
108Variable
109ExprTuple110
110Variable