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 unitary_gate_op
In [2]:
# check that the built expression is the same as the stored expression
assert unitary_gate_op == stored_expr
assert unitary_gate_op._style_id == stored_expr._style_id
print("Passed sanity check: unitary_gate_op matches stored_expr")
Passed sanity check: unitary_gate_op 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 \psi \rangle} & \gate{U} & \qout{U \thinspace \lvert \psi \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
3ExprTuple6
4ExprTuple7
5ExprTuple8
6ExprRangelambda_map: 9
start_index: 34
end_index: 35
7ExprRangelambda_map: 10
start_index: 34
end_index: 35
8ExprRangelambda_map: 11
start_index: 34
end_index: 35
9Lambdaparameter: 33
body: 12
10Lambdaparameter: 33
body: 13
11Lambdaparameter: 33
body: 15
12Operationoperator: 18
operands: 16
13Operationoperator: 18
operands: 17
14ExprTuple33
15Operationoperator: 18
operands: 19
16NamedExprselement: 20
targets: 23
17NamedExprselement: 21
targets: 23
18Literal
19NamedExprselement: 22
targets: 23
20Operationoperator: 24
operands: 25
21Operationoperator: 26
operands: 27
22Operationoperator: 28
operands: 29
23Operationoperator: 30
operands: 31
24Literal
25NamedExprsstate: 39
part: 33
26Literal
27NamedExprsoperation: 38
part: 33
28Literal
29NamedExprsstate: 32
part: 33
30Literal
31ExprTuple34, 35
32Operationoperator: 36
operands: 37
33Variable
34Literal
35Variable
36Literal
37ExprTuple38, 39
38Variable
39Variable