logo

Expression of type Image

from the theory of proveit.physics.quantum.QPE

In [1]:
import proveit
# Automation is not needed when 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 Expression classes needed to build the expression
from proveit import Lambda, m
from proveit.logic import Image
from proveit.physics.quantum.QPE import _m_domain, _phase_est_circuit
In [2]:
# build up the expression from sub-expressions
expr = Image(Lambda(m, _phase_est_circuit), _m_domain)
expr:
In [3]:
# check that the built expression is the same as the stored expression
assert expr == stored_expr
assert expr._style_id == stored_expr._style_id
print("Passed sanity check: expr matches stored_expr")
Passed sanity check: expr matches stored_expr
In [4]:
# Show the LaTeX representation of the expression for convenience if you need it.
print(stored_expr.latex())
\left[m \mapsto \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{\lvert + \rangle} & \multigate{4}{\textrm{QPE}\left(U, t\right)} & \meter & \multiqout{3}{\lvert m \rangle_{t}} \\
\qin{\lvert + \rangle} & \ghost{\textrm{QPE}\left(U, t\right)} & \meter & \ghostqout{\lvert m \rangle_{t}} \\
\qin{\begin{array}{c}:\\ \left(t - 3\right) \times \\:\end{array}} & \ghost{\textrm{QPE}\left(U, t\right)} & \measure{\begin{array}{c}:\\ \left(t - 3\right) \times \\:\end{array}} \qw & \ghostqout{\lvert m \rangle_{t}} \\
\qin{\lvert + \rangle} & \ghost{\textrm{QPE}\left(U, t\right)} & \meter & \ghostqout{\lvert m \rangle_{t}} \\
\qin{\lvert u \rangle} & \ghost{\textrm{QPE}\left(U, t\right)} & { /^{s} } \qw & \qout{\lvert u \rangle}
} \end{array}\right)\right]^{\rightarrow}(\{0~\ldotp \ldotp~2^{t} - 1\})
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()()('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple3, 4
3Lambdaparameter: 93
body: 6
4Operationoperator: 76
operands: 7
5ExprTuple93
6Operationoperator: 8
operands: 9
7ExprTuple10, 11
8Literal
9ExprTuple12, 13, 14, 15
10Literal
11Operationoperator: 90
operands: 16
12ExprTuple17, 18
13ExprTuple19, 20
14ExprTuple21, 22
15ExprTuple23, 24
16ExprTuple25, 26
17ExprRangelambda_map: 27
start_index: 94
end_index: 95
18ExprRangelambda_map: 28
start_index: 94
end_index: 96
19ExprRangelambda_map: 29
start_index: 94
end_index: 95
20ExprRangelambda_map: 29
start_index: 83
end_index: 84
21ExprRangelambda_map: 30
start_index: 94
end_index: 95
22ExprRangelambda_map: 31
start_index: 94
end_index: 96
23ExprRangelambda_map: 32
start_index: 94
end_index: 95
24ExprRangelambda_map: 33
start_index: 94
end_index: 96
25Operationoperator: 34
operands: 35
26Operationoperator: 36
operand: 94
27Lambdaparameter: 82
body: 38
28Lambdaparameter: 82
body: 39
29Lambdaparameter: 82
body: 40
30Lambdaparameter: 82
body: 41
31Lambdaparameter: 82
body: 42
32Lambdaparameter: 82
body: 43
33Lambdaparameter: 82
body: 45
34Literal
35ExprTuple46, 95
36Literal
37ExprTuple94
38Operationoperator: 68
operands: 47
39Operationoperator: 54
operands: 48
40Operationoperator: 54
operands: 49
41Operationoperator: 50
operands: 51
42Operationoperator: 69
operands: 52
43Operationoperator: 54
operands: 53
44ExprTuple82
45Operationoperator: 54
operands: 55
46Literal
47NamedExprsstate: 56
48NamedExprselement: 57
targets: 65
49NamedExprselement: 58
targets: 59
50Literal
51NamedExprsbasis: 60
52NamedExprsoperation: 61
53NamedExprselement: 62
targets: 63
54Literal
55NamedExprselement: 64
targets: 65
56Operationoperator: 66
operand: 78
57Operationoperator: 68
operands: 75
58Operationoperator: 69
operands: 70
59Operationoperator: 76
operands: 71
60Literal
61Literal
62Operationoperator: 74
operands: 72
63Operationoperator: 76
operands: 73
64Operationoperator: 74
operands: 75
65Operationoperator: 76
operands: 77
66Literal
67ExprTuple78
68Literal
69Literal
70NamedExprsoperation: 79
part: 82
71ExprTuple94, 84
72NamedExprsstate: 80
part: 82
73ExprTuple94, 95
74Literal
75NamedExprsstate: 81
part: 82
76Literal
77ExprTuple83, 84
78Literal
79Operationoperator: 85
operands: 86
80Operationoperator: 87
operands: 88
81Literal
82Variable
83Operationoperator: 90
operands: 89
84Operationoperator: 90
operands: 91
85Literal
86ExprTuple92, 95
87Literal
88ExprTuple93, 95
89ExprTuple95, 94
90Literal
91ExprTuple95, 96
92Literal
93Variable
94Literal
95Literal
96Literal