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 Complex, 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), Complex)
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), \mathbb{C}\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: 3
operand: 5
2Literal
3Literal
4ExprTuple5
5Lambdaparameter: 45
body: 7
6ExprTuple45
7Conditionalvalue: 8
condition: 9
8Operationoperator: 39
operands: 10
9Operationoperator: 11
operands: 12
10ExprTuple13, 14
11Literal
12ExprTuple45, 15
13Operationoperator: 41
operands: 16
14Operationoperator: 41
operands: 17
15Operationoperator: 18
operands: 19
16ExprTuple21, 20
17ExprTuple21, 22
18Literal
19ExprTuple23, 24
20Operationoperator: 39
operands: 25
21Literal
22Operationoperator: 34
operand: 30
23Literal
24Operationoperator: 27
operands: 28
25ExprTuple47, 43, 44, 29, 45
26ExprTuple30
27Literal
28ExprTuple37, 31
29Literal
30Operationoperator: 32
operands: 33
31Operationoperator: 34
operand: 38
32Literal
33ExprTuple36, 37
34Literal
35ExprTuple38
36Operationoperator: 39
operands: 40
37Operationoperator: 41
operands: 42
38Literal
39Literal
40ExprTuple47, 43, 44, 45, 46
41Literal
42ExprTuple47, 48
43Literal
44Literal
45Variable
46Variable
47Literal
48Literal