logo

Expression of type Iff

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 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, 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 = 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)
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())
\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}
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()(2)('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
directionDirection of the relation (normal or reversed)normalnormal('with_direction_reversed', 'is_reversed')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple3, 4
3Operationoperator: 38
operands: 5
4Operationoperator: 21
operand: 9
5ExprTuple7, 8
6ExprTuple9
7Operationoperator: 73
operands: 10
8Operationoperator: 73
operands: 11
9Lambdaparameters: 12
body: 13
10ExprTuple14, 44
11ExprTuple44, 14
12ExprTuple15
13Conditionalvalue: 16
condition: 17
14Operationoperator: 18
operand: 44
15ExprRangelambda_map: 20
start_index: 79
end_index: 80
16Operationoperator: 21
operand: 24
17Operationoperator: 65
operands: 23
18Literal
19ExprTuple44
20Lambdaparameter: 71
body: 62
21Literal
22ExprTuple24
23ExprTuple25, 26
24Lambdaparameters: 27
body: 28
25Operationoperator: 42
operand: 35
26Operationoperator: 30
operand: 36
27ExprTuple32
28Conditionalvalue: 33
condition: 34
29ExprTuple35
30Literal
31ExprTuple36
32ExprRangelambda_map: 37
start_index: 79
end_index: 80
33Operationoperator: 38
operands: 39
34Operationoperator: 40
operands: 41
35Operationoperator: 42
operands: 43
36Variable
37Lambdaparameter: 71
body: 60
38Literal
39ExprTuple44, 45
40Literal
41ExprTuple46
42Literal
43ExprTuple47
44Variable
45Operationoperator: 48
operand: 52
46ExprRangelambda_map: 50
start_index: 79
end_index: 80
47ExprRangelambda_map: 51
start_index: 79
end_index: 80
48Literal
49ExprTuple52
50Lambdaparameter: 71
body: 53
51Lambdaparameter: 71
body: 54
52Lambdaparameter: 87
body: 55
53Operationoperator: 65
operands: 56
54Operationoperator: 81
operand: 62
55Conditionalvalue: 58
condition: 59
56ExprTuple60, 61
57ExprTuple62
58Operationoperator: 63
operands: 64
59Operationoperator: 65
operands: 66
60IndexedVarvariable: 72
index: 71
61Literal
62IndexedVarvariable: 85
index: 71
63Literal
64ExprTuple68, 69
65Literal
66ExprTuple87, 70
67ExprTuple71
68IndexedVarvariable: 72
index: 87
69Operationoperator: 73
operands: 74
70Operationoperator: 75
operands: 76
71Variable
72Variable
73Literal
74ExprTuple77, 78
75Literal
76ExprTuple79, 80
77Operationoperator: 81
operand: 84
78Operationoperator: 82
operand: 84
79Literal
80Variable
81Literal
82Literal
83ExprTuple84
84IndexedVarvariable: 85
index: 87
85Variable
86ExprTuple87
87Variable