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, t
from proveit.linear_algebra import ScalarMult, TensorProd
from proveit.logic import CartExp, InSet
from proveit.numbers import Complex, Exp, Interval, Mult, e, i, one, pi, subtract, two, zero
from proveit.physics.quantum import NumKet, QubitSpace, ket1
from proveit.physics.quantum.QPE import _phase, two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Lambda(k, Conditional(InSet(ScalarMult(Exp(e, Mult(two, pi, i, _phase, k)), TensorProd(ket1, NumKet(k, t))), TensorProd(QubitSpace, CartExp(Complex, two_pow_t))), InSet(k, Interval(zero, subtract(two_pow_t, one)))))
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\{\left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \left(\lvert 1 \rangle {\otimes} \lvert k \rangle_{t}\right)\right) \in \left(\mathbb{C}^{2} {\otimes} \mathbb{C}^{2^{t}}\right) \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: 49
body: 2
1ExprTuple49
2Conditionalvalue: 3
condition: 4
3Operationoperator: 6
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple49, 10
8Operationoperator: 11
operands: 12
9Operationoperator: 23
operands: 13
10Operationoperator: 14
operands: 15
11Literal
12ExprTuple16, 17
13ExprTuple18, 19
14Literal
15ExprTuple20, 21
16Operationoperator: 42
operands: 22
17Operationoperator: 23
operands: 24
18Operationoperator: 26
operands: 25
19Operationoperator: 26
operands: 27
20Literal
21Operationoperator: 28
operands: 29
22ExprTuple30, 31
23Literal
24ExprTuple32, 33
25ExprTuple34, 50
26Literal
27ExprTuple34, 35
28Literal
29ExprTuple35, 36
30Literal
31Operationoperator: 37
operands: 38
32Operationoperator: 39
operand: 52
33Operationoperator: 40
operands: 41
34Literal
35Operationoperator: 42
operands: 43
36Operationoperator: 44
operand: 52
37Literal
38ExprTuple50, 46, 47, 48, 49
39Literal
40Literal
41ExprTuple49, 51
42Literal
43ExprTuple50, 51
44Literal
45ExprTuple52
46Literal
47Literal
48Literal
49Variable
50Literal
51Variable
52Literal