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 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 = 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))
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())
\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]
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('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: 32
operand: 2
1ExprTuple2
2Lambdaparameter: 90
body: 4
3ExprTuple90
4Conditionalvalue: 5
condition: 6
5Operationoperator: 32
operand: 9
6Operationoperator: 87
operands: 8
7ExprTuple9
8ExprTuple90, 10
9Lambdaparameters: 11
body: 12
10Operationoperator: 13
operands: 14
11ExprTuple83, 104
12Conditionalvalue: 15
condition: 16
13Literal
14ExprTuple46, 64
15Operationoperator: 32
operand: 20
16Operationoperator: 18
operands: 19
17ExprTuple20
18Literal
19ExprTuple21, 22
20Lambdaparameters: 23
body: 24
21Operationoperator: 87
operands: 25
22Operationoperator: 87
operands: 26
23ExprTuple27
24Conditionalvalue: 28
condition: 29
25ExprTuple83, 30
26ExprTuple104, 30
27ExprRangelambda_map: 31
start_index: 103
end_index: 83
28Operationoperator: 32
operand: 35
29Operationoperator: 87
operands: 34
30Literal
31Lambdaparameter: 84
body: 65
32Literal
33ExprTuple35
34ExprTuple36, 37
35Lambdaparameters: 38
body: 39
36Operationoperator: 57
operands: 40
37Operationoperator: 59
operand: 46
38ExprTuple42
39Conditionalvalue: 43
condition: 44
40ExprTuple45
41ExprTuple46
42ExprRangelambda_map: 47
start_index: 103
end_index: 104
43Operationoperator: 48
operands: 49
44Operationoperator: 87
operands: 50
45ExprRangelambda_map: 51
start_index: 103
end_index: 83
46Variable
47Lambdaparameter: 84
body: 77
48Literal
49ExprTuple90, 52
50ExprTuple53, 54
51Lambdaparameter: 84
body: 55
52Operationoperator: 71
operand: 62
53Operationoperator: 57
operands: 58
54Operationoperator: 59
operand: 64
55Operationoperator: 95
operand: 65
56ExprTuple62
57Literal
58ExprTuple63
59Literal
60ExprTuple64
61ExprTuple65
62Lambdaparameter: 110
body: 66
63ExprRangelambda_map: 67
start_index: 103
end_index: 104
64Variable
65IndexedVarvariable: 107
index: 84
66Conditionalvalue: 68
condition: 69
67Lambdaparameter: 84
body: 70
68Operationoperator: 71
operand: 75
69Operationoperator: 87
operands: 73
70Operationoperator: 95
operand: 77
71Literal
72ExprTuple75
73ExprTuple110, 76
74ExprTuple77
75Lambdaparameter: 109
body: 78
76Operationoperator: 99
operands: 79
77IndexedVarvariable: 105
index: 84
78Conditionalvalue: 81
condition: 82
79ExprTuple103, 83
80ExprTuple84
81Operationoperator: 85
operands: 86
82Operationoperator: 87
operands: 88
83Variable
84Variable
85Literal
86ExprTuple89, 90, 91, 92, 93
87Literal
88ExprTuple109, 94
89Operationoperator: 97
operand: 101
90Variable
91Operationoperator: 95
operand: 102
92Operationoperator: 95
operand: 101
93Operationoperator: 97
operand: 102
94Operationoperator: 99
operands: 100
95Literal
96ExprTuple101
97Literal
98ExprTuple102
99Literal
100ExprTuple103, 104
101IndexedVarvariable: 105
index: 109
102IndexedVarvariable: 107
index: 110
103Literal
104Variable
105Variable
106ExprTuple109
107Variable
108ExprTuple110
109Variable
110Variable