logo

Expression of type ExprTuple

from the theory of proveit.physics.quantum.QPE

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 ExprTuple, Function, Variable, k, t
from proveit.linear_algebra import ScalarMult, TensorProd, VecAdd, VecSum
from proveit.numbers import Add, Exp, Interval, Mult, e, i, one, pi, subtract, two, zero
from proveit.physics.quantum import NumKet, ket1
from proveit.physics.quantum.QPE import _phase, two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [k]
sub_expr2 = Exp(e, Mult(two, pi, i, _phase, k))
sub_expr3 = Interval(zero, subtract(two_pow_t, one))
expr = ExprTuple(VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr2, NumKet(k, Add(t, one))), domain = Interval(zero, subtract(Mult(two, two_pow_t), one))), VecAdd(VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr2, Function(Variable("_a", latex_format = r"{_{-}a}"), sub_expr1)), domain = sub_expr3), ScalarMult(Exp(e, Mult(two, pi, i, _phase, two_pow_t)), TensorProd(ket1, VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr2, NumKet(k, t)), domain = sub_expr3)))))
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(\sum_{k=0}^{\left(2 \cdot 2^{t}\right) - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \lvert k \rangle_{t + 1}\right), \left(\sum_{k=0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot {_{-}a}\left(k\right)\right)\right) + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot 2^{t}} \cdot \left(\lvert 1 \rangle {\otimes} \left(\sum_{k=0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \lvert k \rangle_{t}\right)\right)\right)\right)\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1Operationoperator: 34
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple7, 8
6Lambdaparameter: 72
body: 9
7Operationoperator: 34
operand: 14
8Operationoperator: 49
operands: 11
9Conditionalvalue: 12
condition: 13
10ExprTuple14
11ExprTuple15, 16
12Operationoperator: 49
operands: 17
13Operationoperator: 51
operands: 18
14Lambdaparameter: 72
body: 19
15Operationoperator: 75
operands: 20
16Operationoperator: 21
operands: 22
17ExprTuple53, 23
18ExprTuple72, 24
19Conditionalvalue: 25
condition: 47
20ExprTuple61, 26
21Literal
22ExprTuple27, 28
23Operationoperator: 57
operands: 29
24Operationoperator: 59
operands: 30
25Operationoperator: 49
operands: 31
26Operationoperator: 65
operands: 32
27Operationoperator: 33
operand: 81
28Operationoperator: 34
operand: 39
29ExprTuple72, 36
30ExprTuple63, 37
31ExprTuple53, 38
32ExprTuple79, 69, 70, 71, 73
33Literal
34Literal
35ExprTuple39
36Operationoperator: 67
operands: 40
37Operationoperator: 67
operands: 41
38Operationoperator: 42
operand: 72
39Lambdaparameter: 72
body: 44
40ExprTuple80, 81
41ExprTuple45, 74
42Variable
43ExprTuple72
44Conditionalvalue: 46
condition: 47
45Operationoperator: 65
operands: 48
46Operationoperator: 49
operands: 50
47Operationoperator: 51
operands: 52
48ExprTuple79, 73
49Literal
50ExprTuple53, 54
51Literal
52ExprTuple72, 55
53Operationoperator: 75
operands: 56
54Operationoperator: 57
operands: 58
55Operationoperator: 59
operands: 60
56ExprTuple61, 62
57Literal
58ExprTuple72, 80
59Literal
60ExprTuple63, 64
61Literal
62Operationoperator: 65
operands: 66
63Literal
64Operationoperator: 67
operands: 68
65Literal
66ExprTuple79, 69, 70, 71, 72
67Literal
68ExprTuple73, 74
69Literal
70Literal
71Literal
72Variable
73Operationoperator: 75
operands: 76
74Operationoperator: 77
operand: 81
75Literal
76ExprTuple79, 80
77Literal
78ExprTuple81
79Literal
80Variable
81Literal