logo

Expression of type Conditional

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, 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 = 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\{\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..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 10
operand: 5
2Operationoperator: 93
operands: 4
3ExprTuple5
4ExprTuple108, 6
5Lambdaparameter: 64
body: 7
6Literal
7Conditionalvalue: 8
condition: 9
8Operationoperator: 10
operand: 13
9Operationoperator: 68
operands: 12
10Literal
11ExprTuple13
12ExprTuple14, 15
13Lambdaparameter: 72
body: 16
14Operationoperator: 17
operands: 18
15Operationoperator: 66
operands: 19
16Conditionalvalue: 20
condition: 21
17Literal
18ExprTuple64, 22
19ExprTuple23, 108
20Operationoperator: 24
operands: 25
21Operationoperator: 93
operands: 26
22Literal
23Operationoperator: 27
operand: 64
24Literal
25ExprTuple28, 29
26ExprTuple72, 30
27Literal
28Operationoperator: 66
operands: 31
29Operationoperator: 49
operand: 37
30Operationoperator: 33
operands: 34
31ExprTuple35, 36
32ExprTuple37
33Literal
34ExprTuple64, 64
35Operationoperator: 101
operands: 38
36Operationoperator: 101
operands: 39
37Lambdaparameters: 40
body: 41
38ExprTuple42, 72
39ExprTuple72, 42
40ExprTuple43
41Conditionalvalue: 44
condition: 45
42Operationoperator: 46
operand: 72
43ExprRangelambda_map: 48
start_index: 107
end_index: 108
44Operationoperator: 49
operand: 52
45Operationoperator: 93
operands: 51
46Literal
47ExprTuple72
48Lambdaparameter: 99
body: 90
49Literal
50ExprTuple52
51ExprTuple53, 54
52Lambdaparameters: 55
body: 56
53Operationoperator: 70
operand: 63
54Operationoperator: 58
operand: 64
55ExprTuple60
56Conditionalvalue: 61
condition: 62
57ExprTuple63
58Literal
59ExprTuple64
60ExprRangelambda_map: 65
start_index: 107
end_index: 108
61Operationoperator: 66
operands: 67
62Operationoperator: 68
operands: 69
63Operationoperator: 70
operands: 71
64Variable
65Lambdaparameter: 99
body: 88
66Literal
67ExprTuple72, 73
68Literal
69ExprTuple74
70Literal
71ExprTuple75
72Variable
73Operationoperator: 76
operand: 80
74ExprRangelambda_map: 78
start_index: 107
end_index: 108
75ExprRangelambda_map: 79
start_index: 107
end_index: 108
76Literal
77ExprTuple80
78Lambdaparameter: 99
body: 81
79Lambdaparameter: 99
body: 82
80Lambdaparameter: 115
body: 83
81Operationoperator: 93
operands: 84
82Operationoperator: 109
operand: 90
83Conditionalvalue: 86
condition: 87
84ExprTuple88, 89
85ExprTuple90
86Operationoperator: 91
operands: 92
87Operationoperator: 93
operands: 94
88IndexedVarvariable: 100
index: 99
89Literal
90IndexedVarvariable: 113
index: 99
91Literal
92ExprTuple96, 97
93Literal
94ExprTuple115, 98
95ExprTuple99
96IndexedVarvariable: 100
index: 115
97Operationoperator: 101
operands: 102
98Operationoperator: 103
operands: 104
99Variable
100Variable
101Literal
102ExprTuple105, 106
103Literal
104ExprTuple107, 108
105Operationoperator: 109
operand: 112
106Operationoperator: 110
operand: 112
107Literal
108Variable
109Literal
110Literal
111ExprTuple112
112IndexedVarvariable: 113
index: 115
113Variable
114ExprTuple115
115Variable