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 = Exp(e, Mult(two, pi, i, _phase, k))
sub_expr3 = ScalarMult(sub_expr2, NumKet(k, Add(t, one)))
sub_expr4 = Interval(zero, subtract(two_pow_t, one))
expr = Equals(VecSum(index_or_indices = sub_expr1, summand = sub_expr3, domain = Interval(zero, subtract(Mult(two, two_pow_t), one))), VecAdd(VecSum(index_or_indices = sub_expr1, summand = sub_expr3, domain = sub_expr4), ScalarMult(Exp(e, Mult(two, pi, i, _phase, two_pow_t)), TensorProd(ket1, VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr2, NumKet(k, t)), domain = sub_expr4)))))
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(\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)
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: 32
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple9, 10
8Lambdaparameter: 70
body: 11
9Operationoperator: 32
operand: 15
10Operationoperator: 47
operands: 13
11Conditionalvalue: 24
condition: 14
12ExprTuple15
13ExprTuple16, 17
14Operationoperator: 49
operands: 18
15Lambdaparameter: 70
body: 19
16Operationoperator: 73
operands: 20
17Operationoperator: 21
operands: 22
18ExprTuple70, 23
19Conditionalvalue: 24
condition: 44
20ExprTuple59, 25
21Literal
22ExprTuple26, 27
23Operationoperator: 57
operands: 28
24Operationoperator: 47
operands: 29
25Operationoperator: 63
operands: 30
26Operationoperator: 31
operand: 79
27Operationoperator: 32
operand: 36
28ExprTuple61, 34
29ExprTuple51, 35
30ExprTuple77, 67, 68, 69, 71
31Literal
32Literal
33ExprTuple36
34Operationoperator: 65
operands: 37
35Operationoperator: 55
operands: 38
36Lambdaparameter: 70
body: 40
37ExprTuple41, 72
38ExprTuple70, 42
39ExprTuple70
40Conditionalvalue: 43
condition: 44
41Operationoperator: 63
operands: 45
42Operationoperator: 65
operands: 46
43Operationoperator: 47
operands: 48
44Operationoperator: 49
operands: 50
45ExprTuple77, 71
46ExprTuple78, 79
47Literal
48ExprTuple51, 52
49Literal
50ExprTuple70, 53
51Operationoperator: 73
operands: 54
52Operationoperator: 55
operands: 56
53Operationoperator: 57
operands: 58
54ExprTuple59, 60
55Literal
56ExprTuple70, 78
57Literal
58ExprTuple61, 62
59Literal
60Operationoperator: 63
operands: 64
61Literal
62Operationoperator: 65
operands: 66
63Literal
64ExprTuple77, 67, 68, 69, 70
65Literal
66ExprTuple71, 72
67Literal
68Literal
69Literal
70Variable
71Operationoperator: 73
operands: 74
72Operationoperator: 75
operand: 79
73Literal
74ExprTuple77, 78
75Literal
76ExprTuple79
77Literal
78Variable
79Literal