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, j, n
from proveit.core_expr_types import v_1_to_n, v_i, v_j
from proveit.linear_algebra import Adj, MatrixSpace, OrthoNormBases, Unitary
from proveit.logic import CartExp, Equals, Forall, Implies, InSet, Set
from proveit.numbers import Complex, Interval, KroneckerDelta, one
from proveit.physics.quantum import Bra, Ket, Qmult
from proveit.physics.quantum.algebra import v_1_to_n_kets
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(U, Conditional(Forall(instance_param_or_params = [v_1_to_n], instance_expr = Implies(Forall(instance_param_or_params = [i, j], instance_expr = Equals(Qmult(Bra(v_i), Adj(U), U, Ket(v_j)), KroneckerDelta(i, j)), domain = Interval(one, n)), InSet(U, Unitary(n))), condition = InSet(Set(v_1_to_n_kets), OrthoNormBases(CartExp(Complex, n)))).with_wrapping(), InSet(U, MatrixSpace(field = Complex, rows = n, columns = 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}\forall_{v_{1}, v_{2}, \ldots, v_{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[\forall_{i, j \in \{1~\ldotp \ldotp~n\}}~\left(\left(\langle v_{i} \rvert \thinspace U^{\dagger} \thinspace U \thinspace \lvert v_{j} \rangle\right) = \delta_{i, j}\right)\right] \Rightarrow \left(U \in \textrm{U}\left(n\right)\right)\right)\end{array} \textrm{ if } U \in \mathbb{C}^{n \times 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: 78
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 24
operand: 7
4Operationoperator: 60
operands: 6
5ExprTuple7
6ExprTuple78, 8
7Lambdaparameters: 9
body: 10
8Operationoperator: 11
operands: 12
9ExprTuple13
10Conditionalvalue: 14
condition: 15
11Literal
12NamedExprsfield: 44
rows: 81
columns: 81
13ExprRangelambda_map: 16
start_index: 80
end_index: 81
14Operationoperator: 17
operands: 18
15Operationoperator: 60
operands: 19
16Lambdaparameter: 82
body: 67
17Literal
18ExprTuple20, 21
19ExprTuple22, 23
20Operationoperator: 24
operand: 30
21Operationoperator: 60
operands: 26
22Operationoperator: 37
operand: 32
23Operationoperator: 28
operand: 33
24Literal
25ExprTuple30
26ExprTuple78, 31
27ExprTuple32
28Literal
29ExprTuple33
30Lambdaparameters: 58
body: 34
31Operationoperator: 35
operand: 81
32Operationoperator: 37
operands: 38
33Operationoperator: 39
operands: 40
34Conditionalvalue: 41
condition: 42
35Literal
36ExprTuple81
37Literal
38ExprTuple43
39Literal
40ExprTuple44, 81
41Operationoperator: 45
operands: 46
42Operationoperator: 47
operands: 48
43ExprRangelambda_map: 49
start_index: 80
end_index: 81
44Literal
45Literal
46ExprTuple50, 51
47Literal
48ExprTuple52, 53
49Lambdaparameter: 82
body: 54
50Operationoperator: 55
operands: 56
51Operationoperator: 57
operands: 58
52Operationoperator: 60
operands: 59
53Operationoperator: 60
operands: 61
54Operationoperator: 72
operand: 67
55Literal
56ExprTuple63, 64, 78, 65
57Literal
58ExprTuple86, 87
59ExprTuple86, 66
60Literal
61ExprTuple87, 66
62ExprTuple67
63Operationoperator: 68
operand: 77
64Operationoperator: 70
operand: 78
65Operationoperator: 72
operand: 79
66Operationoperator: 74
operands: 75
67IndexedVarvariable: 84
index: 82
68Literal
69ExprTuple77
70Literal
71ExprTuple78
72Literal
73ExprTuple79
74Literal
75ExprTuple80, 81
76ExprTuple82
77IndexedVarvariable: 84
index: 86
78Variable
79IndexedVarvariable: 84
index: 87
80Literal
81Variable
82Variable
83ExprTuple86
84Variable
85ExprTuple87
86Variable
87Variable