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 ExprRange, ExprTuple, Variable, VertExprArray
from proveit.numbers import Interval, one
from proveit.physics.quantum.QFT import InverseFourierTransform
from proveit.physics.quantum.QPE import _Psi_ket, _psi__t_ket, _t
from proveit.physics.quantum.circuits import Gate, Input, MultiQubitElem, Output, Qcircuit
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = Interval(one, _t)
expr = ExprTuple(Prob(Qcircuit(vert_expr_array = VertExprArray([ExprRange(sub_expr1, MultiQubitElem(element = Input(state = _psi__t_ket, part = sub_expr1), targets = sub_expr2), one, _t)], [ExprRange(sub_expr1, MultiQubitElem(element = Gate(operation = InverseFourierTransform(_t), part = sub_expr1), targets = sub_expr2), one, _t)], [ExprRange(sub_expr1, MultiQubitElem(element = Output(state = _Psi_ket, part = sub_expr1), targets = sub_expr2), one, _t)]))), one)
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 \psi_{t} \rangle} & \gate{{\mathrm {FT}}^{\dag}_{t}} & \qout{\lvert \Psi \rangle}
} \end{array}\right), 1\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, 40
1Operationoperator: 2
operand: 4
2Literal
3ExprTuple4
4Operationoperator: 5
operands: 6
5Literal
6ExprTuple7, 8, 9
7ExprTuple10
8ExprTuple11
9ExprTuple12
10ExprRangelambda_map: 13
start_index: 40
end_index: 44
11ExprRangelambda_map: 14
start_index: 40
end_index: 44
12ExprRangelambda_map: 15
start_index: 40
end_index: 44
13Lambdaparameter: 39
body: 16
14Lambdaparameter: 39
body: 17
15Lambdaparameter: 39
body: 19
16Operationoperator: 22
operands: 20
17Operationoperator: 22
operands: 21
18ExprTuple39
19Operationoperator: 22
operands: 23
20NamedExprselement: 24
targets: 27
21NamedExprselement: 25
targets: 27
22Literal
23NamedExprselement: 26
targets: 27
24Operationoperator: 28
operands: 29
25Operationoperator: 30
operands: 31
26Operationoperator: 32
operands: 33
27Operationoperator: 34
operands: 35
28Literal
29NamedExprsstate: 36
part: 39
30Literal
31NamedExprsoperation: 37
part: 39
32Literal
33NamedExprsstate: 38
part: 39
34Literal
35ExprTuple40, 44
36Operationoperator: 41
operand: 44
37Operationoperator: 42
operand: 44
38Literal
39Variable
40Literal
41Literal
42Literal
43ExprTuple44
44Literal