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, Variable, k, t
from proveit.linear_algebra import ScalarMult, VecAdd, 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 = ScalarMult(Exp(e, Mult(two, pi, i, _phase, k)), NumKet(k, Add(t, one)))
expr = ExprTuple(VecSum(index_or_indices = sub_expr1, summand = sub_expr2, domain = Interval(zero, subtract(Mult(two, two_pow_t), one))), VecAdd(VecSum(index_or_indices = sub_expr1, summand = sub_expr2, domain = Interval(zero, subtract(two_pow_t, one))), Variable("_a", latex_format = r"{_{-}a}")))
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 \lvert k \rangle_{t + 1}\right)\right) + {_{-}a}\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: 10
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple7, 8
6Lambdaparameter: 50
body: 9
7Operationoperator: 10
operand: 13
8Variable
9Conditionalvalue: 18
condition: 12
10Literal
11ExprTuple13
12Operationoperator: 23
operands: 14
13Lambdaparameter: 50
body: 16
14ExprTuple50, 17
15ExprTuple50
16Conditionalvalue: 18
condition: 19
17Operationoperator: 33
operands: 20
18Operationoperator: 21
operands: 22
19Operationoperator: 23
operands: 24
20ExprTuple39, 25
21Literal
22ExprTuple26, 27
23Literal
24ExprTuple50, 28
25Operationoperator: 45
operands: 29
26Operationoperator: 53
operands: 30
27Operationoperator: 31
operands: 32
28Operationoperator: 33
operands: 34
29ExprTuple35, 52
30ExprTuple36, 37
31Literal
32ExprTuple50, 38
33Literal
34ExprTuple39, 40
35Operationoperator: 42
operands: 41
36Literal
37Operationoperator: 42
operands: 43
38Operationoperator: 45
operands: 44
39Literal
40Operationoperator: 45
operands: 46
41ExprTuple57, 51
42Literal
43ExprTuple57, 47, 48, 49, 50
44ExprTuple58, 59
45Literal
46ExprTuple51, 52
47Literal
48Literal
49Literal
50Variable
51Operationoperator: 53
operands: 54
52Operationoperator: 55
operand: 59
53Literal
54ExprTuple57, 58
55Literal
56ExprTuple59
57Literal
58Variable
59Literal