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 And, Forall, InSet
from proveit.numbers import Add, Exp, Interval, NaturalPos, 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([s, t], Conditional(Forall(instance_param_or_params = [U], instance_expr = 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)]))), domain = Unitary(Exp(two, s))), And(InSet(s, NaturalPos), 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())
\left(\left(s, t\right) \mapsto \left\{\forall_{U \in \textrm{U}\left(2^{s}\right)}~\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)\right) \textrm{ if } s \in \mathbb{N}^+ ,  t \in \mathbb{N}^+\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
1Lambdaparameters: 2
body: 3
2ExprTuple88, 89
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple11, 12
10Lambdaparameter: 87
body: 14
11Operationoperator: 22
operands: 15
12Operationoperator: 22
operands: 16
13ExprTuple87
14Conditionalvalue: 17
condition: 18
15ExprTuple88, 19
16ExprTuple89, 19
17Operationoperator: 20
operands: 21
18Operationoperator: 22
operands: 23
19Literal
20Literal
21ExprTuple24, 25
22Literal
23ExprTuple87, 26
24Operationoperator: 28
operand: 32
25Operationoperator: 28
operands: 29
26Operationoperator: 30
operand: 35
27ExprTuple32
28Literal
29ExprTuple33, 34
30Literal
31ExprTuple35
32ExprTuple36, 37
33ExprTuple38, 39
34ExprTuple40, 41
35Operationoperator: 42
operands: 43
36ExprRangelambda_map: 44
start_index: 79
end_index: 89
37ExprRangelambda_map: 44
start_index: 46
end_index: 76
38ExprRangelambda_map: 45
start_index: 79
end_index: 89
39ExprRangelambda_map: 45
start_index: 46
end_index: 76
40ExprRangelambda_map: 47
start_index: 79
end_index: 89
41ExprRangelambda_map: 48
start_index: 79
end_index: 88
42Literal
43ExprTuple49, 88
44Lambdaparameter: 78
body: 50
45Lambdaparameter: 78
body: 51
46Operationoperator: 83
operands: 52
47Lambdaparameter: 78
body: 53
48Lambdaparameter: 78
body: 55
49Literal
50Operationoperator: 58
operands: 56
51Operationoperator: 58
operands: 57
52ExprTuple89, 79
53Operationoperator: 58
operands: 59
54ExprTuple78
55Operationoperator: 70
operands: 60
56NamedExprselement: 61
targets: 63
57NamedExprselement: 62
targets: 63
58Literal
59NamedExprselement: 64
targets: 65
60NamedExprsoperation: 66
61Operationoperator: 70
operands: 67
62Operationoperator: 70
operands: 68
63Operationoperator: 72
operands: 69
64Operationoperator: 70
operands: 71
65Operationoperator: 72
operands: 73
66Literal
67NamedExprsoperation: 74
part: 78
68NamedExprsoperation: 75
part: 78
69ExprTuple79, 76
70Literal
71NamedExprsoperation: 77
part: 78
72Literal
73ExprTuple79, 89
74Operationoperator: 80
operands: 82
75Operationoperator: 81
operands: 82
76Operationoperator: 83
operands: 84
77Operationoperator: 85
operand: 89
78Variable
79Literal
80Literal
81Literal
82ExprTuple87, 89
83Literal
84ExprTuple89, 88
85Literal
86ExprTuple89
87Variable
88Variable
89Variable