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