logo

Expression of type ExprTuple

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, ExprTuple, 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 = ExprTuple(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())
\left(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..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 73
body: 3
2ExprTuple73
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple73, 12
10Operationoperator: 14
operand: 18
11Operationoperator: 14
operands: 15
12Operationoperator: 16
operand: 21
13ExprTuple18
14Literal
15ExprTuple19, 20
16Literal
17ExprTuple21
18ExprTuple22, 23
19ExprTuple24, 25
20ExprTuple26, 27
21Operationoperator: 28
operands: 29
22ExprRangelambda_map: 30
start_index: 65
end_index: 75
23ExprRangelambda_map: 30
start_index: 32
end_index: 62
24ExprRangelambda_map: 31
start_index: 65
end_index: 75
25ExprRangelambda_map: 31
start_index: 32
end_index: 62
26ExprRangelambda_map: 33
start_index: 65
end_index: 75
27ExprRangelambda_map: 34
start_index: 65
end_index: 74
28Literal
29ExprTuple35, 74
30Lambdaparameter: 64
body: 36
31Lambdaparameter: 64
body: 37
32Operationoperator: 69
operands: 38
33Lambdaparameter: 64
body: 39
34Lambdaparameter: 64
body: 41
35Literal
36Operationoperator: 44
operands: 42
37Operationoperator: 44
operands: 43
38ExprTuple75, 65
39Operationoperator: 44
operands: 45
40ExprTuple64
41Operationoperator: 56
operands: 46
42NamedExprselement: 47
targets: 49
43NamedExprselement: 48
targets: 49
44Literal
45NamedExprselement: 50
targets: 51
46NamedExprsoperation: 52
47Operationoperator: 56
operands: 53
48Operationoperator: 56
operands: 54
49Operationoperator: 58
operands: 55
50Operationoperator: 56
operands: 57
51Operationoperator: 58
operands: 59
52Literal
53NamedExprsoperation: 60
part: 64
54NamedExprsoperation: 61
part: 64
55ExprTuple65, 62
56Literal
57NamedExprsoperation: 63
part: 64
58Literal
59ExprTuple65, 75
60Operationoperator: 66
operands: 68
61Operationoperator: 67
operands: 68
62Operationoperator: 69
operands: 70
63Operationoperator: 71
operand: 75
64Variable
65Literal
66Literal
67Literal
68ExprTuple73, 75
69Literal
70ExprTuple75, 74
71Literal
72ExprTuple75
73Variable
74Variable
75Variable