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, Mult, Neg, Sum, e, frac, i, one, pi, two
from proveit.physics.quantum.QPE import _alpha_m, _m_domain, _phase, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(m, Conditional(Equals(_alpha_m, 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, _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(m \mapsto \left\{\alpha_{m} = \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 \{0~\ldotp \ldotp~2^{t} - 1\}\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: 59
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 24
operands: 7
5Literal
6ExprTuple8, 9
7ExprTuple59, 28
8Operationoperator: 10
operand: 59
9Operationoperator: 52
operands: 12
10Literal
11ExprTuple59
12ExprTuple13, 14
13Operationoperator: 45
operands: 15
14Operationoperator: 16
operand: 18
15ExprTuple51, 50
16Literal
17ExprTuple18
18Lambdaparameter: 58
body: 20
19ExprTuple58
20Conditionalvalue: 21
condition: 22
21Operationoperator: 52
operands: 23
22Operationoperator: 24
operands: 25
23ExprTuple26, 27
24Literal
25ExprTuple58, 28
26Operationoperator: 54
operands: 29
27Operationoperator: 54
operands: 30
28Operationoperator: 31
operands: 32
29ExprTuple34, 33
30ExprTuple34, 35
31Literal
32ExprTuple36, 37
33Operationoperator: 47
operand: 42
34Literal
35Operationoperator: 52
operands: 39
36Literal
37Operationoperator: 40
operands: 41
38ExprTuple42
39ExprTuple60, 56, 57, 43, 58
40Literal
41ExprTuple50, 44
42Operationoperator: 45
operands: 46
43Literal
44Operationoperator: 47
operand: 51
45Literal
46ExprTuple49, 50
47Literal
48ExprTuple51
49Operationoperator: 52
operands: 53
50Operationoperator: 54
operands: 55
51Literal
52Literal
53ExprTuple60, 56, 57, 58, 59
54Literal
55ExprTuple60, 61
56Literal
57Literal
58Variable
59Variable
60Literal
61Literal