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 = VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, _phase, two_pow_t)), ket1))
sub_expr4 = 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(ScalarMult(frac(one, Exp(two, subtract(sub_expr2, sub_expr1))), sub_expr3), ScalarMult(frac(one, Exp(two, sub_expr1)), sub_expr4)), ScalarMult(frac(one, Exp(two, sub_expr2)), TensorProd(sub_expr3, sub_expr4)))
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 \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) = \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: 14
operands: 5
4Operationoperator: 47
operands: 6
5ExprTuple7, 8
6ExprTuple9, 10
7Operationoperator: 47
operands: 11
8Operationoperator: 47
operands: 12
9Operationoperator: 72
operands: 13
10Operationoperator: 14
operands: 15
11ExprTuple16, 19
12ExprTuple17, 20
13ExprTuple90, 18
14Literal
15ExprTuple19, 20
16Operationoperator: 72
operands: 21
17Operationoperator: 72
operands: 22
18Operationoperator: 84
operands: 23
19Operationoperator: 24
operands: 25
20Operationoperator: 26
operand: 32
21ExprTuple90, 28
22ExprTuple90, 29
23ExprTuple88, 51
24Literal
25ExprTuple30, 31
26Literal
27ExprTuple32
28Operationoperator: 84
operands: 33
29Operationoperator: 84
operands: 34
30Operationoperator: 46
operand: 69
31Operationoperator: 47
operands: 36
32Lambdaparameter: 81
body: 38
33ExprTuple88, 39
34ExprTuple88, 66
35ExprTuple69
36ExprTuple40, 41
37ExprTuple81
38Conditionalvalue: 42
condition: 43
39Operationoperator: 76
operands: 44
40Operationoperator: 84
operands: 45
41Operationoperator: 46
operand: 90
42Operationoperator: 47
operands: 48
43Operationoperator: 49
operands: 50
44ExprTuple51, 52
45ExprTuple67, 53
46Literal
47Literal
48ExprTuple54, 55
49Literal
50ExprTuple81, 56
51Operationoperator: 72
operands: 57
52Operationoperator: 86
operand: 66
53Operationoperator: 74
operands: 59
54Operationoperator: 84
operands: 60
55Operationoperator: 61
operands: 62
56Operationoperator: 63
operands: 64
57ExprTuple65, 88
58ExprTuple66
59ExprTuple88, 78, 79, 80, 82
60ExprTuple67, 68
61Literal
62ExprTuple81, 89
63Literal
64ExprTuple69, 70
65Operationoperator: 76
operands: 71
66Operationoperator: 72
operands: 73
67Literal
68Operationoperator: 74
operands: 75
69Literal
70Operationoperator: 76
operands: 77
71ExprTuple89, 90
72Literal
73ExprTuple89, 88
74Literal
75ExprTuple88, 78, 79, 80, 81
76Literal
77ExprTuple82, 83
78Literal
79Literal
80Literal
81Variable
82Operationoperator: 84
operands: 85
83Operationoperator: 86
operand: 90
84Literal
85ExprTuple88, 89
86Literal
87ExprTuple90
88Literal
89Variable
90Literal