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, 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
from proveit.physics.quantum.QPE import _phase, two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [k]
sub_expr2 = ScalarMult(Exp(e, Mult(two, pi, i, _phase, k)), NumKet(k, Add(t, one)))
expr = Equals(VecSum(index_or_indices = sub_expr1, summand = sub_expr2, domain = Interval(zero, subtract(Mult(two, two_pow_t), one))), VecAdd(VecSum(index_or_indices = sub_expr1, summand = sub_expr2, domain = Interval(zero, subtract(two_pow_t, one))), 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(\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) + {_{-}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: 12
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple9, 10
8Lambdaparameter: 52
body: 11
9Operationoperator: 12
operand: 15
10Variable
11Conditionalvalue: 20
condition: 14
12Literal
13ExprTuple15
14Operationoperator: 25
operands: 16
15Lambdaparameter: 52
body: 18
16ExprTuple52, 19
17ExprTuple52
18Conditionalvalue: 20
condition: 21
19Operationoperator: 35
operands: 22
20Operationoperator: 23
operands: 24
21Operationoperator: 25
operands: 26
22ExprTuple41, 27
23Literal
24ExprTuple28, 29
25Literal
26ExprTuple52, 30
27Operationoperator: 47
operands: 31
28Operationoperator: 55
operands: 32
29Operationoperator: 33
operands: 34
30Operationoperator: 35
operands: 36
31ExprTuple37, 54
32ExprTuple38, 39
33Literal
34ExprTuple52, 40
35Literal
36ExprTuple41, 42
37Operationoperator: 44
operands: 43
38Literal
39Operationoperator: 44
operands: 45
40Operationoperator: 47
operands: 46
41Literal
42Operationoperator: 47
operands: 48
43ExprTuple59, 53
44Literal
45ExprTuple59, 49, 50, 51, 52
46ExprTuple60, 61
47Literal
48ExprTuple53, 54
49Literal
50Literal
51Literal
52Variable
53Operationoperator: 55
operands: 56
54Operationoperator: 57
operand: 61
55Literal
56ExprTuple59, 60
57Literal
58ExprTuple61
59Literal
60Variable
61Literal