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.core_expr_types import Len
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}")
expr = Equals(Len(operands = [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())]), Len(operands = [ExprRange(sub_expr1, sub_expr1, one, two)]))
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)| = |\left(1, \ldots, 2\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
6Literal
7ExprTuple10
8Operationoperator: 62
operands: 11
9Operationoperator: 12
operands: 13
10ExprRangelambda_map: 14
start_index: 70
end_index: 79
11ExprTuple70, 15
12Literal
13ExprTuple16, 17
14Lambdaparameter: 83
body: 83
15Operationoperator: 77
operands: 18
16Operationoperator: 40
operands: 19
17ExprRangelambda_map: 20
start_index: 21
end_index: 58
18ExprTuple79, 22
19ExprTuple46, 23
20Lambdaparameter: 83
body: 24
21Operationoperator: 48
operands: 25
22Operationoperator: 48
operands: 26
23Operationoperator: 54
operands: 27
24Operationoperator: 54
operands: 28
25ExprTuple29, 70
26ExprTuple30, 31
27ExprTuple32, 60
28ExprTuple33, 34
29Operationoperator: 81
operand: 67
30Operationoperator: 62
operands: 36
31Operationoperator: 81
operand: 43
32Operationoperator: 77
operands: 38
33Operationoperator: 62
operands: 39
34Operationoperator: 40
operands: 41
35ExprTuple67
36ExprTuple42, 79
37ExprTuple43
38ExprTuple68, 44
39ExprTuple70, 45
40Literal
41ExprTuple46, 47
42Operationoperator: 48
operands: 49
43Operationoperator: 62
operands: 50
44Operationoperator: 71
operands: 51
45Operationoperator: 77
operands: 52
46Operationoperator: 65
operand: 58
47Operationoperator: 54
operands: 55
48Literal
49ExprTuple67, 70
50ExprTuple67, 79
51ExprTuple79, 73, 74, 76, 56
52ExprTuple79, 57
53ExprTuple58
54Literal
55ExprTuple59, 60
56Operationoperator: 77
operands: 61
57Operationoperator: 62
operands: 63
58Literal
59Operationoperator: 77
operands: 64
60Operationoperator: 65
operand: 70
61ExprTuple79, 67
62Literal
63ExprTuple70, 79
64ExprTuple68, 69
65Literal
66ExprTuple70
67Variable
68Literal
69Operationoperator: 71
operands: 72
70Literal
71Literal
72ExprTuple79, 73, 74, 75, 76
73Literal
74Literal
75Operationoperator: 77
operands: 78
76Literal
77Literal
78ExprTuple79, 80
79Literal
80Operationoperator: 81
operand: 83
81Literal
82ExprTuple83
83Variable