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_i
from proveit.linear_algebra import ScalarMult, VecSum
from proveit.logic import Equals, Exists
from proveit.numbers import Complex, Interval, one
from proveit.physics.quantum import Bra, Ket, Qmult
In [2]:
# build up the expression from sub-expressions
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()
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_{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}
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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameters: 4
body: 5
4ExprTuple6
5Conditionalvalue: 7
condition: 8
6ExprRangelambda_map: 9
start_index: 44
end_index: 45
7Operationoperator: 10
operands: 11
8Operationoperator: 12
operands: 13
9Lambdaparameter: 36
body: 26
10Literal
11ExprTuple14, 15
12Literal
13ExprTuple16
14Variable
15Operationoperator: 17
operand: 20
16ExprRangelambda_map: 19
start_index: 44
end_index: 45
17Literal
18ExprTuple20
19Lambdaparameter: 36
body: 21
20Lambdaparameter: 52
body: 22
21Operationoperator: 30
operands: 23
22Conditionalvalue: 24
condition: 25
23ExprTuple26, 27
24Operationoperator: 28
operands: 29
25Operationoperator: 30
operands: 31
26IndexedVarvariable: 37
index: 36
27Literal
28Literal
29ExprTuple33, 34
30Literal
31ExprTuple52, 35
32ExprTuple36
33IndexedVarvariable: 37
index: 52
34Operationoperator: 38
operands: 39
35Operationoperator: 40
operands: 41
36Variable
37Variable
38Literal
39ExprTuple42, 43
40Literal
41ExprTuple44, 45
42Operationoperator: 46
operand: 49
43Operationoperator: 47
operand: 49
44Literal
45Variable
46Literal
47Literal
48ExprTuple49
49IndexedVarvariable: 50
index: 52
50Variable
51ExprTuple52
52Variable