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 = [k]
sub_expr2 = Add(t, one)
sub_expr3 = frac(t, two)
sub_expr4 = frac(sub_expr2, two)
sub_expr5 = Exp(e, Mult(two, pi, i, _phase, k))
expr = Equals(ScalarMult(frac(one, Exp(two, sub_expr4)), VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr5, NumKet(k, sub_expr2)), domain = Interval(zero, subtract(Mult(two, two_pow_t), one)))), TensorProd(ScalarMult(frac(one, Exp(two, subtract(sub_expr4, sub_expr3))), VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, _phase, two_pow_t)), ket1))), ScalarMult(frac(one, Exp(two, sub_expr3)), VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr5, NumKet(k, t)), domain = Interval(zero, subtract(two_pow_t, one))))))
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(\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)\right) = \left(\left(\frac{1}{2^{\frac{t + 1}{2} - \frac{t}{2}}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot 2^{t}} \cdot \lvert 1 \rangle\right)\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)
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: 57
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple10, 11
8Operationoperator: 86
operands: 12
9Operationoperator: 28
operand: 17
10Operationoperator: 57
operands: 14
11Operationoperator: 57
operands: 15
12ExprTuple104, 16
13ExprTuple17
14ExprTuple18, 19
15ExprTuple20, 21
16Operationoperator: 98
operands: 22
17Lambdaparameter: 95
body: 23
18Operationoperator: 86
operands: 24
19Operationoperator: 25
operands: 26
20Operationoperator: 86
operands: 27
21Operationoperator: 28
operand: 36
22ExprTuple102, 62
23Conditionalvalue: 30
condition: 31
24ExprTuple104, 32
25Literal
26ExprTuple33, 34
27ExprTuple104, 35
28Literal
29ExprTuple36
30Operationoperator: 57
operands: 37
31Operationoperator: 59
operands: 38
32Operationoperator: 98
operands: 39
33Operationoperator: 56
operand: 82
34Operationoperator: 57
operands: 41
35Operationoperator: 98
operands: 42
36Lambdaparameter: 95
body: 44
37ExprTuple65, 45
38ExprTuple95, 46
39ExprTuple102, 47
40ExprTuple82
41ExprTuple48, 49
42ExprTuple102, 79
43ExprTuple95
44Conditionalvalue: 50
condition: 51
45Operationoperator: 73
operands: 52
46Operationoperator: 75
operands: 53
47Operationoperator: 90
operands: 54
48Operationoperator: 98
operands: 55
49Operationoperator: 56
operand: 104
50Operationoperator: 57
operands: 58
51Operationoperator: 59
operands: 60
52ExprTuple95, 78
53ExprTuple82, 61
54ExprTuple62, 63
55ExprTuple80, 64
56Literal
57Literal
58ExprTuple65, 66
59Literal
60ExprTuple95, 67
61Operationoperator: 90
operands: 68
62Operationoperator: 86
operands: 69
63Operationoperator: 100
operand: 79
64Operationoperator: 88
operands: 71
65Operationoperator: 98
operands: 72
66Operationoperator: 73
operands: 74
67Operationoperator: 75
operands: 76
68ExprTuple77, 97
69ExprTuple78, 102
70ExprTuple79
71ExprTuple102, 92, 93, 94, 96
72ExprTuple80, 81
73Literal
74ExprTuple95, 103
75Literal
76ExprTuple82, 83
77Operationoperator: 88
operands: 84
78Operationoperator: 90
operands: 85
79Operationoperator: 86
operands: 87
80Literal
81Operationoperator: 88
operands: 89
82Literal
83Operationoperator: 90
operands: 91
84ExprTuple102, 96
85ExprTuple103, 104
86Literal
87ExprTuple103, 102
88Literal
89ExprTuple102, 92, 93, 94, 95
90Literal
91ExprTuple96, 97
92Literal
93Literal
94Literal
95Variable
96Operationoperator: 98
operands: 99
97Operationoperator: 100
operand: 104
98Literal
99ExprTuple102, 103
100Literal
101ExprTuple104
102Literal
103Variable
104Literal