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, 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, ket0, 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 = VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr2, NumKet(k, t)), domain = 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(TensorProd(ket0, sub_expr3), ScalarMult(Exp(e, Mult(two, pi, i, _phase, two_pow_t)), TensorProd(ket1, 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(\lvert 0 \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) + \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: 32
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple7, 8
6Lambdaparameter: 68
body: 9
7Operationoperator: 21
operands: 10
8Operationoperator: 45
operands: 11
9Conditionalvalue: 12
condition: 13
10ExprTuple14, 27
11ExprTuple15, 16
12Operationoperator: 45
operands: 17
13Operationoperator: 47
operands: 18
14Operationoperator: 31
operand: 59
15Operationoperator: 71
operands: 20
16Operationoperator: 21
operands: 22
17ExprTuple49, 23
18ExprTuple68, 24
19ExprTuple59
20ExprTuple57, 25
21Literal
22ExprTuple26, 27
23Operationoperator: 53
operands: 28
24Operationoperator: 55
operands: 29
25Operationoperator: 61
operands: 30
26Operationoperator: 31
operand: 77
27Operationoperator: 32
operand: 36
28ExprTuple68, 34
29ExprTuple59, 35
30ExprTuple75, 65, 66, 67, 69
31Literal
32Literal
33ExprTuple36
34Operationoperator: 63
operands: 37
35Operationoperator: 63
operands: 38
36Lambdaparameter: 68
body: 40
37ExprTuple76, 77
38ExprTuple41, 70
39ExprTuple68
40Conditionalvalue: 42
condition: 43
41Operationoperator: 61
operands: 44
42Operationoperator: 45
operands: 46
43Operationoperator: 47
operands: 48
44ExprTuple75, 69
45Literal
46ExprTuple49, 50
47Literal
48ExprTuple68, 51
49Operationoperator: 71
operands: 52
50Operationoperator: 53
operands: 54
51Operationoperator: 55
operands: 56
52ExprTuple57, 58
53Literal
54ExprTuple68, 76
55Literal
56ExprTuple59, 60
57Literal
58Operationoperator: 61
operands: 62
59Literal
60Operationoperator: 63
operands: 64
61Literal
62ExprTuple75, 65, 66, 67, 68
63Literal
64ExprTuple69, 70
65Literal
66Literal
67Literal
68Variable
69Operationoperator: 71
operands: 72
70Operationoperator: 73
operand: 77
71Literal
72ExprTuple75, 76
73Literal
74ExprTuple77
75Literal
76Variable
77Literal