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 U, i, n
from proveit.core_expr_types import v_1_to_n, v_i, w_1_to_n, w_i
from proveit.linear_algebra import OrthoNormBases, VecSum
from proveit.logic import CartExp, 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, w_1_to_n_kets
In [2]:
# build up the expression from sub-expressions
sub_expr1 = OrthoNormBases(CartExp(Complex, n))
expr = Exists(instance_param_or_params = [v_1_to_n, w_1_to_n], instance_expr = Equals(U, VecSum(index_or_indices = [i], summand = Qmult(Ket(v_i), Bra(w_i)), domain = Interval(one, n))), conditions = [InSet(Set(v_1_to_n_kets), sub_expr1), InSet(Set(w_1_to_n_kets), sub_expr1)]).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}, w_{1}, w_{2}, \ldots, w_{n}~|~\left\{\left\{\lvert v_{1} \rangle, \lvert v_{2} \rangle, \ldots, \lvert v_{n} \rangle\right\}\right\} \in \textrm{O.N.Bases}\left(\mathbb{C}^{n}\right), \left\{\left\{\lvert w_{1} \rangle, \lvert w_{2} \rangle, \ldots, \lvert w_{n} \rangle\right\}\right\} \in \textrm{O.N.Bases}\left(\mathbb{C}^{n}\right)}~\\
\left(U = \left(\sum_{i=1}^{n} \left(\lvert v_{i} \rangle \thinspace \langle w_{i} \rvert\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, 7
5Conditionalvalue: 8
condition: 9
6ExprRangelambda_map: 10
start_index: 62
end_index: 63
7ExprRangelambda_map: 11
start_index: 62
end_index: 63
8Operationoperator: 12
operands: 13
9Operationoperator: 14
operands: 15
10Lambdaparameter: 76
body: 71
11Lambdaparameter: 76
body: 72
12Literal
13ExprTuple16, 17
14Literal
15ExprTuple18, 19
16Variable
17Operationoperator: 20
operand: 24
18Operationoperator: 40
operands: 22
19Operationoperator: 40
operands: 23
20Literal
21ExprTuple24
22ExprTuple25, 27
23ExprTuple26, 27
24Lambdaparameter: 70
body: 28
25Operationoperator: 43
operand: 35
26Operationoperator: 43
operand: 36
27Operationoperator: 31
operand: 37
28Conditionalvalue: 33
condition: 34
29ExprTuple35
30ExprTuple36
31Literal
32ExprTuple37
33Operationoperator: 38
operands: 39
34Operationoperator: 40
operands: 41
35Operationoperator: 43
operands: 42
36Operationoperator: 43
operands: 44
37Operationoperator: 45
operands: 46
38Literal
39ExprTuple47, 48
40Literal
41ExprTuple70, 49
42ExprTuple50
43Literal
44ExprTuple51
45Literal
46ExprTuple52, 63
47Operationoperator: 68
operand: 60
48Operationoperator: 54
operand: 61
49Operationoperator: 56
operands: 57
50ExprRangelambda_map: 58
start_index: 62
end_index: 63
51ExprRangelambda_map: 59
start_index: 62
end_index: 63
52Literal
53ExprTuple60
54Literal
55ExprTuple61
56Literal
57ExprTuple62, 63
58Lambdaparameter: 76
body: 64
59Lambdaparameter: 76
body: 65
60IndexedVarvariable: 73
index: 70
61IndexedVarvariable: 74
index: 70
62Literal
63Variable
64Operationoperator: 68
operand: 71
65Operationoperator: 68
operand: 72
66ExprTuple70
67ExprTuple71
68Literal
69ExprTuple72
70Variable
71IndexedVarvariable: 73
index: 76
72IndexedVarvariable: 74
index: 76
73Variable
74Variable
75ExprTuple76
76Variable