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 InSet
from proveit.numbers import Exp, Mod, Mult, Neg, e, frac, i, pi, two
from proveit.physics.quantum.QPE import _m_domain, _phase, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Lambda(k, Conditional(Mult(Exp(e, Neg(frac(Mult(two, pi, i, k, Mod(m, _two_pow_t)), _two_pow_t))), Exp(e, Mult(two, pi, i, _phase, k))), InSet(k, _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())
k \mapsto \left\{\mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot \left(m ~\textup{mod}~ 2^{t}\right)}{2^{t}}} \cdot \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \textrm{ if } k \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: 37
body: 2
1ExprTuple37
2Conditionalvalue: 3
condition: 4
3Operationoperator: 33
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple37, 10
8Operationoperator: 43
operands: 11
9Operationoperator: 43
operands: 12
10Operationoperator: 13
operands: 14
11ExprTuple16, 15
12ExprTuple16, 17
13Literal
14ExprTuple18, 19
15Operationoperator: 29
operand: 24
16Literal
17Operationoperator: 33
operands: 21
18Literal
19Operationoperator: 22
operands: 23
20ExprTuple24
21ExprTuple45, 35, 36, 25, 37
22Literal
23ExprTuple42, 26
24Operationoperator: 27
operands: 28
25Literal
26Operationoperator: 29
operand: 32
27Literal
28ExprTuple31, 42
29Literal
30ExprTuple32
31Operationoperator: 33
operands: 34
32Literal
33Literal
34ExprTuple45, 35, 36, 37, 38
35Literal
36Literal
37Variable
38Operationoperator: 39
operands: 40
39Literal
40ExprTuple41, 42
41Variable
42Operationoperator: 43
operands: 44
43Literal
44ExprTuple45, 46
45Literal
46Literal