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, one, pi, two
from proveit.physics.quantum.QPE import _alpha_m_mod_two_pow_t, _m_domain, _phase, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(_alpha_m_mod_two_pow_t, Mult(frac(one, _two_pow_t), Sum(index_or_indices = [k], summand = Mult(Exp(e, Neg(frac(Mult(two, pi, i, k, m), _two_pow_t))), Exp(e, Mult(two, pi, i, _phase, k))), 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(\alpha_{m ~\textup{mod}~ 2^{t}}, \frac{1}{2^{t}} \cdot \left(\sum_{k = 0}^{2^{t} - 1} \left(\mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}} \cdot \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k}\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: 3
operand: 6
2Operationoperator: 48
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Operationoperator: 9
operands: 10
7Operationoperator: 41
operands: 11
8Operationoperator: 12
operand: 14
9Literal
10ExprTuple55, 46
11ExprTuple47, 46
12Literal
13ExprTuple14
14Lambdaparameter: 54
body: 16
15ExprTuple54
16Conditionalvalue: 17
condition: 18
17Operationoperator: 48
operands: 19
18Operationoperator: 20
operands: 21
19ExprTuple22, 23
20Literal
21ExprTuple54, 24
22Operationoperator: 50
operands: 25
23Operationoperator: 50
operands: 26
24Operationoperator: 27
operands: 28
25ExprTuple30, 29
26ExprTuple30, 31
27Literal
28ExprTuple32, 33
29Operationoperator: 43
operand: 38
30Literal
31Operationoperator: 48
operands: 35
32Literal
33Operationoperator: 36
operands: 37
34ExprTuple38
35ExprTuple56, 52, 53, 39, 54
36Literal
37ExprTuple46, 40
38Operationoperator: 41
operands: 42
39Literal
40Operationoperator: 43
operand: 47
41Literal
42ExprTuple45, 46
43Literal
44ExprTuple47
45Operationoperator: 48
operands: 49
46Operationoperator: 50
operands: 51
47Literal
48Literal
49ExprTuple56, 52, 53, 54, 55
50Literal
51ExprTuple56, 57
52Literal
53Literal
54Variable
55Variable
56Literal
57Literal