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_theorem_expr # Load the stored theorem expression as 'stored_expr'
# import the special expression
from proveit.physics.quantum.circuits import phase_kickback
In [2]:
# check that the built expression is the same as the stored expression
assert phase_kickback.expr == stored_expr
assert phase_kickback.expr._style_id == stored_expr._style_id
print("Passed sanity check: phase_kickback matches stored_expr")
Passed sanity check: phase_kickback matches stored_expr
In [3]:
# Show the LaTeX representation of the expression for convenience if you need it.
print(stored_expr.latex())
\forall_{m \in \mathbb{N}^+}~\left[\forall_{U \in \textrm{U}\left(2^{m}\right)}~\left[\forall_{\lvert u \rangle \in \mathbb{C}^{2^{m}}~|~\left \|\lvert u \rangle\right \| = 1}~\left[\forall_{\varphi~|~\left(U \thinspace \lvert u \rangle\right) = \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi} \cdot \lvert u \rangle\right)}~\left(\textrm{Pr}\left(\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}\right) = 1\right)\right]\right]\right]
In [4]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [5]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 24
operand: 2
1ExprTuple2
2Lambdaparameter: 128
body: 4
3ExprTuple128
4Conditionalvalue: 5
condition: 6
5Operationoperator: 24
operand: 9
6Operationoperator: 33
operands: 8
7ExprTuple9
8ExprTuple128, 10
9Lambdaparameter: 111
body: 12
10Literal
11ExprTuple111
12Conditionalvalue: 13
condition: 14
13Operationoperator: 24
operand: 17
14Operationoperator: 33
operands: 16
15ExprTuple17
16ExprTuple111, 18
17Lambdaparameter: 115
body: 19
18Operationoperator: 20
operand: 51
19Conditionalvalue: 22
condition: 23
20Literal
21ExprTuple51
22Operationoperator: 24
operand: 28
23Operationoperator: 26
operands: 27
24Literal
25ExprTuple28
26Literal
27ExprTuple29, 30
28Lambdaparameter: 143
body: 32
29Operationoperator: 33
operands: 34
30Operationoperator: 41
operands: 35
31ExprTuple143
32Conditionalvalue: 36
condition: 37
33Literal
34ExprTuple115, 38
35ExprTuple39, 137
36Operationoperator: 41
operands: 40
37Operationoperator: 41
operands: 42
38Operationoperator: 43
operands: 44
39Operationoperator: 45
operand: 115
40ExprTuple47, 137
41Literal
42ExprTuple48, 49
43Literal
44ExprTuple50, 51
45Literal
46ExprTuple115
47Operationoperator: 52
operand: 58
48Operationoperator: 54
operands: 55
49Operationoperator: 120
operands: 56
50Literal
51Operationoperator: 131
operands: 57
52Literal
53ExprTuple58
54Literal
55ExprTuple111, 115
56ExprTuple126, 115
57ExprTuple140, 128
58Operationoperator: 59
operands: 60
59Literal
60ExprTuple61, 62, 63
61ExprTuple64, 65
62ExprTuple66, 67
63ExprTuple68, 69
64Operationoperator: 101
operands: 70
65ExprRangelambda_map: 71
start_index: 137
end_index: 76
66Operationoperator: 92
operands: 72
67ExprRangelambda_map: 73
start_index: 137
end_index: 76
68Operationoperator: 107
operands: 74
69ExprRangelambda_map: 75
start_index: 137
end_index: 76
70NamedExprsstate: 77
71Lambdaparameter: 116
body: 78
72NamedExprselement: 79
targets: 80
73Lambdaparameter: 116
body: 81
74NamedExprsstate: 82
75Lambdaparameter: 116
body: 84
76Operationoperator: 122
operands: 85
77Operationoperator: 133
operand: 94
78Operationoperator: 92
operands: 87
79Literal
80Operationoperator: 88
operand: 140
81Operationoperator: 92
operands: 90
82Operationoperator: 120
operands: 91
83ExprTuple116
84Operationoperator: 92
operands: 93
85ExprTuple128, 137
86ExprTuple94
87NamedExprselement: 95
targets: 100
88Literal
89ExprTuple140
90NamedExprselement: 96
targets: 100
91ExprTuple97, 98
92Literal
93NamedExprselement: 99
targets: 100
94Literal
95Operationoperator: 101
operands: 108
96Operationoperator: 102
operands: 103
97Operationoperator: 129
operands: 104
98Operationoperator: 105
operands: 106
99Operationoperator: 107
operands: 108
100Operationoperator: 109
operands: 110
101Literal
102Literal
103NamedExprsoperation: 111
part: 116
104ExprTuple137, 112
105Literal
106ExprTuple113, 114
107Literal
108NamedExprsstate: 115
part: 116
109Literal
110ExprTuple140, 117
111Variable
112Operationoperator: 131
operands: 118
113Operationoperator: 133
operand: 125
114Operationoperator: 120
operands: 121
115Variable
116Variable
117Operationoperator: 122
operands: 123
118ExprTuple140, 124
119ExprTuple125
120Literal
121ExprTuple126, 127
122Literal
123ExprTuple128, 140
124Operationoperator: 129
operands: 130
125Literal
126Operationoperator: 131
operands: 132
127Operationoperator: 133
operand: 137
128Variable
129Literal
130ExprTuple137, 140
131Literal
132ExprTuple135, 136
133Literal
134ExprTuple137
135Literal
136Operationoperator: 138
operands: 139
137Literal
138Literal
139ExprTuple140, 141, 142, 143
140Literal
141Literal
142Literal
143Variable