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 LinMap, OrthoNormBases, VecSum
from proveit.logic import 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 = [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), InSet(A, LinMap(V, 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\{\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] \textrm{ if } A \in \mathcal{L}\left(V, 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: 28
operand: 5
2Operationoperator: 83
operands: 4
3ExprTuple5
4ExprTuple86, 6
5Lambdaparameters: 7
body: 8
6Operationoperator: 9
operands: 10
7ExprTuple79, 100
8Conditionalvalue: 11
condition: 12
9Literal
10ExprTuple42, 60
11Operationoperator: 28
operand: 16
12Operationoperator: 14
operands: 15
13ExprTuple16
14Literal
15ExprTuple17, 18
16Lambdaparameters: 19
body: 20
17Operationoperator: 83
operands: 21
18Operationoperator: 83
operands: 22
19ExprTuple23
20Conditionalvalue: 24
condition: 25
21ExprTuple79, 26
22ExprTuple100, 26
23ExprRangelambda_map: 27
start_index: 99
end_index: 79
24Operationoperator: 28
operand: 31
25Operationoperator: 83
operands: 30
26Literal
27Lambdaparameter: 80
body: 61
28Literal
29ExprTuple31
30ExprTuple32, 33
31Lambdaparameters: 34
body: 35
32Operationoperator: 53
operands: 36
33Operationoperator: 55
operand: 42
34ExprTuple38
35Conditionalvalue: 39
condition: 40
36ExprTuple41
37ExprTuple42
38ExprRangelambda_map: 43
start_index: 99
end_index: 100
39Operationoperator: 44
operands: 45
40Operationoperator: 83
operands: 46
41ExprRangelambda_map: 47
start_index: 99
end_index: 79
42Variable
43Lambdaparameter: 80
body: 73
44Literal
45ExprTuple86, 48
46ExprTuple49, 50
47Lambdaparameter: 80
body: 51
48Operationoperator: 67
operand: 58
49Operationoperator: 53
operands: 54
50Operationoperator: 55
operand: 60
51Operationoperator: 91
operand: 61
52ExprTuple58
53Literal
54ExprTuple59
55Literal
56ExprTuple60
57ExprTuple61
58Lambdaparameter: 106
body: 62
59ExprRangelambda_map: 63
start_index: 99
end_index: 100
60Variable
61IndexedVarvariable: 103
index: 80
62Conditionalvalue: 64
condition: 65
63Lambdaparameter: 80
body: 66
64Operationoperator: 67
operand: 71
65Operationoperator: 83
operands: 69
66Operationoperator: 91
operand: 73
67Literal
68ExprTuple71
69ExprTuple106, 72
70ExprTuple73
71Lambdaparameter: 105
body: 74
72Operationoperator: 95
operands: 75
73IndexedVarvariable: 101
index: 80
74Conditionalvalue: 77
condition: 78
75ExprTuple99, 79
76ExprTuple80
77Operationoperator: 81
operands: 82
78Operationoperator: 83
operands: 84
79Variable
80Variable
81Literal
82ExprTuple85, 86, 87, 88, 89
83Literal
84ExprTuple105, 90
85Operationoperator: 93
operand: 97
86Variable
87Operationoperator: 91
operand: 98
88Operationoperator: 91
operand: 97
89Operationoperator: 93
operand: 98
90Operationoperator: 95
operands: 96
91Literal
92ExprTuple97
93Literal
94ExprTuple98
95Literal
96ExprTuple99, 100
97IndexedVarvariable: 101
index: 105
98IndexedVarvariable: 103
index: 106
99Literal
100Variable
101Variable
102ExprTuple105
103Variable
104ExprTuple106
105Variable
106Variable