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.QPE import QPE1, QPE1_U_t_circuit
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 = MultiQubitElem(element = Gate(operation = QPE1(U, t), part = sub_expr1), targets = Interval(one, sub_expr2))
expr = ExprTuple(Lambda(U, Conditional(QcircuitEquiv(Qcircuit(vert_expr_array = VertExprArray([ExprRange(sub_expr1, sub_expr3, one, t), ExprRange(sub_expr1, sub_expr3, Add(t, one), sub_expr2)])), QPE1_U_t_circuit), 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}_1\left(U, t\right)} & { /^{t} } \qw \\
& \ghost{\textrm{QPE}_1\left(U, t\right)} & { /^{s} } \qw
} \end{array}\right) \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \control{} \qw \qwx[1] & \qw & \gate{\cdots} \qwx[1] & \qw & \qw \\
& \qw \qwx[1] & \control{} \qw \qwx[1] & \gate{\cdots} \qwx[1] & \qw & \qw \\
& \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} & \qw \\
& \qw \qwx[1] & \qw \qwx[1] & \gate{\cdots} \qwx[1] & \control{} \qw \qwx[1] & \qw \\
& \gate{U^{2^{t - 1}}} & \gate{U^{2^{t - 2}}} & \gate{\cdots} & \gate{U^{2^{0}}} & { /^{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: 82
body: 3
2ExprTuple82
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple82, 12
10Operationoperator: 14
operand: 18
11Operationoperator: 14
operands: 15
12Operationoperator: 16
operand: 20
13ExprTuple18
14Literal
15ExprTuple19
16Literal
17ExprTuple20
18ExprTuple21, 22
19ExprRangelambda_map: 23
start_index: 24
end_index: 25
20Operationoperator: 86
operands: 26
21ExprRangelambda_map: 27
start_index: 93
end_index: 92
22ExprRangelambda_map: 27
start_index: 85
end_index: 70
23Lambdaparameter: 96
body: 28
24Operationoperator: 88
operands: 29
25Literal
26ExprTuple90, 84
27Lambdaparameter: 75
body: 30
28ExprTuple31, 32
29ExprTuple33, 93
30Operationoperator: 62
operands: 34
31ExprRangelambda_map: 35
start_index: 93
end_index: 92
32ExprRangelambda_map: 36
start_index: 93
end_index: 84
33Operationoperator: 94
operand: 92
34NamedExprselement: 38
targets: 39
35Lambdaparameter: 75
body: 40
36Lambdaparameter: 75
body: 42
37ExprTuple92
38Operationoperator: 65
operands: 43
39Operationoperator: 60
operands: 44
40Operationoperator: 45
operands: 46
41ExprTuple75
42Operationoperator: 62
operands: 47
43NamedExprsoperation: 48
part: 75
44ExprTuple93, 70
45Literal
46ExprTuple49, 50
47NamedExprselement: 51
targets: 52
48Operationoperator: 53
operands: 54
49Conditionalvalue: 55
condition: 56
50Conditionalvalue: 57
condition: 58
51Operationoperator: 65
operands: 59
52Operationoperator: 60
operands: 61
53Literal
54ExprTuple82, 92
55Operationoperator: 62
operands: 63
56Operationoperator: 64
operands: 68
57Operationoperator: 65
operands: 66
58Operationoperator: 67
operands: 68
59NamedExprsoperation: 69
part: 75
60Literal
61ExprTuple85, 70
62Literal
63NamedExprselement: 71
targets: 72
64Literal
65Literal
66NamedExprsoperation: 73
67Literal
68ExprTuple74, 75
69Operationoperator: 76
operands: 77
70Operationoperator: 88
operands: 78
71Literal
72Operationoperator: 79
operand: 85
73Literal
74Operationoperator: 88
operands: 81
75Variable
76Literal
77ExprTuple82, 83
78ExprTuple92, 84
79Literal
80ExprTuple85
81ExprTuple96, 92
82Variable
83Operationoperator: 86
operands: 87
84Variable
85Operationoperator: 88
operands: 89
86Literal
87ExprTuple90, 91
88Literal
89ExprTuple92, 93
90Literal
91Operationoperator: 94
operand: 96
92Variable
93Literal
94Literal
95ExprTuple96
96Variable