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 ExprRange, Variable, t
from proveit.linear_algebra import ScalarMult, TensorProd, VecAdd
from proveit.logic import Equals
from proveit.numbers import Add, Exp, Mult, Neg, e, frac, i, one, pi, sqrt, two, zero
from proveit.physics.quantum import ket0, ket1
from proveit.physics.quantum.QPE import SubIndexed, _phase, _psi, two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = frac(one, sqrt(two))
expr = Equals(SubIndexed(_psi, [Add(t, one)]), ScalarMult(sub_expr2, TensorProd(VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, two_pow_t, _phase)), ket1)), ExprRange(sub_expr1, ScalarMult(sub_expr2, VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, Exp(two, Neg(sub_expr1)), _phase)), ket1))), Add(Neg(t), one), zero).with_decreasing_order())))
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())
\lvert \psi_{t + 1} \rangle = \left(\frac{1}{\sqrt{2}} \cdot \left(\left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{t} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right){\otimes} \left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{t - 1} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)\right) {\otimes}  \left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{t - 2} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)\right) {\otimes}  \ldots {\otimes}  \left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{0} \cdot \varphi} \cdot \lvert 1 \rangle\right)\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: 5
operand: 8
4Operationoperator: 40
operands: 7
5Literal
6ExprTuple8
7ExprTuple26, 9
8Operationoperator: 20
operands: 10
9Operationoperator: 11
operands: 12
10ExprTuple53, 56
11Literal
12ExprTuple13, 14
13Operationoperator: 31
operands: 15
14ExprRangelambda_map: 16
start_index: 17
end_index: 44
15ExprTuple35, 18
16Lambdaparameter: 69
body: 19
17Operationoperator: 20
operands: 21
18Operationoperator: 40
operands: 22
19Operationoperator: 40
operands: 23
20Literal
21ExprTuple24, 56
22ExprTuple25, 46
23ExprTuple26, 27
24Operationoperator: 67
operand: 53
25Operationoperator: 63
operands: 29
26Operationoperator: 48
operands: 30
27Operationoperator: 31
operands: 32
28ExprTuple53
29ExprTuple54, 33
30ExprTuple56, 34
31Literal
32ExprTuple35, 36
33Operationoperator: 57
operands: 37
34Operationoperator: 63
operands: 38
35Operationoperator: 51
operand: 44
36Operationoperator: 40
operands: 41
37ExprTuple65, 59, 60, 42, 62
38ExprTuple65, 43
39ExprTuple44
40Literal
41ExprTuple45, 46
42Operationoperator: 63
operands: 47
43Operationoperator: 48
operands: 49
44Literal
45Operationoperator: 63
operands: 50
46Operationoperator: 51
operand: 56
47ExprTuple65, 53
48Literal
49ExprTuple56, 65
50ExprTuple54, 55
51Literal
52ExprTuple56
53Variable
54Literal
55Operationoperator: 57
operands: 58
56Literal
57Literal
58ExprTuple65, 59, 60, 61, 62
59Literal
60Literal
61Operationoperator: 63
operands: 64
62Literal
63Literal
64ExprTuple65, 66
65Literal
66Operationoperator: 67
operand: 69
67Literal
68ExprTuple69
69Variable