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, ExprRange, Lambda, Variable, t
from proveit.linear_algebra import ScalarMult, TensorProd, VecAdd
from proveit.logic import Equals, InSet
from proveit.numbers import Add, Exp, Mult, NaturalPos, Neg, e, frac, i, one, pi, sqrt, two, zero
from proveit.physics.quantum import ket0, ket1
from proveit.physics.quantum.QPE import _phase, _psi_t_ket
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda(t, Conditional(Equals(_psi_t_ket, TensorProd(ExprRange(sub_expr1, ScalarMult(frac(one, sqrt(two)), VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, Exp(two, Neg(sub_expr1)), _phase)), ket1))), Add(Neg(t), one), zero).with_decreasing_order())), InSet(t, NaturalPos)))
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())
t \mapsto \left\{\lvert \psi_{t} \rangle = \left(\left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{t - 1} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)\right) {\otimes}  \left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{t - 2} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)\right) {\otimes}  \ldots {\otimes}  \left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{0} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)\right)\right) \textrm{ if } t \in \mathbb{N}^+\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 28
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operands: 5
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8, 9
6Literal
7ExprTuple28, 10
8Operationoperator: 11
operand: 28
9Operationoperator: 12
operands: 13
10Literal
11Literal
12Literal
13ExprTuple14
14ExprRangelambda_map: 15
start_index: 16
end_index: 37
15Lambdaparameter: 60
body: 17
16Operationoperator: 18
operands: 19
17Operationoperator: 34
operands: 20
18Literal
19ExprTuple21, 47
20ExprTuple22, 23
21Operationoperator: 58
operand: 28
22Operationoperator: 40
operands: 25
23Operationoperator: 26
operands: 27
24ExprTuple28
25ExprTuple47, 29
26Literal
27ExprTuple30, 31
28Variable
29Operationoperator: 54
operands: 32
30Operationoperator: 43
operand: 37
31Operationoperator: 34
operands: 35
32ExprTuple56, 36
33ExprTuple37
34Literal
35ExprTuple38, 39
36Operationoperator: 40
operands: 41
37Literal
38Operationoperator: 54
operands: 42
39Operationoperator: 43
operand: 47
40Literal
41ExprTuple47, 56
42ExprTuple45, 46
43Literal
44ExprTuple47
45Literal
46Operationoperator: 48
operands: 49
47Literal
48Literal
49ExprTuple56, 50, 51, 52, 53
50Literal
51Literal
52Operationoperator: 54
operands: 55
53Literal
54Literal
55ExprTuple56, 57
56Literal
57Operationoperator: 58
operand: 60
58Literal
59ExprTuple60
60Variable