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, 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 = frac(one, Exp(two, frac(t, two)))
sub_expr2 = VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, _phase, two_pow_t)), ket1))
sub_expr3 = 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(TensorProd(sub_expr2, ScalarMult(sub_expr1, sub_expr3)), ScalarMult(sub_expr1, TensorProd(sub_expr2, sub_expr3))).with_wrapping_at(1)
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())
\begin{array}{c} \begin{array}{l} \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(\frac{1}{2^{\frac{t}{2}}} \cdot \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) \\  = \left(\frac{1}{2^{\frac{t}{2}}} \cdot \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)\right) \end{array} \end{array}
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.()(1)('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: 10
operands: 5
4Operationoperator: 38
operands: 6
5ExprTuple13, 7
6ExprTuple12, 8
7Operationoperator: 38
operands: 9
8Operationoperator: 10
operands: 11
9ExprTuple12, 14
10Literal
11ExprTuple13, 14
12Operationoperator: 34
operands: 15
13Operationoperator: 16
operands: 17
14Operationoperator: 18
operand: 23
15ExprTuple72, 20
16Literal
17ExprTuple21, 22
18Literal
19ExprTuple23
20Operationoperator: 66
operands: 24
21Operationoperator: 37
operand: 54
22Operationoperator: 38
operands: 26
23Lambdaparameter: 63
body: 28
24ExprTuple70, 29
25ExprTuple54
26ExprTuple30, 31
27ExprTuple63
28Conditionalvalue: 32
condition: 33
29Operationoperator: 34
operands: 35
30Operationoperator: 66
operands: 36
31Operationoperator: 37
operand: 72
32Operationoperator: 38
operands: 39
33Operationoperator: 40
operands: 41
34Literal
35ExprTuple71, 70
36ExprTuple52, 42
37Literal
38Literal
39ExprTuple43, 44
40Literal
41ExprTuple63, 45
42Operationoperator: 56
operands: 46
43Operationoperator: 66
operands: 47
44Operationoperator: 48
operands: 49
45Operationoperator: 50
operands: 51
46ExprTuple70, 60, 61, 62, 64
47ExprTuple52, 53
48Literal
49ExprTuple63, 71
50Literal
51ExprTuple54, 55
52Literal
53Operationoperator: 56
operands: 57
54Literal
55Operationoperator: 58
operands: 59
56Literal
57ExprTuple70, 60, 61, 62, 63
58Literal
59ExprTuple64, 65
60Literal
61Literal
62Literal
63Variable
64Operationoperator: 66
operands: 67
65Operationoperator: 68
operand: 72
66Literal
67ExprTuple70, 71
68Literal
69ExprTuple72
70Literal
71Variable
72Literal