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 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 = 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\{\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..
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: 3
operand: 6
2Operationoperator: 61
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameter: 65
body: 9
7Operationoperator: 10
operands: 11
8Operationoperator: 59
operands: 12
9Conditionalvalue: 13
condition: 14
10Literal
11ExprTuple57, 15
12ExprTuple16, 101
13Operationoperator: 17
operands: 18
14Operationoperator: 86
operands: 19
15Literal
16Operationoperator: 20
operand: 57
17Literal
18ExprTuple21, 22
19ExprTuple65, 23
20Literal
21Operationoperator: 59
operands: 24
22Operationoperator: 42
operand: 30
23Operationoperator: 26
operands: 27
24ExprTuple28, 29
25ExprTuple30
26Literal
27ExprTuple57, 57
28Operationoperator: 94
operands: 31
29Operationoperator: 94
operands: 32
30Lambdaparameters: 33
body: 34
31ExprTuple35, 65
32ExprTuple65, 35
33ExprTuple36
34Conditionalvalue: 37
condition: 38
35Operationoperator: 39
operand: 65
36ExprRangelambda_map: 41
start_index: 100
end_index: 101
37Operationoperator: 42
operand: 45
38Operationoperator: 86
operands: 44
39Literal
40ExprTuple65
41Lambdaparameter: 92
body: 83
42Literal
43ExprTuple45
44ExprTuple46, 47
45Lambdaparameters: 48
body: 49
46Operationoperator: 63
operand: 56
47Operationoperator: 51
operand: 57
48ExprTuple53
49Conditionalvalue: 54
condition: 55
50ExprTuple56
51Literal
52ExprTuple57
53ExprRangelambda_map: 58
start_index: 100
end_index: 101
54Operationoperator: 59
operands: 60
55Operationoperator: 61
operands: 62
56Operationoperator: 63
operands: 64
57Variable
58Lambdaparameter: 92
body: 81
59Literal
60ExprTuple65, 66
61Literal
62ExprTuple67
63Literal
64ExprTuple68
65Variable
66Operationoperator: 69
operand: 73
67ExprRangelambda_map: 71
start_index: 100
end_index: 101
68ExprRangelambda_map: 72
start_index: 100
end_index: 101
69Literal
70ExprTuple73
71Lambdaparameter: 92
body: 74
72Lambdaparameter: 92
body: 75
73Lambdaparameter: 108
body: 76
74Operationoperator: 86
operands: 77
75Operationoperator: 102
operand: 83
76Conditionalvalue: 79
condition: 80
77ExprTuple81, 82
78ExprTuple83
79Operationoperator: 84
operands: 85
80Operationoperator: 86
operands: 87
81IndexedVarvariable: 93
index: 92
82Literal
83IndexedVarvariable: 106
index: 92
84Literal
85ExprTuple89, 90
86Literal
87ExprTuple108, 91
88ExprTuple92
89IndexedVarvariable: 93
index: 108
90Operationoperator: 94
operands: 95
91Operationoperator: 96
operands: 97
92Variable
93Variable
94Literal
95ExprTuple98, 99
96Literal
97ExprTuple100, 101
98Operationoperator: 102
operand: 105
99Operationoperator: 103
operand: 105
100Literal
101Variable
102Literal
103Literal
104ExprTuple105
105IndexedVarvariable: 106
index: 108
106Variable
107ExprTuple108
108Variable