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 A, Conditional, W, i, j, m, n
from proveit.core_expr_types import v_i, w_j
from proveit.linear_algebra import OrthoNormBases, VecSum
from proveit.logic import Equals, InSet
from proveit.numbers import Interval, one
from proveit.physics.quantum import Bra, Ket, Qmult
from proveit.physics.quantum.algebra import w_1_to_n_kets
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Equals(A, VecSum(index_or_indices = [i], summand = VecSum(index_or_indices = [j], summand = Qmult(Bra(w_j), A, Ket(v_i), Ket(w_j), Bra(v_i)), domain = Interval(one, n)), domain = Interval(one, m))), InSet(w_1_to_n_kets, OrthoNormBases(W)))
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\{A = \left(\sum_{i=1}^{m} \left(\sum_{j=1}^{n} \left(\langle w_{j} \rvert \thinspace A \thinspace \lvert v_{i} \rangle \thinspace \lvert w_{j} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right) \textrm{ if } \left\{\lvert w_{1} \rangle, \lvert w_{2} \rangle, \ldots, \lvert w_{n} \rangle\right\} \in \textrm{O.N.Bases}\left(W\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: 38
operands: 5
3Literal
4ExprTuple41, 6
5ExprTuple7, 8
6Operationoperator: 22
operand: 14
7Operationoperator: 10
operands: 11
8Operationoperator: 12
operand: 16
9ExprTuple14
10Literal
11ExprTuple15
12Literal
13ExprTuple16
14Lambdaparameter: 61
body: 17
15ExprRangelambda_map: 18
start_index: 54
end_index: 55
16Variable
17Conditionalvalue: 19
condition: 20
18Lambdaparameter: 35
body: 21
19Operationoperator: 22
operand: 26
20Operationoperator: 38
operands: 24
21Operationoperator: 46
operand: 28
22Literal
23ExprTuple26
24ExprTuple61, 27
25ExprTuple28
26Lambdaparameter: 60
body: 29
27Operationoperator: 50
operands: 30
28IndexedVarvariable: 56
index: 35
29Conditionalvalue: 32
condition: 33
30ExprTuple54, 34
31ExprTuple35
32Operationoperator: 36
operands: 37
33Operationoperator: 38
operands: 39
34Variable
35Variable
36Literal
37ExprTuple40, 41, 42, 43, 44
38Literal
39ExprTuple60, 45
40Operationoperator: 48
operand: 52
41Variable
42Operationoperator: 46
operand: 53
43Operationoperator: 46
operand: 52
44Operationoperator: 48
operand: 53
45Operationoperator: 50
operands: 51
46Literal
47ExprTuple52
48Literal
49ExprTuple53
50Literal
51ExprTuple54, 55
52IndexedVarvariable: 56
index: 60
53IndexedVarvariable: 58
index: 61
54Literal
55Variable
56Variable
57ExprTuple60
58Variable
59ExprTuple61
60Variable
61Variable