logo

Expression of type Exists

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 Hspace, OrthoNormBases, ScalarMult, VecSum
from proveit.logic import Equals, Exists, 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
expr = 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()
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}\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}
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: 67
end_index: 68
6Operationoperator: 9
operand: 12
7Operationoperator: 53
operands: 11
8Lambdaparameter: 59
body: 50
9Literal
10ExprTuple12
11ExprTuple13, 14
12Lambdaparameters: 15
body: 16
13Operationoperator: 30
operand: 23
14Operationoperator: 18
operand: 24
15ExprTuple20
16Conditionalvalue: 21
condition: 22
17ExprTuple23
18Literal
19ExprTuple24
20ExprRangelambda_map: 25
start_index: 67
end_index: 68
21Operationoperator: 26
operands: 27
22Operationoperator: 28
operands: 29
23Operationoperator: 30
operands: 31
24Variable
25Lambdaparameter: 59
body: 48
26Literal
27ExprTuple32, 33
28Literal
29ExprTuple34
30Literal
31ExprTuple35
32Variable
33Operationoperator: 36
operand: 40
34ExprRangelambda_map: 38
start_index: 67
end_index: 68
35ExprRangelambda_map: 39
start_index: 67
end_index: 68
36Literal
37ExprTuple40
38Lambdaparameter: 59
body: 41
39Lambdaparameter: 59
body: 42
40Lambdaparameter: 75
body: 43
41Operationoperator: 53
operands: 44
42Operationoperator: 69
operand: 50
43Conditionalvalue: 46
condition: 47
44ExprTuple48, 49
45ExprTuple50
46Operationoperator: 51
operands: 52
47Operationoperator: 53
operands: 54
48IndexedVarvariable: 60
index: 59
49Literal
50IndexedVarvariable: 73
index: 59
51Literal
52ExprTuple56, 57
53Literal
54ExprTuple75, 58
55ExprTuple59
56IndexedVarvariable: 60
index: 75
57Operationoperator: 61
operands: 62
58Operationoperator: 63
operands: 64
59Variable
60Variable
61Literal
62ExprTuple65, 66
63Literal
64ExprTuple67, 68
65Operationoperator: 69
operand: 72
66Operationoperator: 70
operand: 72
67Literal
68Variable
69Literal
70Literal
71ExprTuple72
72IndexedVarvariable: 73
index: 75
73Variable
74ExprTuple75
75Variable