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, 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 = [U], instance_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(), domain = Unitary(n)), 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\{\forall_{U \in \textrm{U}\left(n\right)}~\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}\right] \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: 80
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 57
operands: 7
5Literal
6ExprTuple8
7ExprTuple80, 9
8Lambdaparameter: 33
body: 11
9Literal
10ExprTuple33
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operand: 17
13Operationoperator: 57
operands: 16
14Literal
15ExprTuple17
16ExprTuple33, 18
17Lambdaparameters: 19
body: 20
18Operationoperator: 21
operand: 80
19ExprTuple23, 24
20Conditionalvalue: 25
condition: 26
21Literal
22ExprTuple80
23ExprRangelambda_map: 27
start_index: 79
end_index: 80
24ExprRangelambda_map: 28
start_index: 79
end_index: 80
25Operationoperator: 29
operands: 30
26Operationoperator: 31
operands: 32
27Lambdaparameter: 93
body: 88
28Lambdaparameter: 93
body: 89
29Literal
30ExprTuple33, 34
31Literal
32ExprTuple35, 36
33Variable
34Operationoperator: 37
operand: 41
35Operationoperator: 57
operands: 39
36Operationoperator: 57
operands: 40
37Literal
38ExprTuple41
39ExprTuple42, 44
40ExprTuple43, 44
41Lambdaparameter: 87
body: 45
42Operationoperator: 60
operand: 52
43Operationoperator: 60
operand: 53
44Operationoperator: 48
operand: 54
45Conditionalvalue: 50
condition: 51
46ExprTuple52
47ExprTuple53
48Literal
49ExprTuple54
50Operationoperator: 55
operands: 56
51Operationoperator: 57
operands: 58
52Operationoperator: 60
operands: 59
53Operationoperator: 60
operands: 61
54Operationoperator: 62
operands: 63
55Literal
56ExprTuple64, 65
57Literal
58ExprTuple87, 66
59ExprTuple67
60Literal
61ExprTuple68
62Literal
63ExprTuple69, 80
64Operationoperator: 85
operand: 77
65Operationoperator: 71
operand: 78
66Operationoperator: 73
operands: 74
67ExprRangelambda_map: 75
start_index: 79
end_index: 80
68ExprRangelambda_map: 76
start_index: 79
end_index: 80
69Literal
70ExprTuple77
71Literal
72ExprTuple78
73Literal
74ExprTuple79, 80
75Lambdaparameter: 93
body: 81
76Lambdaparameter: 93
body: 82
77IndexedVarvariable: 90
index: 87
78IndexedVarvariable: 91
index: 87
79Literal
80Variable
81Operationoperator: 85
operand: 88
82Operationoperator: 85
operand: 89
83ExprTuple87
84ExprTuple88
85Literal
86ExprTuple89
87Variable
88IndexedVarvariable: 90
index: 93
89IndexedVarvariable: 91
index: 93
90Variable
91Variable
92ExprTuple93
93Variable