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
from proveit.numbers import Add, Interval, one
from proveit.physics.quantum.QPE import _ket_u, _psi__t_ket, _s, _t
from proveit.physics.quantum.circuits import Input, MultiQubitElem
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple([ExprRange(sub_expr1, MultiQubitElem(element = Input(state = _psi__t_ket, part = sub_expr1), targets = Interval(one, _t)), one, _t), ExprRange(sub_expr1, MultiQubitElem(element = Input(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{
& \qin{\lvert \psi_{t} \rangle~\mbox{part}~1~\mbox{on}~\{1~\ldotp \ldotp~t\}} & \qw 
} \end{array}, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \qin{\lvert \psi_{t} \rangle~\mbox{part}~2~\mbox{on}~\{1~\ldotp \ldotp~t\}} & \qw 
} \end{array}, \ldots, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \qin{\lvert \psi_{t} \rangle~\mbox{part}~t~\mbox{on}~\{1~\ldotp \ldotp~t\}} & \qw 
} \end{array},\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \qin{\lvert u \rangle~\mbox{part}~1~\mbox{on}~\{t + 1~\ldotp \ldotp~t + s\}} & \qw 
} \end{array}, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \qin{\lvert u \rangle~\mbox{part}~2~\mbox{on}~\{t + 1~\ldotp \ldotp~t + s\}} & \qw 
} \end{array}, \ldots, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \qin{\lvert u \rangle~\mbox{part}~s~\mbox{on}~\{t + 1~\ldotp \ldotp~t + s\}} & \qw 
} \end{array}\right)\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1ExprTuple2, 3
2ExprRangelambda_map: 4
start_index: 32
end_index: 33
3ExprRangelambda_map: 5
start_index: 32
end_index: 34
4Lambdaparameter: 24
body: 6
5Lambdaparameter: 24
body: 8
6Operationoperator: 10
operands: 9
7ExprTuple24
8Operationoperator: 10
operands: 11
9NamedExprselement: 12
targets: 13
10Literal
11NamedExprselement: 14
targets: 15
12Operationoperator: 18
operands: 16
13Operationoperator: 20
operands: 17
14Operationoperator: 18
operands: 19
15Operationoperator: 20
operands: 21
16NamedExprsstate: 22
part: 24
17ExprTuple32, 33
18Literal
19NamedExprsstate: 23
part: 24
20Literal
21ExprTuple25, 26
22Operationoperator: 27
operand: 33
23Literal
24Variable
25Operationoperator: 30
operands: 29
26Operationoperator: 30
operands: 31
27Literal
28ExprTuple33
29ExprTuple33, 32
30Literal
31ExprTuple33, 34
32Literal
33Literal
34Literal