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, NaturalPos, 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(n, Conditional(Forall(instance_param_or_params = [U], instance_expr = 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(), domain = MatrixSpace(field = Complex, rows = n, columns = 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 \mathbb{C}^{n \times n}}~\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}\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: 88
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 31
operand: 7
4Operationoperator: 67
operands: 6
5ExprTuple7
6ExprTuple88, 8
7Lambdaparameter: 85
body: 9
8Literal
9Conditionalvalue: 10
condition: 11
10Operationoperator: 31
operand: 14
11Operationoperator: 67
operands: 13
12ExprTuple14
13ExprTuple85, 15
14Lambdaparameters: 16
body: 17
15Operationoperator: 18
operands: 19
16ExprTuple20
17Conditionalvalue: 21
condition: 22
18Literal
19NamedExprsfield: 51
rows: 88
columns: 88
20ExprRangelambda_map: 23
start_index: 87
end_index: 88
21Operationoperator: 24
operands: 25
22Operationoperator: 67
operands: 26
23Lambdaparameter: 89
body: 74
24Literal
25ExprTuple27, 28
26ExprTuple29, 30
27Operationoperator: 31
operand: 37
28Operationoperator: 67
operands: 33
29Operationoperator: 44
operand: 39
30Operationoperator: 35
operand: 40
31Literal
32ExprTuple37
33ExprTuple85, 38
34ExprTuple39
35Literal
36ExprTuple40
37Lambdaparameters: 65
body: 41
38Operationoperator: 42
operand: 88
39Operationoperator: 44
operands: 45
40Operationoperator: 46
operands: 47
41Conditionalvalue: 48
condition: 49
42Literal
43ExprTuple88
44Literal
45ExprTuple50
46Literal
47ExprTuple51, 88
48Operationoperator: 52
operands: 53
49Operationoperator: 54
operands: 55
50ExprRangelambda_map: 56
start_index: 87
end_index: 88
51Literal
52Literal
53ExprTuple57, 58
54Literal
55ExprTuple59, 60
56Lambdaparameter: 89
body: 61
57Operationoperator: 62
operands: 63
58Operationoperator: 64
operands: 65
59Operationoperator: 67
operands: 66
60Operationoperator: 67
operands: 68
61Operationoperator: 79
operand: 74
62Literal
63ExprTuple70, 71, 85, 72
64Literal
65ExprTuple93, 94
66ExprTuple93, 73
67Literal
68ExprTuple94, 73
69ExprTuple74
70Operationoperator: 75
operand: 84
71Operationoperator: 77
operand: 85
72Operationoperator: 79
operand: 86
73Operationoperator: 81
operands: 82
74IndexedVarvariable: 91
index: 89
75Literal
76ExprTuple84
77Literal
78ExprTuple85
79Literal
80ExprTuple86
81Literal
82ExprTuple87, 88
83ExprTuple89
84IndexedVarvariable: 91
index: 93
85Variable
86IndexedVarvariable: 91
index: 94
87Literal
88Variable
89Variable
90ExprTuple93
91Variable
92ExprTuple94
93Variable
94Variable