logo

Expression of type ExprTuple

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 ExprTuple, t
from proveit.linear_algebra import ScalarMult, VecAdd
from proveit.numbers import Add, Exp, Mult, e, frac, i, one, pi, subtract, two
from proveit.physics.quantum import ket0, ket1
from proveit.physics.quantum.QPE import _phase, two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(ScalarMult(frac(one, Exp(two, subtract(frac(Add(t, one), two), frac(t, two)))), VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, _phase, two_pow_t)), ket1))))
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} - \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)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Operationoperator: 13
operands: 2
2ExprTuple3, 4
3Operationoperator: 40
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple44, 8
6Literal
7ExprTuple9, 10
8Operationoperator: 42
operands: 11
9Operationoperator: 21
operand: 16
10Operationoperator: 13
operands: 14
11ExprTuple45, 15
12ExprTuple16
13Literal
14ExprTuple17, 18
15Operationoperator: 38
operands: 19
16Literal
17Operationoperator: 42
operands: 20
18Operationoperator: 21
operand: 44
19ExprTuple23, 24
20ExprTuple25, 26
21Literal
22ExprTuple44
23Operationoperator: 40
operands: 27
24Operationoperator: 28
operand: 33
25Literal
26Operationoperator: 30
operands: 31
27ExprTuple32, 45
28Literal
29ExprTuple33
30Literal
31ExprTuple45, 34, 35, 36, 37
32Operationoperator: 38
operands: 39
33Operationoperator: 40
operands: 41
34Literal
35Literal
36Literal
37Operationoperator: 42
operands: 43
38Literal
39ExprTuple46, 44
40Literal
41ExprTuple46, 45
42Literal
43ExprTuple45, 46
44Literal
45Literal
46Variable