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_1_to_m, v_i, w_1_to_n, w_j
from proveit.linear_algebra import OrthoNormBases, VecSum
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Interval, NaturalPos, 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 = [v_1_to_m], instance_expr = 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(), condition = InSet(v_1_to_m_kets, OrthoNormBases(V))).with_wrapping(), And(InSet(m, NaturalPos), InSet(n, NaturalPos)))
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_{v_{1}, v_{2}, \ldots, v_{m}~|~\left\{\lvert v_{1} \rangle, \lvert v_{2} \rangle, \ldots, \lvert v_{m} \rangle\right\} \in \textrm{O.N.Bases}\left(V\right)}~\\
\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}\right]\end{array} \textrm{ if } m \in \mathbb{N}^+ ,  n \in \mathbb{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: 18
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple7, 8
6Lambdaparameters: 9
body: 10
7Operationoperator: 73
operands: 11
8Operationoperator: 73
operands: 12
9ExprTuple13
10Conditionalvalue: 14
condition: 15
11ExprTuple69, 16
12ExprTuple90, 16
13ExprRangelambda_map: 17
start_index: 89
end_index: 69
14Operationoperator: 18
operand: 21
15Operationoperator: 73
operands: 20
16Literal
17Lambdaparameter: 70
body: 51
18Literal
19ExprTuple21
20ExprTuple22, 23
21Lambdaparameters: 24
body: 25
22Operationoperator: 43
operands: 26
23Operationoperator: 45
operand: 32
24ExprTuple28
25Conditionalvalue: 29
condition: 30
26ExprTuple31
27ExprTuple32
28ExprRangelambda_map: 33
start_index: 89
end_index: 90
29Operationoperator: 34
operands: 35
30Operationoperator: 73
operands: 36
31ExprRangelambda_map: 37
start_index: 89
end_index: 69
32Variable
33Lambdaparameter: 70
body: 63
34Literal
35ExprTuple76, 38
36ExprTuple39, 40
37Lambdaparameter: 70
body: 41
38Operationoperator: 57
operand: 48
39Operationoperator: 43
operands: 44
40Operationoperator: 45
operand: 50
41Operationoperator: 81
operand: 51
42ExprTuple48
43Literal
44ExprTuple49
45Literal
46ExprTuple50
47ExprTuple51
48Lambdaparameter: 96
body: 52
49ExprRangelambda_map: 53
start_index: 89
end_index: 90
50Variable
51IndexedVarvariable: 93
index: 70
52Conditionalvalue: 54
condition: 55
53Lambdaparameter: 70
body: 56
54Operationoperator: 57
operand: 61
55Operationoperator: 73
operands: 59
56Operationoperator: 81
operand: 63
57Literal
58ExprTuple61
59ExprTuple96, 62
60ExprTuple63
61Lambdaparameter: 95
body: 64
62Operationoperator: 85
operands: 65
63IndexedVarvariable: 91
index: 70
64Conditionalvalue: 67
condition: 68
65ExprTuple89, 69
66ExprTuple70
67Operationoperator: 71
operands: 72
68Operationoperator: 73
operands: 74
69Variable
70Variable
71Literal
72ExprTuple75, 76, 77, 78, 79
73Literal
74ExprTuple95, 80
75Operationoperator: 83
operand: 87
76Variable
77Operationoperator: 81
operand: 88
78Operationoperator: 81
operand: 87
79Operationoperator: 83
operand: 88
80Operationoperator: 85
operands: 86
81Literal
82ExprTuple87
83Literal
84ExprTuple88
85Literal
86ExprTuple89, 90
87IndexedVarvariable: 91
index: 95
88IndexedVarvariable: 93
index: 96
89Literal
90Variable
91Variable
92ExprTuple95
93Variable
94ExprTuple96
95Variable
96Variable