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, TensorProd, VecAdd
from proveit.numbers import Add, Exp, Mult, Neg, e, frac, i, one, pi, sqrt, subtract, 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}")
expr = ExprTuple(frac(one, Exp(two, subtract(frac(Add(t, one), two), frac(t, two)))), TensorProd(VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, _phase, two_pow_t)), ket1)), ExprRange(sub_expr1, 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()))
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}{2^{\frac{t + 1}{2} - \frac{t}{2}}}, \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot 2^{t}} \cdot \lvert 1 \rangle\right)\right){\otimes} \left(\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)\right) {\otimes}  \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) {\otimes}  \ldots {\otimes}  \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)
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
1Operationoperator: 53
operands: 3
2Operationoperator: 4
operands: 5
3ExprTuple61, 6
4Literal
5ExprTuple7, 8
6Operationoperator: 68
operands: 9
7Operationoperator: 31
operands: 10
8ExprRangelambda_map: 11
start_index: 12
end_index: 49
9ExprTuple70, 13
10ExprTuple37, 14
11Lambdaparameter: 74
body: 15
12Operationoperator: 39
operands: 16
13Operationoperator: 39
operands: 17
14Operationoperator: 45
operands: 18
15Operationoperator: 45
operands: 19
16ExprTuple20, 61
17ExprTuple21, 22
18ExprTuple23, 51
19ExprTuple24, 25
20Operationoperator: 72
operand: 58
21Operationoperator: 53
operands: 27
22Operationoperator: 72
operand: 34
23Operationoperator: 68
operands: 29
24Operationoperator: 53
operands: 30
25Operationoperator: 31
operands: 32
26ExprTuple58
27ExprTuple33, 70
28ExprTuple34
29ExprTuple59, 35
30ExprTuple61, 36
31Literal
32ExprTuple37, 38
33Operationoperator: 39
operands: 40
34Operationoperator: 53
operands: 41
35Operationoperator: 62
operands: 42
36Operationoperator: 68
operands: 43
37Operationoperator: 56
operand: 49
38Operationoperator: 45
operands: 46
39Literal
40ExprTuple58, 61
41ExprTuple58, 70
42ExprTuple70, 64, 65, 67, 47
43ExprTuple70, 48
44ExprTuple49
45Literal
46ExprTuple50, 51
47Operationoperator: 68
operands: 52
48Operationoperator: 53
operands: 54
49Literal
50Operationoperator: 68
operands: 55
51Operationoperator: 56
operand: 61
52ExprTuple70, 58
53Literal
54ExprTuple61, 70
55ExprTuple59, 60
56Literal
57ExprTuple61
58Variable
59Literal
60Operationoperator: 62
operands: 63
61Literal
62Literal
63ExprTuple70, 64, 65, 66, 67
64Literal
65Literal
66Operationoperator: 68
operands: 69
67Literal
68Literal
69ExprTuple70, 71
70Literal
71Operationoperator: 72
operand: 74
72Literal
73ExprTuple74
74Variable