logo

Expression of type Equals

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.logic import Equals
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}")
sub_expr2 = 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)))
sub_expr3 = 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 = Equals(TensorProd(sub_expr2, TensorProd(sub_expr3)), TensorProd(sub_expr2, sub_expr3)).with_wrapping_at(1)
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())
\begin{array}{c} \begin{array}{l} \left(\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(\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)\right) \\  = \left(\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)\right) \end{array} \end{array}
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.()(1)('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',)
directionDirection of the relation (normal or reversed)normalnormal('with_direction_reversed', 'is_reversed')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple3, 4
3Operationoperator: 9
operands: 5
4Operationoperator: 9
operands: 6
5ExprTuple8, 7
6ExprTuple8, 12
7Operationoperator: 9
operands: 10
8Operationoperator: 45
operands: 11
9Literal
10ExprTuple12
11ExprTuple13, 14
12ExprRangelambda_map: 15
start_index: 16
end_index: 51
13Operationoperator: 63
operands: 17
14Operationoperator: 33
operands: 18
15Lambdaparameter: 82
body: 19
16Operationoperator: 61
operands: 20
17ExprTuple68, 21
18ExprTuple38, 22
19Operationoperator: 45
operands: 23
20ExprTuple24, 68
21Operationoperator: 76
operands: 25
22Operationoperator: 45
operands: 26
23ExprTuple27, 28
24Operationoperator: 80
operand: 69
25ExprTuple78, 30
26ExprTuple31, 53
27Operationoperator: 63
operands: 32
28Operationoperator: 33
operands: 34
29ExprTuple69
30Operationoperator: 61
operands: 35
31Operationoperator: 76
operands: 36
32ExprTuple68, 37
33Literal
34ExprTuple38, 39
35ExprTuple40, 41
36ExprTuple66, 42
37Operationoperator: 76
operands: 43
38Operationoperator: 59
operand: 51
39Operationoperator: 45
operands: 46
40Operationoperator: 63
operands: 47
41Operationoperator: 80
operand: 55
42Operationoperator: 70
operands: 49
43ExprTuple78, 50
44ExprTuple51
45Literal
46ExprTuple52, 53
47ExprTuple54, 78
48ExprTuple55
49ExprTuple78, 72, 73, 75, 56
50Operationoperator: 63
operands: 57
51Literal
52Operationoperator: 76
operands: 58
53Operationoperator: 59
operand: 68
54Operationoperator: 61
operands: 62
55Operationoperator: 63
operands: 64
56Operationoperator: 76
operands: 65
57ExprTuple68, 78
58ExprTuple66, 67
59Literal
60ExprTuple68
61Literal
62ExprTuple69, 68
63Literal
64ExprTuple69, 78
65ExprTuple78, 69
66Literal
67Operationoperator: 70
operands: 71
68Literal
69Variable
70Literal
71ExprTuple78, 72, 73, 74, 75
72Literal
73Literal
74Operationoperator: 76
operands: 77
75Literal
76Literal
77ExprTuple78, 79
78Literal
79Operationoperator: 80
operand: 82
80Literal
81ExprTuple82
82Variable