logo

Expression of type TensorProd

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, 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 = TensorProd(ScalarMult(frac(one, Exp(two, subtract(frac(Add(t, one), two), frac(t, two)))), 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}}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot 2^{t}} \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 - 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)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()()('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple3, 4
3Operationoperator: 35
operands: 5
4ExprRangelambda_map: 6
start_index: 7
end_index: 41
5ExprTuple8, 9
6Lambdaparameter: 75
body: 10
7Operationoperator: 56
operands: 11
8Operationoperator: 58
operands: 12
9Operationoperator: 24
operands: 13
10Operationoperator: 35
operands: 14
11ExprTuple15, 63
12ExprTuple63, 16
13ExprTuple29, 17
14ExprTuple18, 19
15Operationoperator: 73
operand: 64
16Operationoperator: 69
operands: 21
17Operationoperator: 35
operands: 22
18Operationoperator: 58
operands: 23
19Operationoperator: 24
operands: 25
20ExprTuple64
21ExprTuple71, 26
22ExprTuple27, 43
23ExprTuple63, 28
24Literal
25ExprTuple29, 30
26Operationoperator: 56
operands: 31
27Operationoperator: 69
operands: 32
28Operationoperator: 69
operands: 33
29Operationoperator: 49
operand: 41
30Operationoperator: 35
operands: 36
31ExprTuple37, 38
32ExprTuple54, 39
33ExprTuple71, 40
34ExprTuple41
35Literal
36ExprTuple42, 43
37Operationoperator: 58
operands: 44
38Operationoperator: 73
operand: 52
39Operationoperator: 61
operands: 46
40Operationoperator: 58
operands: 47
41Literal
42Operationoperator: 69
operands: 48
43Operationoperator: 49
operand: 63
44ExprTuple51, 71
45ExprTuple52
46ExprTuple71, 65, 66, 68, 53
47ExprTuple63, 71
48ExprTuple54, 55
49Literal
50ExprTuple63
51Operationoperator: 56
operands: 57
52Operationoperator: 58
operands: 59
53Operationoperator: 69
operands: 60
54Literal
55Operationoperator: 61
operands: 62
56Literal
57ExprTuple64, 63
58Literal
59ExprTuple64, 71
60ExprTuple71, 64
61Literal
62ExprTuple71, 65, 66, 67, 68
63Literal
64Variable
65Literal
66Literal
67Operationoperator: 69
operands: 70
68Literal
69Literal
70ExprTuple71, 72
71Literal
72Operationoperator: 73
operand: 75
73Literal
74ExprTuple75
75Variable