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, 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 = Add(sub_expr2, one)
sub_expr4 = frac(one, sqrt(two))
sub_expr5 = ScalarMult(sub_expr4, VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, Exp(two, Neg(sub_expr1)), _phase)), ket1)))
expr = Equals(TensorProd(ScalarMult(sub_expr4, VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, Exp(two, Neg(sub_expr3)), _phase)), ket1))), ExprRange(sub_expr1, sub_expr5, Add(sub_expr2, two), zero).with_decreasing_order(), _ket_u), TensorProd(ExprRange(sub_expr1, sub_expr5, sub_expr3, 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(\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){\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}  \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) {\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) {\otimes} \lvert u \rangle\right) = \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) {\otimes} \lvert u \rangle\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',)
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: 6
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9, 11
6Literal
7ExprTuple10, 11
8Operationoperator: 34
operands: 12
9ExprRangelambda_map: 14
start_index: 13
end_index: 38
10ExprRangelambda_map: 14
start_index: 61
end_index: 38
11Literal
12ExprTuple21, 15
13Operationoperator: 64
operands: 16
14Lambdaparameter: 69
body: 17
15Operationoperator: 25
operands: 18
16ExprTuple67, 62
17Operationoperator: 34
operands: 19
18ExprTuple29, 20
19ExprTuple21, 22
20Operationoperator: 34
operands: 23
21Operationoperator: 42
operands: 24
22Operationoperator: 25
operands: 26
23ExprTuple27, 40
24ExprTuple68, 28
25Literal
26ExprTuple29, 30
27Operationoperator: 59
operands: 31
28Operationoperator: 59
operands: 32
29Operationoperator: 45
operand: 38
30Operationoperator: 34
operands: 35
31ExprTuple48, 36
32ExprTuple62, 37
33ExprTuple38
34Literal
35ExprTuple39, 40
36Operationoperator: 51
operands: 41
37Operationoperator: 42
operands: 43
38Literal
39Operationoperator: 59
operands: 44
40Operationoperator: 45
operand: 68
41ExprTuple62, 54, 55, 47, 57
42Literal
43ExprTuple68, 62
44ExprTuple48, 49
45Literal
46ExprTuple68
47Operationoperator: 59
operands: 50
48Literal
49Operationoperator: 51
operands: 52
50ExprTuple62, 53
51Literal
52ExprTuple62, 54, 55, 56, 57
53Operationoperator: 70
operand: 61
54Literal
55Literal
56Operationoperator: 59
operands: 60
57Literal
58ExprTuple61
59Literal
60ExprTuple62, 63
61Operationoperator: 64
operands: 65
62Literal
63Operationoperator: 70
operand: 69
64Literal
65ExprTuple67, 68
66ExprTuple69
67Operationoperator: 70
operand: 72
68Literal
69Variable
70Literal
71ExprTuple72
72Variable