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 Variable, k, t
from proveit.linear_algebra import ScalarMult, TensorProd, VecAdd, VecSum
from proveit.logic import Equals
from proveit.numbers import Add, Exp, Interval, Mult, e, frac, i, one, pi, subtract, two, zero
from proveit.physics.quantum import NumKet, ket0, ket1
from proveit.physics.quantum.QPE import _phase, two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Add(t, one)
sub_expr2 = frac(sub_expr1, two)
expr = Equals(ScalarMult(frac(one, Exp(two, sub_expr2)), VecSum(index_or_indices = [k], summand = ScalarMult(Exp(e, Mult(two, pi, i, _phase, k)), NumKet(k, sub_expr1)), domain = Interval(zero, subtract(Mult(two, two_pow_t), one)))), TensorProd(ScalarMult(frac(one, Exp(two, subtract(sub_expr2, frac(t, two)))), VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, _phase, two_pow_t)), ket1))), Variable("_a", latex_format = r"{_{-}a}")))
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}}} \cdot \left(\sum_{k=0}^{\left(2 \cdot 2^{t}\right) - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \lvert k \rangle_{t + 1}\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} {_{-}a}\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: 36
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple10, 11
8Operationoperator: 78
operands: 12
9Operationoperator: 13
operand: 17
10Operationoperator: 36
operands: 15
11Variable
12ExprTuple81, 16
13Literal
14ExprTuple17
15ExprTuple18, 19
16Operationoperator: 82
operands: 20
17Lambdaparameter: 64
body: 22
18Operationoperator: 78
operands: 23
19Operationoperator: 24
operands: 25
20ExprTuple84, 55
21ExprTuple64
22Conditionalvalue: 26
condition: 27
23ExprTuple81, 28
24Literal
25ExprTuple29, 30
26Operationoperator: 36
operands: 31
27Operationoperator: 32
operands: 33
28Operationoperator: 82
operands: 34
29Operationoperator: 51
operand: 53
30Operationoperator: 36
operands: 37
31ExprTuple38, 39
32Literal
33ExprTuple64, 40
34ExprTuple84, 41
35ExprTuple53
36Literal
37ExprTuple42, 43
38Operationoperator: 82
operands: 44
39Operationoperator: 45
operands: 46
40Operationoperator: 47
operands: 48
41Operationoperator: 76
operands: 49
42Operationoperator: 82
operands: 50
43Operationoperator: 51
operand: 81
44ExprTuple57, 52
45Literal
46ExprTuple64, 67
47Literal
48ExprTuple53, 54
49ExprTuple55, 56
50ExprTuple57, 58
51Literal
52Operationoperator: 72
operands: 59
53Literal
54Operationoperator: 76
operands: 60
55Operationoperator: 78
operands: 61
56Operationoperator: 74
operand: 68
57Literal
58Operationoperator: 72
operands: 63
59ExprTuple84, 69, 70, 71, 64
60ExprTuple65, 66
61ExprTuple67, 84
62ExprTuple68
63ExprTuple84, 69, 70, 71, 80
64Variable
65Operationoperator: 72
operands: 73
66Operationoperator: 74
operand: 81
67Operationoperator: 76
operands: 77
68Operationoperator: 78
operands: 79
69Literal
70Literal
71Literal
72Literal
73ExprTuple84, 80
74Literal
75ExprTuple81
76Literal
77ExprTuple85, 81
78Literal
79ExprTuple85, 84
80Operationoperator: 82
operands: 83
81Literal
82Literal
83ExprTuple84, 85
84Literal
85Variable