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 phase_kickback_circuit
In [2]:
# check that the built expression is the same as the stored expression
assert phase_kickback_circuit == stored_expr
assert phase_kickback_circuit._style_id == stored_expr._style_id
print("Passed sanity check: phase_kickback_circuit matches stored_expr")
Passed sanity check: phase_kickback_circuit 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} & \control{} \qw \qwx[1] & \qout{\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)} \\
\qin{\lvert u \rangle} & \gate{U} & \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
3ExprTuple6, 7
4ExprTuple8, 9
5ExprTuple10, 11
6Operationoperator: 43
operands: 12
7ExprRangelambda_map: 13
start_index: 79
end_index: 18
8Operationoperator: 34
operands: 14
9ExprRangelambda_map: 15
start_index: 79
end_index: 18
10Operationoperator: 49
operands: 16
11ExprRangelambda_map: 17
start_index: 79
end_index: 18
12NamedExprsstate: 19
13Lambdaparameter: 58
body: 20
14NamedExprselement: 21
targets: 22
15Lambdaparameter: 58
body: 23
16NamedExprsstate: 24
17Lambdaparameter: 58
body: 26
18Operationoperator: 64
operands: 27
19Operationoperator: 75
operand: 36
20Operationoperator: 34
operands: 29
21Literal
22Operationoperator: 30
operand: 82
23Operationoperator: 34
operands: 32
24Operationoperator: 62
operands: 33
25ExprTuple58
26Operationoperator: 34
operands: 35
27ExprTuple70, 79
28ExprTuple36
29NamedExprselement: 37
targets: 42
30Literal
31ExprTuple82
32NamedExprselement: 38
targets: 42
33ExprTuple39, 40
34Literal
35NamedExprselement: 41
targets: 42
36Literal
37Operationoperator: 43
operands: 50
38Operationoperator: 44
operands: 45
39Operationoperator: 71
operands: 46
40Operationoperator: 47
operands: 48
41Operationoperator: 49
operands: 50
42Operationoperator: 51
operands: 52
43Literal
44Literal
45NamedExprsoperation: 53
part: 58
46ExprTuple79, 54
47Literal
48ExprTuple55, 56
49Literal
50NamedExprsstate: 57
part: 58
51Literal
52ExprTuple82, 59
53Variable
54Operationoperator: 73
operands: 60
55Operationoperator: 75
operand: 67
56Operationoperator: 62
operands: 63
57Variable
58Variable
59Operationoperator: 64
operands: 65
60ExprTuple82, 66
61ExprTuple67
62Literal
63ExprTuple68, 69
64Literal
65ExprTuple70, 82
66Operationoperator: 71
operands: 72
67Literal
68Operationoperator: 73
operands: 74
69Operationoperator: 75
operand: 79
70Variable
71Literal
72ExprTuple79, 82
73Literal
74ExprTuple77, 78
75Literal
76ExprTuple79
77Literal
78Operationoperator: 80
operands: 81
79Literal
80Literal
81ExprTuple82, 83, 84, 85
82Literal
83Literal
84Literal
85Variable