logo

Expression of type ExprTuple

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 Conditional, ExprTuple, Lambda, 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, Unitary, 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 = ExprTuple(Lambda(U, Conditional(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(), InSet(U, Unitary(n)))))
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())
\left(U \mapsto \left\{\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} \textrm{ if } U \in \textrm{U}\left(n\right)\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 25
body: 3
2ExprTuple25
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 49
operands: 8
6Literal
7ExprTuple9
8ExprTuple25, 10
9Lambdaparameters: 11
body: 12
10Operationoperator: 13
operand: 72
11ExprTuple15, 16
12Conditionalvalue: 17
condition: 18
13Literal
14ExprTuple72
15ExprRangelambda_map: 19
start_index: 71
end_index: 72
16ExprRangelambda_map: 20
start_index: 71
end_index: 72
17Operationoperator: 21
operands: 22
18Operationoperator: 23
operands: 24
19Lambdaparameter: 85
body: 80
20Lambdaparameter: 85
body: 81
21Literal
22ExprTuple25, 26
23Literal
24ExprTuple27, 28
25Variable
26Operationoperator: 29
operand: 33
27Operationoperator: 49
operands: 31
28Operationoperator: 49
operands: 32
29Literal
30ExprTuple33
31ExprTuple34, 36
32ExprTuple35, 36
33Lambdaparameter: 79
body: 37
34Operationoperator: 52
operand: 44
35Operationoperator: 52
operand: 45
36Operationoperator: 40
operand: 46
37Conditionalvalue: 42
condition: 43
38ExprTuple44
39ExprTuple45
40Literal
41ExprTuple46
42Operationoperator: 47
operands: 48
43Operationoperator: 49
operands: 50
44Operationoperator: 52
operands: 51
45Operationoperator: 52
operands: 53
46Operationoperator: 54
operands: 55
47Literal
48ExprTuple56, 57
49Literal
50ExprTuple79, 58
51ExprTuple59
52Literal
53ExprTuple60
54Literal
55ExprTuple61, 72
56Operationoperator: 77
operand: 69
57Operationoperator: 63
operand: 70
58Operationoperator: 65
operands: 66
59ExprRangelambda_map: 67
start_index: 71
end_index: 72
60ExprRangelambda_map: 68
start_index: 71
end_index: 72
61Literal
62ExprTuple69
63Literal
64ExprTuple70
65Literal
66ExprTuple71, 72
67Lambdaparameter: 85
body: 73
68Lambdaparameter: 85
body: 74
69IndexedVarvariable: 82
index: 79
70IndexedVarvariable: 83
index: 79
71Literal
72Variable
73Operationoperator: 77
operand: 80
74Operationoperator: 77
operand: 81
75ExprTuple79
76ExprTuple80
77Literal
78ExprTuple81
79Variable
80IndexedVarvariable: 82
index: 85
81IndexedVarvariable: 83
index: 85
82Variable
83Variable
84ExprTuple85
85Variable