logo

Expression of type QcircuitEquiv

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 ExprRange, U, Variable, VertExprArray, s, t
from proveit.numbers import Add, Interval, one
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 = 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)
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(\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)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()()('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
directionDirection of the relation (normal or reversed)normalnormal('with_direction_reversed', 'is_reversed')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple3, 4
3Operationoperator: 6
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple9
8ExprTuple10, 11
9ExprRangelambda_map: 12
start_index: 13
end_index: 14
10ExprRangelambda_map: 15
start_index: 81
end_index: 80
11ExprRangelambda_map: 15
start_index: 73
end_index: 58
12Lambdaparameter: 84
body: 16
13Operationoperator: 76
operands: 17
14Literal
15Lambdaparameter: 63
body: 18
16ExprTuple19, 20
17ExprTuple21, 81
18Operationoperator: 50
operands: 22
19ExprRangelambda_map: 23
start_index: 81
end_index: 80
20ExprRangelambda_map: 24
start_index: 81
end_index: 72
21Operationoperator: 82
operand: 80
22NamedExprselement: 26
targets: 27
23Lambdaparameter: 63
body: 28
24Lambdaparameter: 63
body: 30
25ExprTuple80
26Operationoperator: 53
operands: 31
27Operationoperator: 48
operands: 32
28Operationoperator: 33
operands: 34
29ExprTuple63
30Operationoperator: 50
operands: 35
31NamedExprsoperation: 36
part: 63
32ExprTuple81, 58
33Literal
34ExprTuple37, 38
35NamedExprselement: 39
targets: 40
36Operationoperator: 41
operands: 42
37Conditionalvalue: 43
condition: 44
38Conditionalvalue: 45
condition: 46
39Operationoperator: 53
operands: 47
40Operationoperator: 48
operands: 49
41Literal
42ExprTuple70, 80
43Operationoperator: 50
operands: 51
44Operationoperator: 52
operands: 56
45Operationoperator: 53
operands: 54
46Operationoperator: 55
operands: 56
47NamedExprsoperation: 57
part: 63
48Literal
49ExprTuple73, 58
50Literal
51NamedExprselement: 59
targets: 60
52Literal
53Literal
54NamedExprsoperation: 61
55Literal
56ExprTuple62, 63
57Operationoperator: 64
operands: 65
58Operationoperator: 76
operands: 66
59Literal
60Operationoperator: 67
operand: 73
61Literal
62Operationoperator: 76
operands: 69
63Variable
64Literal
65ExprTuple70, 71
66ExprTuple80, 72
67Literal
68ExprTuple73
69ExprTuple84, 80
70Variable
71Operationoperator: 74
operands: 75
72Variable
73Operationoperator: 76
operands: 77
74Literal
75ExprTuple78, 79
76Literal
77ExprTuple80, 81
78Literal
79Operationoperator: 82
operand: 84
80Variable
81Literal
82Literal
83ExprTuple84
84Variable