logo

Expression of type ExprTuple

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 ExprTuple
from proveit.physics.quantum.QPE import _alpha_m_sqrd, _phase_est_circuit
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Prob(_phase_est_circuit), _alpha_m_sqrd)
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(\textrm{Pr}\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), \left|\alpha_{m}\right|^{2}\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1Operationoperator: 3
operand: 7
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7
5Literal
6ExprTuple8, 9
7Operationoperator: 10
operands: 11
8Operationoperator: 12
operand: 18
9Literal
10Literal
11ExprTuple14, 15, 16, 17
12Literal
13ExprTuple18
14ExprTuple19, 20
15ExprTuple21, 22
16ExprTuple23, 24
17ExprTuple25, 26
18Operationoperator: 27
operand: 90
19ExprRangelambda_map: 29
start_index: 91
end_index: 92
20ExprRangelambda_map: 30
start_index: 91
end_index: 93
21ExprRangelambda_map: 31
start_index: 91
end_index: 92
22ExprRangelambda_map: 31
start_index: 80
end_index: 81
23ExprRangelambda_map: 32
start_index: 91
end_index: 92
24ExprRangelambda_map: 33
start_index: 91
end_index: 93
25ExprRangelambda_map: 34
start_index: 91
end_index: 92
26ExprRangelambda_map: 35
start_index: 91
end_index: 93
27Literal
28ExprTuple90
29Lambdaparameter: 79
body: 36
30Lambdaparameter: 79
body: 37
31Lambdaparameter: 79
body: 38
32Lambdaparameter: 79
body: 39
33Lambdaparameter: 79
body: 40
34Lambdaparameter: 79
body: 41
35Lambdaparameter: 79
body: 43
36Operationoperator: 65
operands: 44
37Operationoperator: 51
operands: 45
38Operationoperator: 51
operands: 46
39Operationoperator: 47
operands: 48
40Operationoperator: 66
operands: 49
41Operationoperator: 51
operands: 50
42ExprTuple79
43Operationoperator: 51
operands: 52
44NamedExprsstate: 53
45NamedExprselement: 54
targets: 62
46NamedExprselement: 55
targets: 56
47Literal
48NamedExprsbasis: 57
49NamedExprsoperation: 58
50NamedExprselement: 59
targets: 60
51Literal
52NamedExprselement: 61
targets: 62
53Operationoperator: 63
operand: 75
54Operationoperator: 65
operands: 72
55Operationoperator: 66
operands: 67
56Operationoperator: 73
operands: 68
57Literal
58Literal
59Operationoperator: 71
operands: 69
60Operationoperator: 73
operands: 70
61Operationoperator: 71
operands: 72
62Operationoperator: 73
operands: 74
63Literal
64ExprTuple75
65Literal
66Literal
67NamedExprsoperation: 76
part: 79
68ExprTuple91, 81
69NamedExprsstate: 77
part: 79
70ExprTuple91, 92
71Literal
72NamedExprsstate: 78
part: 79
73Literal
74ExprTuple80, 81
75Literal
76Operationoperator: 82
operands: 83
77Operationoperator: 84
operands: 85
78Literal
79Variable
80Operationoperator: 87
operands: 86
81Operationoperator: 87
operands: 88
82Literal
83ExprTuple89, 92
84Literal
85ExprTuple90, 92
86ExprTuple92, 91
87Literal
88ExprTuple92, 93
89Literal
90Variable
91Literal
92Literal
93Literal