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, 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 = [k]
sub_expr2 = Add(t, one)
sub_expr3 = Exp(e, Mult(two, pi, i, _phase, k))
sub_expr4 = frac(one, Exp(two, frac(sub_expr2, two)))
sub_expr5 = VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr3, NumKet(k, t)), domain = Interval(zero, subtract(two_pow_t, one)))
expr = Equals(ScalarMult(sub_expr4, VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr3, NumKet(k, sub_expr2)), domain = Interval(zero, subtract(Mult(two, two_pow_t), one)))), ScalarMult(sub_expr4, VecAdd(TensorProd(ket0, sub_expr5), ScalarMult(Exp(e, Mult(two, pi, i, _phase, two_pow_t)), TensorProd(ket1, sub_expr5)))))
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(\frac{1}{2^{\frac{t + 1}{2}}} \cdot \left(\left(\lvert 0 \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) + \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: 1
operands: 2
1Literal
2ExprTuple3, 4
3Operationoperator: 58
operands: 5
4Operationoperator: 58
operands: 6
5ExprTuple8, 7
6ExprTuple8, 9
7Operationoperator: 45
operand: 14
8Operationoperator: 30
operands: 11
9Operationoperator: 12
operands: 13
10ExprTuple14
11ExprTuple90, 15
12Literal
13ExprTuple16, 17
14Lambdaparameter: 81
body: 18
15Operationoperator: 84
operands: 19
16Operationoperator: 34
operands: 20
17Operationoperator: 58
operands: 21
18Conditionalvalue: 22
condition: 23
19ExprTuple88, 24
20ExprTuple25, 40
21ExprTuple26, 27
22Operationoperator: 58
operands: 28
23Operationoperator: 60
operands: 29
24Operationoperator: 30
operands: 31
25Operationoperator: 44
operand: 72
26Operationoperator: 84
operands: 33
27Operationoperator: 34
operands: 35
28ExprTuple62, 36
29ExprTuple81, 37
30Literal
31ExprTuple47, 88
32ExprTuple72
33ExprTuple70, 38
34Literal
35ExprTuple39, 40
36Operationoperator: 66
operands: 41
37Operationoperator: 68
operands: 42
38Operationoperator: 74
operands: 43
39Operationoperator: 44
operand: 90
40Operationoperator: 45
operand: 49
41ExprTuple81, 47
42ExprTuple72, 48
43ExprTuple88, 78, 79, 80, 82
44Literal
45Literal
46ExprTuple49
47Operationoperator: 76
operands: 50
48Operationoperator: 76
operands: 51
49Lambdaparameter: 81
body: 53
50ExprTuple89, 90
51ExprTuple54, 83
52ExprTuple81
53Conditionalvalue: 55
condition: 56
54Operationoperator: 74
operands: 57
55Operationoperator: 58
operands: 59
56Operationoperator: 60
operands: 61
57ExprTuple88, 82
58Literal
59ExprTuple62, 63
60Literal
61ExprTuple81, 64
62Operationoperator: 84
operands: 65
63Operationoperator: 66
operands: 67
64Operationoperator: 68
operands: 69
65ExprTuple70, 71
66Literal
67ExprTuple81, 89
68Literal
69ExprTuple72, 73
70Literal
71Operationoperator: 74
operands: 75
72Literal
73Operationoperator: 76
operands: 77
74Literal
75ExprTuple88, 78, 79, 80, 81
76Literal
77ExprTuple82, 83
78Literal
79Literal
80Literal
81Variable
82Operationoperator: 84
operands: 85
83Operationoperator: 86
operand: 90
84Literal
85ExprTuple88, 89
86Literal
87ExprTuple90
88Literal
89Variable
90Literal