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 A, B, i, n
from proveit.core_expr_types import a_1_to_n, a_i, b_1_to_n, b_i, v_i
from proveit.linear_algebra import ScalarMult, VecSum
from proveit.logic import And, 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
sub_expr1 = [i]
sub_expr2 = Interval(one, n)
sub_expr3 = Qmult(Ket(v_i), Bra(v_i))
expr = Exists(instance_param_or_params = [a_1_to_n, b_1_to_n], instance_expr = And(Equals(A, VecSum(index_or_indices = sub_expr1, summand = ScalarMult(a_i, sub_expr3), domain = sub_expr2)), Equals(B, VecSum(index_or_indices = sub_expr1, summand = ScalarMult(b_i, sub_expr3), domain = sub_expr2))).with_wrapping_at(2), 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}, b_{1}, b_{2}, \ldots, b_{n} \in \mathbb{C}}~\\
\left(\begin{array}{c} \left(A = \left(\sum_{i=1}^{n} \left(a_{i} \cdot \left(\lvert v_{i} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right)\right) \land  \\ \left(B = \left(\sum_{i=1}^{n} \left(b_{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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameters: 4
body: 5
4ExprTuple6, 7
5Conditionalvalue: 8
condition: 9
6ExprRangelambda_map: 10
start_index: 64
end_index: 65
7ExprRangelambda_map: 11
start_index: 64
end_index: 65
8Operationoperator: 13
operands: 12
9Operationoperator: 13
operands: 14
10Lambdaparameter: 46
body: 37
11Lambdaparameter: 46
body: 38
12ExprTuple15, 16
13Literal
14ExprTuple17, 18
15Operationoperator: 20
operands: 19
16Operationoperator: 20
operands: 21
17ExprRangelambda_map: 22
start_index: 64
end_index: 65
18ExprRangelambda_map: 23
start_index: 64
end_index: 65
19ExprTuple24, 25
20Literal
21ExprTuple26, 27
22Lambdaparameter: 46
body: 28
23Lambdaparameter: 46
body: 29
24Variable
25Operationoperator: 31
operand: 35
26Variable
27Operationoperator: 31
operand: 36
28Operationoperator: 50
operands: 33
29Operationoperator: 50
operands: 34
30ExprTuple35
31Literal
32ExprTuple36
33ExprTuple37, 39
34ExprTuple38, 39
35Lambdaparameter: 72
body: 40
36Lambdaparameter: 72
body: 41
37IndexedVarvariable: 56
index: 46
38IndexedVarvariable: 57
index: 46
39Literal
40Conditionalvalue: 43
condition: 45
41Conditionalvalue: 44
condition: 45
42ExprTuple46
43Operationoperator: 48
operands: 47
44Operationoperator: 48
operands: 49
45Operationoperator: 50
operands: 51
46Variable
47ExprTuple52, 54
48Literal
49ExprTuple53, 54
50Literal
51ExprTuple72, 55
52IndexedVarvariable: 56
index: 72
53IndexedVarvariable: 57
index: 72
54Operationoperator: 58
operands: 59
55Operationoperator: 60
operands: 61
56Variable
57Variable
58Literal
59ExprTuple62, 63
60Literal
61ExprTuple64, 65
62Operationoperator: 66
operand: 69
63Operationoperator: 67
operand: 69
64Literal
65Variable
66Literal
67Literal
68ExprTuple69
69IndexedVarvariable: 70
index: 72
70Variable
71ExprTuple72
72Variable