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 M, i, n
from proveit.core_expr_types import a_1_to_n, a_i, v_1_to_n, v_i
from proveit.linear_algebra import Adj, Hspace, LinMap, OrthoNormBases, ScalarMult, VecSum
from proveit.logic import Equals, Exists, Forall, Iff, InSet, Set
from proveit.numbers import Complex, Interval, one
from proveit.physics.quantum import Bra, Ket, Qmult
from proveit.physics.quantum.algebra import v_1_to_n_kets
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Adj(M)
expr = Forall(instance_param_or_params = [M], instance_expr = Iff(Equals(Qmult(sub_expr1, M), Qmult(M, sub_expr1)), Exists(instance_param_or_params = [v_1_to_n], instance_expr = Exists(instance_param_or_params = [a_1_to_n], instance_expr = Equals(M, VecSum(index_or_indices = [i], summand = ScalarMult(a_i, Qmult(Ket(v_i), Bra(v_i))), domain = Interval(one, n))), domain = Complex).with_wrapping(), condition = InSet(Set(v_1_to_n_kets), OrthoNormBases(Hspace))).with_wrapping()).with_wrapping_at(2), domain = LinMap(Hspace, Hspace))
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 \in \mathcal{L}\left(\mathcal{H}, \mathcal{H}\right)}~\left(\begin{array}{c} \begin{array}{l} \left(\left(M^{\dagger} \thinspace M\right) = \left(M \thinspace M^{\dagger}\right)\right) \Leftrightarrow  \\ \left[\begin{array}{l}\exists_{v_{1}, v_{2}, \ldots, v_{n}~|~\left\{\left\{\lvert v_{1} \rangle, \lvert v_{2} \rangle, \ldots, \lvert v_{n} \rangle\right\}\right\} \in \textrm{O.N.Bases}\left(\mathcal{H}\right)}~\\
\left[\begin{array}{l}\exists_{a_{1}, a_{2}, \ldots, a_{n} \in \mathbb{C}}~\\
\left(M = \left(\sum_{i=1}^{n} \left(a_{i} \cdot \left(\lvert v_{i} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right)\right)\end{array}\right]\end{array}\right] \end{array} \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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameter: 54
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operands: 8
6Operationoperator: 75
operands: 9
7Literal
8ExprTuple10, 11
9ExprTuple54, 12
10Operationoperator: 48
operands: 13
11Operationoperator: 31
operand: 19
12Operationoperator: 15
operands: 16
13ExprTuple17, 18
14ExprTuple19
15Literal
16ExprTuple46, 46
17Operationoperator: 83
operands: 20
18Operationoperator: 83
operands: 21
19Lambdaparameters: 22
body: 23
20ExprTuple24, 54
21ExprTuple54, 24
22ExprTuple25
23Conditionalvalue: 26
condition: 27
24Operationoperator: 28
operand: 54
25ExprRangelambda_map: 30
start_index: 89
end_index: 90
26Operationoperator: 31
operand: 34
27Operationoperator: 75
operands: 33
28Literal
29ExprTuple54
30Lambdaparameter: 81
body: 72
31Literal
32ExprTuple34
33ExprTuple35, 36
34Lambdaparameters: 37
body: 38
35Operationoperator: 52
operand: 45
36Operationoperator: 40
operand: 46
37ExprTuple42
38Conditionalvalue: 43
condition: 44
39ExprTuple45
40Literal
41ExprTuple46
42ExprRangelambda_map: 47
start_index: 89
end_index: 90
43Operationoperator: 48
operands: 49
44Operationoperator: 50
operands: 51
45Operationoperator: 52
operands: 53
46Variable
47Lambdaparameter: 81
body: 70
48Literal
49ExprTuple54, 55
50Literal
51ExprTuple56
52Literal
53ExprTuple57
54Variable
55Operationoperator: 58
operand: 62
56ExprRangelambda_map: 60
start_index: 89
end_index: 90
57ExprRangelambda_map: 61
start_index: 89
end_index: 90
58Literal
59ExprTuple62
60Lambdaparameter: 81
body: 63
61Lambdaparameter: 81
body: 64
62Lambdaparameter: 97
body: 65
63Operationoperator: 75
operands: 66
64Operationoperator: 91
operand: 72
65Conditionalvalue: 68
condition: 69
66ExprTuple70, 71
67ExprTuple72
68Operationoperator: 73
operands: 74
69Operationoperator: 75
operands: 76
70IndexedVarvariable: 82
index: 81
71Literal
72IndexedVarvariable: 95
index: 81
73Literal
74ExprTuple78, 79
75Literal
76ExprTuple97, 80
77ExprTuple81
78IndexedVarvariable: 82
index: 97
79Operationoperator: 83
operands: 84
80Operationoperator: 85
operands: 86
81Variable
82Variable
83Literal
84ExprTuple87, 88
85Literal
86ExprTuple89, 90
87Operationoperator: 91
operand: 94
88Operationoperator: 92
operand: 94
89Literal
90Variable
91Literal
92Literal
93ExprTuple94
94IndexedVarvariable: 95
index: 97
95Variable
96ExprTuple97
97Variable