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, 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 = [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)
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_{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]
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: 22
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple73, 94
4Conditionalvalue: 5
condition: 6
5Operationoperator: 22
operand: 10
6Operationoperator: 8
operands: 9
7ExprTuple10
8Literal
9ExprTuple11, 12
10Lambdaparameters: 13
body: 14
11Operationoperator: 77
operands: 15
12Operationoperator: 77
operands: 16
13ExprTuple17
14Conditionalvalue: 18
condition: 19
15ExprTuple73, 20
16ExprTuple94, 20
17ExprRangelambda_map: 21
start_index: 93
end_index: 73
18Operationoperator: 22
operand: 25
19Operationoperator: 77
operands: 24
20Literal
21Lambdaparameter: 74
body: 55
22Literal
23ExprTuple25
24ExprTuple26, 27
25Lambdaparameters: 28
body: 29
26Operationoperator: 47
operands: 30
27Operationoperator: 49
operand: 36
28ExprTuple32
29Conditionalvalue: 33
condition: 34
30ExprTuple35
31ExprTuple36
32ExprRangelambda_map: 37
start_index: 93
end_index: 94
33Operationoperator: 38
operands: 39
34Operationoperator: 77
operands: 40
35ExprRangelambda_map: 41
start_index: 93
end_index: 73
36Variable
37Lambdaparameter: 74
body: 67
38Literal
39ExprTuple80, 42
40ExprTuple43, 44
41Lambdaparameter: 74
body: 45
42Operationoperator: 61
operand: 52
43Operationoperator: 47
operands: 48
44Operationoperator: 49
operand: 54
45Operationoperator: 85
operand: 55
46ExprTuple52
47Literal
48ExprTuple53
49Literal
50ExprTuple54
51ExprTuple55
52Lambdaparameter: 100
body: 56
53ExprRangelambda_map: 57
start_index: 93
end_index: 94
54Variable
55IndexedVarvariable: 97
index: 74
56Conditionalvalue: 58
condition: 59
57Lambdaparameter: 74
body: 60
58Operationoperator: 61
operand: 65
59Operationoperator: 77
operands: 63
60Operationoperator: 85
operand: 67
61Literal
62ExprTuple65
63ExprTuple100, 66
64ExprTuple67
65Lambdaparameter: 99
body: 68
66Operationoperator: 89
operands: 69
67IndexedVarvariable: 95
index: 74
68Conditionalvalue: 71
condition: 72
69ExprTuple93, 73
70ExprTuple74
71Operationoperator: 75
operands: 76
72Operationoperator: 77
operands: 78
73Variable
74Variable
75Literal
76ExprTuple79, 80, 81, 82, 83
77Literal
78ExprTuple99, 84
79Operationoperator: 87
operand: 91
80Variable
81Operationoperator: 85
operand: 92
82Operationoperator: 85
operand: 91
83Operationoperator: 87
operand: 92
84Operationoperator: 89
operands: 90
85Literal
86ExprTuple91
87Literal
88ExprTuple92
89Literal
90ExprTuple93, 94
91IndexedVarvariable: 95
index: 99
92IndexedVarvariable: 97
index: 100
93Literal
94Variable
95Variable
96ExprTuple99
97Variable
98ExprTuple100
99Variable
100Variable