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 Conditional, ExprTuple, Lambda, k, m
from proveit.logic import Equals, InSet
from proveit.numbers import Exp, Integer, Mult, Sum, e, frac, i, one, pi, subtract, 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(Lambda(m, Conditional(Equals(_alpha_m_mod_two_pow_t, Mult(frac(one, _two_pow_t), Sum(index_or_indices = [k], summand = Exp(Exp(e, Mult(two, pi, i, subtract(_phase, frac(m, _two_pow_t)))), k), domain = _m_domain))), InSet(m, Integer))))
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(m \mapsto \left\{\alpha_{m ~\textup{mod}~ 2^{t}} = \left(\frac{1}{2^{t}} \cdot \left(\sum_{k = 0}^{2^{t} - 1} (\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(\varphi - \frac{m}{2^{t}}\right)})^{k}\right)\right) \textrm{ if } m \in \mathbb{Z}\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
1Lambdaparameter: 58
body: 3
2ExprTuple58
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 28
operands: 8
6Literal
7ExprTuple9, 10
8ExprTuple58, 11
9Operationoperator: 12
operand: 15
10Operationoperator: 40
operands: 14
11Literal
12Literal
13ExprTuple15
14ExprTuple16, 17
15Operationoperator: 18
operands: 57
16Operationoperator: 56
operands: 19
17Operationoperator: 20
operand: 22
18Literal
19ExprTuple52, 59
20Literal
21ExprTuple22
22Lambdaparameter: 31
body: 24
23ExprTuple31
24Conditionalvalue: 25
condition: 26
25Operationoperator: 60
operands: 27
26Operationoperator: 28
operands: 29
27ExprTuple30, 31
28Literal
29ExprTuple31, 32
30Operationoperator: 60
operands: 33
31Variable
32Operationoperator: 34
operands: 35
33ExprTuple36, 37
34Literal
35ExprTuple38, 39
36Literal
37Operationoperator: 40
operands: 41
38Literal
39Operationoperator: 47
operands: 42
40Literal
41ExprTuple62, 43, 44, 45
42ExprTuple59, 46
43Literal
44Literal
45Operationoperator: 47
operands: 48
46Operationoperator: 53
operand: 52
47Literal
48ExprTuple50, 51
49ExprTuple52
50Literal
51Operationoperator: 53
operand: 55
52Literal
53Literal
54ExprTuple55
55Operationoperator: 56
operands: 57
56Literal
57ExprTuple58, 59
58Variable
59Operationoperator: 60
operands: 61
60Literal
61ExprTuple62, 63
62Literal
63Literal