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, m
from proveit.numbers import Add, Interval, one
from proveit.physics.quantum import NumKet, Z
from proveit.physics.quantum.QPE import _ket_u, _s, _s_wire, _t
from proveit.physics.quantum.circuits import Measure, MultiQubitElem, Output
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple([ExprRange(sub_expr1, Measure(basis = Z), one, _t), _s_wire], [ExprRange(sub_expr1, MultiQubitElem(element = Output(state = NumKet(m, _t), part = sub_expr1), targets = Interval(one, _t)), one, _t), ExprRange(sub_expr1, MultiQubitElem(element = Output(state = _ket_u, part = sub_expr1), targets = Interval(Add(_t, one), Add(_t, _s))), one, _s)])
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(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \meter 
} \end{array}, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \meter 
} \end{array}, ..\left(t - 3\right) \times.., \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \meter 
} \end{array},\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qw & \qw 
} \end{array}, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qw & \qw 
} \end{array}, ..\left(s - 3\right) \times.., \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qw & \qw 
} \end{array}\right), \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\lvert m \rangle_{t}~\mbox{part}~1~\mbox{on}~\{1~\ldotp \ldotp~t\}} 
} \end{array}, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\lvert m \rangle_{t}~\mbox{part}~2~\mbox{on}~\{1~\ldotp \ldotp~t\}} 
} \end{array}, \ldots, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\lvert m \rangle_{t}~\mbox{part}~t~\mbox{on}~\{1~\ldotp \ldotp~t\}} 
} \end{array},\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\lvert u \rangle~\mbox{part}~1~\mbox{on}~\{t + 1~\ldotp \ldotp~t + s\}} 
} \end{array}, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\lvert u \rangle~\mbox{part}~2~\mbox{on}~\{t + 1~\ldotp \ldotp~t + s\}} 
} \end{array}, \ldots, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\lvert u \rangle~\mbox{part}~s~\mbox{on}~\{t + 1~\ldotp \ldotp~t + s\}} 
} \end{array}\right)\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
1ExprTuple3, 4
2ExprTuple5, 6
3ExprRangelambda_map: 7
start_index: 46
end_index: 47
4ExprRangelambda_map: 8
start_index: 46
end_index: 48
5ExprRangelambda_map: 9
start_index: 46
end_index: 47
6ExprRangelambda_map: 10
start_index: 46
end_index: 48
7Lambdaparameter: 37
body: 11
8Lambdaparameter: 37
body: 12
9Lambdaparameter: 37
body: 13
10Lambdaparameter: 37
body: 15
11Operationoperator: 16
operands: 17
12Operationoperator: 18
operands: 19
13Operationoperator: 21
operands: 20
14ExprTuple37
15Operationoperator: 21
operands: 22
16Literal
17NamedExprsbasis: 23
18Literal
19NamedExprsoperation: 24
20NamedExprselement: 25
targets: 26
21Literal
22NamedExprselement: 27
targets: 28
23Literal
24Literal
25Operationoperator: 31
operands: 29
26Operationoperator: 33
operands: 30
27Operationoperator: 31
operands: 32
28Operationoperator: 33
operands: 34
29NamedExprsstate: 35
part: 37
30ExprTuple46, 47
31Literal
32NamedExprsstate: 36
part: 37
33Literal
34ExprTuple38, 39
35Operationoperator: 40
operands: 41
36Literal
37Variable
38Operationoperator: 43
operands: 42
39Operationoperator: 43
operands: 44
40Literal
41ExprTuple45, 47
42ExprTuple47, 46
43Literal
44ExprTuple47, 48
45Variable
46Literal
47Literal
48Literal