logo

Expression of type Lambda

from the theory of proveit.physics.quantum.QFT

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, l, n
from proveit.logic import And, Equals, InSet
from proveit.numbers import Exp, Interval, Mult, Neg, e, frac, i, one, pi, subtract, two, zero
from proveit.physics.quantum import NumBra, NumKet, Qmult
from proveit.physics.quantum.QFT import InverseFourierTransform
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Exp(two, n)
sub_expr2 = Interval(zero, subtract(sub_expr1, one))
expr = Lambda([k, l], Conditional(Equals(Qmult(NumBra(l, n), InverseFourierTransform(n), NumKet(k, n)), Mult(frac(one, Exp(two, frac(n, two))), Exp(e, frac(Neg(Mult(two, pi, i, k, l)), sub_expr1)))), And(InSet(k, sub_expr2), InSet(l, sub_expr2))))
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())
\left(k, l\right) \mapsto \left\{\left({_{n}}\langle l \rvert \thinspace {\mathrm {FT}}^{\dag}_{n} \thinspace \lvert k \rangle_{n}\right) = \left(\frac{1}{2^{\frac{n}{2}}} \cdot \mathsf{e}^{\frac{-\left(2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot l\right)}{2^{n}}}\right) \textrm{ if } k \in \{0~\ldotp \ldotp~2^{n} - 1\} ,  l \in \{0~\ldotp \ldotp~2^{n} - 1\}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple63, 64
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12
9Operationoperator: 13
operands: 14
10Operationoperator: 58
operands: 15
11Operationoperator: 17
operands: 16
12Operationoperator: 17
operands: 18
13Literal
14ExprTuple19, 20, 21
15ExprTuple22, 23
16ExprTuple63, 24
17Literal
18ExprTuple64, 24
19Operationoperator: 25
operands: 26
20Operationoperator: 27
operand: 56
21Operationoperator: 29
operands: 30
22Operationoperator: 48
operands: 31
23Operationoperator: 51
operands: 32
24Operationoperator: 33
operands: 34
25Literal
26ExprTuple64, 56
27Literal
28ExprTuple56
29Literal
30ExprTuple63, 56
31ExprTuple57, 35
32ExprTuple36, 37
33Literal
34ExprTuple38, 39
35Operationoperator: 51
operands: 40
36Literal
37Operationoperator: 48
operands: 41
38Literal
39Operationoperator: 42
operands: 43
40ExprTuple60, 44
41ExprTuple45, 46
42Literal
43ExprTuple46, 47
44Operationoperator: 48
operands: 49
45Operationoperator: 53
operand: 55
46Operationoperator: 51
operands: 52
47Operationoperator: 53
operand: 57
48Literal
49ExprTuple56, 60
50ExprTuple55
51Literal
52ExprTuple60, 56
53Literal
54ExprTuple57
55Operationoperator: 58
operands: 59
56Variable
57Literal
58Literal
59ExprTuple60, 61, 62, 63, 64
60Literal
61Literal
62Literal
63Variable
64Variable