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 CartExp, Forall, InSet, Set
from proveit.numbers import Complex, Interval, NaturalPos, 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(n, Conditional(Forall(instance_param_or_params = [v_1_to_n, w_1_to_n], instance_expr = InSet(VecSum(index_or_indices = [i], summand = Qmult(Ket(v_i), Bra(w_i)), domain = Interval(one, n)), Unitary(n)), conditions = [InSet(Set(v_1_to_n_kets), sub_expr1), InSet(Set(w_1_to_n_kets), sub_expr1)]).with_wrapping(), InSet(n, NaturalPos))))
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(n \mapsto \left\{\begin{array}{l}\forall_{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(\left(\sum_{i=1}^{n} \left(\lvert v_{i} \rangle \thinspace \langle w_{i} \rvert\right)\right) \in \textrm{U}\left(n\right)\right)\end{array} \textrm{ if } n \in \mathbb{N}^+\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: 70
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 47
operands: 7
5Literal
6ExprTuple8
7ExprTuple70, 9
8Lambdaparameters: 10
body: 11
9Literal
10ExprTuple12, 13
11Conditionalvalue: 14
condition: 15
12ExprRangelambda_map: 16
start_index: 69
end_index: 70
13ExprRangelambda_map: 17
start_index: 69
end_index: 70
14Operationoperator: 47
operands: 18
15Operationoperator: 19
operands: 20
16Lambdaparameter: 83
body: 78
17Lambdaparameter: 83
body: 79
18ExprTuple21, 22
19Literal
20ExprTuple23, 24
21Operationoperator: 25
operand: 31
22Operationoperator: 27
operand: 70
23Operationoperator: 47
operands: 29
24Operationoperator: 47
operands: 30
25Literal
26ExprTuple31
27Literal
28ExprTuple70
29ExprTuple32, 34
30ExprTuple33, 34
31Lambdaparameter: 77
body: 35
32Operationoperator: 50
operand: 42
33Operationoperator: 50
operand: 43
34Operationoperator: 38
operand: 44
35Conditionalvalue: 40
condition: 41
36ExprTuple42
37ExprTuple43
38Literal
39ExprTuple44
40Operationoperator: 45
operands: 46
41Operationoperator: 47
operands: 48
42Operationoperator: 50
operands: 49
43Operationoperator: 50
operands: 51
44Operationoperator: 52
operands: 53
45Literal
46ExprTuple54, 55
47Literal
48ExprTuple77, 56
49ExprTuple57
50Literal
51ExprTuple58
52Literal
53ExprTuple59, 70
54Operationoperator: 75
operand: 67
55Operationoperator: 61
operand: 68
56Operationoperator: 63
operands: 64
57ExprRangelambda_map: 65
start_index: 69
end_index: 70
58ExprRangelambda_map: 66
start_index: 69
end_index: 70
59Literal
60ExprTuple67
61Literal
62ExprTuple68
63Literal
64ExprTuple69, 70
65Lambdaparameter: 83
body: 71
66Lambdaparameter: 83
body: 72
67IndexedVarvariable: 80
index: 77
68IndexedVarvariable: 81
index: 77
69Literal
70Variable
71Operationoperator: 75
operand: 78
72Operationoperator: 75
operand: 79
73ExprTuple77
74ExprTuple78
75Literal
76ExprTuple79
77Variable
78IndexedVarvariable: 80
index: 83
79IndexedVarvariable: 81
index: 83
80Variable
81Variable
82ExprTuple83
83Variable