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, U, Variable, VertExprArray, s, t
from proveit.linear_algebra import Unitary
from proveit.logic import InSet
from proveit.numbers import Add, Exp, Interval, one, two
from proveit.physics.quantum import I
from proveit.physics.quantum.QFT import InverseFourierTransform
from proveit.physics.quantum.QPE import QPE, QPE1
from proveit.physics.quantum.circuits import Gate, MultiQubitElem, Qcircuit, QcircuitEquiv
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = Add(t, s)
sub_expr3 = Add(t, one)
sub_expr4 = Interval(one, sub_expr2)
sub_expr5 = MultiQubitElem(element = Gate(operation = QPE(U, t), part = sub_expr1), targets = sub_expr4)
sub_expr6 = MultiQubitElem(element = Gate(operation = QPE1(U, t), part = sub_expr1), targets = sub_expr4)
expr = Lambda(U, Conditional(QcircuitEquiv(Qcircuit(vert_expr_array = VertExprArray([ExprRange(sub_expr1, sub_expr5, one, t), ExprRange(sub_expr1, sub_expr5, sub_expr3, sub_expr2)])), Qcircuit(vert_expr_array = VertExprArray([ExprRange(sub_expr1, sub_expr6, one, t), ExprRange(sub_expr1, sub_expr6, sub_expr3, sub_expr2)], [ExprRange(sub_expr1, MultiQubitElem(element = Gate(operation = InverseFourierTransform(t), part = sub_expr1), targets = Interval(one, t)), one, t), ExprRange(sub_expr1, Gate(operation = I).with_implicit_representation(), one, s)]))), InSet(U, Unitary(Exp(two, s)))))
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())
U \mapsto \left\{\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \multigate{1}{\textrm{QPE}\left(U, t\right)} & { /^{t} } \qw \\
& \ghost{\textrm{QPE}\left(U, t\right)} & { /^{s} } \qw
} \end{array}\right) \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \multigate{1}{\textrm{QPE}_1\left(U, t\right)} & \gate{{\mathrm {FT}}^{\dag}_{t}} & { /^{t} } \qw \\
& \ghost{\textrm{QPE}_1\left(U, t\right)} & { /^{s} } \qw & { /^{s} } \qw
} \end{array}\right) \textrm{ if } U \in \textrm{U}\left(2^{s}\right)\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 72
body: 2
1ExprTuple72
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple72, 11
9Operationoperator: 13
operand: 17
10Operationoperator: 13
operands: 14
11Operationoperator: 15
operand: 20
12ExprTuple17
13Literal
14ExprTuple18, 19
15Literal
16ExprTuple20
17ExprTuple21, 22
18ExprTuple23, 24
19ExprTuple25, 26
20Operationoperator: 27
operands: 28
21ExprRangelambda_map: 29
start_index: 64
end_index: 74
22ExprRangelambda_map: 29
start_index: 31
end_index: 61
23ExprRangelambda_map: 30
start_index: 64
end_index: 74
24ExprRangelambda_map: 30
start_index: 31
end_index: 61
25ExprRangelambda_map: 32
start_index: 64
end_index: 74
26ExprRangelambda_map: 33
start_index: 64
end_index: 73
27Literal
28ExprTuple34, 73
29Lambdaparameter: 63
body: 35
30Lambdaparameter: 63
body: 36
31Operationoperator: 68
operands: 37
32Lambdaparameter: 63
body: 38
33Lambdaparameter: 63
body: 40
34Literal
35Operationoperator: 43
operands: 41
36Operationoperator: 43
operands: 42
37ExprTuple74, 64
38Operationoperator: 43
operands: 44
39ExprTuple63
40Operationoperator: 55
operands: 45
41NamedExprselement: 46
targets: 48
42NamedExprselement: 47
targets: 48
43Literal
44NamedExprselement: 49
targets: 50
45NamedExprsoperation: 51
46Operationoperator: 55
operands: 52
47Operationoperator: 55
operands: 53
48Operationoperator: 57
operands: 54
49Operationoperator: 55
operands: 56
50Operationoperator: 57
operands: 58
51Literal
52NamedExprsoperation: 59
part: 63
53NamedExprsoperation: 60
part: 63
54ExprTuple64, 61
55Literal
56NamedExprsoperation: 62
part: 63
57Literal
58ExprTuple64, 74
59Operationoperator: 65
operands: 67
60Operationoperator: 66
operands: 67
61Operationoperator: 68
operands: 69
62Operationoperator: 70
operand: 74
63Variable
64Literal
65Literal
66Literal
67ExprTuple72, 74
68Literal
69ExprTuple74, 73
70Literal
71ExprTuple74
72Variable
73Variable
74Variable