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.circuits import register_meas
In [2]:
# check that the built expression is the same as the stored expression
assert register_meas == stored_expr
assert register_meas._style_id == stored_expr._style_id
print("Passed sanity check: register_meas matches stored_expr")
Passed sanity check: register_meas 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{
\multiqin{3}{\lvert \psi \rangle} & \meter & \multiqout{3}{\lvert n \rangle_{m}} \\
\ghostqin{\lvert \psi \rangle} & \meter & \ghostqout{\lvert n \rangle_{m}} \\
\ghostqin{\lvert \psi \rangle} & \measure{\begin{array}{c}:\\ \left(m - 3\right) \times \\:\end{array}} \qw & \ghostqout{\lvert n \rangle_{m}} \\
\ghostqin{\lvert \psi \rangle} & \meter & \ghostqout{\lvert n \rangle_{m}}
} \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
3ExprTuple6
4ExprTuple7
5ExprTuple8
6ExprRangelambda_map: 9
start_index: 34
end_index: 38
7ExprRangelambda_map: 10
start_index: 34
end_index: 38
8ExprRangelambda_map: 11
start_index: 34
end_index: 38
9Lambdaparameter: 33
body: 12
10Lambdaparameter: 33
body: 13
11Lambdaparameter: 33
body: 15
12Operationoperator: 19
operands: 16
13Operationoperator: 17
operands: 18
14ExprTuple33
15Operationoperator: 19
operands: 20
16NamedExprselement: 21
targets: 24
17Literal
18NamedExprsbasis: 22
19Literal
20NamedExprselement: 23
targets: 24
21Operationoperator: 25
operands: 26
22Literal
23Operationoperator: 27
operands: 28
24Operationoperator: 29
operands: 30
25Literal
26NamedExprsstate: 31
part: 33
27Literal
28NamedExprsstate: 32
part: 33
29Literal
30ExprTuple34, 38
31Variable
32Operationoperator: 35
operands: 36
33Variable
34Literal
35Literal
36ExprTuple37, 38
37Variable
38Variable