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 = Exp(e, Mult(two, pi, i, _phase, two_pow_t))
sub_expr2 = frac(one, Exp(two, frac(Add(t, one), two)))
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(ScalarMult(sub_expr2, VecAdd(TensorProd(ket0, sub_expr3), ScalarMult(sub_expr1, TensorProd(ket1, sub_expr3)))), ScalarMult(sub_expr2, TensorProd(VecAdd(ket0, ScalarMult(sub_expr1, ket1)), 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(\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) = \left(\frac{1}{2^{\frac{t + 1}{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)
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: 48
operands: 5
4Operationoperator: 48
operands: 6
5ExprTuple8, 7
6ExprTuple8, 9
7Operationoperator: 20
operands: 10
8Operationoperator: 28
operands: 11
9Operationoperator: 26
operands: 12
10ExprTuple13, 14
11ExprTuple80, 15
12ExprTuple16, 32
13Operationoperator: 26
operands: 17
14Operationoperator: 48
operands: 18
15Operationoperator: 74
operands: 19
16Operationoperator: 20
operands: 21
17ExprTuple24, 32
18ExprTuple34, 22
19ExprTuple78, 23
20Literal
21ExprTuple24, 25
22Operationoperator: 26
operands: 27
23Operationoperator: 28
operands: 29
24Operationoperator: 40
operand: 62
25Operationoperator: 48
operands: 31
26Literal
27ExprTuple35, 32
28Literal
29ExprTuple33, 78
30ExprTuple62
31ExprTuple34, 35
32Operationoperator: 36
operand: 41
33Operationoperator: 66
operands: 38
34Operationoperator: 74
operands: 39
35Operationoperator: 40
operand: 80
36Literal
37ExprTuple41
38ExprTuple79, 80
39ExprTuple60, 42
40Literal
41Lambdaparameter: 71
body: 44
42Operationoperator: 64
operands: 45
43ExprTuple71
44Conditionalvalue: 46
condition: 47
45ExprTuple78, 68, 69, 70, 72
46Operationoperator: 48
operands: 49
47Operationoperator: 50
operands: 51
48Literal
49ExprTuple52, 53
50Literal
51ExprTuple71, 54
52Operationoperator: 74
operands: 55
53Operationoperator: 56
operands: 57
54Operationoperator: 58
operands: 59
55ExprTuple60, 61
56Literal
57ExprTuple71, 79
58Literal
59ExprTuple62, 63
60Literal
61Operationoperator: 64
operands: 65
62Literal
63Operationoperator: 66
operands: 67
64Literal
65ExprTuple78, 68, 69, 70, 71
66Literal
67ExprTuple72, 73
68Literal
69Literal
70Literal
71Variable
72Operationoperator: 74
operands: 75
73Operationoperator: 76
operand: 80
74Literal
75ExprTuple78, 79
76Literal
77ExprTuple80
78Literal
79Variable
80Literal