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, VecSum
from proveit.logic import And, CartExp, Equals, 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([v_1_to_n, w_1_to_n], Conditional(Equals(U, VecSum(index_or_indices = [i], summand = Qmult(Ket(v_i), Bra(w_i)), domain = Interval(one, n))), And(InSet(Set(v_1_to_n_kets), sub_expr1), InSet(Set(w_1_to_n_kets), sub_expr1)))))
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(\left(v_{1}, v_{2}, \ldots, v_{n}, w_{1}, w_{2}, \ldots, w_{n}\right) \mapsto \left\{U = \left(\sum_{i=1}^{n} \left(\lvert v_{i} \rangle \thinspace \langle w_{i} \rvert\right)\right) \textrm{ if } \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)\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
1Lambdaparameters: 2
body: 3
2ExprTuple4, 5
3Conditionalvalue: 6
condition: 7
4ExprRangelambda_map: 8
start_index: 60
end_index: 61
5ExprRangelambda_map: 9
start_index: 60
end_index: 61
6Operationoperator: 10
operands: 11
7Operationoperator: 12
operands: 13
8Lambdaparameter: 74
body: 69
9Lambdaparameter: 74
body: 70
10Literal
11ExprTuple14, 15
12Literal
13ExprTuple16, 17
14Variable
15Operationoperator: 18
operand: 22
16Operationoperator: 38
operands: 20
17Operationoperator: 38
operands: 21
18Literal
19ExprTuple22
20ExprTuple23, 25
21ExprTuple24, 25
22Lambdaparameter: 68
body: 26
23Operationoperator: 41
operand: 33
24Operationoperator: 41
operand: 34
25Operationoperator: 29
operand: 35
26Conditionalvalue: 31
condition: 32
27ExprTuple33
28ExprTuple34
29Literal
30ExprTuple35
31Operationoperator: 36
operands: 37
32Operationoperator: 38
operands: 39
33Operationoperator: 41
operands: 40
34Operationoperator: 41
operands: 42
35Operationoperator: 43
operands: 44
36Literal
37ExprTuple45, 46
38Literal
39ExprTuple68, 47
40ExprTuple48
41Literal
42ExprTuple49
43Literal
44ExprTuple50, 61
45Operationoperator: 66
operand: 58
46Operationoperator: 52
operand: 59
47Operationoperator: 54
operands: 55
48ExprRangelambda_map: 56
start_index: 60
end_index: 61
49ExprRangelambda_map: 57
start_index: 60
end_index: 61
50Literal
51ExprTuple58
52Literal
53ExprTuple59
54Literal
55ExprTuple60, 61
56Lambdaparameter: 74
body: 62
57Lambdaparameter: 74
body: 63
58IndexedVarvariable: 71
index: 68
59IndexedVarvariable: 72
index: 68
60Literal
61Variable
62Operationoperator: 66
operand: 69
63Operationoperator: 66
operand: 70
64ExprTuple68
65ExprTuple69
66Literal
67ExprTuple70
68Variable
69IndexedVarvariable: 71
index: 74
70IndexedVarvariable: 72
index: 74
71Variable
72Variable
73ExprTuple74
74Variable