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_on_register_circuit
In [2]:
# check that the built expression is the same as the stored expression
assert phase_kickback_on_register_circuit == stored_expr
assert phase_kickback_on_register_circuit._style_id == stored_expr._style_id
print("Passed sanity check: phase_kickback_on_register_circuit matches stored_expr")
Passed sanity check: phase_kickback_on_register_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] & \qw & \gate{\cdots} \qwx[1] & \qw & \qout{\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi_{1}} \cdot \lvert 1 \rangle\right)\right)} \\
\qin{\lvert + \rangle} & \qw \qwx[1] & \control{} \qw \qwx[1] & \gate{\cdots} \qwx[1] & \qw & \qout{\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi_{2}} \cdot \lvert 1 \rangle\right)\right)} \\
\qin{\begin{array}{c}:\\ \left(t - 3\right) \times \\:\end{array}} & \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} & \qout{\vdots} \\
\qin{\lvert + \rangle} & \qw \qwx[1] & \qw \qwx[1] & \gate{\cdots} \qwx[1] & \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_{t}} \cdot \lvert 1 \rangle\right)\right)} \\
\qin{\lvert u \rangle} & \gate{U_{1}} & \gate{U_{2}} & \gate{\cdots} & \gate{U_{t}} & \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
4ExprRangelambda_map: 8
start_index: 102
end_index: 101
5ExprTuple9, 10
6ExprRangelambda_map: 11
start_index: 102
end_index: 101
7ExprRangelambda_map: 12
start_index: 102
end_index: 85
8Lambdaparameter: 84
body: 13
9ExprRangelambda_map: 14
start_index: 102
end_index: 101
10ExprRangelambda_map: 15
start_index: 102
end_index: 85
11Lambdaparameter: 111
body: 16
12Lambdaparameter: 111
body: 17
13ExprTuple18, 19
14Lambdaparameter: 111
body: 20
15Lambdaparameter: 111
body: 21
16Operationoperator: 35
operands: 22
17Operationoperator: 60
operands: 23
18ExprRangelambda_map: 24
start_index: 102
end_index: 101
19ExprRangelambda_map: 25
start_index: 102
end_index: 85
20Operationoperator: 40
operands: 26
21Operationoperator: 60
operands: 27
22NamedExprsstate: 28
23NamedExprselement: 29
targets: 46
24Lambdaparameter: 111
body: 30
25Lambdaparameter: 111
body: 31
26NamedExprsstate: 32
27NamedExprselement: 33
targets: 46
28Operationoperator: 95
operand: 42
29Operationoperator: 35
operands: 41
30Operationoperator: 36
operands: 37
31Operationoperator: 60
operands: 38
32Operationoperator: 80
operands: 39
33Operationoperator: 40
operands: 41
34ExprTuple42
35Literal
36Literal
37ExprTuple43, 44
38NamedExprselement: 45
targets: 46
39ExprTuple47, 48
40Literal
41NamedExprsstate: 49
part: 111
42Literal
43Conditionalvalue: 50
condition: 51
44Conditionalvalue: 52
condition: 53
45Operationoperator: 63
operands: 54
46Operationoperator: 55
operands: 56
47Operationoperator: 91
operands: 57
48Operationoperator: 58
operands: 59
49Variable
50Operationoperator: 60
operands: 61
51Operationoperator: 62
operands: 66
52Operationoperator: 63
operands: 64
53Operationoperator: 65
operands: 66
54NamedExprsoperation: 67
part: 111
55Literal
56ExprTuple90, 68
57ExprTuple102, 69
58Literal
59ExprTuple70, 71
60Literal
61NamedExprselement: 72
targets: 73
62Literal
63Literal
64NamedExprsoperation: 74
65Literal
66ExprTuple84, 111
67IndexedVarvariable: 75
index: 84
68Operationoperator: 97
operands: 77
69Operationoperator: 93
operands: 78
70Operationoperator: 95
operand: 87
71Operationoperator: 80
operands: 81
72Literal
73Operationoperator: 82
operand: 90
74Literal
75Variable
76ExprTuple84
77ExprTuple101, 85
78ExprTuple105, 86
79ExprTuple87
80Literal
81ExprTuple88, 89
82Literal
83ExprTuple90
84Variable
85Variable
86Operationoperator: 91
operands: 92
87Literal
88Operationoperator: 93
operands: 94
89Operationoperator: 95
operand: 102
90Operationoperator: 97
operands: 98
91Literal
92ExprTuple102, 105
93Literal
94ExprTuple99, 100
95Literal
96ExprTuple102
97Literal
98ExprTuple101, 102
99Literal
100Operationoperator: 103
operands: 104
101Variable
102Literal
103Literal
104ExprTuple105, 106, 107, 108
105Literal
106Literal
107Literal
108IndexedVarvariable: 109
index: 111
109Variable
110ExprTuple111
111Variable