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, V, W, i, j, m, n
from proveit.core_expr_types import v_i, w_1_to_n, w_j
from proveit.linear_algebra import OrthoNormBases, VecSum
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Interval, one
from proveit.physics.quantum import Bra, Ket, Qmult
from proveit.physics.quantum.algebra import v_1_to_m_kets, w_1_to_n_kets
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [w_1_to_n], instance_expr = 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))), condition = InSet(w_1_to_n_kets, OrthoNormBases(W))).with_wrapping(), InSet(v_1_to_m_kets, OrthoNormBases(V)))
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_{w_{1}, w_{2}, \ldots, w_{n}~|~\left\{\lvert w_{1} \rangle, \lvert w_{2} \rangle, \ldots, \lvert w_{n} \rangle\right\} \in \textrm{O.N.Bases}\left(W\right)}~\\
\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)\right)\end{array} \textrm{ if } \left\{\lvert v_{1} \rangle, \lvert v_{2} \rangle, \ldots, \lvert v_{m} \rangle\right\} \in \textrm{O.N.Bases}\left(V\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
operand: 6
2Operationoperator: 58
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameters: 9
body: 10
7Operationoperator: 28
operands: 11
8Operationoperator: 30
operand: 17
9ExprTuple13
10Conditionalvalue: 14
condition: 15
11ExprTuple16
12ExprTuple17
13ExprRangelambda_map: 18
start_index: 74
end_index: 75
14Operationoperator: 19
operands: 20
15Operationoperator: 58
operands: 21
16ExprRangelambda_map: 22
start_index: 74
end_index: 54
17Variable
18Lambdaparameter: 55
body: 48
19Literal
20ExprTuple61, 23
21ExprTuple24, 25
22Lambdaparameter: 55
body: 26
23Operationoperator: 42
operand: 33
24Operationoperator: 28
operands: 29
25Operationoperator: 30
operand: 35
26Operationoperator: 66
operand: 36
27ExprTuple33
28Literal
29ExprTuple34
30Literal
31ExprTuple35
32ExprTuple36
33Lambdaparameter: 81
body: 37
34ExprRangelambda_map: 38
start_index: 74
end_index: 75
35Variable
36IndexedVarvariable: 78
index: 55
37Conditionalvalue: 39
condition: 40
38Lambdaparameter: 55
body: 41
39Operationoperator: 42
operand: 46
40Operationoperator: 58
operands: 44
41Operationoperator: 66
operand: 48
42Literal
43ExprTuple46
44ExprTuple81, 47
45ExprTuple48
46Lambdaparameter: 80
body: 49
47Operationoperator: 70
operands: 50
48IndexedVarvariable: 76
index: 55
49Conditionalvalue: 52
condition: 53
50ExprTuple74, 54
51ExprTuple55
52Operationoperator: 56
operands: 57
53Operationoperator: 58
operands: 59
54Variable
55Variable
56Literal
57ExprTuple60, 61, 62, 63, 64
58Literal
59ExprTuple80, 65
60Operationoperator: 68
operand: 72
61Variable
62Operationoperator: 66
operand: 73
63Operationoperator: 66
operand: 72
64Operationoperator: 68
operand: 73
65Operationoperator: 70
operands: 71
66Literal
67ExprTuple72
68Literal
69ExprTuple73
70Literal
71ExprTuple74, 75
72IndexedVarvariable: 76
index: 80
73IndexedVarvariable: 78
index: 81
74Literal
75Variable
76Variable
77ExprTuple80
78Variable
79ExprTuple81
80Variable
81Variable