logo

Expression of type Lambda

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, 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 = 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())
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..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 63
body: 2
1ExprTuple63
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 28
operands: 7
5Literal
6ExprTuple8, 9
7ExprTuple63, 10
8Operationoperator: 11
operand: 14
9Operationoperator: 56
operands: 13
10Literal
11Literal
12ExprTuple14
13ExprTuple15, 16
14Operationoperator: 17
operands: 18
15Operationoperator: 49
operands: 19
16Operationoperator: 20
operand: 22
17Literal
18ExprTuple63, 54
19ExprTuple55, 54
20Literal
21ExprTuple22
22Lambdaparameter: 62
body: 24
23ExprTuple62
24Conditionalvalue: 25
condition: 26
25Operationoperator: 56
operands: 27
26Operationoperator: 28
operands: 29
27ExprTuple30, 31
28Literal
29ExprTuple62, 32
30Operationoperator: 58
operands: 33
31Operationoperator: 58
operands: 34
32Operationoperator: 35
operands: 36
33ExprTuple38, 37
34ExprTuple38, 39
35Literal
36ExprTuple40, 41
37Operationoperator: 51
operand: 46
38Literal
39Operationoperator: 56
operands: 43
40Literal
41Operationoperator: 44
operands: 45
42ExprTuple46
43ExprTuple64, 60, 61, 47, 62
44Literal
45ExprTuple54, 48
46Operationoperator: 49
operands: 50
47Literal
48Operationoperator: 51
operand: 55
49Literal
50ExprTuple53, 54
51Literal
52ExprTuple55
53Operationoperator: 56
operands: 57
54Operationoperator: 58
operands: 59
55Literal
56Literal
57ExprTuple64, 60, 61, 62, 63
58Literal
59ExprTuple64, 65
60Literal
61Literal
62Variable
63Variable
64Literal
65Literal