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 Exp, Interval, Mult, e, 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 = Exp(e, Mult(two, pi, i, _phase, two_pow_t))
sub_expr2 = VecSum(index_or_indices = [k], summand = ScalarMult(Exp(e, Mult(two, pi, i, _phase, k)), NumKet(k, t)), domain = Interval(zero, subtract(two_pow_t, one)))
expr = Equals(VecAdd(TensorProd(ket0, sub_expr2), ScalarMult(sub_expr1, TensorProd(ket1, sub_expr2))), TensorProd(VecAdd(ket0, ScalarMult(sub_expr1, ket1)), sub_expr2))
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(\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) = \left(\left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot 2^{t}} \cdot \lvert 1 \rangle\right)\right) {\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)
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
operands: 5
4Operationoperator: 17
operands: 6
5ExprTuple7, 8
6ExprTuple9, 21
7Operationoperator: 17
operands: 10
8Operationoperator: 35
operands: 11
9Operationoperator: 12
operands: 13
10ExprTuple15, 21
11ExprTuple22, 14
12Literal
13ExprTuple15, 16
14Operationoperator: 17
operands: 18
15Operationoperator: 27
operand: 49
16Operationoperator: 35
operands: 20
17Literal
18ExprTuple23, 21
19ExprTuple49
20ExprTuple22, 23
21Operationoperator: 24
operand: 28
22Operationoperator: 61
operands: 26
23Operationoperator: 27
operand: 67
24Literal
25ExprTuple28
26ExprTuple47, 29
27Literal
28Lambdaparameter: 58
body: 31
29Operationoperator: 51
operands: 32
30ExprTuple58
31Conditionalvalue: 33
condition: 34
32ExprTuple65, 55, 56, 57, 59
33Operationoperator: 35
operands: 36
34Operationoperator: 37
operands: 38
35Literal
36ExprTuple39, 40
37Literal
38ExprTuple58, 41
39Operationoperator: 61
operands: 42
40Operationoperator: 43
operands: 44
41Operationoperator: 45
operands: 46
42ExprTuple47, 48
43Literal
44ExprTuple58, 66
45Literal
46ExprTuple49, 50
47Literal
48Operationoperator: 51
operands: 52
49Literal
50Operationoperator: 53
operands: 54
51Literal
52ExprTuple65, 55, 56, 57, 58
53Literal
54ExprTuple59, 60
55Literal
56Literal
57Literal
58Variable
59Operationoperator: 61
operands: 62
60Operationoperator: 63
operand: 67
61Literal
62ExprTuple65, 66
63Literal
64ExprTuple67
65Literal
66Variable
67Literal