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 A, B, Conditional, ExprTuple, Lambda, i, n
from proveit.core_expr_types import a_1_to_n, a_i, b_1_to_n, b_i, v_1_to_n, v_i
from proveit.linear_algebra import OrthoNormBases, ScalarMult, VecSum
from proveit.logic import And, CartExp, Equals, Exists, InSet, Set
from proveit.numbers import Complex, Interval, one
from proveit.physics.quantum import Bra, Ket, Qmult
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [i]
sub_expr2 = Interval(one, n)
sub_expr3 = Qmult(Ket(v_i), Bra(v_i))
expr = ExprTuple(Lambda([v_1_to_n], Conditional(Exists(instance_param_or_params = [a_1_to_n, b_1_to_n], instance_expr = And(Equals(A, VecSum(index_or_indices = sub_expr1, summand = ScalarMult(a_i, sub_expr3), domain = sub_expr2)), Equals(B, VecSum(index_or_indices = sub_expr1, summand = ScalarMult(b_i, sub_expr3), domain = sub_expr2))).with_wrapping_at(2), domain = Complex).with_wrapping(), InSet(Set(v_1_to_n), OrthoNormBases(CartExp(Complex, 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(\left(v_{1}, v_{2}, \ldots, v_{n}\right) \mapsto \left\{\begin{array}{l}\exists_{a_{1}, a_{2}, \ldots, a_{n}, b_{1}, b_{2}, \ldots, b_{n} \in \mathbb{C}}~\\
\left(\begin{array}{c} \left(A = \left(\sum_{i=1}^{n} \left(a_{i} \cdot \left(\lvert v_{i} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right)\right) \land  \\ \left(B = \left(\sum_{i=1}^{n} \left(b_{i} \cdot \left(\lvert v_{i} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right)\right) \end{array}\right)\end{array} \textrm{ if } \left\{v_{1}, v_{2}, \ldots, v_{n}\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: 14
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 67
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameters: 11
body: 12
9Operationoperator: 13
operands: 14
10Operationoperator: 15
operand: 22
11ExprTuple17, 18
12Conditionalvalue: 19
condition: 20
13Literal
14ExprTuple21
15Literal
16ExprTuple22
17ExprRangelambda_map: 23
start_index: 81
end_index: 82
18ExprRangelambda_map: 24
start_index: 81
end_index: 82
19Operationoperator: 26
operands: 25
20Operationoperator: 26
operands: 27
21ExprRangelambda_map: 28
start_index: 81
end_index: 82
22Operationoperator: 29
operands: 30
23Lambdaparameter: 63
body: 54
24Lambdaparameter: 63
body: 55
25ExprTuple31, 32
26Literal
27ExprTuple33, 34
28Lambdaparameter: 63
body: 35
29Literal
30ExprTuple56, 82
31Operationoperator: 37
operands: 36
32Operationoperator: 37
operands: 38
33ExprRangelambda_map: 39
start_index: 81
end_index: 82
34ExprRangelambda_map: 40
start_index: 81
end_index: 82
35IndexedVarvariable: 87
index: 63
36ExprTuple41, 42
37Literal
38ExprTuple43, 44
39Lambdaparameter: 63
body: 45
40Lambdaparameter: 63
body: 46
41Variable
42Operationoperator: 48
operand: 52
43Variable
44Operationoperator: 48
operand: 53
45Operationoperator: 67
operands: 50
46Operationoperator: 67
operands: 51
47ExprTuple52
48Literal
49ExprTuple53
50ExprTuple54, 56
51ExprTuple55, 56
52Lambdaparameter: 89
body: 57
53Lambdaparameter: 89
body: 58
54IndexedVarvariable: 73
index: 63
55IndexedVarvariable: 74
index: 63
56Literal
57Conditionalvalue: 60
condition: 62
58Conditionalvalue: 61
condition: 62
59ExprTuple63
60Operationoperator: 65
operands: 64
61Operationoperator: 65
operands: 66
62Operationoperator: 67
operands: 68
63Variable
64ExprTuple69, 71
65Literal
66ExprTuple70, 71
67Literal
68ExprTuple89, 72
69IndexedVarvariable: 73
index: 89
70IndexedVarvariable: 74
index: 89
71Operationoperator: 75
operands: 76
72Operationoperator: 77
operands: 78
73Variable
74Variable
75Literal
76ExprTuple79, 80
77Literal
78ExprTuple81, 82
79Operationoperator: 83
operand: 86
80Operationoperator: 84
operand: 86
81Literal
82Variable
83Literal
84Literal
85ExprTuple86
86IndexedVarvariable: 87
index: 89
87Variable
88ExprTuple89
89Variable