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}")
sub_expr2 = Neg(t)
sub_expr3 = frac(one, sqrt(two))
expr = ExprTuple(Output(state = ScalarMult(sub_expr3, VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, Exp(two, Neg(Add(sub_expr2, one))), _phase)), ket1)))), ExprRange(sub_expr1, Output(state = ScalarMult(sub_expr3, VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, Exp(two, Neg(sub_expr1)), _phase)), ket1)))), Add(sub_expr2, two), 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^{-\left(-t + 1\right)} \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}, \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 - 3} \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, 3
1Operationoperator: 22
operands: 4
2ExprRangelambda_map: 5
start_index: 6
end_index: 50
3ExprRangelambda_map: 7
start_index: 80
end_index: 42
4NamedExprsstate: 8
5Lambdaparameter: 81
body: 9
6Operationoperator: 76
operands: 10
7Lambdaparameter: 81
body: 11
8Operationoperator: 46
operands: 12
9Operationoperator: 22
operands: 13
10ExprTuple79, 74
11Operationoperator: 14
operands: 15
12ExprTuple27, 16
13NamedExprsstate: 17
14Literal
15NamedExprselement: 18
targets: 19
16Operationoperator: 34
operands: 20
17Operationoperator: 46
operands: 21
18Operationoperator: 22
operands: 23
19Operationoperator: 24
operands: 25
20ExprTuple40, 26
21ExprTuple27, 28
22Literal
23NamedExprsstate: 29
part: 81
24Literal
25ExprTuple30, 31
26Operationoperator: 46
operands: 32
27Operationoperator: 54
operands: 33
28Operationoperator: 34
operands: 35
29Literal
30Operationoperator: 76
operands: 36
31Operationoperator: 76
operands: 37
32ExprTuple38, 52
33ExprTuple80, 39
34Literal
35ExprTuple40, 41
36ExprTuple84, 80
37ExprTuple84, 42
38Operationoperator: 71
operands: 43
39Operationoperator: 71
operands: 44
40Operationoperator: 57
operand: 50
41Operationoperator: 46
operands: 47
42Literal
43ExprTuple60, 48
44ExprTuple74, 49
45ExprTuple50
46Literal
47ExprTuple51, 52
48Operationoperator: 63
operands: 53
49Operationoperator: 54
operands: 55
50Literal
51Operationoperator: 71
operands: 56
52Operationoperator: 57
operand: 80
53ExprTuple74, 66, 67, 59, 69
54Literal
55ExprTuple80, 74
56ExprTuple60, 61
57Literal
58ExprTuple80
59Operationoperator: 71
operands: 62
60Literal
61Operationoperator: 63
operands: 64
62ExprTuple74, 65
63Literal
64ExprTuple74, 66, 67, 68, 69
65Operationoperator: 82
operand: 73
66Literal
67Literal
68Operationoperator: 71
operands: 72
69Literal
70ExprTuple73
71Literal
72ExprTuple74, 75
73Operationoperator: 76
operands: 77
74Literal
75Operationoperator: 82
operand: 81
76Literal
77ExprTuple79, 80
78ExprTuple81
79Operationoperator: 82
operand: 84
80Literal
81Variable
82Literal
83ExprTuple84
84Variable