logo
In [1]:
import proveit
# Automation is not needed when only 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 the special expression
from proveit.physics.quantum.QPE import _phase_est_circuit_b_r
In [2]:
# check that the built expression is the same as the stored expression
assert _phase_est_circuit_b_r == stored_expr
assert _phase_est_circuit_b_r._style_id == stored_expr._style_id
print("Passed sanity check: _phase_est_circuit_b_r matches stored_expr")
Passed sanity check: _phase_est_circuit_b_r matches stored_expr
In [3]:
# Show the LaTeX representation of the expression for convenience if you need it.
print(stored_expr.latex())
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{\lvert + \rangle} & \multigate{4}{\textrm{QPE}\left(U, t\right)} & \meter & \multiqout{3}{\lvert round\left(2^{t} \cdot \varphi\right) ~\textup{mod}~ 2^{t} \rangle_{t}} \\
\qin{\lvert + \rangle} & \ghost{\textrm{QPE}\left(U, t\right)} & \meter & \ghostqout{\lvert round\left(2^{t} \cdot \varphi\right) ~\textup{mod}~ 2^{t} \rangle_{t}} \\
\qin{\begin{array}{c}:\\ \left(t - 3\right) \times \\:\end{array}} & \ghost{\textrm{QPE}\left(U, t\right)} & \measure{\begin{array}{c}:\\ \left(t - 3\right) \times \\:\end{array}} \qw & \ghostqout{\lvert round\left(2^{t} \cdot \varphi\right) ~\textup{mod}~ 2^{t} \rangle_{t}} \\
\qin{\lvert + \rangle} & \ghost{\textrm{QPE}\left(U, t\right)} & \meter & \ghostqout{\lvert round\left(2^{t} \cdot \varphi\right) ~\textup{mod}~ 2^{t} \rangle_{t}} \\
\qin{\lvert u \rangle} & \ghost{\textrm{QPE}\left(U, t\right)} & { /^{s} } \qw & \qout{\lvert u \rangle}
} \end{array}
In [4]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
spacingchange the spacing of a circuit using the format '@C=1em @R=.7em' where C is the column spacing and R is the row spacing@C=1em @R=.7em@C=1em @R=.7em
In [5]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple3, 4, 5, 6
3ExprTuple7, 8
4ExprTuple9, 10
5ExprTuple11, 12
6ExprTuple13, 14
7ExprRangelambda_map: 15
start_index: 77
end_index: 92
8ExprRangelambda_map: 16
start_index: 77
end_index: 78
9ExprRangelambda_map: 17
start_index: 77
end_index: 92
10ExprRangelambda_map: 17
start_index: 66
end_index: 67
11ExprRangelambda_map: 18
start_index: 77
end_index: 92
12ExprRangelambda_map: 19
start_index: 77
end_index: 78
13ExprRangelambda_map: 20
start_index: 77
end_index: 92
14ExprRangelambda_map: 21
start_index: 77
end_index: 78
15Lambdaparameter: 65
body: 22
16Lambdaparameter: 65
body: 23
17Lambdaparameter: 65
body: 24
18Lambdaparameter: 65
body: 25
19Lambdaparameter: 65
body: 26
20Lambdaparameter: 65
body: 27
21Lambdaparameter: 65
body: 29
22Operationoperator: 51
operands: 30
23Operationoperator: 37
operands: 31
24Operationoperator: 37
operands: 32
25Operationoperator: 33
operands: 34
26Operationoperator: 52
operands: 35
27Operationoperator: 37
operands: 36
28ExprTuple65
29Operationoperator: 37
operands: 38
30NamedExprsstate: 39
31NamedExprselement: 40
targets: 48
32NamedExprselement: 41
targets: 42
33Literal
34NamedExprsbasis: 43
35NamedExprsoperation: 44
36NamedExprselement: 45
targets: 46
37Literal
38NamedExprselement: 47
targets: 48
39Operationoperator: 49
operand: 61
40Operationoperator: 51
operands: 58
41Operationoperator: 52
operands: 53
42Operationoperator: 59
operands: 54
43Literal
44Literal
45Operationoperator: 57
operands: 55
46Operationoperator: 59
operands: 56
47Operationoperator: 57
operands: 58
48Operationoperator: 59
operands: 60
49Literal
50ExprTuple61
51Literal
52Literal
53NamedExprsoperation: 62
part: 65
54ExprTuple77, 67
55NamedExprsstate: 63
part: 65
56ExprTuple77, 92
57Literal
58NamedExprsstate: 64
part: 65
59Literal
60ExprTuple66, 67
61Literal
62Operationoperator: 68
operands: 69
63Operationoperator: 70
operands: 71
64Literal
65Variable
66Operationoperator: 73
operands: 72
67Operationoperator: 73
operands: 74
68Literal
69ExprTuple75, 92
70Literal
71ExprTuple76, 92
72ExprTuple92, 77
73Literal
74ExprTuple92, 78
75Literal
76Operationoperator: 79
operands: 80
77Literal
78Literal
79Literal
80ExprTuple81, 87
81Operationoperator: 82
operand: 84
82Literal
83ExprTuple84
84Operationoperator: 85
operands: 86
85Literal
86ExprTuple87, 88
87Operationoperator: 89
operands: 90
88Literal
89Literal
90ExprTuple91, 92
91Literal
92Literal