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 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, i, one, pi, subtract, two, zero
from proveit.physics.quantum import NumKet, ket1
from proveit.physics.quantum.QPE import _phase, two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [k]
sub_expr2 = Add(t, one)
sub_expr3 = Exp(e, Mult(two, pi, i, _phase, k))
sub_expr4 = Add(k, two_pow_t)
sub_expr5 = ScalarMult(sub_expr3, NumKet(k, sub_expr2))
sub_expr6 = Interval(zero, subtract(two_pow_t, one))
sub_expr7 = VecSum(index_or_indices = sub_expr1, summand = sub_expr5, domain = sub_expr6)
sub_expr8 = VecSum(index_or_indices = sub_expr1, summand = sub_expr5, domain = Interval(zero, subtract(Mult(two, two_pow_t), one)))
expr = Equals(Equals(sub_expr8, VecAdd(sub_expr7, VecSum(index_or_indices = sub_expr1, summand = ScalarMult(Exp(e, Mult(two, pi, i, _phase, sub_expr4)), NumKet(sub_expr4, sub_expr2)), domain = sub_expr6))), Equals(sub_expr8, VecAdd(sub_expr7, ScalarMult(Exp(e, Mult(two, pi, i, _phase, two_pow_t)), TensorProd(ket1, VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr3, NumKet(k, t)), domain = sub_expr6))))))
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(\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) = \left(\left(\sum_{k=0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \lvert k \rangle_{t + 1}\right)\right) + \left(\sum_{k=0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot \left(k + 2^{t}\right)} \cdot \lvert k + 2^{t} \rangle_{t + 1}\right)\right)\right)\right) = \left(\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) = \left(\left(\sum_{k=0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \lvert k \rangle_{t + 1}\right)\right) + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot 2^{t}} \cdot \left(\lvert 1 \rangle {\otimes} \left(\sum_{k=0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \lvert k \rangle_{t}\right)\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: 5
operands: 1
1ExprTuple2, 3
2Operationoperator: 5
operands: 4
3Operationoperator: 5
operands: 6
4ExprTuple8, 7
5Literal
6ExprTuple8, 9
7Operationoperator: 12
operands: 10
8Operationoperator: 44
operand: 15
9Operationoperator: 12
operands: 13
10ExprTuple16, 14
11ExprTuple15
12Literal
13ExprTuple16, 17
14Operationoperator: 44
operand: 22
15Lambdaparameter: 90
body: 19
16Operationoperator: 44
operand: 24
17Operationoperator: 65
operands: 21
18ExprTuple22
19Conditionalvalue: 35
condition: 23
20ExprTuple24
21ExprTuple25, 26
22Lambdaparameter: 90
body: 27
23Operationoperator: 67
operands: 28
24Lambdaparameter: 90
body: 29
25Operationoperator: 93
operands: 30
26Operationoperator: 31
operands: 32
27Conditionalvalue: 33
condition: 61
28ExprTuple90, 34
29Conditionalvalue: 35
condition: 61
30ExprTuple79, 36
31Literal
32ExprTuple37, 38
33Operationoperator: 65
operands: 39
34Operationoperator: 77
operands: 40
35Operationoperator: 65
operands: 41
36Operationoperator: 83
operands: 42
37Operationoperator: 43
operand: 99
38Operationoperator: 44
operand: 50
39ExprTuple46, 47
40ExprTuple81, 48
41ExprTuple70, 49
42ExprTuple97, 87, 88, 89, 91
43Literal
44Literal
45ExprTuple50
46Operationoperator: 93
operands: 51
47Operationoperator: 75
operands: 52
48Operationoperator: 85
operands: 53
49Operationoperator: 75
operands: 54
50Lambdaparameter: 90
body: 56
51ExprTuple79, 57
52ExprTuple69, 59
53ExprTuple58, 92
54ExprTuple90, 59
55ExprTuple90
56Conditionalvalue: 60
condition: 61
57Operationoperator: 83
operands: 62
58Operationoperator: 83
operands: 63
59Operationoperator: 85
operands: 64
60Operationoperator: 65
operands: 66
61Operationoperator: 67
operands: 68
62ExprTuple97, 87, 88, 89, 69
63ExprTuple97, 91
64ExprTuple98, 99
65Literal
66ExprTuple70, 71
67Literal
68ExprTuple90, 72
69Operationoperator: 85
operands: 73
70Operationoperator: 93
operands: 74
71Operationoperator: 75
operands: 76
72Operationoperator: 77
operands: 78
73ExprTuple90, 91
74ExprTuple79, 80
75Literal
76ExprTuple90, 98
77Literal
78ExprTuple81, 82
79Literal
80Operationoperator: 83
operands: 84
81Literal
82Operationoperator: 85
operands: 86
83Literal
84ExprTuple97, 87, 88, 89, 90
85Literal
86ExprTuple91, 92
87Literal
88Literal
89Literal
90Variable
91Operationoperator: 93
operands: 94
92Operationoperator: 95
operand: 99
93Literal
94ExprTuple97, 98
95Literal
96ExprTuple99
97Literal
98Variable
99Literal