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, VecSum
from proveit.numbers import Add, Exp, Interval, Mult, e, i, one, pi, subtract, two, zero
from proveit.physics.quantum import NumKet
from proveit.physics.quantum.QPE import _phase, two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [k]
sub_expr2 = Add(t, one)
sub_expr3 = Add(k, two_pow_t)
sub_expr4 = Interval(zero, subtract(two_pow_t, one))
expr = ExprTuple(VecSum(index_or_indices = sub_expr1, summand = ScalarMult(Exp(e, Mult(two, pi, i, _phase, k)), NumKet(k, sub_expr2)), domain = sub_expr4), VecSum(index_or_indices = sub_expr1, summand = ScalarMult(Exp(e, Mult(two, pi, i, _phase, sub_expr3)), NumKet(sub_expr3, sub_expr2)), domain = sub_expr4))
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}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \lvert k \rangle_{t + 1}\right), \sum_{k=0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot \left(k + 2^{t}\right)} \cdot \lvert k + 2^{t} \rangle_{t + 1}\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: 4
operand: 6
2Operationoperator: 4
operand: 7
3ExprTuple6
4Literal
5ExprTuple7
6Lambdaparameter: 51
body: 8
7Lambdaparameter: 51
body: 10
8Conditionalvalue: 11
condition: 13
9ExprTuple51
10Conditionalvalue: 12
condition: 13
11Operationoperator: 15
operands: 14
12Operationoperator: 15
operands: 16
13Operationoperator: 17
operands: 18
14ExprTuple19, 20
15Literal
16ExprTuple21, 22
17Literal
18ExprTuple51, 23
19Operationoperator: 54
operands: 24
20Operationoperator: 27
operands: 25
21Operationoperator: 54
operands: 26
22Operationoperator: 27
operands: 28
23Operationoperator: 29
operands: 30
24ExprTuple32, 31
25ExprTuple51, 34
26ExprTuple32, 33
27Literal
28ExprTuple45, 34
29Literal
30ExprTuple35, 36
31Operationoperator: 38
operands: 37
32Literal
33Operationoperator: 38
operands: 39
34Operationoperator: 47
operands: 40
35Literal
36Operationoperator: 47
operands: 41
37ExprTuple56, 42, 43, 44, 51
38Literal
39ExprTuple56, 42, 43, 44, 45
40ExprTuple57, 53
41ExprTuple52, 46
42Literal
43Literal
44Literal
45Operationoperator: 47
operands: 48
46Operationoperator: 49
operand: 53
47Literal
48ExprTuple51, 52
49Literal
50ExprTuple53
51Variable
52Operationoperator: 54
operands: 55
53Literal
54Literal
55ExprTuple56, 57
56Literal
57Variable