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, Lambda, Variable, t
from proveit.linear_algebra import TensorProd
from proveit.numbers import Add, Interval, one
from proveit.physics.quantum.QPE import _ket_u, _psi_t_ket, _s
from proveit.physics.quantum.circuits import MultiQubitElem, Output
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = TensorProd(_psi_t_ket, _ket_u)
sub_expr3 = Interval(one, Add(t, _s))
expr = ExprTuple(Lambda(Variable("_b", latex_format = r"{_{-}b}"), MultiQubitElem(element = Output(state = sub_expr2, part = one), targets = sub_expr3)), Lambda(sub_expr1, MultiQubitElem(element = Output(state = sub_expr2, part = Add(sub_expr1, t)), targets = sub_expr3)))
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({_{-}b} \mapsto \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\lvert \psi_{t} \rangle {\otimes} \lvert u \rangle~\mbox{part}~1~\mbox{on}~\{1~\ldotp \ldotp~t + s\}} 
} \end{array}, {_{-}a} \mapsto \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\lvert \psi_{t} \rangle {\otimes} \lvert u \rangle~\mbox{part}~{_{-}a} + t~\mbox{on}~\{1~\ldotp \ldotp~t + s\}} 
} \end{array}\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
1Lambdaparameter: 7
body: 4
2Lambdaparameter: 30
body: 6
3ExprTuple7
4Operationoperator: 9
operands: 8
5ExprTuple30
6Operationoperator: 9
operands: 10
7Variable
8NamedExprselement: 11
targets: 13
9Literal
10NamedExprselement: 12
targets: 13
11Operationoperator: 15
operands: 14
12Operationoperator: 15
operands: 16
13Operationoperator: 17
operands: 18
14NamedExprsstate: 19
part: 21
15Literal
16NamedExprsstate: 19
part: 20
17Literal
18ExprTuple21, 22
19Operationoperator: 23
operands: 24
20Operationoperator: 26
operands: 25
21Literal
22Operationoperator: 26
operands: 27
23Literal
24ExprTuple28, 29
25ExprTuple30, 34
26Literal
27ExprTuple34, 31
28Operationoperator: 32
operand: 34
29Literal
30Variable
31Literal
32Literal
33ExprTuple34
34Variable