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 Function, 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, 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 = Interval(zero, subtract(two_pow_t, one))
expr = Equals(VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr2, NumKet(k, Add(t, one))), domain = Interval(zero, subtract(Mult(two, two_pow_t), one))), VecAdd(VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr2, Function(Variable("_a", latex_format = r"{_{-}a}"), sub_expr1)), domain = sub_expr3), 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_expr3)))))
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 {_{-}a}\left(k\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)
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
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple9, 10
8Lambdaparameter: 74
body: 11
9Operationoperator: 36
operand: 16
10Operationoperator: 51
operands: 13
11Conditionalvalue: 14
condition: 15
12ExprTuple16
13ExprTuple17, 18
14Operationoperator: 51
operands: 19
15Operationoperator: 53
operands: 20
16Lambdaparameter: 74
body: 21
17Operationoperator: 77
operands: 22
18Operationoperator: 23
operands: 24
19ExprTuple55, 25
20ExprTuple74, 26
21Conditionalvalue: 27
condition: 49
22ExprTuple63, 28
23Literal
24ExprTuple29, 30
25Operationoperator: 59
operands: 31
26Operationoperator: 61
operands: 32
27Operationoperator: 51
operands: 33
28Operationoperator: 67
operands: 34
29Operationoperator: 35
operand: 83
30Operationoperator: 36
operand: 41
31ExprTuple74, 38
32ExprTuple65, 39
33ExprTuple55, 40
34ExprTuple81, 71, 72, 73, 75
35Literal
36Literal
37ExprTuple41
38Operationoperator: 69
operands: 42
39Operationoperator: 69
operands: 43
40Operationoperator: 44
operand: 74
41Lambdaparameter: 74
body: 46
42ExprTuple82, 83
43ExprTuple47, 76
44Variable
45ExprTuple74
46Conditionalvalue: 48
condition: 49
47Operationoperator: 67
operands: 50
48Operationoperator: 51
operands: 52
49Operationoperator: 53
operands: 54
50ExprTuple81, 75
51Literal
52ExprTuple55, 56
53Literal
54ExprTuple74, 57
55Operationoperator: 77
operands: 58
56Operationoperator: 59
operands: 60
57Operationoperator: 61
operands: 62
58ExprTuple63, 64
59Literal
60ExprTuple74, 82
61Literal
62ExprTuple65, 66
63Literal
64Operationoperator: 67
operands: 68
65Literal
66Operationoperator: 69
operands: 70
67Literal
68ExprTuple81, 71, 72, 73, 74
69Literal
70ExprTuple75, 76
71Literal
72Literal
73Literal
74Variable
75Operationoperator: 77
operands: 78
76Operationoperator: 79
operand: 83
77Literal
78ExprTuple81, 82
79Literal
80ExprTuple83
81Literal
82Variable
83Literal