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, 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
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(ScalarMult(sub_expr3, VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, Exp(two, Neg(Add(sub_expr2, one))), _phase)), ket1))), ExprRange(sub_expr1, 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(), _ket_u)
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(\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),\left(\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)\right), \left(\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)\right), \ldots, \left(\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)\right), \lvert u \rangle\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: 26
operands: 4
2ExprRangelambda_map: 5
start_index: 6
end_index: 30
3Literal
4ExprTuple13, 7
5Lambdaparameter: 61
body: 8
6Operationoperator: 56
operands: 9
7Operationoperator: 17
operands: 10
8Operationoperator: 26
operands: 11
9ExprTuple59, 54
10ExprTuple21, 12
11ExprTuple13, 14
12Operationoperator: 26
operands: 15
13Operationoperator: 34
operands: 16
14Operationoperator: 17
operands: 18
15ExprTuple19, 32
16ExprTuple60, 20
17Literal
18ExprTuple21, 22
19Operationoperator: 51
operands: 23
20Operationoperator: 51
operands: 24
21Operationoperator: 37
operand: 30
22Operationoperator: 26
operands: 27
23ExprTuple40, 28
24ExprTuple54, 29
25ExprTuple30
26Literal
27ExprTuple31, 32
28Operationoperator: 43
operands: 33
29Operationoperator: 34
operands: 35
30Literal
31Operationoperator: 51
operands: 36
32Operationoperator: 37
operand: 60
33ExprTuple54, 46, 47, 39, 49
34Literal
35ExprTuple60, 54
36ExprTuple40, 41
37Literal
38ExprTuple60
39Operationoperator: 51
operands: 42
40Literal
41Operationoperator: 43
operands: 44
42ExprTuple54, 45
43Literal
44ExprTuple54, 46, 47, 48, 49
45Operationoperator: 62
operand: 53
46Literal
47Literal
48Operationoperator: 51
operands: 52
49Literal
50ExprTuple53
51Literal
52ExprTuple54, 55
53Operationoperator: 56
operands: 57
54Literal
55Operationoperator: 62
operand: 61
56Literal
57ExprTuple59, 60
58ExprTuple61
59Operationoperator: 62
operand: 64
60Literal
61Variable
62Literal
63ExprTuple64
64Variable