logo

Expression of type Forall

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, 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 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 = 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()
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())
\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}
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneTrue('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 9
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple5
4Conditionalvalue: 6
condition: 7
5ExprRangelambda_map: 8
start_index: 80
end_index: 60
6Operationoperator: 9
operand: 12
7Operationoperator: 64
operands: 11
8Lambdaparameter: 61
body: 42
9Literal
10ExprTuple12
11ExprTuple13, 14
12Lambdaparameters: 15
body: 16
13Operationoperator: 34
operands: 17
14Operationoperator: 36
operand: 23
15ExprTuple19
16Conditionalvalue: 20
condition: 21
17ExprTuple22
18ExprTuple23
19ExprRangelambda_map: 24
start_index: 80
end_index: 81
20Operationoperator: 25
operands: 26
21Operationoperator: 64
operands: 27
22ExprRangelambda_map: 28
start_index: 80
end_index: 60
23Variable
24Lambdaparameter: 61
body: 54
25Literal
26ExprTuple67, 29
27ExprTuple30, 31
28Lambdaparameter: 61
body: 32
29Operationoperator: 48
operand: 39
30Operationoperator: 34
operands: 35
31Operationoperator: 36
operand: 41
32Operationoperator: 72
operand: 42
33ExprTuple39
34Literal
35ExprTuple40
36Literal
37ExprTuple41
38ExprTuple42
39Lambdaparameter: 87
body: 43
40ExprRangelambda_map: 44
start_index: 80
end_index: 81
41Variable
42IndexedVarvariable: 84
index: 61
43Conditionalvalue: 45
condition: 46
44Lambdaparameter: 61
body: 47
45Operationoperator: 48
operand: 52
46Operationoperator: 64
operands: 50
47Operationoperator: 72
operand: 54
48Literal
49ExprTuple52
50ExprTuple87, 53
51ExprTuple54
52Lambdaparameter: 86
body: 55
53Operationoperator: 76
operands: 56
54IndexedVarvariable: 82
index: 61
55Conditionalvalue: 58
condition: 59
56ExprTuple80, 60
57ExprTuple61
58Operationoperator: 62
operands: 63
59Operationoperator: 64
operands: 65
60Variable
61Variable
62Literal
63ExprTuple66, 67, 68, 69, 70
64Literal
65ExprTuple86, 71
66Operationoperator: 74
operand: 78
67Variable
68Operationoperator: 72
operand: 79
69Operationoperator: 72
operand: 78
70Operationoperator: 74
operand: 79
71Operationoperator: 76
operands: 77
72Literal
73ExprTuple78
74Literal
75ExprTuple79
76Literal
77ExprTuple80, 81
78IndexedVarvariable: 82
index: 86
79IndexedVarvariable: 84
index: 87
80Literal
81Variable
82Variable
83ExprTuple86
84Variable
85ExprTuple87
86Variable
87Variable