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 = frac(t, two)
sub_expr2 = frac(Add(t, one), two)
sub_expr3 = TensorProd(VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, _phase, two_pow_t)), ket1)), 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(Mult(frac(one, Exp(two, subtract(sub_expr2, sub_expr1))), frac(one, Exp(two, sub_expr1))), sub_expr3), ScalarMult(frac(one, Exp(two, sub_expr2)), 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(\left(\frac{1}{2^{\frac{t + 1}{2} - \frac{t}{2}}} \cdot \frac{1}{2^{\frac{t}{2}}}\right) \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) = \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: 45
operands: 5
4Operationoperator: 45
operands: 6
5ExprTuple7, 9
6ExprTuple8, 9
7Operationoperator: 72
operands: 10
8Operationoperator: 70
operands: 11
9Operationoperator: 12
operands: 13
10ExprTuple14, 15
11ExprTuple88, 16
12Literal
13ExprTuple17, 18
14Operationoperator: 70
operands: 19
15Operationoperator: 70
operands: 20
16Operationoperator: 82
operands: 21
17Operationoperator: 22
operands: 23
18Operationoperator: 24
operand: 30
19ExprTuple88, 26
20ExprTuple88, 27
21ExprTuple86, 49
22Literal
23ExprTuple28, 29
24Literal
25ExprTuple30
26Operationoperator: 82
operands: 31
27Operationoperator: 82
operands: 32
28Operationoperator: 44
operand: 67
29Operationoperator: 45
operands: 34
30Lambdaparameter: 79
body: 36
31ExprTuple86, 37
32ExprTuple86, 64
33ExprTuple67
34ExprTuple38, 39
35ExprTuple79
36Conditionalvalue: 40
condition: 41
37Operationoperator: 74
operands: 42
38Operationoperator: 82
operands: 43
39Operationoperator: 44
operand: 88
40Operationoperator: 45
operands: 46
41Operationoperator: 47
operands: 48
42ExprTuple49, 50
43ExprTuple65, 51
44Literal
45Literal
46ExprTuple52, 53
47Literal
48ExprTuple79, 54
49Operationoperator: 70
operands: 55
50Operationoperator: 84
operand: 64
51Operationoperator: 72
operands: 57
52Operationoperator: 82
operands: 58
53Operationoperator: 59
operands: 60
54Operationoperator: 61
operands: 62
55ExprTuple63, 86
56ExprTuple64
57ExprTuple86, 76, 77, 78, 80
58ExprTuple65, 66
59Literal
60ExprTuple79, 87
61Literal
62ExprTuple67, 68
63Operationoperator: 74
operands: 69
64Operationoperator: 70
operands: 71
65Literal
66Operationoperator: 72
operands: 73
67Literal
68Operationoperator: 74
operands: 75
69ExprTuple87, 88
70Literal
71ExprTuple87, 86
72Literal
73ExprTuple86, 76, 77, 78, 79
74Literal
75ExprTuple80, 81
76Literal
77Literal
78Literal
79Variable
80Operationoperator: 82
operands: 83
81Operationoperator: 84
operand: 88
82Literal
83ExprTuple86, 87
84Literal
85ExprTuple88
86Literal
87Variable
88Literal