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, m
from proveit.numbers import Exp, Mult, Neg, Sum, e, frac, i, pi, two
from proveit.physics.quantum.QPE import _m_domain, _phase, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Sum(index_or_indices = [k], summand = Mult(Exp(e, Mult(two, pi, i, _phase, k)), Exp(e, Neg(frac(Mult(two, pi, i, k, m), _two_pow_t)))), domain = _m_domain))
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 \mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}}\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
1Operationoperator: 2
operand: 4
2Literal
3ExprTuple4
4Lambdaparameter: 44
body: 6
5ExprTuple44
6Conditionalvalue: 7
condition: 8
7Operationoperator: 38
operands: 9
8Operationoperator: 10
operands: 11
9ExprTuple12, 13
10Literal
11ExprTuple44, 14
12Operationoperator: 40
operands: 15
13Operationoperator: 40
operands: 16
14Operationoperator: 17
operands: 18
15ExprTuple20, 19
16ExprTuple20, 21
17Literal
18ExprTuple22, 23
19Operationoperator: 38
operands: 24
20Literal
21Operationoperator: 33
operand: 29
22Literal
23Operationoperator: 26
operands: 27
24ExprTuple46, 42, 43, 28, 44
25ExprTuple29
26Literal
27ExprTuple36, 30
28Literal
29Operationoperator: 31
operands: 32
30Operationoperator: 33
operand: 37
31Literal
32ExprTuple35, 36
33Literal
34ExprTuple37
35Operationoperator: 38
operands: 39
36Operationoperator: 40
operands: 41
37Literal
38Literal
39ExprTuple46, 42, 43, 44, 45
40Literal
41ExprTuple46, 47
42Literal
43Literal
44Variable
45Variable
46Literal
47Literal