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 = frac(one, sqrt(two))
sub_expr3 = ExprRange(sub_expr1, ScalarMult(sub_expr2, 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(ScalarMult(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)), sub_expr3)), ScalarMult(sub_expr2, TensorProd(VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, two_pow_t, _phase)), ket1)), sub_expr3)))
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(\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)\right) = \left(\frac{1}{\sqrt{2}} \cdot \left(\left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{t} \cdot \varphi} \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)\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: 61
operands: 5
4Operationoperator: 61
operands: 6
5ExprTuple7, 8
6ExprTuple37, 9
7Operationoperator: 69
operands: 10
8Operationoperator: 12
operands: 11
9Operationoperator: 12
operands: 13
10ExprTuple77, 14
11ExprTuple15, 17
12Literal
13ExprTuple16, 17
14Operationoperator: 84
operands: 18
15Operationoperator: 45
operands: 19
16Operationoperator: 45
operands: 20
17ExprRangelambda_map: 21
start_index: 22
end_index: 65
18ExprTuple86, 23
19ExprTuple52, 24
20ExprTuple52, 25
21Lambdaparameter: 90
body: 26
22Operationoperator: 54
operands: 27
23Operationoperator: 54
operands: 28
24Operationoperator: 61
operands: 29
25Operationoperator: 61
operands: 30
26Operationoperator: 61
operands: 31
27ExprTuple32, 77
28ExprTuple33, 34
29ExprTuple35, 67
30ExprTuple36, 67
31ExprTuple37, 38
32Operationoperator: 88
operand: 74
33Operationoperator: 69
operands: 40
34Operationoperator: 88
operand: 48
35Operationoperator: 84
operands: 42
36Operationoperator: 84
operands: 43
37Operationoperator: 69
operands: 44
38Operationoperator: 45
operands: 46
39ExprTuple74
40ExprTuple47, 86
41ExprTuple48
42ExprTuple75, 49
43ExprTuple75, 50
44ExprTuple77, 51
45Literal
46ExprTuple52, 53
47Operationoperator: 54
operands: 55
48Operationoperator: 69
operands: 56
49Operationoperator: 78
operands: 57
50Operationoperator: 78
operands: 58
51Operationoperator: 84
operands: 59
52Operationoperator: 72
operand: 65
53Operationoperator: 61
operands: 62
54Literal
55ExprTuple74, 77
56ExprTuple74, 86
57ExprTuple86, 80, 81, 83, 63
58ExprTuple86, 80, 81, 63, 83
59ExprTuple86, 64
60ExprTuple65
61Literal
62ExprTuple66, 67
63Operationoperator: 84
operands: 68
64Operationoperator: 69
operands: 70
65Literal
66Operationoperator: 84
operands: 71
67Operationoperator: 72
operand: 77
68ExprTuple86, 74
69Literal
70ExprTuple77, 86
71ExprTuple75, 76
72Literal
73ExprTuple77
74Variable
75Literal
76Operationoperator: 78
operands: 79
77Literal
78Literal
79ExprTuple86, 80, 81, 82, 83
80Literal
81Literal
82Operationoperator: 84
operands: 85
83Literal
84Literal
85ExprTuple86, 87
86Literal
87Operationoperator: 88
operand: 90
88Literal
89ExprTuple90
90Variable