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, 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, Mult(two, pi, i, _phase, k)), Exp(e, Neg(frac(Mult(two, pi, i, k, m), _two_pow_t)))), 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}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}} \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: 40
body: 2
1ExprTuple40
2Conditionalvalue: 3
condition: 4
3Operationoperator: 34
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple40, 10
8Operationoperator: 36
operands: 11
9Operationoperator: 36
operands: 12
10Operationoperator: 13
operands: 14
11ExprTuple16, 15
12ExprTuple16, 17
13Literal
14ExprTuple18, 19
15Operationoperator: 34
operands: 20
16Literal
17Operationoperator: 29
operand: 25
18Literal
19Operationoperator: 22
operands: 23
20ExprTuple42, 38, 39, 24, 40
21ExprTuple25
22Literal
23ExprTuple32, 26
24Literal
25Operationoperator: 27
operands: 28
26Operationoperator: 29
operand: 33
27Literal
28ExprTuple31, 32
29Literal
30ExprTuple33
31Operationoperator: 34
operands: 35
32Operationoperator: 36
operands: 37
33Literal
34Literal
35ExprTuple42, 38, 39, 40, 41
36Literal
37ExprTuple42, 43
38Literal
39Literal
40Variable
41Variable
42Literal
43Literal