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, Hspace, LinMap, OrthoNormBases, ScalarMult, VecSum
from proveit.logic import Equals, Exists, Iff, 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(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), InSet(M, LinMap(Hspace, Hspace)))
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}{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} \textrm{ if } M \in \mathcal{L}\left(\mathcal{H}, \mathcal{H}\right)\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
operands: 4
2Operationoperator: 71
operands: 5
3Literal
4ExprTuple6, 7
5ExprTuple50, 8
6Operationoperator: 44
operands: 9
7Operationoperator: 27
operand: 15
8Operationoperator: 11
operands: 12
9ExprTuple13, 14
10ExprTuple15
11Literal
12ExprTuple42, 42
13Operationoperator: 79
operands: 16
14Operationoperator: 79
operands: 17
15Lambdaparameters: 18
body: 19
16ExprTuple20, 50
17ExprTuple50, 20
18ExprTuple21
19Conditionalvalue: 22
condition: 23
20Operationoperator: 24
operand: 50
21ExprRangelambda_map: 26
start_index: 85
end_index: 86
22Operationoperator: 27
operand: 30
23Operationoperator: 71
operands: 29
24Literal
25ExprTuple50
26Lambdaparameter: 77
body: 68
27Literal
28ExprTuple30
29ExprTuple31, 32
30Lambdaparameters: 33
body: 34
31Operationoperator: 48
operand: 41
32Operationoperator: 36
operand: 42
33ExprTuple38
34Conditionalvalue: 39
condition: 40
35ExprTuple41
36Literal
37ExprTuple42
38ExprRangelambda_map: 43
start_index: 85
end_index: 86
39Operationoperator: 44
operands: 45
40Operationoperator: 46
operands: 47
41Operationoperator: 48
operands: 49
42Variable
43Lambdaparameter: 77
body: 66
44Literal
45ExprTuple50, 51
46Literal
47ExprTuple52
48Literal
49ExprTuple53
50Variable
51Operationoperator: 54
operand: 58
52ExprRangelambda_map: 56
start_index: 85
end_index: 86
53ExprRangelambda_map: 57
start_index: 85
end_index: 86
54Literal
55ExprTuple58
56Lambdaparameter: 77
body: 59
57Lambdaparameter: 77
body: 60
58Lambdaparameter: 93
body: 61
59Operationoperator: 71
operands: 62
60Operationoperator: 87
operand: 68
61Conditionalvalue: 64
condition: 65
62ExprTuple66, 67
63ExprTuple68
64Operationoperator: 69
operands: 70
65Operationoperator: 71
operands: 72
66IndexedVarvariable: 78
index: 77
67Literal
68IndexedVarvariable: 91
index: 77
69Literal
70ExprTuple74, 75
71Literal
72ExprTuple93, 76
73ExprTuple77
74IndexedVarvariable: 78
index: 93
75Operationoperator: 79
operands: 80
76Operationoperator: 81
operands: 82
77Variable
78Variable
79Literal
80ExprTuple83, 84
81Literal
82ExprTuple85, 86
83Operationoperator: 87
operand: 90
84Operationoperator: 88
operand: 90
85Literal
86Variable
87Literal
88Literal
89ExprTuple90
90IndexedVarvariable: 91
index: 93
91Variable
92ExprTuple93
93Variable