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, 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(Lambda(m, Conditional(Equals(_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))), 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} \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) \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: 64
body: 3
2ExprTuple64
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 29
operands: 8
6Literal
7ExprTuple9, 10
8ExprTuple64, 11
9Operationoperator: 12
operand: 15
10Operationoperator: 57
operands: 14
11Literal
12Literal
13ExprTuple15
14ExprTuple16, 17
15Operationoperator: 18
operands: 19
16Operationoperator: 50
operands: 20
17Operationoperator: 21
operand: 23
18Literal
19ExprTuple64, 55
20ExprTuple56, 55
21Literal
22ExprTuple23
23Lambdaparameter: 63
body: 25
24ExprTuple63
25Conditionalvalue: 26
condition: 27
26Operationoperator: 57
operands: 28
27Operationoperator: 29
operands: 30
28ExprTuple31, 32
29Literal
30ExprTuple63, 33
31Operationoperator: 59
operands: 34
32Operationoperator: 59
operands: 35
33Operationoperator: 36
operands: 37
34ExprTuple39, 38
35ExprTuple39, 40
36Literal
37ExprTuple41, 42
38Operationoperator: 52
operand: 47
39Literal
40Operationoperator: 57
operands: 44
41Literal
42Operationoperator: 45
operands: 46
43ExprTuple47
44ExprTuple65, 61, 62, 48, 63
45Literal
46ExprTuple55, 49
47Operationoperator: 50
operands: 51
48Literal
49Operationoperator: 52
operand: 56
50Literal
51ExprTuple54, 55
52Literal
53ExprTuple56
54Operationoperator: 57
operands: 58
55Operationoperator: 59
operands: 60
56Literal
57Literal
58ExprTuple65, 61, 62, 63, 64
59Literal
60ExprTuple65, 66
61Literal
62Literal
63Variable
64Variable
65Literal
66Literal