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