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 _phase, two_pow_t
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))
sub_expr4 = ScalarMult(sub_expr3, VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, Exp(two, Neg(sub_expr1)), _phase)), ket1)))
expr = ExprTuple([ExprRange(sub_expr1, sub_expr4, sub_expr2, zero)], [ScalarMult(sub_expr3, VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, two_pow_t, _phase)), ket1))), ExprRange(sub_expr1, sub_expr4, Add(sub_expr2, one), zero)])
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(\left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{-\left(-t\right)} \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^{-\left(-t + 1\right)} \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)\right), \left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{t} \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^{-\left(-t + 1\right)} \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^{-\left(-t + 2\right)} \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)\right)\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
1ExprTuple3
2ExprTuple4, 5
3ExprRangelambda_map: 7
start_index: 15
end_index: 35
4Operationoperator: 31
operands: 6
5ExprRangelambda_map: 7
start_index: 8
end_index: 35
6ExprTuple17, 9
7Lambdaparameter: 62
body: 10
8Operationoperator: 11
operands: 12
9Operationoperator: 22
operands: 13
10Operationoperator: 31
operands: 14
11Literal
12ExprTuple15, 47
13ExprTuple26, 16
14ExprTuple17, 18
15Operationoperator: 60
operand: 51
16Operationoperator: 31
operands: 20
17Operationoperator: 39
operands: 21
18Operationoperator: 22
operands: 23
19ExprTuple51
20ExprTuple24, 37
21ExprTuple47, 25
22Literal
23ExprTuple26, 27
24Operationoperator: 56
operands: 28
25Operationoperator: 56
operands: 29
26Operationoperator: 42
operand: 35
27Operationoperator: 31
operands: 32
28ExprTuple45, 33
29ExprTuple58, 34
30ExprTuple35
31Literal
32ExprTuple36, 37
33Operationoperator: 49
operands: 38
34Operationoperator: 39
operands: 40
35Literal
36Operationoperator: 56
operands: 41
37Operationoperator: 42
operand: 47
38ExprTuple58, 52, 53, 44, 55
39Literal
40ExprTuple47, 58
41ExprTuple45, 46
42Literal
43ExprTuple47
44Operationoperator: 56
operands: 48
45Literal
46Operationoperator: 49
operands: 50
47Literal
48ExprTuple58, 51
49Literal
50ExprTuple58, 52, 53, 54, 55
51Variable
52Literal
53Literal
54Operationoperator: 56
operands: 57
55Literal
56Literal
57ExprTuple58, 59
58Literal
59Operationoperator: 60
operand: 62
60Literal
61ExprTuple62
62Variable