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 HilbertSpaces, LinMap, OrthoNormBases, VecSum
from proveit.logic import And, Equals, Forall, InClass, 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 = [A], instance_expr = Forall(instance_param_or_params = [m, n], instance_expr = 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(), domain = NaturalPos), domain = LinMap(V, W)), And(InClass(V, HilbertSpaces), InClass(W, HilbertSpaces)))
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\{\forall_{A \in \mathcal{L}\left(V, W\right)}~\left[\forall_{m, n \in \mathbb{N}^+}~\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}\right]\right] \textrm{ if } V \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces} ,  W \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces}\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: 41
operand: 5
2Operationoperator: 27
operands: 4
3ExprTuple5
4ExprTuple6, 7
5Lambdaparameter: 99
body: 9
6Operationoperator: 11
operands: 10
7Operationoperator: 11
operands: 12
8ExprTuple99
9Conditionalvalue: 13
condition: 14
10ExprTuple55, 15
11Literal
12ExprTuple73, 15
13Operationoperator: 41
operand: 18
14Operationoperator: 96
operands: 17
15Literal
16ExprTuple18
17ExprTuple99, 19
18Lambdaparameters: 20
body: 21
19Operationoperator: 22
operands: 23
20ExprTuple92, 113
21Conditionalvalue: 24
condition: 25
22Literal
23ExprTuple55, 73
24Operationoperator: 41
operand: 29
25Operationoperator: 27
operands: 28
26ExprTuple29
27Literal
28ExprTuple30, 31
29Lambdaparameters: 32
body: 33
30Operationoperator: 96
operands: 34
31Operationoperator: 96
operands: 35
32ExprTuple36
33Conditionalvalue: 37
condition: 38
34ExprTuple92, 39
35ExprTuple113, 39
36ExprRangelambda_map: 40
start_index: 112
end_index: 92
37Operationoperator: 41
operand: 44
38Operationoperator: 96
operands: 43
39Literal
40Lambdaparameter: 93
body: 74
41Literal
42ExprTuple44
43ExprTuple45, 46
44Lambdaparameters: 47
body: 48
45Operationoperator: 66
operands: 49
46Operationoperator: 68
operand: 55
47ExprTuple51
48Conditionalvalue: 52
condition: 53
49ExprTuple54
50ExprTuple55
51ExprRangelambda_map: 56
start_index: 112
end_index: 113
52Operationoperator: 57
operands: 58
53Operationoperator: 96
operands: 59
54ExprRangelambda_map: 60
start_index: 112
end_index: 92
55Variable
56Lambdaparameter: 93
body: 86
57Literal
58ExprTuple99, 61
59ExprTuple62, 63
60Lambdaparameter: 93
body: 64
61Operationoperator: 80
operand: 71
62Operationoperator: 66
operands: 67
63Operationoperator: 68
operand: 73
64Operationoperator: 104
operand: 74
65ExprTuple71
66Literal
67ExprTuple72
68Literal
69ExprTuple73
70ExprTuple74
71Lambdaparameter: 119
body: 75
72ExprRangelambda_map: 76
start_index: 112
end_index: 113
73Variable
74IndexedVarvariable: 116
index: 93
75Conditionalvalue: 77
condition: 78
76Lambdaparameter: 93
body: 79
77Operationoperator: 80
operand: 84
78Operationoperator: 96
operands: 82
79Operationoperator: 104
operand: 86
80Literal
81ExprTuple84
82ExprTuple119, 85
83ExprTuple86
84Lambdaparameter: 118
body: 87
85Operationoperator: 108
operands: 88
86IndexedVarvariable: 114
index: 93
87Conditionalvalue: 90
condition: 91
88ExprTuple112, 92
89ExprTuple93
90Operationoperator: 94
operands: 95
91Operationoperator: 96
operands: 97
92Variable
93Variable
94Literal
95ExprTuple98, 99, 100, 101, 102
96Literal
97ExprTuple118, 103
98Operationoperator: 106
operand: 110
99Variable
100Operationoperator: 104
operand: 111
101Operationoperator: 104
operand: 110
102Operationoperator: 106
operand: 111
103Operationoperator: 108
operands: 109
104Literal
105ExprTuple110
106Literal
107ExprTuple111
108Literal
109ExprTuple112, 113
110IndexedVarvariable: 114
index: 118
111IndexedVarvariable: 116
index: 119
112Literal
113Variable
114Variable
115ExprTuple118
116Variable
117ExprTuple119
118Variable
119Variable