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, t
from proveit.linear_algebra import ScalarMult, VecAdd
from proveit.numbers import Add, Exp, Interval, Mult, Neg, e, frac, i, one, pi, sqrt, two, zero
from proveit.physics.quantum import ket0, ket1
from proveit.physics.quantum.QPE import _ket_u, _phase, _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}")
expr = ExprTuple(ExprRange(sub_expr1, Output(state = ScalarMult(frac(one, sqrt(two)), VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, Exp(two, Neg(sub_expr1)), _phase)), ket1)))), Add(Neg(t), one), zero).with_decreasing_order(), ExprRange(sub_expr1, MultiQubitElem(element = Output(state = _ket_u, part = sub_expr1), targets = Interval(Add(t, one), Add(t, _s))), one, _s).with_wrapping_at(2,6))
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(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{t - 1} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)} 
} \end{array}, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{t - 2} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)} 
} \end{array}, \ldots, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{0} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)} 
} \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)
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
1ExprRangelambda_map: 3
start_index: 4
end_index: 43
2ExprRangelambda_map: 5
start_index: 53
end_index: 37
3Lambdaparameter: 66
body: 6
4Operationoperator: 31
operands: 7
5Lambdaparameter: 66
body: 8
6Operationoperator: 18
operands: 9
7ExprTuple10, 53
8Operationoperator: 11
operands: 12
9NamedExprsstate: 13
10Operationoperator: 64
operand: 36
11Literal
12NamedExprselement: 15
targets: 16
13Operationoperator: 40
operands: 17
14ExprTuple36
15Operationoperator: 18
operands: 19
16Operationoperator: 20
operands: 21
17ExprTuple22, 23
18Literal
19NamedExprsstate: 24
part: 66
20Literal
21ExprTuple25, 26
22Operationoperator: 46
operands: 27
23Operationoperator: 28
operands: 29
24Literal
25Operationoperator: 31
operands: 30
26Operationoperator: 31
operands: 32
27ExprTuple53, 33
28Literal
29ExprTuple34, 35
30ExprTuple36, 53
31Literal
32ExprTuple36, 37
33Operationoperator: 60
operands: 38
34Operationoperator: 49
operand: 43
35Operationoperator: 40
operands: 41
36Variable
37Literal
38ExprTuple62, 42
39ExprTuple43
40Literal
41ExprTuple44, 45
42Operationoperator: 46
operands: 47
43Literal
44Operationoperator: 60
operands: 48
45Operationoperator: 49
operand: 53
46Literal
47ExprTuple53, 62
48ExprTuple51, 52
49Literal
50ExprTuple53
51Literal
52Operationoperator: 54
operands: 55
53Literal
54Literal
55ExprTuple62, 56, 57, 58, 59
56Literal
57Literal
58Operationoperator: 60
operands: 61
59Literal
60Literal
61ExprTuple62, 63
62Literal
63Operationoperator: 64
operand: 66
64Literal
65ExprTuple66
66Variable