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, Variable, t
from proveit.linear_algebra import ScalarMult, VecAdd
from proveit.logic import InSet
from proveit.numbers import Add, Exp, Interval, Mult, Neg, e, frac, i, one, pi, sqrt, two, zero
from proveit.physics.quantum import QubitSpace, ket0, ket1
from proveit.physics.quantum.QPE import _phase
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda(sub_expr1, Conditional(InSet(ScalarMult(frac(one, sqrt(two)), VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, Exp(two, Neg(sub_expr1)), _phase)), ket1))), QubitSpace), InSet(sub_expr1, Interval(Add(Neg(t), one), zero))))
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())
{_{-}a} \mapsto \left\{\left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{-{_{-}a}} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)\right) \in \mathbb{C}^{2} \textrm{ if } {_{-}a} \in \{-t + 1~\ldotp \ldotp~0\}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 58
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 5
operands: 4
3Operationoperator: 5
operands: 6
4ExprTuple7, 8
5Literal
6ExprTuple58, 9
7Operationoperator: 30
operands: 10
8Operationoperator: 11
operands: 12
9Operationoperator: 13
operands: 14
10ExprTuple15, 16
11Literal
12ExprTuple17, 54
13Literal
14ExprTuple18, 34
15Operationoperator: 38
operands: 19
16Operationoperator: 20
operands: 21
17Literal
18Operationoperator: 22
operands: 23
19ExprTuple45, 24
20Literal
21ExprTuple25, 26
22Literal
23ExprTuple27, 45
24Operationoperator: 52
operands: 28
25Operationoperator: 41
operand: 34
26Operationoperator: 30
operands: 31
27Operationoperator: 56
operand: 37
28ExprTuple54, 33
29ExprTuple34
30Literal
31ExprTuple35, 36
32ExprTuple37
33Operationoperator: 38
operands: 39
34Literal
35Operationoperator: 52
operands: 40
36Operationoperator: 41
operand: 45
37Variable
38Literal
39ExprTuple45, 54
40ExprTuple43, 44
41Literal
42ExprTuple45
43Literal
44Operationoperator: 46
operands: 47
45Literal
46Literal
47ExprTuple54, 48, 49, 50, 51
48Literal
49Literal
50Operationoperator: 52
operands: 53
51Literal
52Literal
53ExprTuple54, 55
54Literal
55Operationoperator: 56
operand: 58
56Literal
57ExprTuple58
58Variable