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, 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 And, CartExp, 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(InSet(VecSum(index_or_indices = [i], summand = Qmult(Ket(v_i), Bra(w_i)), domain = Interval(one, n)), Unitary(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\{\left(\sum_{i=1}^{n} \left(\lvert v_{i} \rangle \thinspace \langle w_{i} \rvert\right)\right) \in \textrm{U}\left(n\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: 61
end_index: 62
5ExprRangelambda_map: 9
start_index: 61
end_index: 62
6Operationoperator: 39
operands: 10
7Operationoperator: 11
operands: 12
8Lambdaparameter: 75
body: 70
9Lambdaparameter: 75
body: 71
10ExprTuple13, 14
11Literal
12ExprTuple15, 16
13Operationoperator: 17
operand: 23
14Operationoperator: 19
operand: 62
15Operationoperator: 39
operands: 21
16Operationoperator: 39
operands: 22
17Literal
18ExprTuple23
19Literal
20ExprTuple62
21ExprTuple24, 26
22ExprTuple25, 26
23Lambdaparameter: 69
body: 27
24Operationoperator: 42
operand: 34
25Operationoperator: 42
operand: 35
26Operationoperator: 30
operand: 36
27Conditionalvalue: 32
condition: 33
28ExprTuple34
29ExprTuple35
30Literal
31ExprTuple36
32Operationoperator: 37
operands: 38
33Operationoperator: 39
operands: 40
34Operationoperator: 42
operands: 41
35Operationoperator: 42
operands: 43
36Operationoperator: 44
operands: 45
37Literal
38ExprTuple46, 47
39Literal
40ExprTuple69, 48
41ExprTuple49
42Literal
43ExprTuple50
44Literal
45ExprTuple51, 62
46Operationoperator: 67
operand: 59
47Operationoperator: 53
operand: 60
48Operationoperator: 55
operands: 56
49ExprRangelambda_map: 57
start_index: 61
end_index: 62
50ExprRangelambda_map: 58
start_index: 61
end_index: 62
51Literal
52ExprTuple59
53Literal
54ExprTuple60
55Literal
56ExprTuple61, 62
57Lambdaparameter: 75
body: 63
58Lambdaparameter: 75
body: 64
59IndexedVarvariable: 72
index: 69
60IndexedVarvariable: 73
index: 69
61Literal
62Variable
63Operationoperator: 67
operand: 70
64Operationoperator: 67
operand: 71
65ExprTuple69
66ExprTuple70
67Literal
68ExprTuple71
69Variable
70IndexedVarvariable: 72
index: 75
71IndexedVarvariable: 73
index: 75
72Variable
73Variable
74ExprTuple75
75Variable